de.mguennewig.pobjects
Class Junction

java.lang.Object
  extended by de.mguennewig.pobjects.Junction
All Implemented Interfaces:
Condition, Term, java.lang.Iterable<Term>

public class Junction
extends java.lang.Object
implements Condition

A conjunction or disjunction of Terms as part of a SQL statement.

Author:
Michael Günnewig
See Also:
CheckConstraint, Query

Field Summary
 
Fields inherited from interface de.mguennewig.pobjects.Condition
AND, OR
 
Constructor Summary
Junction(int op, Term... terms)
          Creates a new Junction.
 
Method Summary
static Junction and(Term... terms)
           
static Junction convert(Predicate pred)
          Converts a given AND or OR Predicate into a Junction.
 boolean equals(java.lang.Object o)
          
 Junction flatten()
           
 int getNumTerms()
           
 int getOperand()
           
 java.lang.String getSqlValue(EvalContext eval)
          Returns the SQL expression for this term.
 Term getTerm(int i)
           
 int hashCode()
          
 boolean isConstant()
          Tests whether the expression can be evaluated without an object.
 boolean isJoin()
          Tests whether this expression enforces any kind of join.
 boolean isSelection()
          Tests whether this expression is a selection.
 java.util.Iterator<Term> iterator()
           
static Junction or(Term... terms)
           
 Junction removeDuplicates()
           
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Junction

public Junction(int op,
                Term... terms)
Creates a new Junction.

Method Detail

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getSqlValue

public java.lang.String getSqlValue(EvalContext eval)
Returns the SQL expression for this term.

Specified by:
getSqlValue in interface Term

isConstant

public boolean isConstant()
Tests whether the expression can be evaluated without an object.

Specified by:
isConstant in interface Term

isJoin

public boolean isJoin()
Tests whether this expression enforces any kind of join.

Specified by:
isJoin in interface Term

isSelection

public boolean isSelection()
Tests whether this expression is a selection.

With selection is an expression meant that binds a Member to one Literal.

Specified by:
isSelection in interface Term

iterator

public java.util.Iterator<Term> iterator()
Specified by:
iterator in interface java.lang.Iterable<Term>

flatten

public Junction flatten()

getOperand

public final int getOperand()
Specified by:
getOperand in interface Condition

getNumTerms

public final int getNumTerms()

getTerm

public final Term getTerm(int i)

removeDuplicates

public Junction removeDuplicates()

and

public static Junction and(Term... terms)

or

public static Junction or(Term... terms)

convert

public static Junction convert(Predicate pred)
Converts a given AND or OR Predicate into a Junction.

NOTE: This conversion is just done on the top-most level and it is advisable to call flatten() on the resulting junction.

Throws:
java.lang.IllegalArgumentException - if pred is not an AND or OR expression.