Search in sources :

Example 1 with WrappedRuntimeException

use of org.apache.xml.utils.WrappedRuntimeException in project robovm by robovm.

the class RedundentExprEliminator method createIteratorFromSteps.

/**
   * Create a new WalkingIterator from the steps in another WalkingIterator.
   * 
   * @param wi The iterator from where the steps will be taken.
   * @param numSteps The number of steps from the first to copy into the new 
   *                 iterator.
   * @return The new iterator.
   */
protected WalkingIterator createIteratorFromSteps(final WalkingIterator wi, int numSteps) {
    WalkingIterator newIter = new WalkingIterator(wi.getPrefixResolver());
    try {
        AxesWalker walker = (AxesWalker) wi.getFirstWalker().clone();
        newIter.setFirstWalker(walker);
        walker.setLocPathIterator(newIter);
        for (int i = 1; i < numSteps; i++) {
            AxesWalker next = (AxesWalker) walker.getNextWalker().clone();
            walker.setNextWalker(next);
            next.setLocPathIterator(newIter);
            walker = next;
        }
        walker.setNextWalker(null);
    } catch (CloneNotSupportedException cnse) {
        throw new WrappedRuntimeException(cnse);
    }
    return newIter;
}
Also used : AxesWalker(org.apache.xpath.axes.AxesWalker) WalkingIterator(org.apache.xpath.axes.WalkingIterator) WrappedRuntimeException(org.apache.xml.utils.WrappedRuntimeException)

Example 2 with WrappedRuntimeException

use of org.apache.xml.utils.WrappedRuntimeException in project j2objc by google.

the class RedundentExprEliminator method createIteratorFromSteps.

/**
   * Create a new WalkingIterator from the steps in another WalkingIterator.
   * 
   * @param wi The iterator from where the steps will be taken.
   * @param numSteps The number of steps from the first to copy into the new 
   *                 iterator.
   * @return The new iterator.
   */
protected WalkingIterator createIteratorFromSteps(final WalkingIterator wi, int numSteps) {
    WalkingIterator newIter = new WalkingIterator(wi.getPrefixResolver());
    try {
        AxesWalker walker = (AxesWalker) wi.getFirstWalker().clone();
        newIter.setFirstWalker(walker);
        walker.setLocPathIterator(newIter);
        for (int i = 1; i < numSteps; i++) {
            AxesWalker next = (AxesWalker) walker.getNextWalker().clone();
            walker.setNextWalker(next);
            next.setLocPathIterator(newIter);
            walker = next;
        }
        walker.setNextWalker(null);
    } catch (CloneNotSupportedException cnse) {
        throw new WrappedRuntimeException(cnse);
    }
    return newIter;
}
Also used : AxesWalker(org.apache.xpath.axes.AxesWalker) WalkingIterator(org.apache.xpath.axes.WalkingIterator) WrappedRuntimeException(org.apache.xml.utils.WrappedRuntimeException)

Example 3 with WrappedRuntimeException

use of org.apache.xml.utils.WrappedRuntimeException in project j2objc by google.

the class KeyTable method getRefsTable.

/**
   * @return lazy initialized refs table associating evaluation of key function
   *         with a XNodeSet
   */
private Hashtable getRefsTable() {
    if (m_refsTable == null) {
        // initial capacity set to a prime number to improve hash performance
        m_refsTable = new Hashtable(89);
        KeyIterator ki = (KeyIterator) (m_keyNodes).getContainedIter();
        XPathContext xctxt = ki.getXPathContext();
        Vector keyDecls = getKeyDeclarations();
        int nKeyDecls = keyDecls.size();
        int currentNode;
        m_keyNodes.reset();
        while (DTM.NULL != (currentNode = m_keyNodes.nextNode())) {
            try {
                for (int keyDeclIdx = 0; keyDeclIdx < nKeyDecls; keyDeclIdx++) {
                    KeyDeclaration keyDeclaration = (KeyDeclaration) keyDecls.elementAt(keyDeclIdx);
                    XObject xuse = keyDeclaration.getUse().execute(xctxt, currentNode, ki.getPrefixResolver());
                    if (xuse.getType() != xuse.CLASS_NODESET) {
                        XMLString exprResult = xuse.xstr();
                        addValueInRefsTable(xctxt, exprResult, currentNode);
                    } else {
                        DTMIterator i = ((XNodeSet) xuse).iterRaw();
                        int currentNodeInUseClause;
                        while (DTM.NULL != (currentNodeInUseClause = i.nextNode())) {
                            DTM dtm = xctxt.getDTM(currentNodeInUseClause);
                            XMLString exprResult = dtm.getStringValue(currentNodeInUseClause);
                            addValueInRefsTable(xctxt, exprResult, currentNode);
                        }
                    }
                }
            } catch (TransformerException te) {
                throw new WrappedRuntimeException(te);
            }
        }
    }
    return m_refsTable;
}
Also used : Hashtable(java.util.Hashtable) DTMIterator(org.apache.xml.dtm.DTMIterator) XNodeSet(org.apache.xpath.objects.XNodeSet) KeyDeclaration(org.apache.xalan.templates.KeyDeclaration) XPathContext(org.apache.xpath.XPathContext) XMLString(org.apache.xml.utils.XMLString) DTM(org.apache.xml.dtm.DTM) Vector(java.util.Vector) XObject(org.apache.xpath.objects.XObject) TransformerException(javax.xml.transform.TransformerException) WrappedRuntimeException(org.apache.xml.utils.WrappedRuntimeException)

