Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.QNameSetBuilder


                    if (!children[children.length - 1].isSkippable())
                    {
                        particlesMatchingAfter(children[0], suspectSet, result, eliminate, false);
                        break recurse;
                    }
                    QNameSetBuilder remainingSuspects = new QNameSetBuilder(suspectSet);
                    QNameSetBuilder suspectsToEliminate = new QNameSetBuilder();
                    for (int i = children.length - 1; i >= 0; i--)
                    {
                        particlesMatchingAfter(children[i], remainingSuspects, result, suspectsToEliminate, false);
                        eliminate.addAll(suspectsToEliminate);
                        if (!children[i].isSkippable())
                            break recurse;
                        remainingSuspects.removeAll(suspectsToEliminate);
                        if (remainingSuspects.isEmpty())
                            break recurse;
                        suspectsToEliminate.clear();
                    }
                    break recurse;
                }
        }
View Full Code Here


        // Remember previously computed results to avoid complexity explosion
        QNameSet result = (QNameSet)state.get(contentModel);
        if (result != null)
            return result;

        QNameSetBuilder builder;

        switch (contentModel.getParticleType())
        {
            case SchemaParticle.ALL:
            case SchemaParticle.CHOICE:
            case SchemaParticle.SEQUENCE:
            default:
                builder = new QNameSetBuilder();
                for (int i = 0; i < contentModel.countOfParticleChild(); i++)
                {
                    builder.addAll(computeAllContainedElements(contentModel.getParticleChild(i), state));
                }
                result = builder.toQNameSet();
                break;

            case SchemaParticle.WILDCARD:
                result = contentModel.getWildcardSet();
                break;
View Full Code Here

        // If iterated, then all contents are delimiting.
        if (contentModel.getMaxOccurs() == null ||
            contentModel.getMaxOccurs().compareTo(BigInteger.ONE) > 0)
            return allContents;

        QNameSetBuilder builder;

        switch (contentModel.getParticleType())
        {
            case SchemaParticle.ALL:
            case SchemaParticle.ELEMENT:
            default:
                return allContents;

            case SchemaParticle.WILDCARD:
                return QNameSet.singleton(target);

            case SchemaParticle.CHOICE:
                builder = new QNameSetBuilder();
                for (int i = 0; i < contentModel.countOfParticleChild(); i++)
                {
                    QNameSet childContents = computeAllContainedElements(contentModel.getParticleChild(i), state);
                    if (childContents.contains(target))
                        builder.addAll(computeNondelimitingElements(target, contentModel.getParticleChild(i), state));
                }
                return builder.toQNameSet();

            case SchemaParticle.SEQUENCE:
                builder = new QNameSetBuilder();
                boolean seenTarget = false;
                for (int i = contentModel.countOfParticleChild(); i > 0; )
                {
                    i--;
                    QNameSet childContents = computeAllContainedElements(contentModel.getParticleChild(i), state);
                    if (seenTarget)
                    {
                        builder.addAll(childContents);
                    }
                    else if (childContents.contains(target))
                    {
                        builder.addAll(computeAllContainedElements(contentModel.getParticleChild(i), state));
                        seenTarget = true;
                    }
                }
                return builder.toQNameSet();
        }
    }
View Full Code Here

        for (int i = 0; i < eltProps.length; i++)
        {
            SchemaPropertyImpl sImpl = (SchemaPropertyImpl)eltProps[i];
            QNameSet nde = computeNondelimitingElements(sImpl.getName(), contentModel, state);
            QNameSetBuilder builder = new QNameSetBuilder(allContents);
            builder.removeAll(nde);
            sImpl.setJavaSetterDelimiter(builder.toQNameSet());
        }
    }
