|
http://www.eteks.com | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.eteks.parser.Parser | +--com.eteks.parser.FunctionParser | +--com.eteks.parser.ExpressionParser | +--com.eteks.jeks.JeksExpressionParser
Parser for expressions entered in table cells. This parser stores the interpreter used
to compute expressions at runtime and the functions
entered by user and available for expressions.
This class provides also methods used to shift cells in expressions.
Constructor Summary | |
JeksExpressionParser(JeksExpressionSyntax syntax,
ExpressionParameter expressionParameter,
Interpreter interpreter)
Creates an expression parser with no user function parser. |
|
JeksExpressionParser(JeksExpressionSyntax syntax,
ExpressionParameter expressionParameter,
Interpreter interpreter,
JeksFunctionParser functionParser,
java.util.Vector userFunctions)
Creates an expression parser. |
|
JeksExpressionParser(javax.swing.table.TableModel tableModel)
Creates an expression parser from the table model tableModel ,
using instances of JeksExpressionSyntax and of JeksFunctionSyntax
for expression and function syntaxes, an instance of JeksInterpreter as interpreter
and an instance of JeksParameter as expression parameter. |
Method Summary | |
void |
addUserFunction(Function userFunction)
Add the user function userFunction to the expression
and function syntaxes of this parser. |
CompiledExpression |
compileExpression(java.lang.String expressionDefinition)
Parses and compiles the expression definition expressionDefinition
and returns an instance of JeksExpression . |
java.lang.Object |
getEditedValue(java.lang.Object value)
Returns value as an editable object. |
JeksFunctionParser |
getFunctionParser()
Returns the parser used to parse user functions. |
Interpreter |
getInterpreter()
Returns the interpreter of this parser. |
java.lang.Object |
getModelValue(java.lang.String data)
Returns an object of the same wrapping class as the string data . |
java.util.Vector |
getUserFunctions()
Returns a copy of the user functions set. |
java.lang.Object |
parseLitteral(java.lang.String data)
Returns an object of the same wrapping class as the string data . |
void |
removeAllUserFunctions()
Remove all the user functions from the expression and function syntaxes of this parser. |
void |
removeUserFunction(Function userFunction)
Remove the user function userFunction from the expression
and function syntaxes of this parser. |
java.lang.String |
shiftExpression(CompiledExpression expression,
int rowShift,
int columnShift)
Shifts the cells used in the definition of expression of rowShift
rows and columnShift columns and returns the shifted definition.
|
java.lang.String |
shiftExpression(CompiledExpression expression,
int rowShift,
int columnShift,
int cellSetFirstRow,
int cellSetFirstColumn,
int cellSetLastRow,
int cellSetLastColumn)
Shifts the cells used in the definition of expression of rowShift
rows and columnShift columns and returns the shifted expression.
|
Methods inherited from class com.eteks.parser.ExpressionParser |
getExpressionParameter |
Methods inherited from class com.eteks.parser.FunctionParser |
compileFunction, getSyntax |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JeksExpressionParser(javax.swing.table.TableModel tableModel)
tableModel
,
using instances of JeksExpressionSyntax
and of JeksFunctionSyntax
for expression and function syntaxes, an instance of JeksInterpreter
as interpreter
and an instance of JeksParameter
as expression parameter.public JeksExpressionParser(JeksExpressionSyntax syntax, ExpressionParameter expressionParameter, Interpreter interpreter)
public JeksExpressionParser(JeksExpressionSyntax syntax, ExpressionParameter expressionParameter, Interpreter interpreter, JeksFunctionParser functionParser, java.util.Vector userFunctions)
Method Detail |
public CompiledExpression compileExpression(java.lang.String expressionDefinition) throws CompilationException
expressionDefinition
and returns an instance of JeksExpression
.compileExpression
in class ExpressionParser
com.eteks.parser.ExpressionParser
expressionDefinition
- the definition of the expression.CompiledExpression
, with which values can be computed.CompilationException
- if the syntax of the expression is incorrect or if some of its
elements (literals, constants, operators, functions,...) are not
accepted by the syntax of the parser.public Interpreter getInterpreter()
public JeksFunctionParser getFunctionParser()
public java.util.Vector getUserFunctions()
public void addUserFunction(Function userFunction)
userFunction
to the expression
and function syntaxes of this parser.public void removeUserFunction(Function userFunction)
userFunction
from the expression
and function syntaxes of this parser.public void removeAllUserFunctions()
public java.lang.Object getEditedValue(java.lang.Object value)
value
as an editable object. If value
is an
instance of JeksExpression
the definition of the expression is returned,
if value
is a number or a date its localized string representation
is returned, otherwise the object value
itself is returned.value
- a value stored in the table model.public java.lang.Object getModelValue(java.lang.String data) throws CompilationException
data
. This method tries to create an instance
of one of the following classes in this order: Long
,
Double
, Date
, Boolean
or the string itself.
If the string starts with an assignment operator (equal sign =), it tries
to compile the expression to create a JeksExpression
instance.data
- a string.Long
, Double
,
Date
, Boolean
, String
or JeksExpression
.public java.lang.Object parseLitteral(java.lang.String data)
data
. This method tries to create an instance
of one of the following classes in this order: Long
,
Double
, Date
, Boolean
.
If it fails it returns the string itself.data
- a string.Long
, Double
,
Date
, Boolean
or String
.public java.lang.String shiftExpression(CompiledExpression expression, int rowShift, int columnShift)
expression
of rowShift
rows and columnShift
columns and returns the shifted definition.
Columns and rows prefixed by the character returned
by the getConstantChar ()
method are unchanged. The string returned
by getCellError (JeksExpressionSyntax.ERROR_ILLEGAL_CELL)
of expression
syntax replaces any shifted cell with a negative column or row.public java.lang.String shiftExpression(CompiledExpression expression, int rowShift, int columnShift, int cellSetFirstRow, int cellSetFirstColumn, int cellSetLastRow, int cellSetLastColumn)
expression
of rowShift
rows and columnShift
columns and returns the shifted expression.
The only cells which are shifted in the returned definition are the ones
belonging to the cells set defined by the opposite cells (cellSetFirstRow
,
cellSetFirstColumn
) and (cellSetLastRow
, cellSetLastColumn
).
Columns and rows are shifted even if they are prefixed by the constant character.
This method is used to shift cut expressions and their referring cells
during a cut / paste operation.
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |