Package org.geotools.measure
Class BaseUnitFormatter
- Object
-
- AbstractUnitFormat
-
- SimpleUnitFormat
-
- BaseUnitFormatter
-
- All Implemented Interfaces:
UnitFormat
,UnitFormatter
public class BaseUnitFormatter extends SimpleUnitFormat implements UnitFormatter
This class encapsulates the required machinations to initialize the unit formatter implementation of a certain third-party unit library.GeoTools' unit formatters should be implemented by calling the provided constructors.
-
-
Constructor Summary
Constructors Constructor Description BaseUnitFormatter(List<UnitDefinition> unitDefinitions)
Create a newBaseUnitFormatter
instance, initialized with provided the unit definitions.BaseUnitFormatter(UnitDefinition... unitDefinitions)
Create a newBaseUnitFormatter
instance, initialized with provided the unit definitions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addUnit(Unit<?> unit)
Defaults to being a no-op, subclasses can overridevoid
alias(Unit<?> unit, String alias)
Appendable
format(Unit<?> unit, Appendable appendable)
Map<String,Unit<?>>
getSymbolToUnitMap()
Deprecated.Map<Unit<?>,String>
getUnitToSymbolMap()
Deprecated.protected static boolean
isUnitIdentifierPart(char ch)
protected boolean
isValidIdentifier(String name)
Copy from DefaultFormattervoid
label(Unit<?> unit, String label)
Unit<?>
parse(CharSequence csq)
protected Unit<?>
parse(CharSequence csq, int index)
Unit<?>
parse(CharSequence csq, ParsePosition cursor)
Unit<? extends Quantity>
parseProductUnit(CharSequence csq, ParsePosition pos)
Unit<? extends Quantity>
parseSingleUnit(CharSequence csq, ParsePosition pos)
-
Methods inherited from class SimpleUnitFormat
format, getInstance, getInstance, getNewInstance, getNewInstance, parseObject
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface UnitFormatter
format
-
-
-
-
Constructor Detail
-
BaseUnitFormatter
public BaseUnitFormatter(UnitDefinition... unitDefinitions)
Create a newBaseUnitFormatter
instance, initialized with provided the unit definitions.- Parameters:
unitDefinitions
- unit definitions used to initialize this new instance
-
BaseUnitFormatter
public BaseUnitFormatter(List<UnitDefinition> unitDefinitions)
Create a newBaseUnitFormatter
instance, initialized with provided the unit definitions.- Parameters:
unitDefinitions
- a list of unit definitions used to initialize this new instance
-
-
Method Detail
-
getUnitToSymbolMap
@Deprecated public Map<Unit<?>,String> getUnitToSymbolMap()
Deprecated.- Returns:
- an immutable map that shows the units (associated with their symbols) that this unit formatter contains
-
getSymbolToUnitMap
@Deprecated public Map<String,Unit<?>> getSymbolToUnitMap()
Deprecated.- Returns:
- an immutable map that shows the symbols (associated with their units) that this unit formatter contains
-
addUnit
protected void addUnit(Unit<?> unit)
Defaults to being a no-op, subclasses can override
-
format
public Appendable format(Unit<?> unit, Appendable appendable) throws IOException
- Specified by:
format
in interfaceUnitFormat
- Specified by:
format
in interfaceUnitFormatter
- Specified by:
format
in classSimpleUnitFormat
- Throws:
IOException
-
parseProductUnit
public Unit<? extends Quantity> parseProductUnit(CharSequence csq, ParsePosition pos) throws MeasurementParseException
- Specified by:
parseProductUnit
in classSimpleUnitFormat
- Throws:
MeasurementParseException
-
parseSingleUnit
public Unit<? extends Quantity> parseSingleUnit(CharSequence csq, ParsePosition pos) throws MeasurementParseException
- Specified by:
parseSingleUnit
in classSimpleUnitFormat
- Throws:
MeasurementParseException
-
label
public void label(Unit<?> unit, String label)
- Specified by:
label
in interfaceUnitFormat
- Specified by:
label
in classSimpleUnitFormat
-
parse
public Unit<?> parse(CharSequence csq, ParsePosition cursor) throws IllegalArgumentException
- Specified by:
parse
in interfaceUnitFormat
- Specified by:
parse
in interfaceUnitFormatter
- Specified by:
parse
in classAbstractUnitFormat
- Throws:
IllegalArgumentException
-
parse
public Unit<?> parse(CharSequence csq) throws MeasurementParseException
- Specified by:
parse
in interfaceUnitFormat
- Specified by:
parse
in interfaceUnitFormatter
- Throws:
MeasurementParseException
-
parse
protected Unit<?> parse(CharSequence csq, int index) throws IllegalArgumentException
- Specified by:
parse
in classAbstractUnitFormat
- Throws:
IllegalArgumentException
-
alias
public void alias(Unit<?> unit, String alias)
- Specified by:
alias
in classSimpleUnitFormat
-
isValidIdentifier
protected boolean isValidIdentifier(String name)
Copy from DefaultFormatter- Specified by:
isValidIdentifier
in classSimpleUnitFormat
-
isUnitIdentifierPart
protected static boolean isUnitIdentifierPart(char ch)
-
-