Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lp.wrap
Class LparseWrapper

    java.lang.Object
      lp.wrap.LparseWrapper

    public class LparseWrapper

extends Object

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.

Version:
  1.0.0
Author:
  Martin Slota

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

### WU

    private static final WrapperUtils WU

  The singleton `WrapperUtils` instance used in the implementation.

### lparsePath

    private String lparsePath

  The path to the lparse binary.

### options

    private String options

  The command line options used when executing lparse in the `exec()` method.

### process

    private Process process

  The lparse process.

### errorProcessor

    private final LparseWrapper.ErrorStreamProcessor errorProcessor

  A `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.

### errorThread

    private Thread errorThread

  The thread on which `errorProcessor` is running.

### error

    private LparseMessage error

  Contains the lparse error message if one is found on its standard error output.

### warnings

    private final List<LparseMessage> warnings

  A list of warnings that lparse issued on the previous input.

Constructor Detail

### LparseWrapper

    public LparseWrapper()

  Creates a new instance of `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

### setLparsePath

    public void setLparsePath(String lparsePath)

  Sets the path to lparse binary that is used to invoke lparse.

  Parameters:
    `lparsePath` - path to the lparse binary
  Throws:
    `IllegalArgumentException` - if `lparsePath` is `null` or an empty string

### setOptions

    public LparseWrapper setOptions(String options)

  Sets the command line options that are passed to lparse by the `exec()` method. If `null` is passed in as a parameter, options string is set to an empty string.

  Parameters:
    `options` - command line options for lparse
  Returns:
    a reference to this `LparseWrapper`

### exec

    public void exec()

  Executes lparse and passes the current command line options to it (see `setOptions(String method)`).

  Throws:
    `WrapperException` - if an `IOException` occurs while creating the process

### getStdin

    public OutputStream getStdin()

  Returns the standard input stream of the currently executed lparse process.

  Returns:
    as specified above

### closeStdin

    public void closeStdin()

  Closes the standard output stream of the currently executed lparse process.

  Throws:
    `WrapperException` - if an I/O error occurs while closing the standard input stream of the lparse process

### getStdout

    public InputStream getStdout()

  Returns the standard output stream of the currently executed lparse process.

  Returns:
    as specified above

### waitFor

    public int waitFor()

  Waits for the currently executed lparse process to finish computation and returns its exit value (see `Process.waitFor()`.

  Returns:
    the return value of the lparse process
  Throws:
    `WrapperException` - if an `InterruptedException` occurs while waiting for the error stream thread or lparse process to finish their tasks

### getError

    public LparseMessage getError()

  Returns an lparse error message that was issued by lparse on the last input. Should only be called after `waitFor()` was called.

  Returns:
    as specified above

### getWarnings

    public List<LparseMessage> getWarnings()

  Returns lparse warning messages that were issued by lparse on the last input. Should only be called after `waitFor()` was called.

  Returns:
    as specified above

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD