Package org.geotools.referencing.wkt
Class Element
Object
Element
An element in a Well Know Text (WKT). A
Element
is made of String
, Number
and
other Element
. For example:
EachPRIMEM["Greenwich", 0.0, AUTHORITY["some authority", "Greenwich"]]
Element
object can contains an arbitrary amount of other elements. The result is a tree, which can be
printed with print(java.io.PrintWriter, int)
. Elements can be pull in a first in, first out order.- Since:
- 2.0
- Author:
- Remi Eve, Martin Desruisseaux (IRD)
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this element.boolean
isRoot()
Returnstrue
if this element is the root element.parseFailed
(Exception cause, String message) Returns aParseException
with the specified cause.peek()
Returns the next element, ornull
if there is no more element.void
print
(PrintWriter out, int level) Print thisElement
as a tree.double
pullDouble
(String key) Removes the nextNumber
from the list and returns it.pullElement
(String key) Removes the nextElement
from the list and returns it.int
pullInteger
(String key) Removes the nextNumber
from the list and returns it as an integer.Removes the nextElement
from the list and returns it.pullOptionalString
(String key) Removes the nextString
from the list and returns it.Removes and returns the nextElement
with no bracket, if available, or null otherwise.pullString
(String key) Removes the nextString
from the list and returns it.pullVoidElement
(String key) Removes and returns the nextElement
with no bracket.toString()
Returns the keyword.
-
Field Details
-
keyword
Keyword of this entity. For example: "PRIMEM".
-
-
Method Details
-
parseFailed
Returns aParseException
with the specified cause. A localized string"Error in <
will be prepend to the message. The error index will be the starting index of thiskeyword
>"Element
.- Parameters:
cause
- The cause of the failure, ornull
if none.message
- The message explaining the cause of the failure, ornull
for reusing the same message thancause
.- Returns:
- The exception to be thrown.
-
isRoot
public boolean isRoot()Returnstrue
if this element is the root element. For example in a WKT like"GEOGCS["name", DATUM["name, ...]]"
, this is true for"GEOGCS"
and false for all other elements inside, like"DATUM"
.- Returns:
true
if this element is the root element.- Since:
- 2.3
-
pullDouble
Removes the nextNumber
from the list and returns it.- Parameters:
key
- The parameter name. Used for formatting an error message if no number are found.- Returns:
- The next
Number
on the list as adouble
. - Throws:
ParseException
- if no more number is available.
-
pullInteger
Removes the nextNumber
from the list and returns it as an integer.- Parameters:
key
- The parameter name. Used for formatting an error message if no number are found.- Returns:
- The next
Number
on the list as anint
. - Throws:
ParseException
- if no more number is available, or the number is not an integer.
-
pullString
Removes the nextString
from the list and returns it.- Parameters:
key
- The parameter name. Used for formatting an error message if no number are found.- Returns:
- The next
String
on the list. - Throws:
ParseException
- if no more string is available.
-
pullOptionalString
Removes the nextString
from the list and returns it.- Parameters:
key
- The parameter name. Used for formatting an error message if no number are found.- Returns:
- The next
String
on the list ornull
if no more element is available.
-
pullElement
Removes the nextElement
from the list and returns it.- Parameters:
key
- The element name (e.g."PRIMEM"
).- Returns:
- The next
Element
on the list. - Throws:
ParseException
- if no more element is available.
-
pullOptionalElement
Removes the nextElement
from the list and returns it.- Parameters:
key
- The element name (e.g."PRIMEM"
).- Returns:
- The next
Element
on the list, ornull
if no more element is available.
-
pullVoidElement
Removes and returns the nextElement
with no bracket. The key is used only for only for formatting an error message.- Parameters:
key
- The parameter name. Used only for formatting an error message.- Returns:
- The next
Element
in the list, with no bracket. - Throws:
ParseException
- if no more void element is available.
-
pullOptionalVoidElement
Removes and returns the nextElement
with no bracket, if available, or null otherwise.- Returns:
- The next
Element
in the list, with no bracket, or null if none was found - Throws:
ParseException
- if no more void element is available.
-
peek
Returns the next element, ornull
if there is no more element. The element is not removed from the list.- Returns:
- The next element, or
null
if there is no more elements.
-
close
Close this element.- Throws:
ParseException
- If the list still contains some unprocessed elements.
-
toString
Returns the keyword. This overriding is needed for correct formatting of the error message inclose()
. -
print
Print thisElement
as a tree. This method is used for debugging purpose only.- Parameters:
out
- The output stream.level
- The indentation level (usually 0).
-