oracle.toplink.queryframework
Class QueryByExamplePolicy

java.lang.Object
  |
  +--oracle.toplink.queryframework.QueryByExamplePolicy
All Implemented Interfaces:
java.io.Serializable

public class QueryByExamplePolicy
extends java.lang.Object
implements java.io.Serializable

Purpose: This policy defines the configuration options for a Query By Example query.

Description: Allow for the a set of values to be ignored, a set of attributes to always include, and special operators to be used for different types.

Since:
TOPLink/Java 3.0
See Also:
Serialized Form

Field Summary
TypeField
 java.util.Hashtable attributesToAlwaysInclude
           
 boolean shouldUseEqualityForNulls
           
 java.util.Hashtable specialOperations
           
 java.util.Hashtable valuesToExclude
           
 
Constructor Summary
QueryByExamplePolicy()
          PUBLIC: construct a QueryByExamplePolicy, and put the default values to be excluded, (that includes 0, false, empty String, etc).
 
Method Summary
TypeMethod
 void addSpecialOperation(java.lang.Class theClass, java.lang.String operation)
          PUBLIC: QueryByExamplePolicy allows for specail operations to be used for comparisons in addition to equality.
 void alwaysIncludeAttribute(java.lang.Class exampleClass, java.lang.String attributeName)
          PUBLIC: if an attributeValue is null, or if it's value is to be excluded (for example if an int equals to 0, or a String is the empty string), it will automatically be ignored and not included in the query, unless the attribute is in the alwaysIncludedAttribute list.
 void excludeDefaultPrimitiveValues()
          PUBLIC: This method adds the default values to be excluded to the list.
 void excludeValue(boolean value)
          PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.
 void excludeValue(byte value)
          PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.
 void excludeValue(char value)
          PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.
 void excludeValue(double value)
          PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.
 void excludeValue(float value)
          PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.
 void excludeValue(int value)
          PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.
 void excludeValue(long value)
          PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.
 void excludeValue(java.lang.Object value)
          PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.
 void excludeValue(short value)
          PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.
 java.util.Hashtable getAttributesToAlwaysInclude()
          PUBLIC: This method returns the Hashtable that lists all the attributes that are to be included at all times.
 java.util.Hashtable getSpecialOperations()
          PUBLIC: This returns the Hashtable that lists the specail operations.
 java.util.Hashtable getValuesToExclude()
          PUBLIC: This returns the Hashtable that lists the values to be excluded.
 void includeAllValues()
          PUBLIC: This method empties the list of values to be excluced.
 void removeFromValuesToExclude(java.lang.Object value)
          PUBLIC: Removes the value from the list of values to be ignored automatically.
 void setShouldUseEqualityForNulls(boolean shouldUseEqualityForNulls)
          PUBLIC: If an attribute value is null (and it's attribute name belongs to the attributes to always be included) there are two operations that could be used.
 boolean shouldUseEqualityForNulls()
          PUBLIC: Returns if isNull is used for nulls or notNull.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

valuesToExclude

public java.util.Hashtable valuesToExclude

attributesToAlwaysInclude

public java.util.Hashtable attributesToAlwaysInclude

specialOperations

public java.util.Hashtable specialOperations

shouldUseEqualityForNulls

public boolean shouldUseEqualityForNulls
Constructor Detail

QueryByExamplePolicy

public QueryByExamplePolicy()
PUBLIC: construct a QueryByExamplePolicy, and put the default values to be excluded, (that includes 0, false, empty String, etc). by defalt if an attribute is null, and yet has to be included at all times, equality (isNull) is used for the comparison. This is used for searching for an object with a null in a certain field.
Method Detail

addSpecialOperation

public void addSpecialOperation(java.lang.Class theClass,
                                java.lang.String operation)
PUBLIC: QueryByExamplePolicy allows for specail operations to be used for comparisons in addition to equality. (For example notEqual, lessThan, greaterThan, like, etc.) This specail operation will be used for all the attributes values of the certain class that is provided. the name of the operation is a string corresponding to the name of the method that can be used on Expressions.

alwaysIncludeAttribute

public void alwaysIncludeAttribute(java.lang.Class exampleClass,
                                   java.lang.String attributeName)
PUBLIC: if an attributeValue is null, or if it's value is to be excluded (for example if an int equals to 0, or a String is the empty string), it will automatically be ignored and not included in the query, unless the attribute is in the alwaysIncludedAttribute list. This allows for the attributes of a class to be always included. Note: the class is the class that the attribute belongs to, normally this is the example class unless using nested QBE.

excludeDefaultPrimitiveValues

public void excludeDefaultPrimitiveValues()
PUBLIC: This method adds the default values to be excluded to the list.

excludeValue

public void excludeValue(byte value)
PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.

excludeValue

public void excludeValue(char value)
PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.

excludeValue

public void excludeValue(double value)
PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.

excludeValue

public void excludeValue(float value)
PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.

excludeValue

public void excludeValue(int value)
PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.

excludeValue

public void excludeValue(long value)
PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.

excludeValue

public void excludeValue(java.lang.Object value)
PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.

excludeValue

public void excludeValue(short value)
PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.

excludeValue

public void excludeValue(boolean value)
PUBLIC: Using this method, it is possible to always ignore an attribute pair, when the value is equal to the value specified.

getAttributesToAlwaysInclude

public java.util.Hashtable getAttributesToAlwaysInclude()
PUBLIC: This method returns the Hashtable that lists all the attributes that are to be included at all times. These attributes are listed here so they will be included in the query even if they are null, or if their value is listed in the list to be ignored (like the empty String, 0, false).

getSpecialOperations

public java.util.Hashtable getSpecialOperations()
PUBLIC: This returns the Hashtable that lists the specail operations. If desired, special operations (for example notEqual, like, lessThan, greaterThan) can be used for comparisons. In this case a Class is associated with the desired operation, and every attribute from that class will be using the specified operation. The operations are listed as Strings (the method names).

getValuesToExclude

public java.util.Hashtable getValuesToExclude()
PUBLIC: This returns the Hashtable that lists the values to be excluded. If an attribute pair has one of these values it will be ignored, and not included in the query. These values are by default zeros for numeric values, false for booleans, and empty String. If other values are to be excluded they could be added to this list.

includeAllValues

public void includeAllValues()
PUBLIC: This method empties the list of values to be excluced. Therefor if the values is zero, false, or the empty string, it will not automatically be ignored. Using this method could cause problems if some fields of the example object are not set, and therefore zero, or empty by default.

removeFromValuesToExclude

public void removeFromValuesToExclude(java.lang.Object value)
PUBLIC: Removes the value from the list of values to be ignored automatically.

setShouldUseEqualityForNulls

public void setShouldUseEqualityForNulls(boolean shouldUseEqualityForNulls)
PUBLIC: If an attribute value is null (and it's attribute name belongs to the attributes to always be included) there are two operations that could be used. (isNull, or notNull) This method declares which one of these operations should be used. If useEqualilyForIncludedNulls is set to be true isNull, and if false notNull will be used.

shouldUseEqualityForNulls

public boolean shouldUseEqualityForNulls()
PUBLIC: Returns if isNull is used for nulls or notNull.