com.sun.org.apache.xml.internal.dtm.DTM Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTM. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NodeSequence.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * @see DTMIterator#setRoot(int, Object)
 */
public void setRoot(int nodeHandle, Object environment)
{
      // If root is DTM.NULL, then something's wrong with the context
      if (nodeHandle == DTM.NULL)
      {
          throw new RuntimeException("Unable to evaluate expression using " +
                  "this context");
      }

      if(null != m_iter)
      {
              XPathContext xctxt = (XPathContext)environment;
              m_dtmMgr = xctxt.getDTMManager();
              m_iter.setRoot(nodeHandle, environment);
              if(!m_iter.isDocOrdered())
              {
                      if(!hasCache())
                              setShouldCacheNodes(true);
                      runTo(-1);
                      m_next=0;
              }
      }
      else
              assertion(false, "Can not setRoot on a non-iterated NodeSequence!");
}
 
Example #2
Source File: DTMManagerDefault.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Given a DTM, find the ID number in the DTM tables which addresses
 * the start of the document. If overflow addressing is in use, other
 * DTM IDs may also be assigned to this DTM.
 *
 * @param dtm The DTM which (hopefully) contains this node.
 *
 * @return The DTM ID (as the high bits of a NodeHandle, not as our
 * internal index), or -1 if the DTM doesn't belong to this manager.
 */
synchronized public int getDTMIdentity(DTM dtm)
{
      // Shortcut using DTMDefaultBase's extension hooks
      // %REVIEW% Should the lookup be part of the basic DTM API?
      if(dtm instanceof DTMDefaultBase)
      {
              DTMDefaultBase dtmdb=(DTMDefaultBase)dtm;
              if(dtmdb.getManager()==this)
                      return dtmdb.getDTMIDs().elementAt(0);
              else
                      return -1;
      }

  int n = m_dtms.length;

  for (int i = 0; i < n; i++)
  {
    DTM tdtm = m_dtms[i];

    if (tdtm == dtm && m_dtm_offsets[i]==0)
      return i << IDENT_DTM_NODE_BITS;
  }

  return -1;
}
 
Example #3
Source File: DTMNamedNodeMap.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieves a node specified by local name and namespace URI. HTML-only
 * DOM implementations do not need to implement this method.
 * @param namespaceURI The namespace URI of the node to retrieve.
 * @param localName The local name of the node to retrieve.
 *
 * @return A <code>Node</code> (of any type) with the specified local
 *   name and namespace URI, or <code>null</code> if they do not
 *   identify any node in this map.
 * @since DOM Level 2
 */
public Node getNamedItemNS(String namespaceURI, String localName)
{
     Node retNode = null;
     for (int n = dtm.getFirstAttribute(element); n != DTM.NULL;
                     n = dtm.getNextAttribute(n))
     {
       if (localName.equals(dtm.getLocalName(n)))
       {
         String nsURI = dtm.getNamespaceURI(n);
         if ((namespaceURI == null && nsURI == null)
                || (namespaceURI != null && namespaceURI.equals(nsURI)))
         {
           retNode = dtm.getNode(n);
           break;
         }
       }
     }
     return retNode;
}
 
Example #4
Source File: LocPathIterator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Execute an expression in the XPath runtime context, and return the
 * result of the expression.
 *
 *
 * @param xctxt The XPath runtime context.
 * @param handler The target content handler.
 *
 * @return The result of the expression in the form of a <code>XObject</code>.
 *
 * @throws javax.xml.transform.TransformerException if a runtime exception
 *         occurs.
 * @throws org.xml.sax.SAXException
 */
public void executeCharsToContentHandler(
        XPathContext xctxt, org.xml.sax.ContentHandler handler)
          throws javax.xml.transform.TransformerException,
                 org.xml.sax.SAXException
{
  LocPathIterator clone = (LocPathIterator)m_clones.getInstance();

  int current = xctxt.getCurrentNode();
  clone.setRoot(current, xctxt);

  int node = clone.nextNode();
  DTM dtm = clone.getDTM(node);
  clone.detach();

  if(node != DTM.NULL)
  {
    dtm.dispatchCharactersEvents(node, handler, false);
  }
}
 
Example #5
Source File: SAX2DTM.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Report an XML comment anywhere in the document.
 *
 * <p>This callback will be used for comments inside or outside the
 * document element, including comments in the external DTD
 * subset (if read).</p>
 *
 * @param ch An array holding the characters in the comment.
 * @param start The starting position in the array.
 * @param length The number of characters to use from the array.
 * @throws SAXException The application may raise an exception.
 */
