|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlp.wrap.LparseWrapper
public class LparseWrapper
A class responsible for executing lparse with the given command line
arguments. It also parses the resulting error stream and creates
corresponding LparseMessage
objects.
The command line options can be set by calling the
setOptions(String)
method. Initially they are set to am empty
string.
Lparse can be executed by calling the exec()
method. This method can
be called multiple times and each time the current command line options
are passed to the lparse binary.
Nested Class Summary | |
---|---|
private class |
LparseWrapper.ErrorStreamProcessor
A helper thread that reads and parses contents of an lparse standard error stream and stores the resulting LparseMessage objects in
error and warnings . |
Field Summary | |
---|---|
private LparseMessage |
error
Contains the lparse error message if one is found on its standard error output. |
private LparseWrapper.ErrorStreamProcessor |
errorProcessor
A Runnable that keeps reading and parsing the standard error
output of the lparse process while it is being executed. |
private Thread |
errorThread
The thread on which errorProcessor is running. |
private String |
lparsePath
The path to the lparse binary. |
private String |
options
The command line options used when executing lparse in the exec() method. |
private Process |
process
The lparse process. |
private List<LparseMessage> |
warnings
A list of warnings that lparse issued on the previous input. |
private static WrapperUtils |
WU
The singleton WrapperUtils instance used in the implementation. |
Constructor Summary | |
---|---|
LparseWrapper()
Creates a new instance of LparseWrapper . |
Method Summary | |
---|---|
void |
closeStdin()
Closes the standard output stream of the currently executed lparse process. |
void |
exec()
Executes lparse and passes the current command line options to it (see setOptions(String method) ). |
LparseMessage |
getError()
Returns an lparse error message that was issued by lparse on the last input. |
OutputStream |
getStdin()
Returns the standard input stream of the currently executed lparse process. |
InputStream |
getStdout()
Returns the standard output stream of the currently executed lparse process. |
List<LparseMessage> |
getWarnings()
Returns lparse warning messages that were issued by lparse on the last input. |
void |
setLparsePath(String lparsePath)
Sets the path to lparse binary that is used to invoke lparse. |
LparseWrapper |
setOptions(String options)
Sets the command line options that are passed to lparse by the exec() method. |
int |
waitFor()
Waits for the currently executed lparse process to finish computation and returns its exit value (see Process.waitFor() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final WrapperUtils WU
WrapperUtils
instance used in the implementation.
private String lparsePath
private String options
exec()
method.
private Process process
private final LparseWrapper.ErrorStreamProcessor errorProcessor
Runnable
that keeps reading and parsing the standard error
output of the lparse process while it is being executed. This prevents
reaching the upper limit of the native operating system's buffer.
private Thread errorThread
errorProcessor
is running.
private LparseMessage error
private final List<LparseMessage> warnings
Constructor Detail |
---|
public LparseWrapper()
LparseWrapper
.
Initially the path to the lparse binary path is set to "lparse", i.e. it
is assumed that lparse can be executed by issuing the "lparse" command on
the command line of the native operating system. This setting can be
changed by calling the setLparsePath(String)
method.
Command line options for lparse are set to an empty string and can be set
to a different value using the setOptions(String)
method.
Method Detail |
---|
public void setLparsePath(String lparsePath)
lparsePath
- path to the lparse binary
IllegalArgumentException
- if lparsePath
is null
or
an empty stringpublic LparseWrapper setOptions(String options)
exec()
method.
If null
is passed in as a parameter, options string is set to an
empty string.
options
- command line options for lparse
LparseWrapper
public void exec()
setOptions(String method)
).
WrapperException
- if an IOException
occurs while creating
the processpublic OutputStream getStdin()
public void closeStdin()
WrapperException
- if an I/O error occurs while closing the
standard input stream of the lparse processpublic InputStream getStdout()
public int waitFor()
Process.waitFor()
.
WrapperException
- if an InterruptedException
occurs while
waiting for the error stream thread or lparse process to finish their
taskspublic LparseMessage getError()
waitFor()
was called.
public List<LparseMessage> getWarnings()
waitFor()
was called.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |