com.amazon.carbonado.filter
Class PropertyFilter<S extends Storable>

java.lang.Object
  extended by com.amazon.carbonado.filter.Filter<S>
      extended by com.amazon.carbonado.filter.PropertyFilter<S>
All Implemented Interfaces:
Appender, Serializable

public class PropertyFilter<S extends Storable>
extends Filter<S>

Filter tree node that performs a relational test against a specific property value.

Author:
Brian S O'Neill
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.amazon.carbonado.filter.Filter
Filter.NotJoined
 
Method Summary
<R,P> R
accept(Visitor<S,R,P> visitor, P param)
          Accept the given visitor subclass to traverse the filter tree.
 void appendTo(Appendable app, FilterValues<S> values)
          Appends the string value of this filter into the given Appendable.
<T extends Storable>
PropertyFilter<T>
asJoinedFromAny(ChainedProperty<T> joinProperty)
          Allows join from any property type, including one-to-many joins.
 PropertyFilter<S> bind()
          Walks through each property filter, assigning a bind ID to it.
 List<Filter<S>> conjunctiveNormalFormSplit()
          Splits the filter from its conjunctive normal form.
 Object constant()
          Returns the constant value of this PropertyFilter, which is valid only if isConstant returns true.
 PropertyFilter<S> constant(Object value)
          Returns another PropertyFilter instance which is bound to the given constant value.
 List<Filter<S>> disjunctiveNormalFormSplit()
          Splits the filter from its disjunctive normal form.
 boolean equals(Object obj)
           
 int getBindID()
          Bind ID is used to distinguish this PropertyFilter instance from another against the same property.
 Class<?> getBoxedType()
          Returns the type of the ChainedProperty property, boxed into an object if primitive.
 ChainedProperty<S> getChainedProperty()
           
 RelOp getOperator()
           
 Class<?> getType()
          Returns the type of the ChainedProperty.
 boolean isBound()
          Returns true if all property filters are known to be properly bound.
 boolean isConstant()
          Returns true if this PropertyFilter has a constant value.
 PropertyFilter<S> not()
          Returns the logical negation of this filter.
 PropertyFilter<S> unbind()
          Undoes the effect of a bind operation.
 
Methods inherited from class com.amazon.carbonado.filter.Filter
and, and, and, and, andExists, andNotExists, appendTo, asJoinedFrom, asJoinedFrom, conjunctiveNormalForm, disjunctiveNormalForm, filterFor, getClosedFilter, getOpenFilter, getStorableType, hashCode, initialFilterValues, isClosed, isOpen, notJoinedFrom, notJoinedFrom, or, or, or, or, orExists, orNotExists, reduce, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

not

public PropertyFilter<S> not()
Description copied from class: Filter
Returns the logical negation of this filter.

Specified by:
not in class Filter<S extends Storable>
Returns:
canonical Filter instance

disjunctiveNormalFormSplit

public List<Filter<S>> disjunctiveNormalFormSplit()
Description copied from class: Filter
Splits the filter from its disjunctive normal form. Or'ng the filters together produces the full disjunctive normal form.

Overrides:
disjunctiveNormalFormSplit in class Filter<S extends Storable>
Returns:
unmodifiable list of sub filters which don't perform any 'or' operations
Since:
1.1.1

conjunctiveNormalFormSplit

public List<Filter<S>> conjunctiveNormalFormSplit()
Description copied from class: Filter
Splits the filter from its conjunctive normal form. And'ng the filters together produces the full conjunctive normal form.

Overrides:
conjunctiveNormalFormSplit in class Filter<S extends Storable>
Returns:
unmodifiable list of sub filters which don't perform any 'and' operations
Since:
1.1.1

accept

public <R,P> R accept(Visitor<S,R,P> visitor,
                      P param)
Description copied from class: Filter
Accept the given visitor subclass to traverse the filter tree.

Specified by:
accept in class Filter<S extends Storable>
Parameters:
visitor - visitor to traverse through the tree
param - generic input parameter passed to visit methods
Returns:
generic return value passed from visit methods

getChainedProperty

public ChainedProperty<S> getChainedProperty()

getType

public Class<?> getType()
Returns the type of the ChainedProperty.


getBoxedType

public Class<?> getBoxedType()
Returns the type of the ChainedProperty property, boxed into an object if primitive.


getOperator

public RelOp getOperator()

getBindID

public int getBindID()
Bind ID is used to distinguish this PropertyFilter instance from another against the same property. For example, the filter "a = ? | a = ?" references the property 'a' twice. Each '?' parameter is bound to a different value, and so the bind ID for each property filter is different. "a = ?[1] | a = ?[2]".

Returns:
assigned bind ID, or 0 if unbound

bind

public PropertyFilter<S> bind()
Description copied from class: Filter
Walks through each property filter, assigning a bind ID to it. This step is automatically performed for proper dnf/cnf conversion, and for building FilterValues.

Specified by:
bind in class Filter<S extends Storable>
Returns:
canonical Filter instance with bound property filters

unbind

public PropertyFilter<S> unbind()
Description copied from class: Filter
Undoes the effect of a bind operation. The returned filter might still report itself as bound if it doesn't make a distinction between these states.

Specified by:
unbind in class Filter<S extends Storable>
Returns:
canonical Filter instance with unbound property filters

isBound

public boolean isBound()
Description copied from class: Filter
Returns true if all property filters are known to be properly bound. This is a side effect of calling Filter.bind(), Filter.initialFilterValues(), Filter.disjunctiveNormalForm() or Filter.conjunctiveNormalForm().

Specified by:
isBound in class Filter<S extends Storable>

asJoinedFromAny

public <T extends Storable> PropertyFilter<T> asJoinedFromAny(ChainedProperty<T> joinProperty)
Description copied from class: Filter
Allows join from any property type, including one-to-many joins.

Specified by:
asJoinedFromAny in class Filter<S extends Storable>

constant

public PropertyFilter<S> constant(Object value)
Returns another PropertyFilter instance which is bound to the given constant value.

Throws:
IllegalArgumentException - if value is not compatible with property type

constant

public Object constant()
Returns the constant value of this PropertyFilter, which is valid only if isConstant returns true.


isConstant

public boolean isConstant()
Returns true if this PropertyFilter has a constant value.


equals

public boolean equals(Object obj)
Specified by:
equals in class Filter<S extends Storable>

appendTo

public void appendTo(Appendable app,
                     FilterValues<S> values)
              throws IOException
Description copied from class: Filter
Appends the string value of this filter into the given Appendable.

Specified by:
appendTo in class Filter<S extends Storable>
values - optionally supply filter values
Throws:
IOException


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.