org.jopendocument.dom
Enum LengthUnit

java.lang.Object
  extended by java.lang.Enum<LengthUnit>
      extended by org.jopendocument.dom.LengthUnit
All Implemented Interfaces:
Serializable, Comparable<LengthUnit>

public enum LengthUnit
extends Enum<LengthUnit>

Units of length.

Author:
Sylvain CUAZ
See Also:
W3C Definitions

Enum Constant Summary
CM
          The centimetre.
INCH
          The inch.
MM
          The millimetre.
PICA
          The pica (12pt i.e. 1/6in).
POINT
          The point (1/72in).
 
Method Summary
 BigDecimal convertTo(BigDecimal d, LengthUnit other)
          Convert from this unit to another.
 String format(Number n)
           
static LengthUnit fromSymbol(String s)
           
 String getSymbol()
          The symbol for this unit of length.
static Tuple2<BigDecimal,LengthUnit> parseLength(String l)
           
static BigDecimal parseLength(String l, LengthUnit to)
          Parse a length.
static BigDecimal parsePositiveLength(String l, LengthUnit to, boolean strict)
           
static LengthUnit valueOf(String name)
          Returns the enum constant of this type with the specified name.
static LengthUnit[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

MM

public static final LengthUnit MM
The millimetre.


CM

public static final LengthUnit CM
The centimetre.


INCH

public static final LengthUnit INCH
The inch.


POINT

public static final LengthUnit POINT
The point (1/72in).


PICA

public static final LengthUnit PICA
The pica (12pt i.e. 1/6in).

Method Detail

values

public static LengthUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (LengthUnit c : LengthUnit.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static LengthUnit valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

getSymbol

public final String getSymbol()
The symbol for this unit of length.

Returns:
the symbol, eg "cm".

convertTo

public final BigDecimal convertTo(BigDecimal d,
                                  LengthUnit other)
Convert from this unit to another.

Parameters:
d - a length, eg 1.
other - another unit, eg CM.
Returns:
the rounded result, eg 2.54 if this is INCH

format

public final String format(Number n)

fromSymbol

public static final LengthUnit fromSymbol(String s)

parseLength

public static final Tuple2<BigDecimal,LengthUnit> parseLength(String l)

parseLength

public static final BigDecimal parseLength(String l,
                                           LengthUnit to)
Parse a length.

Parameters:
l - the length, can be null, e.g. "2.0cm".
to - the result unit, e.g. MM.
Returns:
the parsed length, null if l is, e.g. 20.

parsePositiveLength

public static final BigDecimal parsePositiveLength(String l,
                                                   LengthUnit to,
                                                   boolean strict)


Copyright © 2010 jOpenDocument All Rights Reserved.