Class LocationFormat
- All Implemented Interfaces:
Serializable, Cloneable, Localized
Formats
Location instances in a tabular format.
This format assumes a monospaced font and an encoding supporting drawing box characters (e.g. UTF-8).
Example
The location identified by "32TNL83" in the military grid reference system can be represented by the following string formatted usingLocale.ENGLISH:
┌─────────────────────────────────────────────────────────────┐ │ Location type: Grid zone designator │ │ Geographic identifier: 32TNL83 │ │ West bound: 580,000 m — 9°57′00″E │ │ Representative value: 585,000 m — 10°00′36″E │ │ East bound: 590,000 m — 10°04′13″E │ │ South bound: 4,530,000 m — 40°54′58″N │ │ Representative value: 4,535,000 m — 40°57′42″N │ │ North bound: 4,540,000 m — 41°00′27″N │ │ Coordinate reference system: WGS 84 / UTM zone 32N │ └─────────────────────────────────────────────────────────────┘
Limitations
- The current implementation can only format features — parsing is not yet implemented.
LocationFormat, like mostjava.text.Formatsubclasses, is not thread-safe.
- Since:
- 0.8
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Format
Format.Field -
Field Summary
Fields inherited from class TabularFormat
beforeFill, columnSeparator, fillCharacter, lineSeparator, omitTrailingNullsModifier and TypeFieldDescriptionprotected StringThe string to write before theTabularFormat.fillCharacter, or an empty string if none.protected StringThe string to write after theTabularFormat.fillCharacter, or an empty string if none.protected charThe character to repeat after the content of a cell for alignment with the next column.protected StringThe line separator to use for formatting the tree.protected booleantrueif the trailingnullvalues shall be omitted at formatting time. -
Constructor Summary
ConstructorsConstructorDescriptionLocationFormat(Locale locale, TimeZone timezone) Creates a new format for the given locale. -
Method Summary
Modifier and TypeMethodDescriptionclone()Returns a clone of this format.protected FormatcreateFormat(Class<?> valueType) Creates the format to use for formatting a latitude, longitude or projected coordinate.voidformat(AbstractLocation location, Appendable toAppendTo) Writes a textual representation of the given location in the given stream or buffer.Returns the type of values formatted by thisFormatinstance.parse(CharSequence text, ParsePosition pos) Unsupported operation.Methods inherited from class TabularFormat
getColumnSeparatorMatcher, getColumnSeparatorPattern, getLineSeparator, setColumnSeparatorPattern, setLineSeparatorModifier and TypeMethodDescriptionprotected MatcherReturns a matcher for the column separators in the given text.Returns the pattern of characters used in column separators.Returns the current line separator.voidsetColumnSeparatorPattern(String pattern) Sets the pattern of the characters to insert between the columns.voidsetLineSeparator(String separator) Sets the line separator.Methods inherited from class CompoundFormat
format, format, formatObject, getFormat, getLocale, getLocale, getTemporalStyle, getTimeZone, parseObject, parseObjectModifier and TypeMethodDescriptionformat(Object object, StringBuffer toAppendTo, FieldPosition pos) Writes a textual representation of the specified object in the given buffer.voidformat(AbstractLocation object, StringBuilder toAppendTo) Writes a textual representation of the given object in the given buffer.voidformatObject(Object object, Appendable toAppendTo) Writes a textual representation of an object of arbitrary class in the given stream or buffer.protected FormatgetFormat(Class<?> valueType) Returns the format to use for parsing and formatting values of the given type.Returns the locale used by this format.getLocale(Locale.Category category) Returns the locale for the given category.protected FormatStylegetTemporalStyle(boolean dates) Returns the style to use for formatting dates or times.Returns the timezone used by this format.parseObject(String text) Creates an object from the given string representation.parseObject(String text, ParsePosition pos) Creates an object from the given string representation, or returnsnullif an error occurred while parsing.Methods inherited from class Format
format, formatToCharacterIterator
-
Constructor Details
-
LocationFormat
Creates a new format for the given locale. The given locale can benullorLocale.ROOTif this format shall format "unlocalized" strings.- Parameters:
locale- the locale for the newFormat, ornullforLocale.ROOT.timezone- the timezone, ornullfor UTC.
-
-
Method Details
-
getValueType
Returns the type of values formatted by thisFormatinstance.- Specified by:
getValueTypein classCompoundFormat<AbstractLocation>- Returns:
- the type of values formatted by this
Formatinstance.
-
format
Writes a textual representation of the given location in the given stream or buffer.Upcoming API change — generalization
in a future SIS version, the type oflocationparameter may be generalized to theorg.opengis.referencing.gazetteer.Locationinterface. This change is pending GeoAPI revision.- Specified by:
formatin classCompoundFormat<AbstractLocation>- Parameters:
location- the location to format.toAppendTo- where to format the location.- Throws:
IOException- if an error occurred while writing to the given appendable.
-
createFormat
Creates the format to use for formatting a latitude, longitude or projected coordinate. This method is invoked byformat(Location, Appendable)when first needed.- Overrides:
createFormatin classCompoundFormat<AbstractLocation>- Parameters:
valueType-Angle.class.Number.classorUnit.class.- Returns:
- a new
AngleFormat,NumberFormatorUnitFormatinstance depending on the argument value.
-
parse
Unsupported operation.- Specified by:
parsein classCompoundFormat<AbstractLocation>- Parameters:
text- the character sequence for the location to parse.pos- the position where to start the parsing.- Returns:
- the parsed location, or
nullif the text is not recognized. - Throws:
ParseException- if an error occurred while parsing the location.
-
clone
Returns a clone of this format.- Overrides:
clonein classTabularFormat<AbstractLocation>- Returns:
- a clone of this format.
-