Class Restriction
- java.lang.Object
-
- 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
Fields Modifier and Type Field Description intcomparisonthe comparison to make between the property and the value, use the defined constants: e.g.static intEQUALSstatic intGREATERstatic intLESSstatic intLIKEstatic intNOT_EQUALSstatic intNOT_NULLstatic intNULLStringpropertythe name of the field (property) in the searchObjectvaluethe value of theproperty(can be an array of items)
-
Constructor Summary
Constructors Constructor Description Restriction(String property, Object value)Simple restriction where the property must equal the valueRestriction(String property, Object value, int comparison)Restriction which defines the type of comparison to make between a property and value
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Object[]getArrayValue()booleangetBooleanValue()intgetComparison()the comparison to make between the property and the value, use the defined constants: e.g.StringgetProperty()the name of the field (property) in the searchObjectgetSingleValue()StringgetStringValue()ObjectgetValue()the value of theproperty(can be an array of items)inthashCode()voidsetComparison(int comparison)voidsetProperty(String property)voidsetValue(Object value)StringtoString()
-
-
-
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
-
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 objectvalue- the value of theproperty(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 objectvalue- the value of theproperty(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)
-
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)
-
-