public void comment(char ch[], int start, int length) throws SAXException
{

  if (m_insideDTD)      // ignore comments if we're inside the DTD
    return;

  charactersFlush();

  int exName = m_expandedNameTable.getExpandedTypeID(DTM.COMMENT_NODE);

  // For now, treat comments as strings...  I guess we should do a
  // seperate FSB buffer instead.
  int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start,
                    length));


  m_previous = addNode(DTM.COMMENT_NODE, exName,
                       m_parents.peek(), m_previous, dataIndex, false);
}
 
Example #6
Source File: SAX2DTM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the <code>Element</code> whose <code>ID</code> is given by
 * <code>elementId</code>. If no such element exists, returns
 * <code>DTM.NULL</code>. Behavior is not defined if more than one element
 * has this <code>ID</code>. Attributes (including those
 * with the name "ID") are not of type ID unless so defined by DTD/Schema
 * information available to the DTM implementation.
 * Implementations that do not know whether attributes are of type ID or
 * not are expected to return <code>DTM.NULL</code>.
 *
 * <p>%REVIEW% Presumably IDs are still scoped to a single document,
 * and this operation searches only within a single document, right?
 * Wouldn't want collisions between DTMs in the same process.</p>
 *
 * @param elementId The unique <code>id</code> value for an element.
 * @return The handle of the matching element.
 */
public int getElementById(String elementId)
{

  Integer intObj;
  boolean isMore = true;

  do
  {
    intObj = m_idAttributes.get(elementId);

    if (null != intObj)
      return makeNodeHandle(intObj.intValue());

    if (!isMore || m_endDocumentOccured)
      break;

    isMore = nextNode();
  }
  while (null == intObj);

  return DTM.NULL;
}
 
Example #7
Source File: XPathExpressionImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private XObject eval ( Object contextItem )
        throws javax.xml.transform.TransformerException {
    com.sun.org.apache.xpath.internal.XPathContext xpathSupport = null;
    if ( functionResolver != null ) {
        JAXPExtensionsProvider jep = new JAXPExtensionsProvider(
                functionResolver, featureSecureProcessing, featureManager );
        xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext( jep );
    } else {
        xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext();
    }

    xpathSupport.setVarStack(new JAXPVariableStack(variableResolver));
    XObject xobj = null;

    Node contextNode = (Node)contextItem;
    // We always need to have a ContextNode with Xalan XPath implementation
    // To allow simple expression evaluation like 1+1 we are setting
    // dummy Document as Context Node

    if ( contextNode == null )
        xobj = xpath.execute(xpathSupport, DTM.NULL, prefixResolver);
    else
        xobj = xpath.execute(xpathSupport, contextNode, prefixResolver);

    return xobj;
}
 
Example #8
Source File: LocPathIterator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Bottleneck the return of a next node, to make returns
 * easier from nextNode().
 *
 * @param nextNode The next node found, may be null.
 *
 * @return The same node that was passed as an argument.
 */
protected int returnNextNode(int nextNode)
{

  if (DTM.NULL != nextNode)
  {
    m_pos++;
  }

  m_lastFetched = nextNode;

  if (DTM.NULL == nextNode)
    m_foundLast = true;

  return nextNode;
}
 
Example #9
Source File: FuncCurrent.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Execute the function.  The function must return
 * a valid object.
 * @param xctxt The current execution context.
 * @return A valid XObject.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{

  SubContextList subContextList = xctxt.getCurrentNodeList();
  int currentNode = DTM.NULL;

  if (null != subContextList) {
      if (subContextList instanceof PredicatedNodeTest) {
          LocPathIterator iter = ((PredicatedNodeTest)subContextList)
                                                        .getLocPathIterator();
          currentNode = iter.getCurrentContextNode();
       } else if(subContextList instanceof StepPattern) {
         throw new RuntimeException(XSLMessages.createMessage(
            XSLTErrorResources.ER_PROCESSOR_ERROR,null));
       }
  } else {
      // not predicate => ContextNode == CurrentNode
      currentNode = xctxt.getContextNode();
  }
  return new XNodeSet(currentNode, xctxt.getDTMManager());
}
 
Example #10
Source File: LocPathIterator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Bottleneck the return of a next node, to make returns
 * easier from nextNode().
 *
 * @param nextNode The next node found, may be null.
 *
 * @return The same node that was passed as an argument.
 */
protected int returnNextNode(int nextNode)
{

  if (DTM.NULL != nextNode)
  {
    m_pos++;
  }

  m_lastFetched = nextNode;

  if (DTM.NULL == nextNode)
    m_foundLast = true;

  return nextNode;
}
 
Example #11
Source File: SAX2DTM.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the <code>Element</code> whose <code>ID</code> is given by
 * <code>elementId</code>. If no such element exists, returns
 * <code>DTM.NULL</code>. Behavior is not defined if more than one element
 * has this <code>ID</code>. Attributes (including those
 * with the name "ID") are not of type ID unless so defined by DTD/Schema
 * information available to the DTM implementation.
 * Implementations that do not know whether attributes are of type ID or
 * not are expected to return <code>DTM.NULL</code>.
 *
 * <p>%REVIEW% Presumably IDs are still scoped to a single document,
 * and this operation searches only within a single document, right?
 * Wouldn't want collisions between DTMs in the same process.</p>
 *
 * @param elementId The unique <code>id</code> value for an element.
 * @return The handle of the matching element.
 */
public int getElementById(String elementId)
{

  Integer intObj;
  boolean isMore = true;

  do
  {
    intObj = m_idAttributes.get(elementId);

    if (null != intObj)
      return makeNodeHandle(intObj.intValue());

    if (!isMore || m_endDocumentOccured)
      break;

    isMore = nextNode();
  }
  while (null == intObj);

  return DTM.NULL;
}
 
Example #12
Source File: XObject.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Cast result object to a result tree fragment.
 *
 * @param support XPath context to use for the conversion
 *
 * @return the objec as a result tree fragment.
 */
public int rtf(XPathContext support)
{

  int result = rtf();

  if (DTM.NULL == result)
  {
    DTM frag = support.createDocumentFragment();

    // %OPT%
    frag.appendTextChild(str());

    result = frag.getDocument();
  }

  return result;
}
 
Example #13
Source File: NodeSequence.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @see DTMIterator#getCurrentNode()
 */
public int getCurrentNode()
{
      if(hasCache())
      {
              int currentIndex = m_next-1;
              NodeVector vec = getVector();
              if((currentIndex >= 0) && (currentIndex < vec.size()))
                      return vec.elementAt(currentIndex);
              else
                      return DTM.NULL;
      }

      if(null != m_iter)
      {
      return m_iter.getCurrentNode();
      }
      else
              return DTM.NULL;
}
 
Example #14
Source File: FuncLocalPart.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Execute the function.  The function must return
 * a valid object.
 * @param xctxt The current execution context.
 * @return A valid XObject.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{

  int context = getArg0AsNode(xctxt);
  if(DTM.NULL == context)
    return XString.EMPTYSTRING;
  DTM dtm = xctxt.getDTM(context);
  String s = (context != DTM.NULL) ? dtm.getLocalName(context) : "";
  if(s.startsWith("#") || s.equals("xmlns"))
    return XString.EMPTYSTRING;

  return new XString(s);
}
 
Example #15
Source File: NodeSetDTM.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return The root node of the Iterator, as specified when it was created.
 * For non-Iterator NodeSetDTMs, this will be null.
 */
public int getRoot()
{
  if(DTM.NULL == m_root)
  {
    if(size() > 0)
      return item(0);
    else
      return DTM.NULL;
  }
  else
    return m_root;
}
 
Example #16
Source File: DTMNodeProxy.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * @param namespaceURI
 * @param localName
 *
 *
 * @see org.w3c.dom.Document as of DOM Level 2
 */
@Override
public final NodeList getElementsByTagNameNS(String namespaceURI,
                                             String localName)
{
  Vector listVector = new Vector();
  Node retNode = dtm.getNode(node);
  if (retNode != null)
  {
    boolean isNamespaceURIWildCard = "*".equals(namespaceURI);
    boolean isLocalNameWildCard    = "*".equals(localName);
    if (DTM.ELEMENT_NODE == retNode.getNodeType())
    {
      NodeList nodeList = retNode.getChildNodes();
      for(int i = 0; i < nodeList.getLength(); i++)
      {
        traverseChildren(listVector, nodeList.item(i), namespaceURI, localName, isNamespaceURIWildCard, isLocalNameWildCard);
      }
    }
    else if(DTM.DOCUMENT_NODE == retNode.getNodeType())
    {
      traverseChildren(listVector, dtm.getNode(node), namespaceURI, localName, isNamespaceURIWildCard, isLocalNameWildCard);
    }
  }
  int size = listVector.size();
  NodeSet nodeSet = new NodeSet(size);
  for (int i = 0; i < size; i++)
  {
    nodeSet.addNode((Node)listVector.elementAt(i));
  }
  return (NodeList) nodeSet;
}
 
