public class FilterItem extends BaseObject implements QueryItem, Cloneable, IRowFilter
FilterClause
,
OperatorType
,
LogicalOperator
,
Serialized FormConstructor and Description |
---|
FilterItem(FilterItem... items)
Creates a compound filter item based on other filter items.
|
FilterItem(List<FilterItem> items)
Creates a composite filter item based on other filter items.
|
FilterItem(LogicalOperator logicalOperator,
FilterItem... items)
Creates a compound filter item based on other filter items.
|
FilterItem(LogicalOperator logicalOperator,
List<FilterItem> items)
Creates a compound filter item based on other filter items.
|
FilterItem(SelectItem selectItem,
OperatorType operator,
Object operand)
Creates a single filter item based on a SelectItem, an operator and an
operand.
|
FilterItem(String expression)
Creates a single unvalidated filter item based on a expression.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Row row)
Filters a row
|
static Object |
appendOperator(StringBuilder sb,
Object operand,
OperatorType operator) |
protected FilterItem |
clone() |
protected void |
decorateIdentity(List<Object> identifiers)
Subclasses should implement this method and add all fields to the list
that are to be included in equals(...) and hashCode() evaluation
|
boolean |
evaluate(Row row)
Does a "manual" evaluation, useful for CSV data and alike, where queries
cannot be created.
|
int |
getChildItemCount()
Get the number of child items, if this is a compound filter item.
|
FilterItem[] |
getChildItems()
Gets the
FilterItem s that this filter item consists of, if it is
a compound filter item. |
String |
getExpression() |
LogicalOperator |
getLogicalOperator() |
Object |
getOperand() |
OperatorType |
getOperator() |
int |
getOrItemCount()
Deprecated.
use
getChildItemCount() instead. |
FilterItem[] |
getOrItems()
Deprecated.
use
getChildItems() instead |
Query |
getQuery() |
SelectItem |
getSelectItem() |
boolean |
isCompoundFilter()
Determines whether this
FilterItem is a compound filter or not
(ie. |
boolean |
isReferenced(Column column) |
FilterItem |
setQuery(Query query) |
String |
toSql() |
String |
toSql(boolean includeSchemaInColumnPaths)
Parses the constraint as a SQL Where-clause item
|
String |
toString() |
classEquals, equals, hashCode
public FilterItem(SelectItem selectItem, OperatorType operator, Object operand) throws IllegalArgumentException
selectItem
- the selectItem to put constraints on, cannot be nulloperator
- The operator to use. Can be OperatorType.EQUALS_TO,
OperatorType.DIFFERENT_FROM,
OperatorType.GREATER_THAN,OperatorType.LESS_THAN
OperatorType.GREATER_THAN_OR_EQUAL,
OperatorType.LESS_THAN_OR_EQUALoperand
- The operand. Can be a constant like null or a String, a
Number, a Boolean, a Date, a Time, a DateTime. Or another
SelectItemIllegalArgumentException
- if the SelectItem is null or if the combination of operator
and operand does not make sense.public FilterItem(String expression)
expression
- An expression to use for the filter, for example
"YEAR(my_date) = 2008".public FilterItem(List<FilterItem> items)
items
- a list of items to include in the compositepublic FilterItem(LogicalOperator logicalOperator, List<FilterItem> items)
LogicalOperator
.logicalOperator
- the logical operator to applyitems
- a list of items to include in the compositepublic FilterItem(LogicalOperator logicalOperator, FilterItem... items)
LogicalOperator
.logicalOperator
- the logical operator to applyitems
- an array of items to include in the compositepublic FilterItem(FilterItem... items)
items
- an array of items to include in the compositepublic SelectItem getSelectItem()
public OperatorType getOperator()
public Object getOperand()
public String getExpression()
public LogicalOperator getLogicalOperator()
public FilterItem setQuery(Query query)
public String toSql(boolean includeSchemaInColumnPaths)
public static Object appendOperator(StringBuilder sb, Object operand, OperatorType operator)
public boolean evaluate(Row row)
protected FilterItem clone()
public boolean isReferenced(Column column)
protected void decorateIdentity(List<Object> identifiers)
BaseObject
decorateIdentity
in class BaseObject
@Deprecated public FilterItem[] getOrItems()
getChildItems()
insteadFilterItem
s that this filter item consists of, if it is
a compound filter item.@Deprecated public int getOrItemCount()
getChildItemCount()
instead.public int getChildItemCount()
public FilterItem[] getChildItems()
FilterItem
s that this filter item consists of, if it is
a compound filter item.public boolean isCompoundFilter()
FilterItem
is a compound filter or not
(ie. if it has child items or not)public String toString()
toString
in interface QueryItem
toString
in class BaseObject
public boolean accept(Row row)
IRowFilter
accept
in interface IRowFilter
Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.