org.geotools.referencing.wkt
Class AbstractParser

java.lang.Object
  extended byjava.text.Format
      extended byorg.geotools.referencing.wkt.AbstractParser
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
MathTransformParser, ParseWKT2GeoTiffMetadata

public abstract class AbstractParser
extends java.text.Format

Base class for Well Know Text (WKT) parser.

Since:
2.0
Version:
$Id: AbstractParser.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Remi Eve, Martin Desruisseaux
See Also:
Well Know Text specification, OGC WKT Coordinate System Issues, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Constructor Summary
AbstractParser(Symbols symbols)
          Constructs a parser using the specified set of symbols.
 
Method Summary
 java.lang.StringBuffer format(java.lang.Object object, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
          Format the specified object as a Well Know Text.
 org.opengis.metadata.citation.Citation getAuthority()
          Returns the preferred authority for formatting WKT entities.
protected  Element getTree(java.lang.String text, java.text.ParsePosition position)
          Returns a tree of Element for the specified text.
protected abstract  java.lang.Object parse(Element element)
          Parses the next element in the specified Well Know Text (WKT) tree.
 java.lang.Object parseObject(java.lang.String text)
          Parses a Well Know Text (WKT).
 java.lang.Object parseObject(java.lang.String text, java.text.ParsePosition position)
          Parses a Well Know Text (WKT).
 void reformat(java.io.BufferedReader in, java.io.Writer out, java.io.PrintWriter err)
          Read WKT strings from an input stream and reformat them to the specified output stream.
 void setAuthority(org.opengis.metadata.citation.Citation authority)
          Set the preferred authority for formatting WKT entities.
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractParser

public AbstractParser(Symbols symbols)
Constructs a parser using the specified set of symbols.

Method Detail

getAuthority

public org.opengis.metadata.citation.Citation getAuthority()
Returns the preferred authority for formatting WKT entities. The format methods will uses the name specified by this authority, if available.


setAuthority

public void setAuthority(org.opengis.metadata.citation.Citation authority)
Set the preferred authority for formatting WKT entities. The format methods will uses the name specified by this authority, if available.


parseObject

public final java.lang.Object parseObject(java.lang.String text)
                                   throws java.text.ParseException
Parses a Well Know Text (WKT).

Parameters:
text - The text to be parsed.
Returns:
The object.
Throws:
java.text.ParseException - if the string can't be parsed.

parseObject

public final java.lang.Object parseObject(java.lang.String text,
                                          java.text.ParsePosition position)
Parses a Well Know Text (WKT).

Parameters:
text - The text to be parsed.
position - The position to start parsing from.
Returns:
The object.

parse

protected abstract java.lang.Object parse(Element element)
                                   throws java.text.ParseException
Parses the next element in the specified Well Know Text (WKT) tree.

Parameters:
element - The element to be parsed.
Returns:
The object.
Throws:
java.text.ParseException - if the element can't be parsed.

getTree

protected final Element getTree(java.lang.String text,
                                java.text.ParsePosition position)
                         throws java.text.ParseException
Returns a tree of Element 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.
Throws:
java.text.ParseException

format

public java.lang.StringBuffer format(java.lang.Object object,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition pos)
Format the specified object as a Well Know Text. Formatting will uses the same set of symbols than the one used for parsing.


reformat

public void reformat(java.io.BufferedReader in,
                     java.io.Writer out,
                     java.io.PrintWriter err)
              throws java.io.IOException
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:
java.io.IOException - if an error occured while reading from the input stream or writting to the output stream.


Copyright © GeoTools. All Rights Reserved.