public abstract class AbstractFilter extends Object implements FilterByCriteria, Cloneable
| Modifier and Type | Field and Description |
|---|---|
protected ThreadLocal |
_bshIntepreterThread
BSH interpreter per thread cache.
|
protected Map |
_filterVarValues
Map used to store properties filter results when evauating the overall filter condition.
|
protected String |
filterCondition
The filter condition logical expression.
|
protected List |
filterProperties
Filter list.
|
protected String |
gt
Greater than symbol.
|
protected String |
gtOrEq
Greater or equals than symbol.
|
protected Locale |
locale
The criteria locale.
|
protected String |
lt
Less than symbol.
|
protected String |
ltOrEq
Less or equals than symbol.
|
protected String |
wildcard
Wildcard symbol.
|
ALLOW_ALL, ALLOW_ANY, ALLOW_NONE| Constructor and Description |
|---|
AbstractFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
addProperties(FilterByCriteria filter)
Add all the specified filter properties.
|
void |
addProperty(String propertyId,
Object minValue,
boolean minValueIncluded,
Object maxValue,
boolean maxValueIncluded,
Collection allowedValues,
int allowMode)
Specifies a property for the filter.
|
boolean |
addProperty(String propertyId,
String filterCriteria)
Specifies a property for the filter in a unstructured way.
|
FilterByCriteria |
cloneFilter()
Create an exact copy of this filter instance.
|
int |
compare(Comparable o1,
Comparable o2,
int ordering)
Compares two comparable objects.
|
protected int |
compareBySimilarity(String propertyId,
Object pattern,
Object value)
Check if the given object instance matchs the specified pattern.
|
boolean |
containsProperty(Collection propIds)
Check if a filter is defined for any of the property identifiers given.
|
boolean |
containsProperty(String propertyId)
Check if the given property filter has been defined.
|
boolean |
equals(Object obj) |
protected Object |
executeBeanShellScript(String beanShellScript,
Map context)
Executes a BeanShell script.
|
protected abstract String |
formatForComparison(String propertyId,
Object value)
Format a given property value valid for string comparfison against other values.
|
protected abstract String |
formatForDisplay(String propertyId,
Object value)
Format a given property value as displayed for the the user.
|
String |
getExtraInfo(String propertyId) |
String |
getFilterCondition() |
String |
getGt()
The greater than symbol.
|
String |
getGtOrEq()
The greater or equals than symbol.
|
Locale |
getLocale()
The criteria always belongs to a locale.
|
String |
getLt()
The less than symbol.
|
String |
getLtOrEq()
The less or equals than symbol.
|
protected Object[] |
getProperty(String propertyId) |
List |
getPropertyAllowedValues(String propertyId)
Get the set of allowed values for the property.
|
int |
getPropertyAllowMode(String propertyId)
Get the allow mode for a property.
|
String[] |
getPropertyIds()
Retgrieve the property ids. specified for this filter.
|
Comparable |
getPropertyMaxValue(String propertyId)
Get the max. value allowed for the property in the filter.
|
Comparable |
getPropertyMinValue(String propertyId)
Get the min. value allowed for the property in the filter.
|
int |
getPropertyPriority(String propertyId)
Get the prioority for a given property defined in the filter.
|
protected abstract Object |
getPropertyValue(String propertyId,
Object obj)
Retrieve the value for a given property.
|
String |
getVariableName(String propertyId) |
String |
getWildcard()
The wildcard symbol used by the filter to compare properties.
|
boolean |
maxValueIncluded(String propertyId)
Check if max. value defined must be considered as valid.
|
void |
merge(AbstractFilter other) |
boolean |
minValueIncluded(String propertyId)
Check if min. value defined must be considered as valid.
|
boolean |
pass(Map obj)
Apply the filter to the given object.
|
boolean |
pass(Object obj)
Apply the filter to the given object.
|
boolean |
pass(String propertyId,
Object value)
Check if a value satisfies a property filter.
|
boolean |
pass(String propertyId,
Object value,
List allowedValues,
int allowMode)
Check if a given value (either a single object or a collection) satisfies a collection of allowed values.
|
boolean |
passValue(String propertyId,
Object value,
List allowedValues,
int allowMode)
Check if a given value satisfies a collection of allowed values.
|
void |
removeAllProperty()
Clear filter.
|
void |
removeProperties(FilterByCriteria filter)
Remove all the specified filter properties.
|
void |
removeProperty(String propertyId)
Remove property from the filter.
|
void |
setExtraInfo(String propertyId,
String extraInfo)
Set additional information regarding the property.
|
void |
setFilterCondition(String logicalExpression)
Define the condition to be applied to the set of property filters when executing the
pass(Object) method. |
void |
setGt(String gt) |
void |
setGtOrEq(String gtOrEq) |
void |
setLocale(Locale locale) |
void |
setLt(String lt) |
void |
setLtOrEq(String ltOrEq) |
void |
setVariableName(String propertyId,
String varName)
An alias or variable to be assigned to the property .
|
void |
setWildcard(String wildcard) |
String |
toString() |
protected List filterProperties
protected String filterCondition
protected String wildcard
protected String gt
protected String lt
protected String gtOrEq
protected String ltOrEq
protected Locale locale
protected transient Map _filterVarValues
protected transient ThreadLocal _bshIntepreterThread
public Locale getLocale()
FilterByCriteriagetLocale in interface FilterByCriteriapublic void setLocale(Locale locale)
setLocale in interface FilterByCriteriapublic String getWildcard()
FilterByCriteriagetWildcard in interface FilterByCriteriapublic void setWildcard(String wildcard)
public String getGt()
FilterByCriteriagetGt in interface FilterByCriteriapublic void setGt(String gt)
public String getGtOrEq()
FilterByCriteriagetGtOrEq in interface FilterByCriteriapublic void setGtOrEq(String gtOrEq)
public String getLt()
FilterByCriteriagetLt in interface FilterByCriteriapublic void setLt(String lt)
public String getLtOrEq()
FilterByCriteriagetLtOrEq in interface FilterByCriteriapublic void setLtOrEq(String ltOrEq)
public void merge(AbstractFilter other)
public void addProperties(FilterByCriteria filter)
FilterByCriteriaaddProperties in interface FilterByCriteriapublic void addProperty(String propertyId, Object minValue, boolean minValueIncluded, Object maxValue, boolean maxValueIncluded, Collection allowedValues, int allowMode)
FilterByCriteriaaddProperty in interface FilterByCriteriapropertyId - The property to set.minValue - The minimun value allowed for the property.minValueIncluded - The minimun value is considered as a valid value.maxValue - The maximum value allowed for the property.maxValueIncluded - The maximum value is considered as a valid value.allowedValues - A set of values allowed.allowMode - public boolean addProperty(String propertyId, String filterCriteria)
FilterByCriteriaaddProperty in interface FilterByCriteriapropertyId - The property to set.filterCriteria - The criteria for the property.
Operators are allowed here: wildcard, greater than, less than and comma. e.g: ">1000",
"Rev*", "1000, 1002, 1003".public void removeProperty(String propertyId)
FilterByCriteriaremoveProperty in interface FilterByCriteriapublic void removeProperties(FilterByCriteria filter)
FilterByCriteriaremoveProperties in interface FilterByCriteriapublic void removeAllProperty()
FilterByCriteriaremoveAllProperty in interface FilterByCriteriapublic int getPropertyPriority(String propertyId)
FilterByCriteriagetPropertyPriority in interface FilterByCriteriapublic Comparable getPropertyMinValue(String propertyId)
FilterByCriteriagetPropertyMinValue in interface FilterByCriteriapublic boolean minValueIncluded(String propertyId)
FilterByCriteriaminValueIncluded in interface FilterByCriteriapublic Comparable getPropertyMaxValue(String propertyId)
FilterByCriteriagetPropertyMaxValue in interface FilterByCriteriapublic boolean maxValueIncluded(String propertyId)
FilterByCriteriamaxValueIncluded in interface FilterByCriteriapublic List getPropertyAllowedValues(String propertyId)
FilterByCriteriagetPropertyAllowedValues in interface FilterByCriteriapublic int getPropertyAllowMode(String propertyId)
FilterByCriteriagetPropertyAllowMode in interface FilterByCriteriaALLOW_ constants defined.public void setVariableName(String propertyId, String varName)
FilterByCriteriaFor more details see setFilterCondition(String logicalExpression) method.
setVariableName in interface FilterByCriteriapublic String getVariableName(String propertyId)
getVariableName in interface FilterByCriteriapublic String getExtraInfo(String propertyId)
getExtraInfo in interface FilterByCriteriapublic void setExtraInfo(String propertyId, String extraInfo)
FilterByCriteriasetExtraInfo in interface FilterByCriteriapublic void setFilterCondition(String logicalExpression)
FilterByCriteriapass(Object) method.setFilterCondition in interface FilterByCriterialogicalExpression - A logical expression where we can combine the different property
pass results in order to calculate the overall filter result. Boolean AND, OR and
NOT operators are supported.
Next some logical expressions samples:
As you can see, powerful and complex boolean expressions can be defined.
public String getFilterCondition()
public String[] getPropertyIds()
FilterByCriteriagetPropertyIds in interface FilterByCriteriapublic boolean containsProperty(String propertyId)
FilterByCriteriacontainsProperty in interface FilterByCriteriapublic boolean containsProperty(Collection propIds)
FilterByCriteriacontainsProperty in interface FilterByCriteriapropIds - A collection of property identifiers.public boolean pass(String propertyId, Object value) throws IllegalArgumentException
pass in interface FilterByCriteriapropertyId - The property to pass.value - The value to check.IllegalArgumentExceptionpublic boolean pass(String propertyId, Object value, List allowedValues, int allowMode)
value - allowedValues - allowMode - See ALLOW_ constants defined.public boolean passValue(String propertyId, Object value, List allowedValues, int allowMode)
value - allowedValues - allowMode - See ALLOW_ constants defined.protected int compareBySimilarity(String propertyId, Object pattern, Object value)
propertyId - The property to compare.pattern - The pattern. In Strings wildcard is accepted.value - The object to check.public boolean pass(Map obj)
Filterpublic boolean pass(Object obj)
Filterprotected Object executeBeanShellScript(String beanShellScript, Map context) throws bsh.EvalError
beanShellScript - The script to execute in BeanShell format.context - A map of arguments to be passed to the script.bsh.EvalErrorpublic int compare(Comparable o1, Comparable o2, int ordering)
ordering: - 1=ascending, -1=descendingpublic FilterByCriteria cloneFilter()
FilterByCriteriacloneFilter in interface FilterByCriteriaprotected abstract String formatForDisplay(String propertyId, Object value)
propertyId - The property identifier.value - The value to format.protected abstract String formatForComparison(String propertyId, Object value)
propertyId - The property identifier.value - The value to format.Copyright © 2012–2016 JBoss by Red Hat. All rights reserved.