public class PositionFilter extends EvalFilter
PositionFilter can only count children of the same parent node; but counted nodes may be a subset of the parent's children. If PositionFilter is applied to children of a different parent, it will start counting again from zero. This is the only way that the same PositionFilter object can be reliably reused. Indexing follows the W3C XPath standard, that is, the first visited index is 1 rather than 0.
Modifier and Type | Field and Description |
---|---|
private int |
count
The local counting index, used to perform counting.
|
private int |
index
The stored search index at which to report true.
|
private Content |
parent
The parent of the nodes being filtered.
|
mask
ALLCONTENT, NAMENODES, PARENTNODES, PROPERTYNODES, VALUENODES, XPATHNODES, XPATHTEXT
Modifier | Constructor and Description |
---|---|
private |
PositionFilter(PositionFilter filter,
int contentType)
Secret constructor to copy a PositionFilter but reset the type mask.
|
|
PositionFilter(java.lang.String operator,
int index)
Creates a PositionFilter accepting any siblings, whose index stands in
the given relationship with a reference index.
|
|
PositionFilter(java.lang.String operator,
int index,
int contentType)
Creates a PositionFilter accepting siblings of the given content type,
whose index stands in the given relationship with a reference index.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Content node)
Reports whether a given Content node is accepted by this
PositionFilter.
|
Filter |
and(Filter filter)
Creates a Filter that is the logical AND of this PositionFilter and
another Filter.
|
protected PositionFilter |
andNodeFilter(NodeFilter other)
Creates a Filter that is the conjunction of this PositionFilter and a
NodeFilter.
|
private boolean |
inRange(Content node)
Counts one of a list of siblings to be counted, and returns true if the
counting index stands in the specified comparison relationship with the
reference index.
|
compareBoolean, compareDecimal, compareIntegral, compareString
getMask
andIndexFilter, not, or, orNodeFilter, toString
private Content parent
private int index
private int count
public PositionFilter(java.lang.String operator, int index)
operator
- a comparison operator, as a String.index
- a reference index.public PositionFilter(java.lang.String operator, int index, int contentType)
operator
- a comparison operator, as a String.index
- a reference index.contentType
- a bit-mask specifying one or more content types.private PositionFilter(PositionFilter filter, int contentType)
filter
- the copied PositionFilter.contentType
- a bit-mask specifying one or more content types.private boolean inRange(Content node)
node
- the Content node to be counted.public boolean accept(Content node)
accept
in class MaskFilter
node
- a Content node.public Filter and(Filter filter)
protected PositionFilter andNodeFilter(NodeFilter other)
andNodeFilter
in class Filter
other
- the other NodeFilter.