Package org.geotools.referencing.wkt
Class AbstractParser
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
MathTransformParser
Base class for Well Know Text (WKT) parser.
- Since:
- 2.0
- Author:
- Remi Eve, Martin Desruisseaux (IRD)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Format
Format.Field
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractParser
(Symbols symbols) Constructs a parser using the specified set of symbols. -
Method Summary
Modifier and TypeMethodDescriptionformat
(Object object, StringBuffer toAppendTo, FieldPosition pos) Format the specified object as a Well Know Text.Returns the preferred authority for formatting WKT entities.protected final Element
getTree
(String text, ParsePosition position) Returns a tree ofElement
for the specified text.If a warning occured during the last WKT formatting, returns the warning.boolean
Returnstrue
if syntax coloring is enabled.protected abstract Object
Parses the next element in the specified Well Know Text (WKT) tree.final Object
parseObject
(String text) Parses a Well Know Text (WKT).final Object
parseObject
(String text, ParsePosition position) Parses a Well Know Text (WKT).void
reformat
(BufferedReader in, Writer out, PrintWriter err) Read WKT strings from an input stream and reformat them to the specified output stream.void
setAuthority
(Citation authority) Set the preferred authority for formatting WKT entities.void
setColorEnabled
(boolean enabled) Enables or disables syntax coloring on ANSI X3.64 (aka ECMA-48 and ISO/IEC 6429) compatible terminal.Methods inherited from class Format
clone, format, formatToCharacterIterator
-
Constructor Details
-
AbstractParser
Constructs a parser using the specified set of symbols.- Parameters:
symbols
- The set of symbols to use.
-
-
Method Details
-
getAuthority
Returns the preferred authority for formatting WKT entities. Theformat
methods will uses the name specified by this authority, if available.- Returns:
- The expected authority.
-
setAuthority
Set the preferred authority for formatting WKT entities. Theformat
methods will uses the name specified by this authority, if available.- Parameters:
authority
- The new authority.
-
isColorEnabled
public boolean isColorEnabled()Returnstrue
if syntax coloring is enabled. By default, syntax coloring is disabled.- Returns:
true
if syntax coloring are enabled.- Since:
- 2.4
-
setColorEnabled
public void setColorEnabled(boolean enabled) Enables or disables syntax coloring on ANSI X3.64 (aka ECMA-48 and ISO/IEC 6429) compatible terminal. This apply only when formatting text. By default, syntax coloring is disabled. When enabled,Format.format(Object)
tries to highlight most of the elements compared byCRS.equalsIgnoreMetadata(java.lang.Object, java.lang.Object)
.- Parameters:
enabled
-true
for enabling syntax coloring.- Since:
- 2.4
-
parseObject
Parses a Well Know Text (WKT).- Overrides:
parseObject
in classFormat
- Parameters:
text
- The text to be parsed.- Returns:
- The object.
- Throws:
ParseException
- if the string can't be parsed.
-
parseObject
Parses a Well Know Text (WKT).- Specified by:
parseObject
in classFormat
- Parameters:
text
- The text to be parsed.position
- The position to start parsing from.- Returns:
- The object.
-
parse
Parses the next element in the specified Well Know Text (WKT) tree.- Parameters:
element
- The element to be parsed.- Returns:
- The object.
- Throws:
ParseException
- if the element can't be parsed.
-
getTree
Returns a tree ofElement
for the specified text.- Parameters:
text
- The text to parse.position
- In input, the position where to start parsing from. In output, the first character after the separator.- Returns:
- The tree of elements to parse.
- Throws:
ParseException
- If an parsing error occured while creating the tree.
-
format
Format the specified object as a Well Know Text. Formatting will uses the same set of symbols than the one used for parsing. -
reformat
Read WKT strings from an input stream and reformat them to the specified output stream. WKT strings are read until the the end-of-stream, or until an unparsable WKT has been hit. In this later case, an error message is formatted to the specified error stream.- Parameters:
in
- The input stream.out
- The output stream.err
- The error stream.- Throws:
IOException
- if an error occured while reading from the input stream or writting to the output stream.
-
getWarning
If a warning occured during the last WKT formatting, returns the warning. Otherwise returnsnull
. The warning is cleared every time a new object is formatted.- Returns:
- The last warning, or
null
if none. - Since:
- 2.4
-