org.brains2b.data
Class Condition

java.lang.Object
  |
  +--org.brains2b.data.Condition
Direct Known Subclasses:
OracleCondition

public abstract class Condition
extends java.lang.Object

Abstract class defining a condition on a datastore.

The condition can be either an equals method for an identifier or an order by clause for your data.

Write an implementation for specific datastores by implementing the getCondition() to be executed as the query part for your default implementation.

Version:
0.22 [12/11/2002]
Author:
dennis@brains2b.nl

Field Summary
protected  java.util.Hashtable mCond
           
protected  java.util.Vector mOrderBy
           
 
Constructor Summary
Condition()
          Default Constructor
Condition(java.lang.String orderBy)
          Create a new Condition.
Condition(java.lang.String field, java.lang.Object value)
          Create new Condition
Condition(java.lang.String field, java.lang.Object value, java.lang.String orderBy)
          Creates new Condition initialized with both an condition and a sort order.
 
Method Summary
 void addCondition(java.lang.String field, int value)
          Adds a single statement to a condition of type identifier equals value
 void addCondition(java.lang.String field, java.lang.Object value)
          Adds a single statement to a condition of type identifier equals value
 void addOrderBy(java.lang.String field)
          Adds a sort order to the condition.
 void clearOrderBy()
          removes previously set sort order.
 boolean equals(java.lang.Object o)
           
abstract  java.lang.Object getCondition()
          abstract function left to specific datasource implementation to actually use condition and order by in a way the implementation does understand
 java.util.Hashtable getConditions()
          get the statements added by the addCondition in a hashtable
 java.util.Vector getOrderBy()
          get Orderby Vector
 void removeCondition(java.lang.String field)
          removes the statement that was set for this identifier
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mOrderBy

protected java.util.Vector mOrderBy

mCond

protected java.util.Hashtable mCond
Constructor Detail

Condition

public Condition()
Default Constructor


Condition

public Condition(java.lang.String orderBy)
Create a new Condition.

Parameters:
orderBy - String the identifier you want to order the data by

Condition

public Condition(java.lang.String field,
                 java.lang.Object value)
Create new Condition

Parameters:
field - String, the field identifier
value - Object, value to look for
See Also:
addCondition(String,Object)

Condition

public Condition(java.lang.String field,
                 java.lang.Object value,
                 java.lang.String orderBy)
Creates new Condition initialized with both an condition and a sort order.

Kind of superflues, but it is here

Parameters:
field - String, te identifier
value - Object, the value to look for
orderBy - String, identifier to sort by
Method Detail

addCondition

public void addCondition(java.lang.String field,
                         java.lang.Object value)
Adds a single statement to a condition of type identifier equals value

Storage type assures you can only have one condition per identifier. In case a field is set multiple times the last value will be used in the condition

Parameters:
field - String, the identifier
value - Object, the value
Throws:
java.lang.NullPointerException - if value or field are empty

addCondition

public void addCondition(java.lang.String field,
                         int value)
Adds a single statement to a condition of type identifier equals value

Parameters:
field - String, the identifier
value - int, the value
See Also:
addCondition(String, Object)

removeCondition

public void removeCondition(java.lang.String field)
removes the statement that was set for this identifier

Parameters:
field -

addOrderBy

public void addOrderBy(java.lang.String field)
Adds a sort order to the condition.

The order and sequence of the data will depend on the implementation. Fields are stored in sequence they where added an multiple identifiers can be specified

Parameters:
field - String, the column identifier

clearOrderBy

public void clearOrderBy()
removes previously set sort order.

No individual identifiers can be removed. Only all values. You can then define a new set of order conditions.


getOrderBy

public java.util.Vector getOrderBy()
get Orderby Vector

Not happy with this function so expect it to change in future releases

Returns:
Vector, Strings containing the order by fields in the sequence they where added, null if no order by clause was defined

getConditions

public java.util.Hashtable getConditions()
get the statements added by the addCondition in a hashtable

Not happy with this function so expect it to change in future releases

Returns:
Hashtable, the fields and values as key, value pairs. Null if no conditions where specified

getCondition

public abstract java.lang.Object getCondition()
abstract function left to specific datasource implementation to actually use condition and order by in a way the implementation does understand

Returns:
Object, most general implementation.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object), Object.hashCode()