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()
FilterByCriteria
getLocale
in interface FilterByCriteria
public void setLocale(Locale locale)
setLocale
in interface FilterByCriteria
public String getWildcard()
FilterByCriteria
getWildcard
in interface FilterByCriteria
public void setWildcard(String wildcard)
public String getGt()
FilterByCriteria
getGt
in interface FilterByCriteria
public void setGt(String gt)
public String getGtOrEq()
FilterByCriteria
getGtOrEq
in interface FilterByCriteria
public void setGtOrEq(String gtOrEq)
public String getLt()
FilterByCriteria
getLt
in interface FilterByCriteria
public void setLt(String lt)
public String getLtOrEq()
FilterByCriteria
getLtOrEq
in interface FilterByCriteria
public void setLtOrEq(String ltOrEq)
public void merge(AbstractFilter other)
public void addProperties(FilterByCriteria filter)
FilterByCriteria
addProperties
in interface FilterByCriteria
public void addProperty(String propertyId, Object minValue, boolean minValueIncluded, Object maxValue, boolean maxValueIncluded, Collection allowedValues, int allowMode)
FilterByCriteria
addProperty
in interface FilterByCriteria
propertyId
- 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)
FilterByCriteria
addProperty
in interface FilterByCriteria
propertyId
- 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)
FilterByCriteria
removeProperty
in interface FilterByCriteria
public void removeProperties(FilterByCriteria filter)
FilterByCriteria
removeProperties
in interface FilterByCriteria
public void removeAllProperty()
FilterByCriteria
removeAllProperty
in interface FilterByCriteria
public int getPropertyPriority(String propertyId)
FilterByCriteria
getPropertyPriority
in interface FilterByCriteria
public Comparable getPropertyMinValue(String propertyId)
FilterByCriteria
getPropertyMinValue
in interface FilterByCriteria
public boolean minValueIncluded(String propertyId)
FilterByCriteria
minValueIncluded
in interface FilterByCriteria
public Comparable getPropertyMaxValue(String propertyId)
FilterByCriteria
getPropertyMaxValue
in interface FilterByCriteria
public boolean maxValueIncluded(String propertyId)
FilterByCriteria
maxValueIncluded
in interface FilterByCriteria
public List getPropertyAllowedValues(String propertyId)
FilterByCriteria
getPropertyAllowedValues
in interface FilterByCriteria
public int getPropertyAllowMode(String propertyId)
FilterByCriteria
getPropertyAllowMode
in interface FilterByCriteria
ALLOW_
constants defined.public void setVariableName(String propertyId, String varName)
FilterByCriteria
For more details see setFilterCondition(String logicalExpression)
method.
setVariableName
in interface FilterByCriteria
public String getVariableName(String propertyId)
getVariableName
in interface FilterByCriteria
public String getExtraInfo(String propertyId)
getExtraInfo
in interface FilterByCriteria
public void setExtraInfo(String propertyId, String extraInfo)
FilterByCriteria
setExtraInfo
in interface FilterByCriteria
public void setFilterCondition(String logicalExpression)
FilterByCriteria
pass(Object)
method.setFilterCondition
in interface FilterByCriteria
logicalExpression
- 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()
FilterByCriteria
getPropertyIds
in interface FilterByCriteria
public boolean containsProperty(String propertyId)
FilterByCriteria
containsProperty
in interface FilterByCriteria
public boolean containsProperty(Collection propIds)
FilterByCriteria
containsProperty
in interface FilterByCriteria
propIds
- A collection of property identifiers.public boolean pass(String propertyId, Object value) throws IllegalArgumentException
pass
in interface FilterByCriteria
propertyId
- The property to pass.value
- The value to check.IllegalArgumentException
public 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)
Filter
public boolean pass(Object obj)
Filter
protected 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.EvalError
public int compare(Comparable o1, Comparable o2, int ordering)
ordering:
- 1=ascending, -1=descendingpublic FilterByCriteria cloneFilter()
FilterByCriteria
cloneFilter
in interface FilterByCriteria
protected 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–2017 JBoss by Red Hat. All rights reserved.