com.singularsys.jep.walkers
Class ExpressionSerializer
java.lang.Object
com.singularsys.jep.walkers.PostfixTreeWalker
com.singularsys.jep.walkers.ExpressionSerializer
public class ExpressionSerializer
- extends PostfixTreeWalker
Serialize an expression in a compact form.
Just the names of variables, functions and operators is stored, on reconstruction
the symbol table, function table of the jep instance and used to rebuild the node tree.
Representation of expressions: nodes are transversed in reverse polish order hence
'1+2*3' will be written in the order 1, 2, 3, *, +. Each node is written with a one byte code letter
followed by data for the node. Specifically
- Variables: code 1, variable name
- Functions: code 2, number of children, function name
- Operators: code 3, number of children, operator name
- Constant (Doubles): code 4, double value
- ...
- Author:
- Richard Morris
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExpressionSerializer
public ExpressionSerializer(Jep xj)
- Parameters:
xj
- the XJep instance
serialize
public void serialize(java.io.ObjectOutputStream oos,
Node root)
throws java.lang.Exception
- Serialize the expression.
- Parameters:
oos
- the output streamroot
- the root node of the expression
- Throws:
java.lang.Exception
deserialize
public Node deserialize(java.io.ObjectInputStream ois)
throws java.lang.Exception
- Deserialize the expression.
- Parameters:
ois
- the input stream
- Throws:
java.lang.Exception
visit
protected void visit(ASTConstant node,
int nchildren,
int depth)
throws EvaluationException
- Specified by:
visit
in class PostfixTreeWalker
- Throws:
EvaluationException
visit
protected void visit(ASTFunNode node,
int nchildren,
int depth)
throws EvaluationException
- Specified by:
visit
in class PostfixTreeWalker
- Throws:
EvaluationException
visit
protected void visit(ASTVarNode node,
int nchildren,
int depth)
throws EvaluationException
- Specified by:
visit
in class PostfixTreeWalker
- Throws:
EvaluationException
Copyright © 2007 Singular Systems http://www.singularsys.com/jep