Package javax.measure.test.format
Class SimpleTestUnitFormat
Object
SimpleTestUnitFormat
- All Implemented Interfaces:
 UnitFormat
Provides a simple interface for formatting and parsing units.
- Version:
 - 1.0, February 13, 2021
 - Author:
 - Werner Keil
 
- 
Method Summary
Modifier and TypeMethodDescriptionfinal StringFormats an object to produce a string.format(Unit<?> unit, Appendable appendable) Formats the specified unit.static UnitFormatReturns the instance for formatting and parsing using case insensitive symbolsstatic UnitFormatReturns the unit format for the default locale.voidfinal Unit<?>parse(CharSequence csq) Parses the specified character sequence to produce a unit (convenience method).protected Unit<?>parse(CharSequence csq, int index) final Unit<?>parse(CharSequence csq, ParsePosition pos) Parses the specified character sequence to produce a unit (convenience method).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface UnitFormat
isLocaleSensitive 
- 
Method Details
- 
geInstance
Returns the instance for formatting and parsing using case insensitive symbols- Returns:
 - the default instance
 
 - 
format
Formats the specified unit.- Specified by:
 formatin interfaceUnitFormat- Parameters:
 unit- the unit to format.appendable- the appendable destination.- Returns:
 - The appendable destination passed in as 
appendable, with formatted text appended. - Throws:
 IOException- if an error occurs.
 - 
label
 - 
getInstance
Returns the unit format for the default locale.- Returns:
 - the locale format.
 
 - 
parse
- Throws:
 MeasurementParseException
 - 
parse
Parses the specified character sequence to produce a unit (convenience method). If the specified sequence is empty, the unitary unit (dimensionless) is returned.- Specified by:
 parsein interfaceUnitFormat- Parameters:
 csq- theCharSequenceto parse.- Returns:
 - the unit parsed from the specified character sub-sequence.
 - Throws:
 MeasurementParseException- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).
 - 
parse
Parses the specified character sequence to produce a unit (convenience method). If the specified sequence is empty, the unitary unit (dimensionless) is returned.- Specified by:
 parsein interfaceUnitFormat- Parameters:
 csq- theCharSequenceto parse.pos- a ParsePosition object holding the current parsing index and error parsing index information as described above.- Returns:
 - the unit parsed from the specified character sub-sequence.
 - Throws:
 MeasurementParseException- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).
 - 
format
Formats an object to produce a string. This is equivalent toformat(unit, new StringBuilder()).toString();- Specified by:
 formatin interfaceUnitFormat- Parameters:
 unit- The unit to format- Returns:
 - Formatted string.
 - Throws:
 IllegalArgumentException- if the Format cannot format the given object
 
 -