|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.referencing.wkt.AbstractConsole
Base class for application performing operations on WKT objects from the command line. Instructions are usually read from the standard input stream and results sent to the standard output stream, but those streams can be redirected. The set of allowed instructions depends on the subclass used.
Field Summary | |
protected java.io.PrintWriter |
err
The error stream, usually the standard one. |
protected java.io.LineNumberReader |
in
The input stream, usually the standard one. |
protected java.lang.String |
lineSeparator
The line separator, usually the system default. |
protected java.io.Writer |
out
The output stream, usually the standard one. |
protected java.text.Format |
parser
The WKT parser, usually a Preprocessor object. |
Constructor Summary | |
AbstractConsole(java.text.Format parser)
Creates a new console instance using standard input stream, standard output stream, error output stream and the system default line separator. |
|
AbstractConsole(java.text.Format parser,
java.io.LineNumberReader in)
Creates a new console instance using the specified input stream. |
|
AbstractConsole(java.text.Format parser,
java.io.LineNumberReader in,
java.io.Writer out,
java.io.PrintWriter err,
java.lang.String lineSeparator)
Creates a new console instance using the specified streams and line separator. |
Method Summary | |
void |
addDefinition(java.lang.String name,
java.lang.String value)
Adds a predefined Well Know Text (WKT). |
protected abstract void |
execute(java.lang.String instruction)
Execute the specified instruction. |
void |
executeAll()
Executes all instructions (like run() ), but stop at the first error. |
java.lang.String |
getPrompt()
Returns the command-line prompt, or if there is none. |
void |
loadDefinitions(java.io.LineNumberReader in)
Load all definitions from the specified stream. |
java.lang.Object |
parseObject(java.lang.String text,
java.lang.Class type)
Parses the specified text. |
void |
printDefinitions()
Prints to the output stream a table of all definitions. |
protected void |
reportError(java.lang.Exception exception)
Print an exception message to the standard error stream. |
void |
run()
Process instructions from the input stream specified at construction time. |
void |
setPrompt(java.lang.String prompt)
Set the command-line prompt, or for none. |
void |
stop()
Stops the run() method. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final java.io.LineNumberReader in
protected final java.io.Writer out
protected final java.io.PrintWriter err
protected final java.lang.String lineSeparator
protected final java.text.Format parser
Preprocessor
object.
Constructor Detail |
public AbstractConsole(java.text.Format parser)
parser
- The WKT parser, usually a Preprocessor
object.public AbstractConsole(java.text.Format parser, java.io.LineNumberReader in)
parser
- The WKT parser, usually a Preprocessor
object.in
- The input stream.public AbstractConsole(java.text.Format parser, java.io.LineNumberReader in, java.io.Writer out, java.io.PrintWriter err, java.lang.String lineSeparator)
parser
- The WKT parser, usually a Preprocessor
object.in
- The input stream.out
- The output stream.err
- The error stream.lineSeparator
- The line separator.Method Detail |
public java.lang.Object parseObject(java.lang.String text, java.lang.Class type) throws java.text.ParseException, org.opengis.referencing.FactoryException
text
- The text, as a name, a WKT to parse, or an authority code.type
- The expected type for the object to be parsed (usually a
CoordinateReferenceSystem.class
or
MathTransform.class
).
java.text.ParseException
- if parsing the specified WKT failed.
org.opengis.referencing.FactoryException
- if the object is not of the expected type.public void addDefinition(java.lang.String name, java.lang.String value) throws java.text.ParseException
Preprocessor
.
name
- The name for the definition to be added.value
- The Well Know Text (WKT) represented by the name.
java.lang.IllegalArgumentException
- if the name is invalid.
java.text.ParseException
- if the WKT can't be parsed.public void loadDefinitions(java.io.LineNumberReader in) throws java.io.IOException, java.text.ParseException
PropertyAuthorityFactory
.
in
- The input stream.
java.io.IOException
- if an input operation failed.
java.text.ParseException
- if a well know text (WKT) can't be parsed.public void printDefinitions() throws java.io.IOException
addDefinition(java.lang.String, java.lang.String)
method. This
method print nothing if the parser is not an instance of Preprocessor
.
java.io.IOException
- if an error occured while writting to the output stream.public java.lang.String getPrompt()
public void setPrompt(java.lang.String prompt)
public void run()
stop()
is invoked. Non-empty and non-comment lines are
given to the execute(java.lang.String)
method. Errors are catched and printed to the
error stream.
run
in interface java.lang.Runnable
public void executeAll() throws java.lang.Exception
run()
), but stop at the first error.
java.lang.Exception
- if an instruction failed.protected abstract void execute(java.lang.String instruction) throws java.lang.Exception
instruction
- The instruction to execute.
java.lang.Exception
- if the instruction failed.public void stop()
run()
method. This method can been invoked from any thread.
If a line is in process, it will be finished before the run()
method
stops.
protected void reportError(java.lang.Exception exception)
ParseException
.
exception
- The exception to report.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |