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 class
Length.Unit
Measurement units for ODF datatype length
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Double
getCentimeter()
Double
getInch()
static Double
getLength(String length, Length.Unit destinationUnit)
Maps the a length string to a different unitDouble
getMicrometer()
WARNING: Not an allowed ODF value, just for interim calculation used!Double
getMillimeters()
Double
getPica()
Double
getPixel()
Double
getPoint()
static boolean
isValid(String stringValue)
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 unitString
mapToUnit(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
parseInt(String length)
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
parseLong(String length)
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
parseUnit(String length)
Returns the Unit of the given length.String
toString()
Returns a String Object representing this Length's valuestatic Length
valueOf(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
- theUnit
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
- theint
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
- theint
value should be obtained fromdestinationUnit
- 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
- thelong
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 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
- thedouble
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 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
-
-