|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectuk.me.nxg.unity.OneUnit
uk.me.nxg.unity.FunctionOfUnit
public class FunctionOfUnit
Represents a function of a unit, such as log(m). This consists of a function (‘log’'
in this case) and an operand (‘m’' in this case). The interpretation of log(m) is
that it represents the log of the dimensionless number obtained by dividing a quantity (which
presumably has the dimensions of length) by the quantity 1 m.
The functions getBaseUnitName(),
getBaseUnitDefinition(), and getBaseUnitString(), apply to the
operand. In particular, they give the information about the first
unit in the function operand, even if it has multiple units (such
as log(V^2/mm). This isn't ideal, but it's probably
roughly what is wanted in the majority of cases where this function
is used.
The functions isRecognisedUnit(uk.me.nxg.unity.Syntax) and isRecommendedUnit(uk.me.nxg.unity.Syntax) are true if they
would be true when applied to the operand and the function is a recognised in this
syntax; there are no usage constraints on functions, so the function
satisfiesUsageConstraints(uk.me.nxg.unity.Syntax) is true if it would be true when applied to the operand.
| Method Summary | |
|---|---|
int |
compareTo(OneUnit o)
|
boolean |
equals(Object o)
|
UnitDefinition |
getBaseUnitDefinition()
Returns the known base unit. |
String |
getBaseUnitName()
Returns the name of this unit. |
String |
getBaseUnitString()
Returns the base unit string, which will only be non-null if this unit was an unrecognised one. |
Dimensions |
getDimensions()
Return the dimensions of the unit, if it is a recognised one. |
FunctionDefinition |
getFunctionDefinition()
The function which is applied to the operand. |
String |
getFunctionName()
The function which is applied to the operand. |
int |
getPrefix()
Returns the prefix of the unit, as a base-ten log. |
OneUnit |
getUnit(UnitDefinition reqUnit)
Returns the unit in the operand which corresponds to the required unit. |
boolean |
isRecognisedUnit(Syntax syntax)
Indicates whether the base unit is one of those recognised within the specification of the given syntax. |
boolean |
isRecommendedUnit(Syntax syntax)
Indicates whether the base unit is one of those recommended within the specification of the given syntax. |
boolean |
satisfiesUsageConstraints(Syntax syntax)
Indicates whether the unit is being used in a way which satisfies any usage constraints. |
String |
toDebugString()
Write out the unit in a testable format. |
String |
toString()
Format this unit in some sort of canonical form. |
String |
toString(Syntax syntax)
Format this unit in some sort of canonical form appropriate to the given syntax. |
String |
unitString(Syntax syntax)
Obtains the string representation of the unit, including prefix, in the given syntax. |
| Methods inherited from class uk.me.nxg.unity.OneUnit |
|---|
getExponent, isQuoted |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public int getPrefix()
OneUnit"m", for ‘milli’, would produce a prefix of -3.
getPrefix in class OneUnitpublic Dimensions getDimensions()
OneUnit
getDimensions in class OneUnitpublic UnitDefinition getBaseUnitDefinition()
OneUnitOneUnit.getBaseUnitString() will not.
Note that the ‘base unit’ is simply the unit without the prefix, and
doesn't refer to the fundamental SI base units. Thus in the
expression "MW", it is ‘W’, Watt, that is the base unit.
getBaseUnitDefinition in class OneUnitpublic String getBaseUnitName()
OneUnit
getBaseUnitName in class OneUnitpublic String getBaseUnitString()
OneUnit
getBaseUnitString in class OneUnitpublic OneUnit getUnit(UnitDefinition reqUnit)
public boolean isRecognisedUnit(Syntax syntax)
OneUnitNote that this checks that the unit is a recommended one: we don't (currently) check whether the abbreviation that got us here is a recommended one (for example, ‘pixel’ is a valid FITS/CDS name for pixels, and ‘pix’ is a FITS and OGIP one).
isRecognisedUnit in class OneUnitsyntax - one of the syntaxes of SyntaxOneUnit.isRecommendedUnit(uk.me.nxg.unity.Syntax)public boolean isRecommendedUnit(Syntax syntax)
OneUnitNote that this checks that the unit is a recommended one: we don't (currently) check whether the abbreviation that got us here is a recommended one (for example, "pixel" is a valid FITS/CDS name for pixels, and "pix" is a FITS and OGIP one).
isRecommendedUnit in class OneUnitsyntax - one of the syntaxes of SyntaxOneUnit.isRecognisedUnit(uk.me.nxg.unity.Syntax)public boolean satisfiesUsageConstraints(Syntax syntax)
OneUnitAn unrecognised unit has no constraints, and so will always satisfy them; this extends to units which are unrecognised in a particular syntax.
satisfiesUsageConstraints in class OneUnitsyntax - one of the syntaxes of Syntaxpublic String toDebugString()
OneUnit
toDebugString in class OneUnitpublic String toString()
OneUnitUnitExpr.toString().
toString in class OneUnitpublic String toString(Syntax syntax)
OneUnitUnitExpr.toString().
toString in class OneUnit
public String unitString(Syntax syntax)
throws UnitParserException
OneUnit
unitString in class OneUnitsyntax - one of the syntaxes of Syntax
UnitParserException - if the syntax is unrecognisedpublic FunctionDefinition getFunctionDefinition()
getFunctionName() returns
non-null, and not both.
public String getFunctionName()
getFunctionDefinition() returns
non-null, and not both.
public boolean equals(Object o)
equals in class Objectpublic int compareTo(OneUnit o)
compareTo in interface Comparable<OneUnit>compareTo in class OneUnit
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||