Example #17
Source File: DOM2DTM.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the <code>Element</code> whose <code>ID</code> is given by
 * <code>elementId</code>. If no such element exists, returns
 * <code>DTM.NULL</code>. Behavior is not defined if more than one element
 * has this <code>ID</code>. Attributes (including those
 * with the name "ID") are not of type ID unless so defined by DTD/Schema
 * information available to the DTM implementation.
 * Implementations that do not know whether attributes are of type ID or
 * not are expected to return <code>DTM.NULL</code>.
 *
 * <p>%REVIEW% Presumably IDs are still scoped to a single document,
 * and this operation searches only within a single document, right?
 * Wouldn't want collisions between DTMs in the same process.</p>
 *
 * @param elementId The unique <code>id</code> value for an element.
 * @return The handle of the matching element.
 */
public int getElementById(String elementId)
{

  Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE)
      ? (Document) m_root : m_root.getOwnerDocument();

  if(null != doc)
  {
    Node elem = doc.getElementById(elementId);
    if(null != elem)
    {
      int elemHandle = getHandleFromNode(elem);

      if(DTM.NULL == elemHandle)
      {
        int identity = m_nodes.size()-1;
        while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
        {
          Node node = getNode(identity);
          if(node == elem)
          {
            elemHandle = getHandleFromNode(elem);
            break;
          }
         }
      }

      return elemHandle;
    }

  }
  return DTM.NULL;
}
 
Example #18
Source File: XSLTC.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Initializes the compiler to produce a new translet
 */
private void reset() {
    _nextGType      = DTM.NTYPES;
    _elements       = new HashMap<>();
    _attributes     = new HashMap<>();
    _namespaces     = new HashMap<>();
    _namespaces.put("",new Integer(_nextNSType));
    _namesIndex     = new Vector(128);
    _namespaceIndex = new Vector(32);
    _namespacePrefixes = new HashMap<>();
    _stylesheet     = null;
    _parser.init();
    //_variableSerial     = 1;
    _modeSerial         = 1;
    _stylesheetSerial   = 1;
    _stepPatternSerial  = 1;
    _helperClassSerial  = 0;
    _attributeSetSerial = 0;
    _multiDocument      = false;
    _hasIdCall          = false;
    _numberFieldIndexes = new int[] {
        -1,         // LEVEL_SINGLE
        -1,         // LEVEL_MULTIPLE
        -1          // LEVEL_ANY
    };
    _externalExtensionFunctions.clear();
}
 
Example #19
Source File: NodeVector.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Deletes the component at the specified index. Each component in
 * this vector with an index greater or equal to the specified
 * index is shifted downward to have an index one smaller than
 * the value it had previously.
 *
 * @param i Index of node to remove
 */
public void removeElementAt(int i)
{

  if (null == m_map)
    return;

  if (i > m_firstFree)
    System.arraycopy(m_map, i + 1, m_map, i - 1, m_firstFree - i);
  else
    m_map[i] = DTM.NULL;
}
 
Example #20
Source File: SAXImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the internal type associated with an expanded QName
 */
public int getGeneralizedType(final String name, boolean searchOnly) {
    String lName, ns = null;
    int index = -1;
    int code;

    // Is there a prefix?
    if ((index = name.lastIndexOf(":"))> -1) {
        ns = name.substring(0, index);
    }

    // Local part of name is after colon.  lastIndexOf returns -1 if
    // there is no colon, so lNameStartIdx will be zero in that case.
    int lNameStartIdx = index+1;

    // Distinguish attribute and element names.  Attribute has @ before
    // local part of name.
    if (name.charAt(lNameStartIdx) == '@') {
        code = DTM.ATTRIBUTE_NODE;
        lNameStartIdx++;
    }
    else {
        code = DTM.ELEMENT_NODE;
    }

    // Extract local name
    lName = (lNameStartIdx == 0) ? name : name.substring(lNameStartIdx);

    return m_expandedNameTable.getExpandedTypeID(ns, lName, code, searchOnly);
}
 