View Full Code Here

        }

        Stack teststack = new Stack(); // stack of sets
        Stack trackstack = new Stack(); // stack of boolean arrays

        QNameSetBuilder current = new QNameSetBuilder();
        boolean[] contents = new boolean[width * namespace.length];
        boolean[] temp;
        int i = 0;
        int j = 0;

        for (int l = 0; l < iterations; l++)
        {
            // for debugging

            if (l == stopat)
                System.err.println("We're here");

            // apply a random operation

            if (rnd.nextInt(3) != 0)
            {
                i = rnd.nextInt(width - 1); // don't do the last one for isAll test
                j = rnd.nextInt(namespace.length - 1); // don't do the last one for isAll test
            }

            String label;

            switch (teststack.size() < 1 ? 24 : rnd.nextInt(iterations - l > teststack.size() ? 24 : 5))
            {
                default:
                    teststack.push(current);
                    trackstack.push(contents);
                    current = new QNameSetBuilder();
                    contents = new boolean[width * namespace.length];
                    label = "new";
                    break;

                case 19:
                case 20:
                case 22:
                    teststack.push(current);
                    trackstack.push(contents);
                    current = new QNameSetBuilder();
                    contents = new boolean[width * namespace.length];

                    if (rnd.nextInt(2) == 0)
                    {
                        current.invert();
                        for (int k = 0; k < width; k++)
                        {
                            contents[k + width * (namespace.length - 1)] = true;
                        }
                    }

                    for (int h = 0; h < namespace.length - 1; h++)
                    {
                        if (rnd.nextInt(2) == 0)
                            current.removeNamespace(namespace[h]);
                        else
                        {
                            current.addNamespace(namespace[h]);
                            contents[width - 1 + width * h] = true;
                        }
                        for (int k = 0; k < width - 1; k++)
                        {
                            if (rnd.nextInt(2) == 0)
                                current.remove(name[k + width * h]);
                            else
                            {
                                current.add(name[k + width * h]);
                                contents[k + width * h] = true;
                            }
                        }
                    }
                    label = "random";
                    break;

                case 0:
                    current.addAll((QNameSetSpecification)teststack.pop());
                    temp = (boolean[])trackstack.pop();
                    for (int k = 0; k < width * namespace.length; k++)
                        if (temp[k])
                            contents[k] = true;
                    label = "add set";
                    break;

                case 1:
                    current.removeAll((QNameSetSpecification)teststack.pop());
                    temp = (boolean[])trackstack.pop();
                    for (int k = 0; k < width * namespace.length; k++)
                        if (temp[k])
                            contents[k] = false;
                    label = "remove set";
                    break;

                case 2:
                    current.restrict((QNameSetSpecification)teststack.pop());
                    temp = (boolean[])trackstack.pop();
                    for (int k = 0; k < width * namespace.length; k++)
                        if (!temp[k])
                            contents[k] = false;
                    label = "restrict set";
                    break;

                case 3:
                    label = "union";
                    current = new QNameSetBuilder(current.union((QNameSetSpecification)teststack.pop()));
                    temp = (boolean[])trackstack.pop();
                    for (int k = 0; k < width * namespace.length; k++)
                        if (temp[k])
                            contents[k] = true;
                    label = "union";
                    break;

                case 4:
                    label = "intersect";
                    current = new QNameSetBuilder(current.intersect((QNameSetSpecification)teststack.pop()));
                    temp = (boolean[])trackstack.pop();
                    for (int k = 0; k < width * namespace.length; k++)
                        if (!temp[k])
                            contents[k] = false;
                    label = "intersect";
                    break;

                case 5:
                    current = new QNameSetBuilder(current);
                    label = "copy";
                    break;

                case 6:
                case 7:
                case 8:
                    current.add(name[i + width * j]);
                    contents[i + width * j] = true;
                    label = "add one " + name[i + width * j];
                    break;

                case 9:
                case 10:
                case 11:
                    current.remove(name[i + width * j]);
                    contents[i + width * j] = false;
                    label = "remove one " + name[i + width * j];
                    break;

                case 12:
                case 13:
                    current.addNamespace(namespace[j]);
                    for (int k = 0; k < width; k++)
                        contents[k + width * j] = true;
                    label = "add namespace " + namespace[j];
                    break;

                case 14:
                case 15:
                    current.removeNamespace(namespace[j]);
                    for (int k = 0; k < width; k++)
                        contents[k + width * j] = false;
                    label = "remove namespace " + namespace[j];
                    break;

                case 16:
                case 17:
                    current.invert();
                    for (int k = 0; k < width * namespace.length; k++)
                        contents[k] = !contents[k];
                    label = "invert";
                    break;

                case 18:
                    current = new QNameSetBuilder(current.inverse());
                    for (int k = 0; k < width * namespace.length; k++)
                        contents[k] = !contents[k];
                    label = "inverse";
                    break;

            }

            // System.out.println(format(teststack.size(), l, label, current));

            // then, verify current matches contents
            int count = 0;
            for (int k = 0; k < width * namespace.length; k++)
            {
                Assert.assertTrue(format(0, l, "Content mismatch " + name[k], current), (current.contains(name[k]) == contents[k]));
                {
                    // testprint(0, l, "ERROR ON " + name[k], current);
                    // testprint(0, l, "expected " + contents[k] + ", got " + !contents[k], current);
                    // System.exit(1);
                }
                if (contents[k])
                    count++;
            }

            Assert.assertTrue(format(0, l, "ERROR: isEmpty is wrong", current), ((count == 0) == current.isEmpty()));
            {
                // testprint(0, l, "ERROR: isEmpty is wrong", current);
                // testprint(0, l, "expected " + (count == 0) + ", got " + !(count == 0), current);
                // System.exit(1);
            }

            Assert.assertTrue(format(0, l, "ERROR: isAll is wrong", current), (count == width * namespace.length) == current.isAll());
            {
                // testprint(0, l, "ERROR: isAll is wrong", current);
                // testprint(0, l, "expected " + (count == width * namespace.length) + ", got " + !(count == width * namespace.length), current);
                // System.exit(1);
            }

            // test isDisjoint and containsAll
            if (teststack.size() >= 1)
            {
                boolean disjoint = true;
                temp = (boolean[])trackstack.peek();
                for (int k = 0; k < width * namespace.length; k++)
                {
                    if (temp[k] && contents[k])
                    {
                        disjoint = false;
                        break;
                    }
                }
                Assert.assertTrue(format(0, l, "ERROR: disjoint is wrong", current), disjoint == current.isDisjoint((QNameSetSpecification)teststack.peek()));
                {
                    // testprint(0, l, "ERROR: disjoint is wrong", current);
                    // testprint(0, l, "expected " + disjoint + ", got " + !disjoint, (QNameSetBuilder)teststack.peek());
                    // System.exit(1);
                }
               
               
                boolean containsAll = true;
                for (int k = 0; k < width * namespace.length; k++)
                {
                    if (temp[k] && !contents[k])
                    {
                        containsAll = false;
                        break;
                    }
                }
                Assert.assertTrue(format(0, l, "ERROR: containsAll is wrong", current), containsAll == current.containsAll((QNameSetSpecification)teststack.peek()));
            }
           
        }
    }
