| java.lang.Object java.text.Format org.geotools.referencing.wkt.Preprocessor
Preprocessor | public class Preprocessor extends Format (Code) | | A parser that performs string replacements before to delegate the work to an other parser.
String replacements are specified through calls to the
Preprocessor.addDefinition addDefinition method. In the example below, the
WGS84 string in the
call is expanded into the full GEOGCS["WGS84", ... string before
to be parsed.
("WGS84", "GEOGCS[\"WGS84\", DATUM[ ...etc... ]]
("PROJCS[\"Mercator_1SP\", WGS84, PROJECTION[ ...etc... ]]")
since: 2.1 version: $Id: Preprocessor.java 22295 2006-10-20 00:58:17Z desruisseaux $ author: Martin Desruisseaux |
Field Summary | |
transient int | offset The initial offset of the line in process of being parsed. | final protected Format | parser The WKT parser, usually a
Parser object. |
Constructor Summary | |
public | Preprocessor(Format parser) Creates a new preprocessor that delegates the work to the specified parser. |
Method Summary | |
public void | addDefinition(String name, String value) Adds a predefined Well Know Text (WKT). | public StringBuffer | format(Object object, StringBuffer toAppendTo, FieldPosition position) Formats the specified object. | public Set | getDefinitionNames() Returns an unmodifiable set which contains all definition's names given to the
(name, ...) method. | public Object | parseObject(String wkt, ParsePosition position) Parses the specified Well Know Text starting at the specified position.
The default implementation delegates the work to
Preprocessor.parseObject(String) parseObject (wkt.substring(position.getIndex())) .
Parameters: wkt - The text to parse. Parameters: position - The index of the first character to parse. | public Object | parseObject(String wkt) Parses the specified Well Know Text without restriction on the expected type.
The default implementation delegates the work to
Preprocessor.parseObject(String,Class) parseObject (wkt, Object.class) .
Parameters: wkt - The text to parse. | public Object | parseObject(String text, Class type) Parses the specified text and ensure that the resulting object is of the specified type.
The text can be any of the following:
- A name declared in some previous call to
(name, ...) .
- A Well Know Text, which may contains itself shortcuts declared in
previous call to
addDefinition .
| public void | printDefinitions(Writer out) Prints to the specified stream a table of all definitions. | public void | removeDefinition(String name) Removes a definition set in some previous call to
(name, ...) . |
offset | transient int offset(Code) | | The initial offset of the line in process of being parsed. This is a helper field
for use by
AbstractConsole only, in order to produce more accurate information in
case of
ParseException . This field has no impact on the object returned as a result
of successful parsing.
|
Preprocessor | public Preprocessor(Format parser)(Code) | | Creates a new preprocessor that delegates the work to the specified parser.
Parameters: parser - The WKT parser, usually a Parser object. |
addDefinition | public void addDefinition(String name, String value) throws ParseException(Code) | | Adds a predefined Well Know Text (WKT). The
value argument given to this method
can contains itself other definitions specified in some previous calls to this method.
Parameters: name - The name for the definition to be added. Parameters: value - The Well Know Text (WKT) represented by the name. throws: IllegalArgumentException - if the name is invalid. throws: ParseException - if the WKT can't be parsed. |
format | public StringBuffer format(Object object, StringBuffer toAppendTo, FieldPosition position)(Code) | | Formats the specified object. This method delegates the work to the
given at construction time.
Parameters: object - The object to format. Parameters: toAppendTo - Where the text is to be appended. Parameters: position - Identification of a field in the formatted text. The string buffer passed in as toAppendTo ,with formatted text appended |
getDefinitionNames | public Set getDefinitionNames()(Code) | | Returns an unmodifiable set which contains all definition's names given to the
(name, ...) method. The
elements in this set are sorted in alphabetical order.
|
parseObject | public Object parseObject(String wkt, ParsePosition position)(Code) | | Parses the specified Well Know Text starting at the specified position.
The default implementation delegates the work to
Preprocessor.parseObject(String) parseObject (wkt.substring(position.getIndex())) .
Parameters: wkt - The text to parse. Parameters: position - The index of the first character to parse. The parsed object, or null in case of failure. |
parseObject | public Object parseObject(String text, Class type) throws ParseException, FactoryException(Code) | | Parses the specified text and ensure that the resulting object is of the specified type.
The text can be any of the following:
- A name declared in some previous call to
(name, ...) .
- A Well Know Text, which may contains itself shortcuts declared in
previous call to
addDefinition . This text is given to
the underlying
Preprocessor.parser .
- Any services provided by subclasses. For example a subclass way recognize
some authority code like
EPSG:6326 .
Parameters: text - The text, as a name, a WKT to parse, or an authority code. Parameters: type - The expected type for the object to be parsed (usually a.class or.class ). The object. throws: ParseException - if parsing the specified WKT failed. throws: FactoryException - if the object is not of the expected type. |
printDefinitions | public void printDefinitions(Writer out) throws IOException(Code) | | Prints to the specified stream a table of all definitions.
The content of this table is inferred from the values given to the
Preprocessor.addDefinition method.
Parameters: out - writer The output stream where to write the table. throws: IOException - if an error occured while writting to the output stream. |
removeDefinition | public void removeDefinition(String name)(Code) | | Removes a definition set in some previous call to
(name, ...) .
Parameters: name - The name of the definition to remove. |
|
|