Example #21
Source File: XSLTC.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the compiler to produce a new translet
 */
private void reset() {
    _nextGType      = DTM.NTYPES;
    _elements       = new Hashtable();
    _attributes     = new Hashtable();
    _namespaces     = new Hashtable();
    _namespaces.put("",new Integer(_nextNSType));
    _namesIndex     = new Vector(128);
    _namespaceIndex = new Vector(32);
    _namespacePrefixes = new Hashtable();
    _stylesheet     = null;
    _parser.init();
    //_variableSerial     = 1;
    _modeSerial         = 1;
    _stylesheetSerial   = 1;
    _stepPatternSerial  = 1;
    _helperClassSerial  = 0;
    _attributeSetSerial = 0;
    _multiDocument      = false;
    _hasIdCall          = false;
    _numberFieldIndexes = new int[] {
        -1,         // LEVEL_SINGLE
        -1,         // LEVEL_MULTIPLE
        -1          // LEVEL_ANY
    };
    _externalExtensionFunctions.clear();
}
 
Example #22
Source File: XPathContext.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a node as a string.
 * @param n Node to be converted to a string.  May be null.
 * @return value of n as a string, or an empty string if n is null.
 */
public String toString(org.w3c.dom.Node n)
{
  // %REVIEW% You can't get much uglier than this...
  int nodeHandle = getDTMHandleFromNode(n);
  DTM dtm = getDTM(nodeHandle);
  XMLString strVal = dtm.getStringValue(nodeHandle);
  return strVal.toString();
}
 
Example #23
Source File: DTMNodeProxy.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 * @param namespaceURI
 * @param localName
 *
 *
 * @see org.w3c.dom.Document as of DOM Level 2
 */
@Override
public final NodeList getElementsByTagNameNS(String namespaceURI,
                                             String localName)
{
  Vector listVector = new Vector();
  Node retNode = dtm.getNode(node);
  if (retNode != null)
  {
    boolean isNamespaceURIWildCard = "*".equals(namespaceURI);
    boolean isLocalNameWildCard    = "*".equals(localName);
    if (DTM.ELEMENT_NODE == retNode.getNodeType())
    {
      NodeList nodeList = retNode.getChildNodes();
      for(int i = 0; i < nodeList.getLength(); i++)
      {
        traverseChildren(listVector, nodeList.item(i), namespaceURI, localName, isNamespaceURIWildCard, isLocalNameWildCard);
      }
    }
    else if(DTM.DOCUMENT_NODE == retNode.getNodeType())
    {
      traverseChildren(listVector, dtm.getNode(node), namespaceURI, localName, isNamespaceURIWildCard, isLocalNameWildCard);
    }
  }
  int size = listVector.size();
  NodeSet nodeSet = new NodeSet(size);
  for (int i = 0; i < size; i++)
  {
    nodeSet.addNode((Node)listVector.elementAt(i));
  }
  return (NodeList) nodeSet;
}
 
Example #24
Source File: SAX2DTM2.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set start to END should 'close' the iterator,
 * i.e. subsequent call to next() should return END.
 *
 * @param node Sets the root of the iteration.
 *
 * @return A DTMAxisIterator set to the start of the iteration.
 */
public DTMAxisIterator setStartNode(int node) {
  //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
  if (node == DTMDefaultBase.ROOTNODE)
    node = getDocument();
  if (_isRestartable) {
    _startNode = node;
    _currentNode = (node == DTM.NULL) ? DTM.NULL :
                     _firstch2(makeNodeIdentity(_startNode));

    return resetPosition();
  }

  return this;
}
 
Example #25
Source File: SimpleResultTreeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public int next()
{
    // Increase the node ID for down traversal. Also match the node type
    // if the type is given.
    if (_direction == DIRECTION_DOWN) {
        while (_currentNode < NUMBER_OF_NODES) {
            if (_type != NO_TYPE) {
                if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE)
                    || (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE))
                    return returnNode(getNodeHandle(_currentNode++));
                else
                    _currentNode++;
            }
            else
                return returnNode(getNodeHandle(_currentNode++));
        }

        return END;
    }
    // Decrease the node ID for up traversal.
    else {
        while (_currentNode >= 0) {
            if (_type != NO_TYPE) {
                if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE)
                    || (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE))
                    return returnNode(getNodeHandle(_currentNode--));
                else
                    _currentNode--;
            }
            else
                return returnNode(getNodeHandle(_currentNode--));
        }

        return END;
    }
}
 
