org.edg.info.sqlutil.parsql
Class Expression

java.lang.Object
  extended byorg.edg.info.sqlutil.parsql.Expression
All Implemented Interfaces:
ExpSelConst, java.io.Serializable

public class Expression
extends java.lang.Object
implements ExpSelConst

An SQL Expression, 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
Expression(java.lang.String operator)
          Create an SQL Expression given the operator
Expression(java.lang.String operator, ExpSelConst operand1)
          Create an SQL Expression given the operator and 1st operand
Expression(java.lang.String operator, ExpSelConst operand1, ExpSelConst operand2)
          Create an SQL Expression given the operator, 1st and 2nd operands
 
Method Summary
 void addOperand(ExpSelConst o)
          Add an operand to the current expression.
 ExpSelConst 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()
          Returns a String representation of this Expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Expression

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

Parameters:
operator - The operator

Expression

public Expression(java.lang.String operator,
                  ExpSelConst operand1)
Create an SQL Expression given the operator and 1st operand

Parameters:
operator - The operator
operand1 - The 1st operand

Expression

public Expression(java.lang.String operator,
                  ExpSelConst operand1,
                  ExpSelConst operand2)
Create an SQL Expression given the operator, 1st and 2nd operands

Parameters:
operator - The operator
operand1 - The 1st operand
operand2 - The 2nd operand
Method Detail

getOperand

public ExpSelConst 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.

setOperands

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

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

getOperands

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

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

getOperator

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

Returns:
the operator.

addOperand

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

Parameters:
o - The operand to add.

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()
Returns a String representation of this Expression.

Returns:
A String representation of this Expression.