Search in sources :

Example 1 with WildcardFilter

use of org.sirix.axis.filter.WildcardFilter 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)

Example 2 with WildcardFilter

use of org.sirix.axis.filter.WildcardFilter in project sirix by sirixdb.

the class WildcardFilterTest method testFilterConvetions.

@Test
public void testFilterConvetions() throws SirixException {
    holder.getReader().moveTo(9L);
    FilterTest.testFilterConventions(new WildcardFilter(holder.getReader(), "b", EType.LOCALNAME), true);
    holder.getReader().moveToAttribute(0);
    FilterTest.testFilterConventions(new WildcardFilter(holder.getReader(), "p", EType.PREFIX), true);
    holder.getReader().moveTo(1L);
    FilterTest.testFilterConventions(new WildcardFilter(holder.getReader(), "p", EType.PREFIX), true);
    FilterTest.testFilterConventions(new WildcardFilter(holder.getReader(), "a", EType.LOCALNAME), true);
    FilterTest.testFilterConventions(new WildcardFilter(holder.getReader(), "c", EType.LOCALNAME), false);
    FilterTest.testFilterConventions(new WildcardFilter(holder.getReader(), "b", EType.PREFIX), false);
}
Also used : WildcardFilter(org.sirix.axis.filter.WildcardFilter) FilterTest(org.sirix.axis.filter.FilterTest) Test(org.junit.Test)

Aggregations

WildcardFilter (org.sirix.axis.filter.WildcardFilter)2 Test (org.junit.Test)1 Filter (org.sirix.api.Filter)1 AttributeFilter (org.sirix.axis.filter.AttributeFilter)1 CommentFilter (org.sirix.axis.filter.CommentFilter)1 DocumentRootNodeFilter (org.sirix.axis.filter.DocumentRootNodeFilter)1 ElementFilter (org.sirix.axis.filter.ElementFilter)1 FilterTest (org.sirix.axis.filter.FilterTest)1 ItemFilter (org.sirix.axis.filter.ItemFilter)1 NameFilter (org.sirix.axis.filter.NameFilter)1 NestedFilter (org.sirix.axis.filter.NestedFilter)1 NodeFilter (org.sirix.axis.filter.NodeFilter)1 PIFilter (org.sirix.axis.filter.PIFilter)1 TextFilter (org.sirix.axis.filter.TextFilter)1 TypeFilter (org.sirix.axis.filter.TypeFilter)1 EType (org.sirix.axis.filter.WildcardFilter.EType)1 SchemaAttributeFilter (org.sirix.service.xml.xpath.filter.SchemaAttributeFilter)1 SchemaElementFilter (org.sirix.service.xml.xpath.filter.SchemaElementFilter)1