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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
CalculateColumnEdit
public CalculateColumnEdit(Document document,
NodeBranchDataAdapter targetAdapter,
String expression)
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: