Search in sources :

Example 1 with Filter

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);
    }
}
Also used : ItemFilter(org.sirix.axis.filter.ItemFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) NameFilter(org.sirix.axis.filter.NameFilter) TypeFilter(org.sirix.axis.filter.TypeFilter) NestedFilter(org.sirix.axis.filter.NestedFilter) DocumentRootNodeFilter(org.sirix.axis.filter.DocumentRootNodeFilter) CommentFilter(org.sirix.axis.filter.CommentFilter) WildcardFilter(org.sirix.axis.filter.WildcardFilter) PIFilter(org.sirix.axis.filter.PIFilter) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) Filter(org.sirix.api.Filter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) TextFilter(org.sirix.axis.filter.TextFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) NodeFilter(org.sirix.axis.filter.NodeFilter) SequenceType(org.sirix.service.xml.xpath.SequenceType)

Example 2 with 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);
    }
}
Also used : ItemFilter(org.sirix.axis.filter.ItemFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) NameFilter(org.sirix.axis.filter.NameFilter) TypeFilter(org.sirix.axis.filter.TypeFilter) NestedFilter(org.sirix.axis.filter.NestedFilter) DocumentRootNodeFilter(org.sirix.axis.filter.DocumentRootNodeFilter) CommentFilter(org.sirix.axis.filter.CommentFilter) WildcardFilter(org.sirix.axis.filter.WildcardFilter) PIFilter(org.sirix.axis.filter.PIFilter) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) Filter(org.sirix.api.Filter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) TextFilter(org.sirix.axis.filter.TextFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) NodeFilter(org.sirix.axis.filter.NodeFilter) AbstractAxis(org.sirix.axis.AbstractAxis) AttributeAxis(org.sirix.axis.AttributeAxis)

Example 3 with 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;
}
Also used : NestedFilter(org.sirix.axis.filter.NestedFilter) NameFilter(org.sirix.axis.filter.NameFilter) ItemFilter(org.sirix.axis.filter.ItemFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) NameFilter(org.sirix.axis.filter.NameFilter) TypeFilter(org.sirix.axis.filter.TypeFilter) NestedFilter(org.sirix.axis.filter.NestedFilter) DocumentRootNodeFilter(org.sirix.axis.filter.DocumentRootNodeFilter) CommentFilter(org.sirix.axis.filter.CommentFilter) WildcardFilter(org.sirix.axis.filter.WildcardFilter) PIFilter(org.sirix.axis.filter.PIFilter) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) Filter(org.sirix.api.Filter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) TextFilter(org.sirix.axis.filter.TextFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) NodeFilter(org.sirix.axis.filter.NodeFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) TypeFilter(org.sirix.axis.filter.TypeFilter)

Example 4 with 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;
}
Also used : NestedFilter(org.sirix.axis.filter.NestedFilter) NameFilter(org.sirix.axis.filter.NameFilter) PIFilter(org.sirix.axis.filter.PIFilter) ItemFilter(org.sirix.axis.filter.ItemFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) NameFilter(org.sirix.axis.filter.NameFilter) TypeFilter(org.sirix.axis.filter.TypeFilter) NestedFilter(org.sirix.axis.filter.NestedFilter) DocumentRootNodeFilter(org.sirix.axis.filter.DocumentRootNodeFilter) CommentFilter(org.sirix.axis.filter.CommentFilter) WildcardFilter(org.sirix.axis.filter.WildcardFilter) PIFilter(org.sirix.axis.filter.PIFilter) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) Filter(org.sirix.api.Filter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) TextFilter(org.sirix.axis.filter.TextFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) NodeFilter(org.sirix.axis.filter.NodeFilter) ValueNode(org.sirix.node.interfaces.ValueNode)

Example 5 with 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;
}
Also used : ItemFilter(org.sirix.axis.filter.ItemFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) NameFilter(org.sirix.axis.filter.NameFilter) TypeFilter(org.sirix.axis.filter.TypeFilter) NestedFilter(org.sirix.axis.filter.NestedFilter) DocumentRootNodeFilter(org.sirix.axis.filter.DocumentRootNodeFilter) CommentFilter(org.sirix.axis.filter.CommentFilter) WildcardFilter(org.sirix.axis.filter.WildcardFilter) PIFilter(org.sirix.axis.filter.PIFilter) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) Filter(org.sirix.api.Filter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) TextFilter(org.sirix.axis.filter.TextFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) NodeFilter(org.sirix.axis.filter.NodeFilter) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) EType(org.sirix.axis.filter.WildcardFilter.EType) WildcardFilter(org.sirix.axis.filter.WildcardFilter)

Aggregations

Filter (org.sirix.api.Filter)13 AttributeFilter (org.sirix.axis.filter.AttributeFilter)11 CommentFilter (org.sirix.axis.filter.CommentFilter)11 DocumentRootNodeFilter (org.sirix.axis.filter.DocumentRootNodeFilter)11 ElementFilter (org.sirix.axis.filter.ElementFilter)11 ItemFilter (org.sirix.axis.filter.ItemFilter)11 NameFilter (org.sirix.axis.filter.NameFilter)11 NestedFilter (org.sirix.axis.filter.NestedFilter)11 NodeFilter (org.sirix.axis.filter.NodeFilter)11 PIFilter (org.sirix.axis.filter.PIFilter)11 TextFilter (org.sirix.axis.filter.TextFilter)11 TypeFilter (org.sirix.axis.filter.TypeFilter)11 WildcardFilter (org.sirix.axis.filter.WildcardFilter)11 SchemaAttributeFilter (org.sirix.service.xml.xpath.filter.SchemaAttributeFilter)11 SchemaElementFilter (org.sirix.service.xml.xpath.filter.SchemaElementFilter)11 AbstractAxis (org.sirix.axis.AbstractAxis)3 AttributeAxis (org.sirix.axis.AttributeAxis)3 ChildAxis (org.sirix.axis.ChildAxis)2 FilterAxis (org.sirix.axis.filter.FilterAxis)2 NoSuchElementException (java.util.NoSuchElementException)1