Examples of IntHashSet


Examples of net.sf.saxon.sort.IntHashSet

                // If the content type of the context item is known, see whether the node test can select anything

                if (contextItemType instanceof DocumentNodeTest && axis == Axis.CHILD && kind == Type.ELEMENT) {
                    NodeTest elementTest = ((DocumentNodeTest)contextItemType).getElementTest();
                    IntHashSet requiredNames = elementTest.getRequiredNodeNames();
                    if (requiredNames != null) {
                        // check that the name appearing in the step is one of the names allowed by the nodetest
                        IntHashSet selected = test.getRequiredNodeNames();
                        if (selected != null && selected.intersect(requiredNames).isEmpty()) {
                            env.issueWarning("Starting at a document node, the step is selecting an element whose name " +
                                    "is not among the names of child elements permitted for this document node type", this);

                            return Literal.makeEmptySequence();
                        }
                    }
                    itemType = elementTest;
                    return this;
                }

                SchemaType contentType = ((NodeTest)contextItemType).getContentType();
                if (contentType == AnyType.getInstance()) {
                    // fast exit in non-schema-aware case
                    return this;
                }

                int targetfp = test.getFingerprint();

                if (contentType.isSimpleType()) {
                    if ((axis == Axis.CHILD || axis==Axis.ATTRIBUTE || axis==Axis.DESCENDANT || axis==Axis.DESCENDANT_OR_SELF) &&
                        (kind==Type.ELEMENT || kind==Type.ATTRIBUTE || kind==Type.DOCUMENT)) {
                        env.issueWarning("The " + Axis.axisName[axis] + " axis will never select any " +
                                NodeKindTest.nodeKindName(kind) +
                                " nodes when starting at a node with simple type " +
                                contentType.getDescription(), this);
                    }
                    else if (axis == Axis.CHILD && kind == Type.TEXT &&
                            (visitor.getParentExpression() instanceof Atomizer)) {
                        env.issueWarning("Selecting the text nodes of an element with simple content may give the " +
                                "wrong answer in the presence of comments or processing instructions. It is usually " +
                                "better to omit the '/text()' step", this);
                    }
                } else if (((ComplexType)contentType).isSimpleContent() &&
                        (axis==Axis.CHILD || axis==Axis.DESCENDANT || axis==Axis.DESCENDANT_OR_SELF) &&
                        (kind==Type.ELEMENT || kind==Type.DOCUMENT)) {
                    env.issueWarning("The " + Axis.axisName[axis] + " axis will never select any " +
                            NodeKindTest.nodeKindName(kind) +
                            " nodes when starting at a node with type " +
                            contentType.getDescription() +
                            ", as this type requires simple content", this);
                } else if (((ComplexType)contentType).isEmptyContent() &&
                        (axis==Axis.CHILD || axis==Axis.DESCENDANT || axis==Axis.DESCENDANT_OR_SELF)) {
                    for (Iterator iter=visitor.getConfiguration().getExtensionsOfType(contentType); iter.hasNext();) {
                        ComplexType extension = (ComplexType)iter.next();
                        if (!extension.isEmptyContent()) {
                            return this;
                        }
                    }
                    env.issueWarning("The " + Axis.axisName[axis] + " axis will never select any " +
                            " nodes when starting at a node with type " +
                            contentType.getDescription() +
                            ", as this type requires empty content", this);
                } else if (axis==Axis.ATTRIBUTE && targetfp != -1) {
                    try {
                        SchemaType schemaType = ((ComplexType)contentType).getAttributeUseType(targetfp);
                        if (schemaType == null) {
                            String n = env.getNamePool().getDisplayName(targetfp);

                            env.issueWarning("The complex type " + contentType.getDescription() +
                                " does not allow an attribute named " + n, this);
                        } else {
                            itemType = new CombinedNodeTest(
                                    test,
                                    Token.INTERSECT,
                                    new ContentTypeTest(Type.ATTRIBUTE, schemaType, env.getConfiguration()));
                        }
                    } catch (SchemaException e) {
                        // ignore the exception
                    }
                } else if (axis==Axis.CHILD && kind==Type.ELEMENT) {
                    try {
                        int childElement = targetfp;
                        if (targetfp == -1) {
                            // select="child::*"
                            IntHashSet children = new IntHashSet();
                            ((ComplexType)contentType).gatherAllPermittedChildren(children);
                            if (children.isEmpty()) {
                                env.issueWarning("The complex type " + contentType.getDescription() +
                                " does not allow children", this);
                                return this;
                            }
                            if (children.contains(-1)) {
                                return this;
                            }
                            if (children.size() == 1) {
                                IntIterator iter = children.iterator();
                                if (iter.hasNext()) {
                                    childElement = iter.next();
                                }
                            } else {
                                return this;
                            }
                        }
                        SchemaType schemaType = ((ComplexType)contentType).getElementParticleType(childElement);
                        if (schemaType == null) {
                            String n = env.getNamePool().getDisplayName(childElement);
                            env.issueWarning("The complex type " + contentType.getDescription() +
                                " does not allow a child element named " + n, this);
                        } else {
                            itemType = new CombinedNodeTest(
                                    test,
                                    Token.INTERSECT,
                                    new ContentTypeTest(Type.ELEMENT, schemaType, env.getConfiguration()));
                            computedCardinality = ((ComplexType)contentType).getElementParticleCardinality(childElement);
                            visitor.resetStaticProperties();
                            if (!Cardinality.allowsMany(computedCardinality)) {
                                // if there can be at most one child of this name, create a FirstItemExpression
                                // to stop the search after the first one is found
                                return new FirstItemExpression(this);
                            }
                        }
                    } catch (SchemaException e) {
                        // ignore the exception
                    }
                } else if (axis==Axis.DESCENDANT && kind==Type.ELEMENT && targetfp != -1) {
                    // when searching for a specific element on the descendant axis, try to produce a more
                    // specific path that avoids searching branches of the tree where the element cannot occur
                    try {
                        IntHashSet descendants = new IntHashSet();
                        ((ComplexType)contentType).gatherAllPermittedDescendants(descendants);
                        if (descendants.contains(-1)) {
                            return this;
                        }
                        if (descendants.contains(targetfp)) {
                            IntHashSet children = new IntHashSet();
                            ((ComplexType)contentType).gatherAllPermittedChildren(children);
                            IntHashSet usefulChildren = new IntHashSet();
                            boolean considerSelf = false;
                            boolean considerDescendants = false;
                            for (IntIterator child = children.iterator(); child.hasNext();) {
                                int c = child.next();
                                if (c == targetfp) {
                                    usefulChildren.add(c);
                                    considerSelf = true;
                                }
                                SchemaType st = ((ComplexType)contentType).getElementParticleType(c);
                                if (st == null) {
                                    throw new AssertionError("Can't find type for element " + c);
                                }
                                if (st instanceof ComplexType) {
                                    IntHashSet subDescendants = new IntHashSet();
                                    ((ComplexType)st).gatherAllPermittedDescendants(subDescendants);
                                    if (subDescendants.contains(targetfp)) {
                                        usefulChildren.add(c);
                                        considerDescendants = true;
                                    }
                                }
                            }
View Full Code Here

Examples of net.sf.saxon.sort.IntHashSet

        String omit = props.getProperty(OutputKeys.OMIT_XML_DECLARATION);
        afterEndTag = omit==null || !Whitespace.trim(omit).equals("yes") ||
                    props.getProperty(OutputKeys.DOCTYPE_SYSTEM)!=null ;
        s = props.getProperty(SaxonOutputKeys.SUPPRESS_INDENTATION);
        if (s != null) {
            suppressedElements = new IntHashSet(8);
            NamePool pool = getNamePool();
            StringTokenizer st = new StringTokenizer(s, " \t\r\n");
            while (st.hasMoreTokens()) {
                String clarkName = st.nextToken();
                int fp = pool.allocateClarkName(clarkName);
View Full Code Here

Examples of net.sf.saxon.sort.IntHashSet

                    // now find the relationship between the node names allowed. Note that although
                    // NamespaceTest and LocalNameTest are NodeTests, they do not occur in SequenceTypes,
                    // so we don't need to consider them.
                    int nodeNameRelationship;
                    IntHashSet n1 = ((NodeTest)t1).getRequiredNodeNames(); // null means all names allowed
                    IntHashSet n2 = ((NodeTest)t2).getRequiredNodeNames(); // null means all names allowed
                    if (n1 == null) {
                        if (n2 == null) {
                            nodeNameRelationship = SAME_TYPE;
                        } else {
                            nodeNameRelationship = SUBSUMES;
                        }
                    } else if (n2 == null) {
                        nodeNameRelationship = SUBSUMED_BY;
                    } else if (n1.containsAll(n2)) {
                        if (n1.size() == n2.size()) {
                            nodeNameRelationship = SAME_TYPE;
                        } else {
                            nodeNameRelationship = SUBSUMES;
                        }
                    } else if (n2.containsAll(n1)) {
                        nodeNameRelationship = SUBSUMED_BY;
                    } else if (n1.containsSome(n2)) {
                        nodeNameRelationship = OVERLAPS;
                    } else {
                        nodeNameRelationship = DISJOINT;
View Full Code Here

Examples of net.sf.saxon.sort.IntHashSet

        } else if (typeCode < 1024) {
            // No other built-in type is an ID
            return false;
        } else {
            if (nonIDs == null) {
                nonIDs = new IntHashSet(20);
            }
            if (nonIDs.contains(typeCode)) {
                return false;
            }
            SchemaType type = getConfiguration().getSchemaType(typeCode);
View Full Code Here

Examples of net.sf.saxon.sort.IntHashSet

    public synchronized int[] getSlotsUsed() {
        if (slotsUsed != null) {
            return slotsUsed;
        }
        IntHashSet slots = new IntHashSet(10);
        gatherSlotsUsed(this, slots);
        slotsUsed = new int[slots.size()];
        int i=0;
        IntIterator iter = slots.iterator();
        while (iter.hasNext()) {
            slotsUsed[i++] = iter.next();
        }
        Arrays.sort(slotsUsed);
        return slotsUsed;
View Full Code Here

Examples of net.sf.saxon.sort.IntHashSet

     */

    protected int classifyTag(int nameCode) {
        if (inlineTagSet == null) {
            NamePool pool = getNamePool();
            inlineTagSet = new IntHashSet(50);
            formattedTagSet = new IntHashSet(10);
            for (int i=0; i<inlineTags.length; i++) {
                int nc = pool.allocate("", NamespaceConstant.XHTML, inlineTags[i]);
                inlineTagSet.add(nc);
            }
            for (int i=0; i<formattedTags.length; i++) {
View Full Code Here

Examples of org.apache.lucene.facet.collections.IntHashSet

public class IntHashSetTest extends FacetTestCase {

  @Test
  public void test0() {
    IntHashSet set0 = new IntHashSet();

    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());
    set0.add(0);
    assertEquals(1, set0.size());
    assertFalse(set0.isEmpty());
    set0.remove(0);
    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());
  }
View Full Code Here

Examples of org.apache.lucene.facet.collections.IntHashSet

    assertTrue(set0.isEmpty());
  }

  @Test
  public void test1() {
    IntHashSet set0 = new IntHashSet();

    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());
    for (int i = 0; i < 1000; ++i) {
      set0.add(i);
    }
    assertEquals(1000, set0.size());
    assertFalse(set0.isEmpty());
    for (int i = 0; i < 1000; ++i) {
      assertTrue(set0.contains(i));
    }

    set0.clear();
    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());

  }
View Full Code Here

Examples of org.apache.lucene.facet.collections.IntHashSet

  }

  @Test
  public void test2() {
    IntHashSet set0 = new IntHashSet();

    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());
    for (int i = 0; i < 1000; ++i) {
      set0.add(1);
      set0.add(-382);
    }
    assertEquals(2, set0.size());
    assertFalse(set0.isEmpty());
    set0.remove(-382);
    set0.remove(1);
    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());

  }
View Full Code Here

Examples of org.apache.lucene.facet.collections.IntHashSet

  }

  @Test
  public void test3() {
    IntHashSet set0 = new IntHashSet();

    assertEquals(0, set0.size());
    assertTrue(set0.isEmpty());
    for (int i = 0; i < 1000; ++i) {
      set0.add(i);
    }

    for (int i = 0; i < 1000; i += 2) {
      set0.remove(i);
    }

    assertEquals(500, set0.size());
    for (int i = 0; i < 1000; ++i) {
      if (i % 2 == 0) {
        assertFalse(set0.contains(i));
      } else {
        assertTrue(set0.contains(i));
      }
    }

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.