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

## lp.trans
Class Grounder<P>

    java.lang.Object
      lp.trans.Grounder<P>

Direct Known Subclasses:
  DlpGrounder, LpGrounder

    public abstract class Grounder<P>

extends Object

An abstract class that contains common functionality of classes used to ground logic programs (`LpGrounder` and `DlpGrounder`).

Version:
  1.0.0
Author:
  Martin Slota
See Also:
  `LpGrounder`, `DlpGrounder`

Field Summary
`private LparseWrapper` | `lw` An `LparseWrapper` instance used to execute lparse when grounding the logic program with tagged rules created from the original (non-ground) dynamic logic program.
`private List<GrounderMessage>` | `warnings` A list of warnings that lparse issued on the input program.

Constructor Summary
`Grounder(LparseWrapper wrapper)` Creates a new instance of `Grounder` that uses the given object to invoke lparse and process its output.

Method Summary
`List<GrounderMessage>` | `getWarnings()` Returns a list of warnings that lparse issued on the input DLP.
`P` | `ground(P inputProgram)` Returns a grounded version of `inputProgram`.
`protected abstract GrounderMessage` | `makeGrounderMessage(LparseMessage lparseMessage, P inputProgram)` Creates an error message based on `lparseMessage` from lparse and the input program.
`protected abstract P` | `parseOutput(String lparseOutput)` Parses the given lparse output and returns the grounded program.
`protected abstract void` | `printProgram(P inputProgram, Writer writer)` Prints `inputProgram` in a form that is groundable by lparse (as long as the programmer didn't break the constraints imposed by lparse).
`void` | `setLparsePath(String lparsePath)` Sets the path to lparse binary that is used to invoke lparse.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### lw

    private final LparseWrapper lw

  An `LparseWrapper` instance used to execute lparse when grounding the logic program with tagged rules created from the original (non-ground) dynamic logic program. It also parses the standard error output of lparse and translates it into `LparseMessage` objects.

### warnings

    private final List<GrounderMessage> warnings

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

Constructor Detail

### Grounder

    public Grounder(LparseWrapper wrapper)

  Creates a new instance of `Grounder` that uses the given object to invoke lparse and process its output.

  Parameters:
    `wrapper` - the object used to execute lparse, parse its warnings and/or errors and create corresponding LparseMessage objects

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

### ground

    public P ground(P inputProgram)

  Returns a grounded version of `inputProgram`.

  Parameters:
    `inputProgram` - the program to ground
  Returns:
    the grounded version of `inputProgram`. If `inputProgram` is `null`, `null` is returned.
  Throws:
    `WrapperException` - if an error occurs while calling lparse, see `LparseWrapper.waitFor()`
    `GrounderMessage` - if lparse refuses to ground the input program, usually this means that it cannot guarantee that the resulting grounded program will be finite
    `IOException` - (wrapped in an `ExceptionAdapter`) if an I/O error occurs while manipulating the standard input and output streams of an lparse process
    `LpParserException` - if this exception is thrown, it is most probably a bug in implementation of this class

### getWarnings

    public List<GrounderMessage> getWarnings()

  Returns a list of warnings that lparse issued on the input DLP. The warnings are in the same order as they were on its standard error output.

  Returns:
    as specified above

### printProgram

    protected abstract void printProgram(P inputProgram,
                                         Writer writer)

  Prints `inputProgram` in a form that is groundable by lparse (as long as the programmer didn't break the constraints imposed by lparse).

  Parameters:
    `inputProgram` - the (ungrounded) input program
    `writer` - a `Writer` to write to
  Throws:
    `IOException` - (wrapped in an `ExceptionAdapter`) if an I/O error occurs while manipulating the standard input and output streams of an lparse process

### makeGrounderMessage

    protected abstract GrounderMessage makeGrounderMessage(LparseMessage lparseMessage,
                                                           P inputProgram)

  Creates an error message based on `lparseMessage` from lparse and the input program.

  Parameters:
    `lparseMessage` - the error or warning message issued by lparse
    `inputProgram` - the input program
  Returns:
    an enhanced message containing a reference to the problematic rule

### parseOutput

    protected abstract P parseOutput(String lparseOutput)

  Parses the given lparse output and returns the grounded program.

  Parameters:
    `lparseOutput` - the lparse output
  Returns:
    the grounded program
  Throws:
    `LpParserException` - if this exception is thrown, it is most probably a bug in implementation of this class

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