use of org.sirix.api.Filter in project sirix by sirixdb.
the class XPathParser method parseSequenceType.
/**
* Parses the the rule SequenceType according to the following production rule: [
* <p>
* 49] SequenceType ::= (ItemType OccurrenceIndicator?) | <"void" "(" ")"> .
* </p>
*
* @return SequenceType
*/
private SequenceType parseSequenceType() {
if (is("empty-sequence", true)) {
consume(TokenType.OPEN_BR, true);
consume(TokenType.CLOSE_BR, true);
return new SequenceType();
} else {
final Filter filter = parseItemType();
if (isWildcard()) {
final char wildcard = parseOccuranceIndicator();
return new SequenceType(filter, wildcard);
}
return new SequenceType(filter);
}
}
use of org.sirix.api.Filter in project sirix by sirixdb.
the class XPathParser method parseReverceStep.
/**
* Parses the the rule ReverceStep according to the following production rule:
* <p>
* [32] ReverseStep ::= (ReverseAxis NodeTest) | AbbrevReverseStep .
* </p>
*/
private void parseReverceStep() {
AbstractAxis axis;
if (mToken.getType() == TokenType.PARENT) {
axis = parseAbbrevReverseStep();
mPipeBuilder.addStep(axis);
} else {
axis = parseReverceAxis();
final Filter filter = parseNodeTest(axis.getClass() == AttributeAxis.class);
mPipeBuilder.addStep(axis, filter);
}
}
use of org.sirix.api.Filter in project sirix by sirixdb.
the class XPathParser method parseAttributeTest.
/**
* Parses the the rule AttributeTest according to the following production rule:
* <p>
* [59] AttributeTest ::= <"attribute" "("> (AttribNameOrWildcard ("," TypeName)?)? ")" .
* </p>
*
* @return filter
*/
private Filter parseAttributeTest() {
consume("attribute", true);
consume(TokenType.OPEN_BR, true);
Filter filter = new AttributeFilter(getTransaction());
if (!(mToken.getType() == TokenType.CLOSE_BR)) {
// add name filter
final String name = parseAttributeNameOrWildcard();
if (!name.equals("*")) {
filter = new NestedFilter(getTransaction(), filter, new NameFilter(getTransaction(), name));
}
if (is(TokenType.COMMA, true)) {
// add type filter
filter = new NestedFilter(getTransaction(), filter, new TypeFilter(getTransaction(), parseTypeName()));
}
}
consume(TokenType.CLOSE_BR, true);
return filter;
}
use of org.sirix.api.Filter in project sirix by sirixdb.
the class XPathParser method parsePITest.
/**
* Parses the the rule PITest according to the following production rule:
* <p>
* [58] PITest ::= <"processing-instruction" "("> (NCName | StringLiteral)? ")" .
* </p>
*
* @return filter
*/
private Filter parsePITest() {
consume("processing-instruction", true);
consume(TokenType.OPEN_BR, true);
Filter filter = new PIFilter(getTransaction());
if (!is(TokenType.CLOSE_BR, true)) {
String stringLiteral;
if (isQuote()) {
final byte[] param = ((ValueNode) getTransaction().getItemList().getItem(parseStringLiteral()).get()).getRawValue();
stringLiteral = Arrays.toString(param);
} else {
stringLiteral = parseNCName();
}
consume(TokenType.CLOSE_BR, true);
filter = new NestedFilter(getTransaction(), filter, new NameFilter(getTransaction(), stringLiteral));
}
return filter;
}
use of org.sirix.api.Filter in project sirix by sirixdb.
the class XPathParser method parseWildcard.
/**
* Parses the the rule Wildcard according to the following production rule:
* <p>
* [37] Wildcard ::= "*" | < NCName ":" "*" > | < "*" ":" NCName > .
* <p>
*
* @param pIsAtt Attribute
* @return filter
*/
private Filter parseWildcard(final boolean pIsAtt) {
Filter filter;
EType isName = EType.PREFIX;
if (is(TokenType.STAR, true)) {
if (is(TokenType.COLON, true)) {
// < "*" ":" NCName > .
isName = EType.LOCALNAME;
} else {
return // "*"
pIsAtt ? new AttributeFilter(getTransaction()) : new ElementFilter(getTransaction());
}
}
filter = new WildcardFilter(getTransaction(), parseNCName(), isName);
if (isName == EType.PREFIX) {
// < NCName ":" "*" >
consume(TokenType.COLON, true);
consume(TokenType.STAR, true);
}
return filter;
}
Aggregations