|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.me.nxg.unity.UnitExpr
public class UnitExpr
A parsed unit expression.
Method Summary | |
---|---|
boolean |
allUnitsRecognised(String syntax)
Indicates whether the parsed expression is composed only of recognised units, in the sense of OneUnit.isRecognisedUnit(java.lang.String) . |
boolean |
allUnitsRecommended(String syntax)
Indicates whether the parsed expression is composed only of recommended units, in the sense of OneUnit.isRecommendedUnit(java.lang.String) . |
boolean |
allUsageConstraintsSatisfied(String syntax)
Indicates whether the expression is being used in a way which satisfies any usage constraints, in the sense of OneUnit.satisfiesUsageConstraints(java.lang.String) . |
Dimensions |
getDimensions()
Obtains the dimensions of the complete expression. |
double |
getFactor()
Obtain the factor multiplying this expression |
double |
getLogFactor()
Obtain the base-10 log of the factor multiplying this expression |
OneUnit |
getUnit(int idx)
Get one of the units within the expression, by index. |
OneUnit |
getUnit(String reqUnit)
Extracts the unit information from the expression, keyed by a symbolic name for the unit, as defined by the syntax which was used to parse the expression. |
OneUnit |
getUnit(UnitDefinition reqUnit)
Extracts the unit information from the expression, keyed by an abstract unit instance. |
boolean |
isFullyConformant(String syntax)
Indicates whether the expression is fully conformant with the appropriate recommendations. |
Iterator<OneUnit> |
iterator()
Return a representation of the parsed expression as an iterator. |
int |
size()
The number of units in the expression, which will always be at least one |
String |
toDebugString()
Format the unit expression as a string, in some sort of canonical/unambiguous form. |
String |
toString()
Produces a string representation of the unit expression, in a form suitable for display |
String |
toString(String syntax)
Produces a string representation of the unit expression, in a format appropriate to the given syntax. |
String |
toString(String syntax,
Locale locale)
Produces a string representation of the unit expression, in a format appropriate to the given syntax, and with output respecting the conventions of the given locale. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public double getLogFactor()
public double getFactor()
public Iterator<OneUnit> iterator()
iterator
in interface Iterable<OneUnit>
public OneUnit getUnit(UnitDefinition reqUnit)
At present, this won't fully work if there is more than one occurrence of a unit in an expression, for example in the case "m^3/mm". It's not clear if that should be disallowed, or if not how it should be manipulated, so this part of the interface will quite possibly change in some way in future.
reqUnit
- a non-null unit definitionpublic OneUnit getUnit(String reqUnit)
If the argument is not a recognised unit in the parsing
system, then this returns the unit which has a matching
symbol. For example, "erg" is not recognised symbol in the CDS
syntax, so if the string "erg/s" were parsed using the CDS
parser, then the call getUnit("erg")
would find the (unknown) unit
"erg", but using getUnit(UnitDefinition)
with an "Erg"
UnitDefinition would retrieve nothing.
reqUnit
- a non-null string indicating a unit symbol
public OneUnit getUnit(int idx)
idx
- the unit to retrievesize()
public int size()
public boolean allUnitsRecommended(String syntax)
OneUnit.isRecommendedUnit(java.lang.String)
. Recommended units are units which
are both recognised and not deprecated.
syntax
- the syntax with respect to which the
units should be checkedpublic boolean allUnitsRecognised(String syntax)
OneUnit.isRecognisedUnit(java.lang.String)
. That
is, an expression composed of only non-deprecated and unknown
units has no deprecated units.
syntax
- the syntax with respect to which the
units should be checkedpublic boolean allUsageConstraintsSatisfied(String syntax)
OneUnit.satisfiesUsageConstraints(java.lang.String)
.
Principally, this tests
whether a unit which may not be used with SI prefixes was
provided with a prefix, but there may be other constraints
present.
An unrecognised unit has no constraints, and so will always satisfy them; this extends to units which are unrecognised in a particular syntax.
syntax
- one of the syntaxes of UnitParser
public boolean isFullyConformant(String syntax)
syntax
- one of the syntaxes of UnitParser
public Dimensions getDimensions()
public String toString()
toString
in class Object
public String toString(String syntax) throws UnitParserException
UnitParser
.
The output is locale-independent (which in practice means it is
in the java.text.Locale.US
locale).
syntax
- the syntax to generate
UnitParserException
public String toString(String syntax, Locale locale) throws UnitParserException
UnitParser
.
If locale
is null, the output is locale-independent
(which in practice means it is in the java.text.Locale.US
locale);
note that this is distinct from the process's default locale.
syntax
- the syntax to generatelocale
- the locale to use, or null to use a 'no-locale' locale
UnitParserException
public String toDebugString()
toString()
method is generally preferred as a
way of formatting expressions.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |