public class LinearUnit extends TypedUnit<LinearUnit> implements java.lang.Comparable<LinearUnit>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
LinearUnit.Custom |
TypedUnit.UnitSelector<U extends TypedUnit<U>>| Modifier and Type | Field and Description |
|---|---|
private java.lang.String[] |
altNames |
private java.lang.String |
breakingSuffix |
private ScaleFactor |
factorToAtom |
private java.lang.String |
idSuffix |
private LinearKindOfQuantity |
kindOfQuantity |
private java.lang.String |
nonBreakingSuffix |
private java.util.Map<java.lang.String,? extends LinearUnit> |
parseMap |
private java.lang.String |
unitDescription |
private java.lang.String |
unitId |
private java.lang.String |
unitSymbol |
EMPTY_STRING_ARRAY| Constructor and Description |
|---|
LinearUnit(LinearKindOfQuantity kindOfQuantity,
java.lang.String unitId,
ScaleFactor factorToAtom,
java.lang.String unitSymbol,
java.lang.String unitDesc,
java.lang.String... altNames) |
| Modifier and Type | Method and Description |
|---|---|
protected ITypedQuantity<LinearUnit> |
add(long numericalAugend,
LinearUnit addendUnit,
long numericalAddend) |
ITypedQuantity<LinearUnit> |
asWellKnownQuantity() |
int |
compareTo(LinearUnit other) |
ITypedQuantity<LinearUnit> |
customParseInteractive(java.lang.String interactiveQuantity)
Parse an interactive string, like
KindOfQuantity.parseInteractive(String), with the
addition that this unit is accepted, even if not generally by the kind of quantity. |
boolean |
equals(java.lang.Object other) |
protected ITypedQuantity<LinearUnit> |
floorQuantize(double numericalValue,
ITypedQuantity<LinearUnit> quanta) |
protected ITypedQuantity<LinearUnit> |
floorQuantize(long numericalValue,
ITypedQuantity<LinearUnit> quanta) |
private long |
floorQuantize(long value,
long alignment) |
java.lang.String[] |
getAltLocalizedNames()
Get alternate names for content assist matching.
|
java.lang.String |
getAppendableSuffix(boolean useBreakingSpace)
Convenience method for (localized) formatters, to prepend a space to
IUnit.getLocalizedSymbol(), if needed. |
LinearKindOfQuantity |
getContentType()
Get the kind of quantity of this unit.
|
LinearUnit |
getDeltaUnit()
Get the unit that the difference between two quantities in this unit will have.
|
java.lang.String |
getIdentifier()
Persistable identifier, not to show interactively.
|
java.lang.String |
getLocalizedDescription()
In the real world, units are sometimes used ambiguously (like MB).
|
java.lang.String |
getLocalizedSymbol()
Symbols for units are most often not locale dependent, but there are exceptions (like in
French).
|
protected LinearUnit |
getScaledUnit(LinearUnit deltaUnit)
Return a unit with the same origin (if absolute) as this unit, but with the given
deltaUnit as its delta unit. |
protected java.lang.Class<LinearUnit> |
getUnitClass()
|
int |
hashCode() |
protected boolean |
isCustom() |
boolean |
isLinear()
If this unit is linear.
|
protected java.lang.String |
localizedFormatFor(java.lang.Number numericalValue,
boolean useBreakingSpace,
boolean allowCustomUnit) |
protected java.lang.String |
persistableStringFor(java.lang.Number numericalValue) |
ITypedQuantity<LinearUnit> |
quantity(double numericalValue)
Create a quantity expressed in this unit and with a numerical quantity value equal to
numericalValue. |
ITypedQuantity<LinearUnit> |
quantity(long numericalValue)
Create a quantity expressed in this unit and with a numerical quantity value equal to
numericalValue. |
protected ITypedQuantity<LinearUnit> |
subtractSame(long numericalMinuend,
LinearUnit subtrahendUnit,
long numericalSubtrahend) |
java.lang.String |
toString() |
private ScaleFactor |
valueFactorToAtom() |
ScaleFactor |
valueTransformTo(LinearUnit targetUnit)
Get a transform for transforming numerical quantity values expressed in this unit to
numerical quantity values expressed in
targetUnit. |
addPossiblyIntegral, quantity, valueTransformToprivate final LinearKindOfQuantity kindOfQuantity
private final ScaleFactor factorToAtom
private final java.lang.String unitId
private final java.lang.String idSuffix
private final java.lang.String unitSymbol
private final java.lang.String nonBreakingSuffix
private final java.lang.String breakingSuffix
private final java.lang.String unitDescription
private final java.lang.String[] altNames
private final java.util.Map<java.lang.String,? extends LinearUnit> parseMap
public LinearUnit(LinearKindOfQuantity kindOfQuantity, java.lang.String unitId, ScaleFactor factorToAtom, java.lang.String unitSymbol, java.lang.String unitDesc, java.lang.String... altNames)
protected final java.lang.Class<LinearUnit> getUnitClass()
TypedUnitClass object of the actual TypedUnit subclass U. This
method is intended to simplify generic code, written in TypedUnit, to go from loosely
typed arguments into stricter parameterized arguments.getUnitClass in class TypedUnit<LinearUnit>public LinearKindOfQuantity getContentType()
IUnitgetContentType in interface IUnitgetContentType in class TypedUnit<LinearUnit>public LinearUnit getDeltaUnit()
IUnitgetDeltaUnit in interface IUnitprotected LinearUnit getScaledUnit(LinearUnit deltaUnit)
TypedUnitdeltaUnit as its delta unit. Linear units will return
deltaUnit.getScaledUnit in class TypedUnit<LinearUnit>public java.lang.String getAppendableSuffix(boolean useBreakingSpace)
IUnitIUnit.getLocalizedSymbol(), if needed.getAppendableSuffix in interface IUnituseBreakingSpace - to use breaking space instead of the default, non-breaking space (only for edit)public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(LinearUnit other)
compareTo in interface java.lang.Comparable<LinearUnit>public ITypedQuantity<LinearUnit> quantity(long numericalValue)
IUnitnumericalValue.quantity in interface IUnitquantity in class TypedUnit<LinearUnit>public ITypedQuantity<LinearUnit> quantity(double numericalValue)
IUnitnumericalValue.quantity in interface IUnitquantity in class TypedUnit<LinearUnit>public ScaleFactor valueTransformTo(LinearUnit targetUnit)
TypedUnittargetUnit. This method is typically only used
internally by the quantity implementations. Note that this method differs from
TypedUnit.valueTransformTo(IUnit) only by stricter typing.valueTransformTo in class TypedUnit<LinearUnit>private ScaleFactor valueFactorToAtom()
public boolean isLinear()
IUnitprotected ITypedQuantity<LinearUnit> add(long numericalAugend, LinearUnit addendUnit, long numericalAddend)
add in class TypedUnit<LinearUnit>protected ITypedQuantity<LinearUnit> subtractSame(long numericalMinuend, LinearUnit subtrahendUnit, long numericalSubtrahend)
subtractSame in class TypedUnit<LinearUnit>private long floorQuantize(long value,
long alignment)
protected ITypedQuantity<LinearUnit> floorQuantize(long numericalValue, ITypedQuantity<LinearUnit> quanta)
floorQuantize in class TypedUnit<LinearUnit>protected ITypedQuantity<LinearUnit> floorQuantize(double numericalValue, ITypedQuantity<LinearUnit> quanta)
floorQuantize in class TypedUnit<LinearUnit>public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getIdentifier()
IUnitgetIdentifier in interface IUnitpublic java.lang.String getLocalizedSymbol()
IUnit
While symbols normally don't contain any white space, spacing occur in circumstances like
custom units. In this case, it is important that they are non-breaking spaces
( ).
getLocalizedSymbol in interface IUnitpublic java.lang.String getLocalizedDescription()
IUnitgetLocalizedDescription in interface IUnitpublic java.lang.String[] getAltLocalizedNames()
IUnitgetAltLocalizedNames in interface IUnitnull.protected boolean isCustom()
public ITypedQuantity<LinearUnit> asWellKnownQuantity()
protected java.lang.String persistableStringFor(java.lang.Number numericalValue)
persistableStringFor in class TypedUnit<LinearUnit>protected java.lang.String localizedFormatFor(java.lang.Number numericalValue,
boolean useBreakingSpace,
boolean allowCustomUnit)
localizedFormatFor in class TypedUnit<LinearUnit>public ITypedQuantity<LinearUnit> customParseInteractive(java.lang.String interactiveQuantity) throws QuantityConversionException
KindOfQuantity.parseInteractive(String), with the
addition that this unit is accepted, even if not generally by the kind of quantity. Only
guaranteed to be able to parse strings produced by
localizedFormatFor(Number, boolean, boolean) for this unit or by
IQuantity.interactiveFormat() for quantities of this kind of quantity, and in the
same locale. Only use this for interactive input, never for persisted strings.interactiveQuantity - interactive string to parseQuantityConversionException - if parsing failed