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

## info.bioinfweb.treegraph.document.undo.edit
Class CalculateColumnEdit

    java.lang.Object
      info.bioinfweb.treegraph.document.undo.DocumentEdit
          info.bioinfweb.treegraph.document.undo.NodeBranchDataEdit
              info.bioinfweb.treegraph.document.undo.edit.CalculateColumnEdit

All Implemented Interfaces:
  UndoableEdit

    public class CalculateColumnEdit

extends NodeBranchDataEdit

Calculates a node/branch data column as specified by the passed expression.

Since:
  2.0.24
Author:
  Ben Stöver

Field Summary
`private Map<String,NodeBranchDataAdapter>` | `adapterMap`
`static String` | `BRANCH_LENGTH_VAR`
`static String` | `CURRENT_VALUE_VAR`
`private List<String>` | `errors`
`private String` | `expression`
`static String` | `GET_VALUE_FUNC`
`static String` | `HAS_VALUE_FUNC`
`private boolean` | `isEvaluating`
`private boolean` | `isEvaluatingDecimal`
`static String` | `NODE_NAMES_VAR`
`private org.nfunk.jep.JEP` | `parser`
`private Node` | `position`
`static String` | `UNIQUE_NODE_NAMES_VAR`

Fields inherited from class info.bioinfweb.treegraph.document.undo.NodeBranchDataEdit
`adapter, backup`

Fields inherited from class info.bioinfweb.treegraph.document.undo.DocumentEdit
`document`

Constructor Summary
`CalculateColumnEdit(Document document, NodeBranchDataAdapter targetAdapter, String expression)`

Method Summary
`private void` | `calculateSubtree(Node root)`
`private HashMap<String,NodeBranchDataAdapter>` | `createAdapterMap()`
`private org.nfunk.jep.JEP` | `createParser()`
`boolean` | `evaluate()` Evaluates the expression of this instance.
`private String` | `evaluationStep(Object defaultValue)` Evaluates the expression with one set of variable values.
`private Object` | `getCurrentValue(NodeBranchDataAdapter adapter)` Returns the value of the specified column in the current line (specified by `position`).
`String[]` | `getErrors()` Returns a description of the errors that occured during the last call of `redo()` or `evaluate()`.
`private Object` | `getIDValue(String id)` Returns the value of the current line in the column specified the passed id present.
`String` | `getPresentationName()`
`void` | `redo()`

Methods inherited from class info.bioinfweb.treegraph.document.undo.NodeBranchDataEdit
`undo`

Methods inherited from class info.bioinfweb.treegraph.document.undo.DocumentEdit
`addEdit, canRedo, canUndo, die, getIsSubedit, getRedoPresentationName, getUndoPresentationName, isSignificant, replaceEdit, setIsSubedit`

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

Field Detail

### CURRENT_VALUE_VAR

    public static final String CURRENT_VALUE_VAR

See Also:
  Constant Field Values

### UNIQUE_NODE_NAMES_VAR

    public static final String UNIQUE_NODE_NAMES_VAR

See Also:
  Constant Field Values

### NODE_NAMES_VAR

    public static final String NODE_NAMES_VAR

See Also:
  Constant Field Values

### BRANCH_LENGTH_VAR

    public static final String BRANCH_LENGTH_VAR

See Also:
  Constant Field Values

### GET_VALUE_FUNC

    public static final String GET_VALUE_FUNC

See Also:
  Constant Field Values

### HAS_VALUE_FUNC

    public static final String HAS_VALUE_FUNC

See Also:
  Constant Field Values

### expression

    private String expression

### parser

    private org.nfunk.jep.JEP parser

### adapterMap

    private Map<String,NodeBranchDataAdapter> adapterMap

### isEvaluating

    private boolean isEvaluating

### isEvaluatingDecimal

    private boolean isEvaluatingDecimal

### position

    private Node position

### errors

    private List<String> errors

Constructor Detail

### CalculateColumnEdit

    public CalculateColumnEdit(Document document,
                               NodeBranchDataAdapter targetAdapter,
                               String expression)

Method Detail

### createParser

    private org.nfunk.jep.JEP createParser()

### createAdapterMap

    private HashMap<String,NodeBranchDataAdapter> createAdapterMap()

### evaluationStep

    private String evaluationStep(Object defaultValue)

  Evaluates the expression with one set of variable values.

  Parameters:
    `defaultValue` - either a string or a double value
  Returns:
    the error information or `null` if no error occurred.

### evaluate

    public boolean evaluate()

  Evaluates the expression of this instance. Error can be obtined by calling `getErrors()`.

  Returns:
    `true` if the expression contained no errors.

### getCurrentValue

    private Object getCurrentValue(NodeBranchDataAdapter adapter)

  Returns the value of the specified column in the current line (specified by `position`).

  Parameters:
    `adapter` - defined the column to use
  Returns:
    a value of type `Double` or `String`

### getIDValue

    private Object getIDValue(String id)
                       throws org.nfunk.jep.ParseException

  Returns the value of the current line in the column specified the passed id present.

  Parameters:
    `id` - the ID of the node/branch data column
  Returns:
    the value (as `Double`, `String`) or `null` if the specified column does not contain any value at the current position or a `Double` with the value 1 if `isEvaluating` is `true`
  Throws:
    `UndefinedIDException` - if no column with the specified ID exists
    `org.nfunk.jep.ParseException`

### calculateSubtree

    private void calculateSubtree(Node root)

### redo

    public void redo()
              throws CannotRedoException

  Specified by:
    `redo` in interface `UndoableEdit`
  Overrides:
    `redo` in class `DocumentEdit`
  Throws:
    `CannotRedoException`

### getPresentationName

    public String getPresentationName()

### getErrors

    public String[] getErrors()

  Returns a description of the errors that occured during the last call of `redo()` or `evaluate()`.

  Returns:

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