Example 4 with WrappedRuntimeException

use of org.apache.xml.utils.WrappedRuntimeException in project robovm by robovm.

the class KeyTable method getRefsTable.

/**
   * @return lazy initialized refs table associating evaluation of key function
   *         with a XNodeSet
   */
private Hashtable getRefsTable() {
    if (m_refsTable == null) {
        // initial capacity set to a prime number to improve hash performance
        m_refsTable = new Hashtable(89);
        KeyIterator ki = (KeyIterator) (m_keyNodes).getContainedIter();
        XPathContext xctxt = ki.getXPathContext();
        Vector keyDecls = getKeyDeclarations();
        int nKeyDecls = keyDecls.size();
        int currentNode;
        m_keyNodes.reset();
        while (DTM.NULL != (currentNode = m_keyNodes.nextNode())) {
            try {
                for (int keyDeclIdx = 0; keyDeclIdx < nKeyDecls; keyDeclIdx++) {
                    KeyDeclaration keyDeclaration = (KeyDeclaration) keyDecls.elementAt(keyDeclIdx);
                    XObject xuse = keyDeclaration.getUse().execute(xctxt, currentNode, ki.getPrefixResolver());
                    if (xuse.getType() != xuse.CLASS_NODESET) {
                        XMLString exprResult = xuse.xstr();
                        addValueInRefsTable(xctxt, exprResult, currentNode);
                    } else {
                        DTMIterator i = ((XNodeSet) xuse).iterRaw();
                        int currentNodeInUseClause;
                        while (DTM.NULL != (currentNodeInUseClause = i.nextNode())) {
                            DTM dtm = xctxt.getDTM(currentNodeInUseClause);
                            XMLString exprResult = dtm.getStringValue(currentNodeInUseClause);
                            addValueInRefsTable(xctxt, exprResult, currentNode);
                        }
                    }
                }
            } catch (TransformerException te) {
                throw new WrappedRuntimeException(te);
            }
        }
    }
    return m_refsTable;
}
Also used : Hashtable(java.util.Hashtable) DTMIterator(org.apache.xml.dtm.DTMIterator) XNodeSet(org.apache.xpath.objects.XNodeSet) KeyDeclaration(org.apache.xalan.templates.KeyDeclaration) XPathContext(org.apache.xpath.XPathContext) XMLString(org.apache.xml.utils.XMLString) DTM(org.apache.xml.dtm.DTM) Vector(java.util.Vector) XObject(org.apache.xpath.objects.XObject) TransformerException(javax.xml.transform.TransformerException) WrappedRuntimeException(org.apache.xml.utils.WrappedRuntimeException)

Aggregations

WrappedRuntimeException (org.apache.xml.utils.WrappedRuntimeException)4 Hashtable (java.util.Hashtable)2 Vector (java.util.Vector)2 TransformerException (javax.xml.transform.TransformerException)2 KeyDeclaration (org.apache.xalan.templates.KeyDeclaration)2 DTM (org.apache.xml.dtm.DTM)2 DTMIterator (org.apache.xml.dtm.DTMIterator)2 XMLString (org.apache.xml.utils.XMLString)2 XPathContext (org.apache.xpath.XPathContext)2 AxesWalker (org.apache.xpath.axes.AxesWalker)2 WalkingIterator (org.apache.xpath.axes.WalkingIterator)2 XNodeSet (org.apache.xpath.objects.XNodeSet)2 XObject (org.apache.xpath.objects.XObject)2