Class Length

java.lang.Object
org.odftoolkit.odfdom.type.Length
All Implemented Interfaces:
OdfDataType
Direct Known Subclasses:
Coordinate, Distance, NonNegativeLength, NonNegativePixelLength, PositiveLength

public class Length extends Object implements OdfDataType
This class represents the in OpenDocument format used data type {
  • Constructor Details

    • Length

      public Length(String length) throws NumberFormatException
      Construct Length by the parsing the given string
      Parameters:
      length - The String to be parsed into Length
      Throws:
      NumberFormatException - if the given argument is not a valid Length (an Integer only will be presumed to be 'pt')
  • Method Details

    • isValid

      public static boolean isValid(String stringValue)
      Check if the specified String instance is a valid {
      Parameters:
      stringValue - the value to be tested
      Returns:
      true if the value of argument is valid for {
    • parseUnit

      public static Length.Unit parseUnit(String length)
      Returns the Unit of the given length.
      Parameters:
      length - the Unit should be obtained from
      Returns:
      Returns a Unit object representing the specified Length unit.
    • parseInt

      public static int parseInt(String length)
      Returns the value of the given length as int.
      Parameters:
      length - the int value should be obtained from
      Returns:
      Returns a int value representing the specified Length value.
    • parseInt

      public static int parseInt(String length, Length.Unit destinationUnit)
      Returns the value of the given length as int.
      Parameters:
      length - the int value should be obtained from
      destinationUnit - The unit to be converted to
      Returns:
      Returns a int value representing the specified Length value.
    • parseLong

      public static long parseLong(String length)
      Returns the value of the given length as long.
      Parameters:
      length - the long value should be obtained from
      Returns:
      Returns a long value representing the specified Length value.
    • parseLong

      public static long parseLong(String length, Length.Unit destinationUnit)
      Maps the a length string to a different unit
      Parameters:
      length - The value to be mapped
      destinationUnit - The unit to be converted to
      Returns:
      The converted value without unit suffix as Double
    • parseDouble

      public static double parseDouble(String length)
      Returns the value of the given length as double.
      Parameters:
      length - the double value should be obtained from
      Returns:
      Returns a double value representing the specified Length value.
    • parseDouble

      public static double parseDouble(String length, Length.Unit destinationUnit)
      Maps the a length string to a different unit
      Parameters:
      length - The value to be mapped
      destinationUnit - The unit to be converted to
      Returns:
      The converted value without unit suffix as double
    • mapToUnit

      public String mapToUnit(Length.Unit destinationUnit)
      Parameters:
      destinationUnit - The unit to be converted to
      Returns:
      The converted value as result
    • getMillimeters

      public Double getMillimeters()
      Returns:
      The length in Millimeter
    • getMicrometer

      public Double getMicrometer()
      WARNING: Not an allowed ODF value, just for interim calculation used!
      Returns:
      The length in Micrometer
    • getPoint

      public Double getPoint()
      Returns:
      The length in point
    • getPixel

      public Double getPixel()
      Returns:
      The length in pixel
    • getPica

      public Double getPica()
      Returns:
      The length in pica
    • getInch

      public Double getInch()
      Returns:
      The length in inch
    • getCentimeter

      public Double getCentimeter()
      Returns:
      The length in centimeter
    • getLength

      public static Double getLength(String length, Length.Unit destinationUnit)
      Maps the a length string to a different unit
      Parameters:
      length - The value to be mapped
      destinationUnit - The unit to be converted to
      Returns:
      The converted value without unit suffix as Integer
    • mapToUnit

      public static String mapToUnit(String length, Length.Unit destinationUnit)
      Maps the a length string to a different unit
      Parameters:
      length - The value to be mapped
      destinationUnit - The unit to be converted to
      Returns:
      The converted value with unit suffix as String
    • valueOf

      public static Length valueOf(String stringValue) throws NumberFormatException
      Returns a Length instance representing the specified String value
      Parameters:
      stringValue - a String value
      Returns:
      return a Length instance representing stringValue
      Throws:
      NumberFormatException - if the given argument is not a valid Length
    • toString

      public String toString()
      Returns a String Object representing this Length's value
      Overrides:
      toString in class Object
      Returns:
      return a string representation of the value of this Length object