Package com.singularsys.jep.walkers
Class SerializableExpression
java.lang.Object
com.singularsys.jep.walkers.PostfixTreeWalker
com.singularsys.jep.walkers.SerializableExpression
- All Implemented Interfaces:
Externalizable,Serializable
A serializable representation of an expression.
To serialize an expression use
ObjectOutputStream oos = ...; SerializableExpression se = new SerializableExpression(node); oos.writeObject(se);To deserialize use
ObjectInputStream ois = ...; SerializableExpression se = (SerializableExpression) ois.readObject(); Node n = se.toNode(jep);Since Jep 4.0 this class will serialize any Hooks added to the nodes (see
Node.HookKey).
Expressions serialized in older versions of Jep can still be read by the Jep 4.0 version of this class.
Expressions serialized by this version can be read by older version, provide no hooks are set.
The HookRemover class can be used to remove any hooks.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn element representing a constant value.static interfaceinterface used in internal representation of expressionstatic classAn element representing a function.static classAn element representing an operator.static classAn element representing a variable. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor used by the serializable mechanism.SerializableExpression(Node node) Construct a SerializableExpression from a given node -
Method Summary
Modifier and TypeMethodDescriptioniterator()Returns an iterator for the reverse polish representation of the expression.final voidreadExternal(ObjectInput ois) final NodeConvert to a node in a given context.toString()protected voidvisit(ASTConstant node, int nchildren, int depth) Visit a constant nodeprotected voidvisit(ASTFunNode node, int nchildren, int depth) Visit a function nodeprotected voidVisit an operator nodeprotected voidvisit(ASTVarNode node, int nchildren, int depth) Visit a variable nodefinal voidWrite a serialized version of the node to a stream.static voidwriteHooks(ObjectOutput oos, Map<Node.HookKey, Object> hooks) Methods inherited from class com.singularsys.jep.walkers.PostfixTreeWalker
suppressExaminingChildren, walk, walkSubEquations
-
Constructor Details
-
SerializableExpression
Construct a SerializableExpression from a given node- Parameters:
node- root node of the expression to serialize- Throws:
JepException
-
SerializableExpression
public SerializableExpression()Constructor used by the serializable mechanism. Not for normal use.
-
-
Method Details
-
toNode
Convert to a node in a given context. Variable, function and operator nodes will refer to the corresponding object in the jep instance.- Parameters:
j- Jep instance specifying the context- Returns:
- root node of the expression
- Throws:
JepException
-
writeExternal
Write a serialized version of the node to a stream.- Specified by:
writeExternalin interfaceExternalizable- Parameters:
out- the stream to write to.- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
visit
Description copied from class:PostfixTreeWalkerVisit a function node- Specified by:
visitin classPostfixTreeWalker- Parameters:
node- the current node being visitednchildren- number of children of the nodedepth- depth of tree, root node is depth 1.
-
visit
Description copied from class:PostfixTreeWalkerVisit an operator node- Specified by:
visitin classPostfixTreeWalker- Parameters:
node- the current node being visitednchildren- number of children of the nodedepth- depth of tree, root node is depth 1.
-
visit
Description copied from class:PostfixTreeWalkerVisit a variable node- Specified by:
visitin classPostfixTreeWalker- Parameters:
node- the current node being visitednchildren- number of children of the nodedepth- depth of tree, root node is depth 1.
-
visit
Description copied from class:PostfixTreeWalkerVisit a constant node- Specified by:
visitin classPostfixTreeWalker- Parameters:
node- the current node being visitednchildren- number of children of the nodedepth- depth of tree, root node is depth 1.
-
iterator
Returns an iterator for the reverse polish representation of the expression. This iterator is unmodifiable. -
writeHooks
- Throws:
IOException
-
toString
-