org.sakaiproject.entitybroker.entityprovider.search
Class Restriction

java.lang.Object
  extended by org.sakaiproject.entitybroker.entityprovider.search.Restriction

public class Restriction
extends Object

A simple bean which defines a restriction in a search, this is like saying: where userId = '123'; OR where userId like '%aaronz%';
Example usage:
Restriction rteq = new Restriction("title", curTitle); // restrict search to title equals value of curTitle
Restriction rtne = new Restriction("title", curTitle, Restriction.NOT_EQUALS); // restrict search to title not equals value of curTitle

Author:
Aaron Zeckoski (azeckoski@gmail.com)

Field Summary
 int comparison
          the comparison to make between the property and the value, use the defined constants: e.g.
static int EQUALS
           
static int GREATER
           
static int LESS
           
static int LIKE
           
static int NOT_EQUALS
           
static int NOT_NULL
           
static int NULL
           
 String property
          the name of the field (property) in the search
 Object value
          the value of the property (can be an array of items)
 
Constructor Summary
Restriction(String property, Object value)
          Simple restriction where the property must equal the value
Restriction(String property, Object value, int comparison)
          Restriction which defines the type of comparison to make between a property and value
 
Method Summary
 boolean equals(Object obj)
           
 Object[] getArrayValue()
           
 boolean getBooleanValue()
           
 int getComparison()
          the comparison to make between the property and the value, use the defined constants: e.g.
 String getProperty()
          the name of the field (property) in the search
 Object getSingleValue()
           
 String getStringValue()
           
 Object getValue()
          the value of the property (can be an array of items)
 int hashCode()
           
 void setComparison(int comparison)
           
 void setProperty(String property)
           
 void setValue(Object value)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EQUALS

public static final int EQUALS
See Also:
Constant Field Values

GREATER

public static final int GREATER
See Also:
Constant Field Values

LESS

public static final int LESS
See Also:
Constant Field Values

LIKE

public static final int LIKE
See Also:
Constant Field Values

NULL

public static final int NULL
See Also:
Constant Field Values

NOT_NULL

public static final int NOT_NULL
See Also:
Constant Field Values

NOT_EQUALS

public static final int NOT_EQUALS
See Also:
Constant Field Values

property

public String property
the name of the field (property) in the search


value

public Object value
the value of the property (can be an array of items)


comparison

public int comparison
the comparison to make between the property and the value, use the defined constants: e.g. EQUALS, LIKE, etc...

Constructor Detail

Restriction

public Restriction(String property,
                   Object value)
Simple restriction where the property must equal the value

Parameters:
property - the name of the field (property) in the persisted object
value - the value of the property (can be an array of items)

Restriction

public Restriction(String property,
                   Object value,
                   int comparison)
Restriction which defines the type of comparison to make between a property and value

Parameters:
property - the name of the field (property) in the persisted object
value - the value of the property (can be an array of items)
comparison - the comparison to make between the property and the value, use the defined constants: e.g. EQUALS, LIKE, etc...
Method Detail

getProperty

public String getProperty()
the name of the field (property) in the search


setProperty

public void setProperty(String property)

getValue

public Object getValue()
the value of the property (can be an array of items)


setValue

public void setValue(Object value)

getStringValue

public String getStringValue()
Returns:
the string value of the property, converts arrays to strings automatically, if null then return ''

getBooleanValue

public boolean getBooleanValue()
Returns:
the value as a boolean, will return false if it is null or cannot be converted to a boolean

getSingleValue

public Object getSingleValue()
Returns:
the value if it is not an array or collection, if it is then return the first object in the array or collection, otherwise return null (including when value is null)

getArrayValue

public Object[] getArrayValue()
Returns:
the value as an array if it is an array or a collection, if it is a single value then return null (also when value is null)

getComparison

public int getComparison()
the comparison to make between the property and the value, use the defined constants: e.g. EQUALS, LIKE, etc...


setComparison

public void setComparison(int comparison)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2013 Sakai Project. All Rights Reserved.