Opus5
Class ExpressionTree

java.lang.Object
  |
  +--Opus5.AbstractObject
        |
        +--Opus5.AbstractContainer
              |
              +--Opus5.AbstractTree
                    |
                    +--Opus5.BinaryTree
                          |
                          +--Opus5.ExpressionTree
All Implemented Interfaces:
Comparable, Container, Tree

public class ExpressionTree
extends BinaryTree

Represents a binary expression as a binary tree.

Version:
$Id: ExpressionTree.java,v 3.1 1998/07/28 01:32:17 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Inner classes inherited from class Opus5.AbstractTree
AbstractTree.TreeEnumeration
 
Fields inherited from class Opus5.BinaryTree
key, left, right
 
Fields inherited from class Opus5.AbstractContainer
count
 
Fields inherited from interface Opus5.Tree
copyright
 
Constructor Summary
ExpressionTree(char c)
          Constructs a ExpressionTree that consists of a single (leaf) node with the specified label.
 
Method Summary
static ExpressionTree parsePostfix(java.io.Reader in)
          Parses a postfix expression read from the specified input stream and constructs the corresponding expression tree.
 java.lang.String toString()
          Returns a string representation of this expression tree using infix notation.
 
Methods inherited from class Opus5.BinaryTree
attachKey, attachLeft, attachRight, compareTo, depthFirstTraversal, detachKey, detachLeft, detachRight, getDegree, getKey, getLeft, getRight, getSubtree, isEmpty, isLeaf, purge
 
Methods inherited from class Opus5.AbstractTree
accept, breadthFirstTraversal, getCount, getEnumeration, getHeight
 
Methods inherited from class Opus5.AbstractContainer
hashCode, isFull
 
Methods inherited from class Opus5.AbstractObject
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Opus5.Container
isFull
 
Methods inherited from interface Opus5.Comparable
compare, isEQ, isGE, isGT, isLE, isLT, isNE
 

Constructor Detail

ExpressionTree

public ExpressionTree(char c)
Constructs a ExpressionTree that consists of a single (leaf) node with the specified label.
Parameters:
c - The label on this node.
Method Detail

parsePostfix

public static ExpressionTree parsePostfix(java.io.Reader in)
                                   throws java.io.IOException
Parses a postfix expression read from the specified input stream and constructs the corresponding expression tree. The postfix expression consists of one-letter symbols, one-digit numbers, +, -, * and /.
Parameters:
in - The input stream.
Returns:
An expression tree.
Throws:
java.io.IOException - If an error occurs while reading input.

toString

public java.lang.String toString()
Returns a string representation of this expression tree using infix notation.
Overrides:
toString in class AbstractContainer
Returns:
A string representation of this expression tree.