Last update: 2011-06-23

org.proteios.core
Class PropertyFilter

java.lang.Object
  extended by org.proteios.core.PropertyFilter

public class PropertyFilter
extends Object

Used to store filter settings in the current context. A filter is a simple expression of the form: property operator value, ie. name = 'Nicklas' or spots > 10000.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2010-12-06 14:57:40 +0100 (Mon, 06 Dec 2010) $

Constructor Summary
PropertyFilter(String property)
          Create a new filter for a property.
 
Method Summary
 Operator getOperator()
          Get the operator to use in the filter.
 String getProperty()
          Get the name of the property this filter is used on.
 Restriction getRestriction()
          Create a restriction from the filter.
 String getValue()
          Get the value to use in the filter.
 Object getValueAsObject()
          Get the value as an object of the correct type.
 Type getValueType()
          Get the type of the property.
 void setOperator(Operator operator)
          Set the operator to use in the filter.
 void setValue(String value)
          Set the value to use in the filter.
 void setValueType(Type valueType)
          Set the type of the property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyFilter

public PropertyFilter(String property)
Create a new filter for a property.

Parameters:
property - The name of the property
Method Detail

getProperty

public String getProperty()
Get the name of the property this filter is used on.


getValueType

public Type getValueType()
Get the type of the property.


setValueType

public void setValueType(Type valueType)
Set the type of the property.

Parameters:
valueType - The type

getOperator

public Operator getOperator()
Get the operator to use in the filter.


setOperator

public void setOperator(Operator operator)
Set the operator to use in the filter.


getValue

public String getValue()
Get the value to use in the filter.

Returns:
The value as a string

setValue

public void setValue(String value)
Set the value to use in the filter.

Parameters:
value - The value as a string

getValueAsObject

public Object getValueAsObject()
Get the value as an object of the correct type. The Type.parseString(String) is used to convert the value.

Returns:
The value as an object
Throws:
InvalidDataException - If the string value can't be parsed

getRestriction

public Restriction getRestriction()
Create a restriction from the filter. There are a few special cases:

If the property starts with a # it is a filter on annotations. The rest of the property is the ID of the annotation type, and we use a AnnotationSimpleRestriction object for the restriction.

If the property starts with a $ it is interpreted as a alias.property value, ignoring the root alias of the query.

If the property starts with a @ the property is a collection of values and we always use an IN restriction, ignoring the specified operator.

The property may also start with $@.

Returns:
The restriction

Last update: 2011-06-23