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 ElementgetTree(String text, ParsePosition position) Returns a tree ofElementfor the specified text.If a warning occured during the last WKT formatting, returns the warning.booleanReturnstrueif syntax coloring is enabled.protected abstract ObjectParses the next element in the specified Well Know Text (WKT) tree.final ObjectparseObject(String text) Parses a Well Know Text (WKT).final ObjectparseObject(String text, ParsePosition position) Parses a Well Know Text (WKT).voidreformat(BufferedReader in, Writer out, PrintWriter err) Read WKT strings from an input stream and reformat them to the specified output stream.voidsetAuthority(Citation authority) Set the preferred authority for formatting WKT entities.voidsetColorEnabled(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. Theformatmethods will uses the name specified by this authority, if available.- Returns:
- The expected authority.
-
setAuthority
Set the preferred authority for formatting WKT entities. Theformatmethods will uses the name specified by this authority, if available.- Parameters:
authority- The new authority.
-
isColorEnabled
public boolean isColorEnabled()Returnstrueif syntax coloring is enabled. By default, syntax coloring is disabled.- Returns:
trueif 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-truefor enabling syntax coloring.- Since:
- 2.4
-
parseObject
Parses a Well Know Text (WKT).- Overrides:
parseObjectin 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:
parseObjectin 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 ofElementfor 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
nullif none. - Since:
- 2.4
-