org.gibello.zql
Class ZExpression

java.lang.Object
  extended by org.gibello.zql.ZExpression
All Implemented Interfaces:
java.io.Serializable, ZExp

public class ZExpression
extends java.lang.Object
implements ZExp

ZExpression: an SQL Expression An SQL expression is an operator and one or more operands Example: a AND b AND c -> operator = AND, operands = (a, b, c)

See Also:
Serialized Form

Constructor Summary
ZExpression(java.lang.String op)
          Create an SQL Expression given the operator
ZExpression(java.lang.String op, ZExp o1)
          Create an SQL Expression given the operator and 1st operand
ZExpression(java.lang.String op, ZExp o1, ZExp o2)
          Create an SQL Expression given the operator, 1st and 2nd operands
 
Method Summary
 void addOperand(ZExp o)
          Add an operand to the current expression.
 ZExp getOperand(int pos)
          Get an operand according to its index (position).
 java.util.Vector getOperands()
          Get this expression's operands.
 java.lang.String getOperator()
          Get this expression's operator.
 int nbOperands()
          Get the number of operands
 void setOperands(java.util.Vector v)
          Set the operands list
 java.lang.String toReversePolish()
          String form of the current expression (reverse polish notation).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZExpression

public ZExpression(java.lang.String op)
Create an SQL Expression given the operator

Parameters:
op - The operator

ZExpression

public ZExpression(java.lang.String op,
                   ZExp o1)
Create an SQL Expression given the operator and 1st operand

Parameters:
op - The operator
o1 - The 1st operand

ZExpression

public ZExpression(java.lang.String op,
                   ZExp o1,
                   ZExp o2)
Create an SQL Expression given the operator, 1st and 2nd operands

Parameters:
op - The operator
o1 - The 1st operand
o2 - The 2nd operand
Method Detail

getOperator

public java.lang.String getOperator()
Get this expression's operator.

Returns:
the operator.

setOperands

public void setOperands(java.util.Vector v)
Set the operands list

Parameters:
v - A vector that contains all operands (ZExp objects).

getOperands

public java.util.Vector getOperands()
Get this expression's operands.

Returns:
the operands (as a Vector of ZExp objects).

addOperand

public void addOperand(ZExp o)
Add an operand to the current expression.

Parameters:
o - The operand to add.

getOperand

public ZExp getOperand(int pos)
Get an operand according to its index (position).

Parameters:
pos - The operand index, starting at 0.
Returns:
The operand at the specified index, null if out of bounds.

nbOperands

public int nbOperands()
Get the number of operands

Returns:
The number of operands

toReversePolish

public java.lang.String toReversePolish()
String form of the current expression (reverse polish notation). Example: a > 1 AND b = 2 -> (AND (> a 1) (= b 2))

Returns:
The current expression in reverse polish notation (a String)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object