Package org.apache.sis.io.wkt
Class WKTDictionary.Loader
java.lang.Object
org.apache.sis.io.wkt.WKTDictionary.Loader
- Enclosing class:
WKTDictionary
Implementation of
WKTDictionary.load(BufferedReader)
method.
Caller must own the write lock before to instantiate and use this class.-
Field Summary
FieldsModifier and TypeFieldDescriptionAliases that existed before inWKTDictionary.parser
before loading started.private String
If the WKT being parsed is an alias, the alias key.private final StringBuilder
Temporary buffer where to put the WKT to parse.private int
Zero-based number of current line.private final ParsePosition
Argument foraddAliasOrDefinition()
.private static final String
Keyword recognized byWKTDictionary.load(BufferedReader)
.private final BufferedReader
The source of WKT definitions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Parses the currentbuffer
content as a WKT elements (possibly with children elements).(package private) final String
canNotRead
(String cause, Exception e) Returns an error message saying "Cannot read WKT at line X".private int
Returns the one-based line number of the last line read.(package private) final void
read()
Adds to the enclosing factory all definitions read from the given source.(package private) final void
restore()
RestoresWKTDictionary.parser
to its initial state.
-
Field Details
-
SET
Keyword recognized byWKTDictionary.load(BufferedReader)
.- See Also:
-
source
The source of WKT definitions. -
buffer
Temporary buffer where to put the WKT to parse. -
aliasKey
If the WKT being parsed is an alias, the alias key. Otherwisenull
. -
pos
Argument foraddAliasOrDefinition()
. -
lineNumber
private int lineNumberZero-based number of current line. Equivalent toLineNumberReader.getLineNumber()
. -
aliases
Aliases that existed before inWKTDictionary.parser
before loading started.
-
-
Constructor Details
-
Loader
Loader(BufferedReader source) Creates a new loader.
-
-
Method Details
-
restore
final void restore()RestoresWKTDictionary.parser
to its initial state. This method should be invoked in a finally block regardless if the parsing succeeded or failed. -
canNotRead
Returns an error message saying "Cannot read WKT at line X". The message is followed by a "Caused by" phrase specified either as a string or an exception. At least one ofcause
ande
shall be non-null. -
getLineNumber
private int getLineNumber()Returns the one-based line number of the last line read. Actually this method returns the zero-based line number of current position, but since current position is after the last line read, this is equivalent to line number of last line read + 1.- Returns:
- one-based line number of current position.
-
read
Adds to the enclosing factory all definitions read from the given source. SeeWKTDictionary.load(BufferedReader)
for a format description.- Throws:
IOException
- if an error occurred while reading lines.ParseException
- if an error occurred while parsing a WKT.FactoryDataException
- if the file has a syntax error.IllegalArgumentException
- if acodespace:version:code
tuple or an alias is assigned twice.
-
addAliasOrDefinition
Parses the currentbuffer
content as a WKT elements (possibly with children elements). This method does not build the fullIdentifiedObject
; this latter part will be done only when first needed.If
aliasKey
is non-null, the first WKT is taken as a fragment associated to the given alias. All other WKT (if any) are taken as definitions of CRS or other objects.- Throws:
ParseException
- if an error occurred while parsing the WKT string.FactoryDataException
- if there is unparsed text after the WKT.IllegalArgumentException
- if acodespace:version:code
tuple or an alias is assigned twice.
-