Example #26
Source File: FunctionPattern.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test a node to see if it matches the given node test.
 *
 * @param xctxt XPath runtime context.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context,
                       DTM dtm, int expType)
        throws javax.xml.transform.TransformerException
{

  DTMIterator nl = m_functionExpr.asIterator(xctxt, context);
  XNumber score = SCORE_NONE;

  if (null != nl)
  {
    int n;

    while (DTM.NULL != (n = nl.nextNode()))
    {
      score = (n == context) ? SCORE_OTHER : SCORE_NONE;

      if (score == SCORE_OTHER)
      {
        context = n;

        break;
      }
    }

    nl.detach();
  }

  return score;
}
 
Example #27
Source File: DTMNodeProxy.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 *
 *
 * @see org.w3c.dom.Node
 */
@Override
public final Node getPreviousSibling()
{

  int newnode = dtm.getPreviousSibling(node);

  return (newnode == DTM.NULL) ? null : dtm.getNode(newnode);
}
 
Example #28
Source File: WalkingIterator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Returns the next node in the set and advances the position of the
 * iterator in the set. After a NodeIterator is created, the first call
 * to nextNode() returns the first node in the set.
 * @return  The next <code>Node</code> in the set being iterated over, or
 *   <code>null</code> if there are no more members in that set.
 */
public int nextNode()
{
      if(m_foundLast)
              return DTM.NULL;

  // If the variable stack position is not -1, we'll have to
  // set our position in the variable stack, so our variable access
  // will be correct.  Iterators that are at the top level of the
  // expression need to reset the variable stack, while iterators
  // in predicates do not need to, and should not, since their execution
  // may be much later than top-level iterators.
  // m_varStackPos is set in setRoot, which is called
  // from the execute method.
  if (-1 == m_stackFrame)
  {
    return returnNextNode(m_firstWalker.nextNode());
  }
  else
  {
    VariableStack vars = m_execContext.getVarStack();

    // These three statements need to be combined into one operation.
    int savedStart = vars.getStackFrame();

    vars.setStackFrame(m_stackFrame);

    int n = returnNextNode(m_firstWalker.nextNode());

    // These two statements need to be combined into one operation.
    vars.setStackFrame(savedStart);

    return n;
  }
}
 
Example #29
Source File: XPathContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reset for new run.
 */
public void reset()
{
  releaseDTMXRTreeFrags();
      // These couldn't be disposed of earlier (see comments in release()); zap them now.
      if(m_rtfdtm_stack!=null)
               for (java.util.Enumeration e = m_rtfdtm_stack.elements() ; e.hasMoreElements() ;)
                      m_dtmManager.release((DTM)e.nextElement(), true);

  m_rtfdtm_stack=null; // drop our references too
  m_which_rtfdtm=-1;

  if(m_global_rtfdtm!=null)
                      m_dtmManager.release(m_global_rtfdtm,true);
  m_global_rtfdtm=null;


  m_dtmManager = DTMManager.newInstance(
                 com.sun.org.apache.xpath.internal.objects.XMLStringFactoryImpl.getFactory()
                 );

  m_saxLocations.removeAllElements();
      m_axesIteratorStack.removeAllElements();
      m_contextNodeLists.removeAllElements();
      m_currentExpressionNodes.removeAllElements();
      m_currentNodes.removeAllElements();
      m_iteratorRoots.RemoveAllNoClear();
      m_predicatePos.removeAllElements();
      m_predicateRoots.RemoveAllNoClear();
      m_prefixResolvers.removeAllElements();

      m_prefixResolvers.push(null);
  m_currentNodes.push(DTM.NULL);
  m_currentExpressionNodes.push(DTM.NULL);
  m_saxLocations.push(null);
}
 
Example #30
Source File: DTMNodeProxy.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 *
 * @see org.w3c.dom.Node
 */
@Override
public final Node getParentNode()
{

  if (getNodeType() == Node.ATTRIBUTE_NODE)
    return null;

  int newnode = dtm.getParent(node);

  return (newnode == DTM.NULL) ? null : dtm.getNode(newnode);
}