de.mguennewig.pobjects
Class Member

java.lang.Object
  extended by de.mguennewig.pobjects.Member
All Implemented Interfaces:
Term

public class Member
extends java.lang.Object
implements Term

Reference to an column of a table.

A member can be a composite designator, following references between tables, and it can indicate that an SQL outer join should be done when using it.

Author:
Michael Günnewig

Constructor Summary
Member(int baseColumn, Column column)
          Create a member reference.
Member(int baseColumn, Column[] selectors)
          Create a member reference.
Member(int baseColumn, Column[] selectors, boolean outerJoin)
          Create a member reference over multiple tables.
Member(int baseColumn, Column column, boolean outerJoin)
          Create a member reference.
Member(int baseColumn, Column column1, Column column2)
          Create a member reference over column1, which references another table to column2 of this one.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Tests whether this member expression is equal to another object.
 int getBaseColumn()
           
 Column getLastSelector()
           
 int getNumSelectors()
           
 Column getSelector(int idx)
           
 Column[] getSelectors()
           
 java.lang.String getSqlValue(EvalContext eval)
          Returns the SQL expression for this term.
 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 isOuterJoin()
           
 boolean isSelection()
          Tests whether this expression is a selection.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Member

public Member(int baseColumn,
              Column[] selectors,
              boolean outerJoin)
Create a member reference over multiple tables.

This method simplifies expressions of this form: ta.b=tb.id AND tb.c=tc.id AND tc.d=td.id AND ...

The corresponding JAVA expression would look like this: new Member(0, new Column[]{attrB, TableB.attrC, TableC.attrD, ...})

Throws:
java.lang.IllegalArgumentException - if selectors contains any null, or if baseColumn is negative.

Member

public Member(int baseColumn,
              Column[] selectors)
Create a member reference.

Throws:
java.lang.IllegalArgumentException - if selectors contains any null.

Member

public Member(int baseColumn,
              Column column1,
              Column column2)
Create a member reference over column1, which references another table to column2 of this one.

The table references by column1 will be added automatically to the FROM clause if needed.

Throws:
java.lang.IllegalArgumentException - if column1 or column2 is null.

Member

public Member(int baseColumn,
              Column column,
              boolean outerJoin)
Create a member reference.

Throws:
java.lang.IllegalArgumentException - if column1 is null.

Member

public Member(int baseColumn,
              Column column)
Create a member reference.

Throws:
java.lang.IllegalArgumentException - if column1 is null.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Tests whether this member expression is equal to another object.

Overrides:
equals in class java.lang.Object
Returns:
true is the other object is an existing member expression for the same table and equal selector list. Two selector lists are equal if the have the same length and each selector is equal and in the same order as in the other list.

getBaseColumn

public final int getBaseColumn()

getNumSelectors

public final int getNumSelectors()

getSelectors

public final Column[] getSelectors()

getSelector

public final Column getSelector(int idx)

getLastSelector

public final Column getLastSelector()

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

isConstant

public final boolean isConstant()
Description copied from interface: Term
Tests whether the expression can be evaluated without an object.

Specified by:
isConstant in interface Term

isJoin

public final boolean isJoin()
Description copied from interface: Term
Tests whether this expression enforces any kind of join.

Specified by:
isJoin in interface Term

isSelection

public final boolean isSelection()
Description copied from interface: Term
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

isOuterJoin

public final boolean isOuterJoin()

getSqlValue

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

As this term represents a column from a table the corresponding name will be returned. Further tables will be added to the FROM clause if more then one column is given.

Specified by:
getSqlValue in interface Term

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object