com.objectwave.persist.constraints
Class CrossField

java.lang.Object
  |
  +--com.objectwave.persist.constraints.Constraint
        |
        +--com.objectwave.persist.constraints.CrossField
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class CrossField
extends Constraint

Use this to create multiple constraints on a multiple fields.

Version:
$Id: CrossField.java,v 2.2 2002/02/08 22:41:28 dave_hoag Exp $
Author:
Dave Hoag
See Also:
Serialized Form

Nested Class Summary
static class CrossField.Test
          Unit test of some simple Between values.
 
Field Summary
 
Fields inherited from class com.objectwave.persist.constraints.Constraint
columnName, defaultObjectFormatter, objectFormatter
 
Constructor Summary
CrossField(boolean and, Constraint first, Constraint second)
           
 
Method Summary
 boolean checkConstraint(java.lang.Object one, java.lang.Object two)
          Do nothing - now uses the other constraint check method
 boolean checkConstraint(SQLQuery query, Persistence poolElement, java.lang.Object fieldObj, java.lang.Object queryObj)
           
 java.lang.String constructQueryString()
          Return the string which will appear in the query string.
protected  java.lang.String deriveColumnName(Constraint constraint)
          Has the side effect of modifying the constraint to have a persistent object if one does not already exist.
 void fromString(java.lang.String str)
          Parse the string.
protected  java.lang.String getAlias()
           
static java.util.Vector getFields()
          Gets the Fields attribute of the CrossField class
 java.util.Enumeration getStaticList()
          Gets the StaticList attribute of the Constraint object
 java.lang.String getType()
          This is a unique, readable string identifying the constraint type (ex, anyof, null)
 boolean isUsingColumnName()
           
 void staticListInsert(java.lang.String field)
          Each type of constraint will have a specific set of fields associated with it.
 java.lang.String stringify()
          Stringify the object.
 
Methods inherited from class com.objectwave.persist.constraints.Constraint
classOfField, clone, equals, findField, formatString, getColumnName, getField, getNot, getObjectFormatter, getPersistence, isComparisonValueFromPersistentObject, setColumnName, setField, setNot, setObjectFormatter, setPersistence, sqlString, stringToObject, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CrossField

public CrossField(boolean and,
                  Constraint first,
                  Constraint second)
Parameters:
and - true if this is an and and false if this is an or
first -
second -
Method Detail

getFields

public static java.util.Vector getFields()
Gets the Fields attribute of the CrossField class

Returns:
The Fields value

getStaticList

public java.util.Enumeration getStaticList()
Description copied from class: Constraint
Gets the StaticList attribute of the Constraint object

Specified by:
getStaticList in class Constraint
Returns:
The StaticList value

getType

public java.lang.String getType()
Description copied from class: Constraint
This is a unique, readable string identifying the constraint type (ex, anyof, null)

Specified by:
getType in class Constraint
Returns:
The Type value

isUsingColumnName

public boolean isUsingColumnName()
Overrides:
isUsingColumnName in class Constraint
Returns:
The UsingColumnName value

getAlias

protected java.lang.String getAlias()
Returns:
The Alias value

checkConstraint

public boolean checkConstraint(java.lang.Object one,
                               java.lang.Object two)
Do nothing - now uses the other constraint check method

Specified by:
checkConstraint in class Constraint
Parameters:
one -
two -
Returns:

checkConstraint

public boolean checkConstraint(SQLQuery query,
                               Persistence poolElement,
                               java.lang.Object fieldObj,
                               java.lang.Object queryObj)
Overrides:
checkConstraint in class Constraint
Parameters:
fieldObj - java.lang.Object
queryObj - java.lang.Object
query -
poolElement -
Returns:
boolean

constructQueryString

public java.lang.String constructQueryString()
Description copied from class: Constraint
Return the string which will appear in the query string. That is, what should follow the field specification? (ex, "NOT IN ('cat','dog')"). If this constraint is simply an operator, and the original comparison value should go on the RHS, then the last character should be a '*'. Ex, If the field is "quote.status", and the field' value has been specified to be "Q%", then returning "MATCHES*" will produce "quote.status MATCHES Q%". Ex, Using the above example, returning "NOT IN ('cat','dog')" will produce "quote.status NOT IN ('cat','dog')". Note that the returned string is never padded with spaces. Note that this method will return null if the string cannot be constructed for some reason (an messafe will already have been presented to the user. Perhaps I should delegate that responsability to the calling method... hmmm....)

Specified by:
constructQueryString in class Constraint
Returns:

fromString

public void fromString(java.lang.String str)
                throws java.text.ParseException
Description copied from class: Constraint
Parse the string. Probably a string encoded via the toString() call, this method attempts to build the object's state from the information in string "str".

Specified by:
fromString in class Constraint
Parameters:
str -
Throws:
java.text.ParseException

staticListInsert

public void staticListInsert(java.lang.String field)
Description copied from class: Constraint
Each type of constraint will have a specific set of fields associated with it. This is to allow the user to select them via Gui.

Specified by:
staticListInsert in class Constraint
Parameters:
field -

stringify

public java.lang.String stringify()
Description copied from class: Constraint
Stringify the object. Object serialization may be a better approach. Oh well. Encode the class's type and state in a readable string.

Specified by:
stringify in class Constraint
Returns:

deriveColumnName

protected java.lang.String deriveColumnName(Constraint constraint)
                                     throws NotFoundException
Has the side effect of modifying the constraint to have a persistent object if one does not already exist.

Parameters:
constraint -
Returns:
Throws:
NotFoundException