org.odftoolkit.odfdom.type
Class Length

java.lang.Object
  extended by 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 length


Nested Class Summary
static class Length.Unit
          Measurement units for ODF datatype length
 
Constructor Summary
Length(String length)
          Construct Length by the parsing the given string
 
Method Summary
static boolean isValid(String stringValue)
          Check if the specified String instance is a valid length data type
 String mapToUnit(Length.Unit destinationUnit)
           
static String mapToUnit(String length, Length.Unit destinationUnit)
          Maps the a length string to a different unit
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 unit
static 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 unit
static Length.Unit parseUnit(String length)
          Returns the Unit of the given length.
 String toString()
          Returns a String Object representing this Length's value
static Length valueOf(String stringValue)
          Returns a Length instance representing the specified String value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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
Method Detail

isValid

public static boolean isValid(String stringValue)
Check if the specified String instance is a valid length data type

Parameters:
stringValue - the value to be tested
Returns:
true if the value of argument is valid for length data type false otherwise

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

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


Copyright © 2008-2011 The Apache Software Foundation. All Rights Reserved.