Package uk.me.nxg.unity
Class UnitDefinition
java.lang.Object
uk.me.nxg.unity.UnitDefinition
- All Implemented Interfaces:
Serializable
,Comparable<UnitDefinition>
Describes a unit.
A ‘unit’is a notion like ‘metre’, or ‘pixel’, and is not dependent on a particular syntax. The information here includes a readable name for a quantity (such as ‘Metre’ or ‘Julian year’), a URI uniquely naming it, and its dimensions.
The URI unique name is derived from the QUDT framework of quantities, units and dimensions, though it is not restricted to the set of units and quantities defined there.
The syntax-specific aspects of describing units concern how the
unit is abbreviated, and indeed whether it is permitted or
recommended in a particular syntax, and this is described by the
class UnitRepresentation
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
Further remarks about this unit, or other commentsThe dimensions of this unit For example, the joule has dimensions ‘L^2 M T^-2’.boolean
Return a representation of this unit, from any syntax that knows of one.getRepresentation
(Syntax syntax) Return the syntax-specific information about this unit.getURI()
The Kind of this unit, named by a URIint
hashCode()
label()
A label for this unit, for example ‘Meter’.A LaTeX version of the unit symbol, if there is one definedname()
The (human-readable) name of this unit, for example ‘Metre’ or ‘Second’toString()
Produces a representation of this unit as a string, combining the name of the unit and a URI referring to it unambiguously.type()
A label for the type of this unit, as a QUDT (or similar) ‘quantity’ URI.
-
Method Details
-
name
The (human-readable) name of this unit, for example ‘Metre’ or ‘Second’- Returns:
- a string unit name (not null)
-
label
A label for this unit, for example ‘Meter’. It is (currently) formed from the URI of the unit, but this version of the library doesn't commit to the label being completely stable. This label will typically be the same as the name, but will not, for example, have spaces in it, and will not necessarily be spelled the same way. For example the URI for the metre has fragment `#Meter`, and that for the second `#SecondTime`.- Returns:
- a string denoting the unit, without spaces and expected to be unique (not null)
-
type
A label for the type of this unit, as a QUDT (or similar) ‘quantity’ URI. For example the metre and the light year are both ‘http://qudt.org/vocab/quantity#Length’- Returns:
- a string unit description (not null)
-
description
Further remarks about this unit, or other comments- Returns:
- comments about the unit, or null if there is nothing more to say
-
latexForm
A LaTeX version of the unit symbol, if there is one defined- Returns:
- a string representation of the unit in LaTeX form, or null if there is no special form
-
dimensions
The dimensions of this unit For example, the joule has dimensions ‘L^2 M T^-2’.- Returns:
- a Dimensions object representing the unit dimensions
-
getURI
The Kind of this unit, named by a URI- Returns:
- a string representing the unit's URI
-
getRepresentation
Return the syntax-specific information about this unit. Returns null if the syntax is unknown for this unit, meaning that the given syntax does not recognise this unit as a recommended one.- Parameters:
syntax
- a non-null string name for the syntax, which should be one of the syntaxes ofSyntax
- Returns:
- the syntax details for this unit in this syntax, or null if the syntax is unknown
-
getRepresentation
Return a representation of this unit, from any syntax that knows of one. Since every known unit appears in at least one map, this will never return null.- Returns:
- a representation of this unit
-
compareTo
- Specified by:
compareTo
in interfaceComparable<UnitDefinition>
-
equals
-
hashCode
public int hashCode() -
toString
Produces a representation of this unit as a string, combining the name of the unit and a URI referring to it unambiguously. This is occasionally useful, but not for formatting expressions into unit strings: for that, useUnitExpr.toString()
. If you wish to get a human-readable representation of the unit, then usegetRepresentation(uk.me.nxg.unity.Syntax)
.
-