Package org.apache.sis.internal.jaxb.gml
Class Measure
java.lang.Object
org.apache.sis.internal.jaxb.gml.Measure
A measurement value together with its unit of measure.
This is used for marshalling an element defined by ISO 19103.
This class duplicates org.apache.sis.measure.Measure, but we have to do that way
because that Measure extends Number and we are not allowed to use the
@XmlValue annotation on a class that extends another class.
XML marshalling
Measures are used in different ways by the ISO 19115 (Metadata) and GML standards. The former expresses some measurements with an object of XML typegco:Distance
(as a substitution for XML type gco:Measure):
while GML will rather use a a syntax like below:
Both have a value of type xs:double and a uom attribute (without namespace)
of type gml:UomIdentifier. Those two information are represented by this class.- Since:
- 0.3
- Version:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleantrueif the units shall be formatted asxpointer.private static final UnitFormatAn instance for formatting units with a syntax close to the UCUM one.javax.measure.Unit<?>The unit of measurement.doubleThe value of the measure. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q>Returnsunitas a unit compatible with the given quantity.getUOM()Constructs a string representation of the units as defined in the ISO 19103 standard.static StringgetUOM(javax.measure.Unit<?> unit, boolean asXPointer, boolean inAxis) Implementation ofgetUOM()as a static method for use by classes that define their ownuomattribute, instead of letting theuomattribute on the measurement value.static voidmissingUOM(Class<?> caller, String methodName) Sends a warning for a missing"uom"attribute.booleansetUnit(javax.measure.Unit<?> newUnit) Sets the unit to the given value, and returnstrueif the currentunitvalue was different.voidSets the unit of measure.
-
Field Details
-
UCUM
An instance for formatting units with a syntax close to the UCUM one. WhileUnitFormatis generally not thread-safe, this particular instance is safe if we never invoke any setter method. -
value
public double valueThe value of the measure. -
unit
public javax.measure.Unit<?> unitThe unit of measurement. -
asXPointer
public boolean asXPointertrueif the units shall be formatted asxpointer. Iffalse(the default), then this class will try to format the units using the GML syntax.
-
-
Constructor Details
-
Measure
public Measure()Default empty constructor for JAXB. The value is initialized to NaN, but JAXB will overwrite that value if a XML value is present. -
Measure
public Measure(double value, javax.measure.Unit<?> unit) Constructs a representation of the measure as defined in ISO 19103 standard, with the UOM attribute like"gmxUom.xml#xpointer(//*[@gml:id='m'])".- Parameters:
value- the value of the measure.unit- the unit of measurement.
-
-
Method Details
-
getUOM
Constructs a string representation of the units as defined in the ISO 19103 standard. This method is invoked during XML marshalling. For example if the units are "metre", then this method returns one of the following strings, in preference order: or one of the following:- Returns:
- the string representation of the unit of measure.
-
getUOM
Implementation ofgetUOM()as a static method for use by classes that define their ownuomattribute, instead of letting theuomattribute on the measurement value. The main example isDefaultCoordinateSystemAxis.- Parameters:
unit- the unit to format.asXPointer-trueif the units shall be formatted asxpointer.inAxis-truefor a unit used in Coordinate System Axis definition.- Returns:
- the string representation of the unit of measure.
-
setUOM
Sets the unit of measure. This method is invoked by JAXB at unmarshalling time.- Parameters:
uom- the unit of measure as a string.- Throws:
URISyntaxException- if theuomlooks like a URI, but cannot be parsed.
-
getUnit
Returnsunitas a unit compatible with the given quantity.- Type Parameters:
Q- compile-time type of thetypeargument.- Parameters:
type- the quantity for the desired unit.- Returns:
- a unit compatible with the given type, or
nullif none.
-
setUnit
public boolean setUnit(javax.measure.Unit<?> newUnit) Sets the unit to the given value, and returnstrueif the currentunitvalue was different. A return value oftruemeans that the caller should log a warning.Example: Some users wrongly assign the "m" unit toEllipsoid.inverseFlattening. The SIS adapter forces the unit toUnits.UNITY, but we want to let the user know that he probably did something wrong.- Parameters:
newUnit- the new unit (cannot be null).- Returns:
trueif a different unit was defined before this method call.
-
missingUOM
Sends a warning for a missing"uom"attribute.- Parameters:
caller- the class of the method invoking this method.methodName- the name of the method invoking this method.
-