Package org.apache.sis.io
Class DefaultFormat
java.lang.Object
java.text.Format
org.apache.sis.io.DefaultFormat
- All Implemented Interfaces:
Serializable,Cloneable
Created by
CompoundFormat for parsing and formatting unlocalized numbers.
This implementation use toString() and valueOf(…) methods instead
than the java.text package because the former provide the best guarantees
to format all significant digits.
Thread safety
The same instance can be safely used by many threads without synchronization on the part of the caller. Note that this is specific toDefaultFormat and generally not true
for arbitrary Format classes.- Since:
- 0.3
- Version:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.Format
Format.Field -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDefaultFormat(Class<?> type) Creates a new instance for parsing and formatting objects of the given type. -
Method Summary
Modifier and TypeMethodDescriptionclone()Unconditionally returnsthissince this format does not contain any modifiable field.format(Object obj, StringBuffer toAppendTo, FieldPosition pos) Formats the given number using itsObject.toString()method.(package private) static FormatgetInstance(Class<?> type) Gets an instance of the given type, ornullif the given type is not supported.parseObject(String source) Parses the given string as a number of the type given at construction time.parseObject(String source, ParsePosition pos) Parses the given string as a number of the type given at construction time.private ObjectResolves to the singleton instance on deserialization.private ObjectParses the given string.Methods inherited from class java.text.Format
format, formatToCharacterIterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
INSTANCES
The array for storing singleton instances for typesbytetodouble. The value at index 0 is reserved for the genericNumbertype. -
type
The type of the objects to parse.
-
-
Constructor Details
-
DefaultFormat
Creates a new instance for parsing and formatting objects of the given type.
-
-
Method Details
-
getInstance
Gets an instance of the given type, ornullif the given type is not supported. -
format
Formats the given number using itsObject.toString()method. -
valueOf
Parses the given string. Callers shall catch theNumberFormatExceptionand handle the error according the caller's method contract.- Throws:
NumberFormatException- if the parsing failed.
-
parseObject
Parses the given string as a number of the type given at construction time.- Overrides:
parseObjectin classFormat- Throws:
ParseException
-
parseObject
Parses the given string as a number of the type given at construction time.- Specified by:
parseObjectin classFormat
-
clone
Unconditionally returnsthissince this format does not contain any modifiable field. The sameDefaultFormatinstances can be shared. -
readResolve
Resolves to the singleton instance on deserialization.- Throws:
ObjectStreamException
-