Package org.odftoolkit.odfdom.type
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 {
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLength.UnitMeasurement units for ODF datatype length
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DoublegetCentimeter()DoublegetInch()static DoublegetLength(String length, Length.Unit destinationUnit)Maps the a length string to a different unitDoublegetMicrometer()WARNING: Not an allowed ODF value, just for interim calculation used!DoublegetMillimeters()DoublegetPica()DoublegetPixel()DoublegetPoint()static booleanisValid(String stringValue)Check if the specified String instance is a valid {static StringmapToUnit(String length, Length.Unit destinationUnit)Maps the a length string to a different unitStringmapToUnit(Length.Unit destinationUnit)static doubleparseDouble(String length)Returns the value of the given length as double.static doubleparseDouble(String length, Length.Unit destinationUnit)Maps the a length string to a different unitstatic intparseInt(String length)Returns the value of the given length as int.static intparseInt(String length, Length.Unit destinationUnit)Returns the value of the given length as int.static longparseLong(String length)Returns the value of the given length as long.static longparseLong(String length, Length.Unit destinationUnit)Maps the a length string to a different unitstatic Length.UnitparseUnit(String length)Returns the Unit of the given length.StringtoString()Returns a String Object representing this Length's valuestatic LengthvalueOf(String stringValue)Returns a Length instance representing the specified String value
-
-
-
Constructor Detail
-
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 Detail
-
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- theUnitshould be obtained from- Returns:
- Returns a
Unitobject representing the specified Length unit.
-
parseInt
public static int parseInt(String length)
Returns the value of the given length as int.- Parameters:
length- theintvalue should be obtained from- Returns:
- Returns a
intvalue 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- theintvalue should be obtained fromdestinationUnit- The unit to be converted to- Returns:
- Returns a
intvalue representing the specified Length value.
-
parseLong
public static long parseLong(String length)
Returns the value of the given length as long.- Parameters:
length- thelongvalue should be obtained from- Returns:
- Returns a
longvalue 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 mappeddestinationUnit- 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- thedoublevalue should be obtained from- Returns:
- Returns a
doublevalue 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 mappeddestinationUnit- 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 mappeddestinationUnit- 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 mappeddestinationUnit- 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
-
-