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
This class represents the in OpenDocument format used data type {
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Measurement units for ODF datatype length -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetInch()
static Double
getLength
(String length, Length.Unit destinationUnit) Maps the a length string to a different unitWARNING: Not an allowed ODF value, just for interim calculation used!getPica()
getPixel()
getPoint()
static boolean
Check if the specified String instance is a valid {static String
mapToUnit
(String length, Length.Unit destinationUnit) Maps the a length string to a different unitmapToUnit
(Length.Unit destinationUnit) static double
parseDouble
(String length) Returns the value of the given length as double.static double
parseDouble
(String length, Length.Unit destinationUnit) Maps the a length string to a different unitstatic int
Returns the value of the given length as int.static int
parseInt
(String length, Length.Unit destinationUnit) Returns the value of the given length as int.static long
Returns the value of the given length as long.static long
parseLong
(String length, Length.Unit destinationUnit) Maps the a length string to a different unitstatic Length.Unit
Returns the Unit of the given length.toString()
Returns a String Object representing this Length's valuestatic Length
Returns a Length instance representing the specified String value
-
Constructor Details
-
Length
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
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
Returns the Unit of the given length.- Parameters:
length
- theUnit
should be obtained from- Returns:
- Returns a
Unit
object representing the specified Length unit.
-
parseInt
Returns the value of the given length as int.- Parameters:
length
- theint
value should be obtained from- Returns:
- Returns a
int
value representing the specified Length value.
-
parseInt
Returns the value of the given length as int.- Parameters:
length
- theint
value should be obtained fromdestinationUnit
- The unit to be converted to- Returns:
- Returns a
int
value representing the specified Length value.
-
parseLong
Returns the value of the given length as long.- Parameters:
length
- thelong
value should be obtained from- Returns:
- Returns a
long
value representing the specified Length value.
-
parseLong
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
Returns the value of the given length as double.- Parameters:
length
- thedouble
value should be obtained from- Returns:
- Returns a
double
value representing the specified Length value.
-
parseDouble
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
- Parameters:
destinationUnit
- The unit to be converted to- Returns:
- The converted value as result
-
getMillimeters
- Returns:
- The length in Millimeter
-
getMicrometer
WARNING: Not an allowed ODF value, just for interim calculation used!- Returns:
- The length in Micrometer
-
getPoint
- Returns:
- The length in point
-
getPixel
- Returns:
- The length in pixel
-
getPica
- Returns:
- The length in pica
-
getInch
- Returns:
- The length in inch
-
getCentimeter
- Returns:
- The length in centimeter
-
getLength
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
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
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
Returns a String Object representing this Length's value
-