|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jopendocument.dom.Length
@Immutable public class Length
An OpenDocument length.
Note: for performance reason, this class has a natural ordering that
is inconsistent with equals(Object).
| Field Summary | |
|---|---|
static Length |
ZERO
The empty length. |
| Constructor Summary | |
|---|---|
Length(Number amount,
LengthUnit unit)
|
|
| Method Summary | |
|---|---|
Length |
add(Length other)
|
static Length |
CM(Number amount)
|
static Length |
CM(String amount)
|
int |
compareTo(Length o)
Compare two lengths. |
Length |
convertTo(LengthUnit destUnit)
Convert this into an instance with the same length but with the passed unit. |
Length |
convertToDecimal()
|
static Length |
create(Number amount,
LengthUnit unit)
|
static Length |
create(String amount,
LengthUnit unit)
|
Number |
divide(Length other)
|
Number |
divide(Length other,
MathContext mc)
|
boolean |
equals(Object obj)
Indicates whether some other object has the exact same amount and unit as this. |
String |
format()
Format this length. |
String |
format(LengthUnit unit)
Optionally convert and then format this. |
Number |
getAmount()
|
BigDecimal |
getDecimalAmount()
|
static Length |
getNone()
The lack of length, e.g. sheets in spreadsheets have no length of their own. |
static MathContext |
getPreciseContext()
The default context, always more accurate than getStandardContext(). |
static MathContext |
getStandardContext()
The context used in roundDecimalAmount(). |
LengthUnit |
getUnit()
The unit. |
int |
hashCode()
|
static Length |
INCH(Number amount)
|
boolean |
isDefined()
|
boolean |
isNone()
|
boolean |
isZero()
Whether this is an empty length. |
static Length |
MM(Number amount)
|
static Length |
MM(String amount)
|
Length |
multiply(Number m)
|
Length |
negate()
|
Length |
roundDecimalAmount()
|
Length |
roundDecimalAmount(MathContext mc)
|
int |
signum()
|
Length |
subtract(Length other)
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Length ZERO
| Constructor Detail |
|---|
public Length(Number amount,
LengthUnit unit)
| Method Detail |
|---|
public static final Length getNone()
null.isNone()public static final MathContext getStandardContext()
roundDecimalAmount().
getPreciseContext()public static final MathContext getPreciseContext()
getStandardContext().
public static final Length create(String amount,
LengthUnit unit)
public static final Length create(Number amount,
LengthUnit unit)
public static final Length MM(Number amount)
public static final Length MM(String amount)
public static final Length CM(Number amount)
public static final Length CM(String amount)
public static final Length INCH(Number amount)
public final boolean isNone()
public final boolean isDefined()
public final boolean isZero()
true if the amount is 0.ZEROpublic final Number getAmount()
public final BigDecimal getDecimalAmount()
public final LengthUnit getUnit()
null if and only if this is getNone().public final Length convertToDecimal()
public final Length convertTo(LengthUnit destUnit)
destUnit - the unit of the result.
public final String format(LengthUnit unit)
unit - the unit to format to, null meaning don't convert.
format()public final String format()
null if and only if this is getNone().public final Length roundDecimalAmount()
public final Length roundDecimalAmount(MathContext mc)
public final Length add(Length other)
public final Length subtract(Length other)
public final Length negate()
public final Length multiply(Number m)
public final Number divide(Length other)
public final Number divide(Length other,
MathContext mc)
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
compareTo(Length). E.g. CM((float)0) is not
equal to CM(0) and MM(0) is not CM(0).
equals in class Objectobj - another length.
true if obj is equal to this.public final int signum()
public int compareTo(Length o)
throws IllegalArgumentException
compareTo in interface Comparable<Length>o - the other length.
IllegalArgumentException - if this or o isNone().public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||