View Full Code Here

        for (int i = 0; i < eltProps.length; i++)
        {
            SchemaPropertyImpl sImpl = (SchemaPropertyImpl)eltProps[i];
            QNameSet nde = computeNondelimitingElements(sImpl.getName(), contentModel, state);
            QNameSetBuilder builder = new QNameSetBuilder(allContents);
            builder.removeAll(nde);
            sImpl.setJavaSetterDelimiter(builder.toQNameSet());
        }
    }
View Full Code Here

        // If iterated, then all contents are delimiting.
        if (contentModel.getMaxOccurs() == null ||
            contentModel.getMaxOccurs().compareTo(BigInteger.ONE) > 0)
            return allContents;

        QNameSetBuilder builder;

        switch (contentModel.getParticleType())
        {
            case SchemaParticle.ALL:
            case SchemaParticle.ELEMENT:
            default:
                return allContents;

            case SchemaParticle.WILDCARD:
                return QNameSet.singleton(target);

            case SchemaParticle.CHOICE:
                builder = new QNameSetBuilder();
                for (int i = 0; i < contentModel.countOfParticleChild(); i++)
                {
                    QNameSet childContents = computeAllContainedElements(contentModel.getParticleChild(i), state);
                    if (childContents.contains(target))
                        builder.addAll(computeNondelimitingElements(target, contentModel.getParticleChild(i), state));
                }
                return builder.toQNameSet();

            case SchemaParticle.SEQUENCE:
                builder = new QNameSetBuilder();
                boolean seenTarget = false;
                for (int i = contentModel.countOfParticleChild(); i > 0; )
                {
                    i--;
                    QNameSet childContents = computeAllContainedElements(contentModel.getParticleChild(i), state);
                    if (seenTarget)
                    {
                        builder.addAll(childContents);
                    }
                    else if (childContents.contains(target))
                    {
                        builder.addAll(computeNondelimitingElements(target, contentModel.getParticleChild(i), state));
                        seenTarget = true;
                    }
                }
                return builder.toQNameSet();
        }
    }
View Full Code Here

        // Remember previously computed results to avoid complexity explosion
        QNameSet result = (QNameSet)state.get(contentModel);
        if (result != null)
            return result;

        QNameSetBuilder builder;

        switch (contentModel.getParticleType())
        {
            case SchemaParticle.ALL:
            case SchemaParticle.CHOICE:
            case SchemaParticle.SEQUENCE:
            default:
                builder = new QNameSetBuilder();
                for (int i = 0; i < contentModel.countOfParticleChild(); i++)
                {
                    builder.addAll(computeAllContainedElements(contentModel.getParticleChild(i), state));
                }
                result = builder.toQNameSet();
                break;

            case SchemaParticle.WILDCARD:
                result = contentModel.getWildcardSet();
                break;
View Full Code Here

     * @return the constructed QNameSet
     */
    public QNameSet qnameSetForWildcardElements()
    {
        SchemaParticle model = this.getContentModel();
        QNameSetBuilder wildcardSet = new QNameSetBuilder();
        computeWildcardSet(model, wildcardSet);

        QNameSetBuilder qnsb = new QNameSetBuilder( wildcardSet );
        SchemaProperty[] props = this.getElementProperties();

        for (int i = 0; i < props.length; i++)
        {
            SchemaProperty prop = props[i];
            qnsb.remove(prop.getName());
        }

        return qnsb.toQNameSet();
    }
View Full Code Here

        QNameSet wildcardSet = model.getWildcardSet();

        if (wildcardSet==null)
            return QNameSet.EMPTY;

        QNameSetBuilder qnsb = new QNameSetBuilder( wildcardSet );

        SchemaProperty[] props = this.getAttributeProperties();

        for (int i = 0; i < props.length; i++)
        {
            SchemaProperty prop = props[i];
            qnsb.remove(prop.getName());
        }

        return qnsb.toQNameSet();
    }
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.QNameSetBuilder

Copyright © 2018 www.massapicom. 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.