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

## 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

Constructor Summary
`ExpressionSerializer(Jep xj)`

Method Summary
`Node` | `deserialize(java.io.ObjectInputStream ois)` Deserialize the expression.
`void` | `serialize(java.io.ObjectOutputStream oos, Node root)` Serialize the expression.
`protected void` | `visit(ASTConstant node, int nchildren, int depth)`
`protected void` | `visit(ASTFunNode node, int nchildren, int depth)`
`protected void` | `visit(ASTVarNode node, int nchildren, int depth)`

Methods inherited from class com.singularsys.jep.walkers.PostfixTreeWalker
`supressExaminingChildren, walk, walkSubEquations`

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

Constructor Detail

### ExpressionSerializer

    public ExpressionSerializer(Jep xj)

Parameters:
  `xj` - the XJep instance

Method Detail

### serialize

    public void serialize(java.io.ObjectOutputStream oos,
                          Node root)
                   throws java.lang.Exception

  Serialize the expression.

  Parameters:
    `oos` - the output stream
    `root` - 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`

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

Copyright © 2007 Singular Systems http://www.singularsys.com/jep