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

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTM. These examples are extracted from open source projects. 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
/**
 * 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 2
Source Project: Bytecoder   Source File: DTMNamedNodeMap.java    License: 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 3
Source Project: jdk1.8-source-analysis   Source File: DTMManagerDefault.java    License: 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 4
Source Project: JDKSourceCode1.8   Source File: NodeSequence.java    License: 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 5
Source Project: JDKSourceCode1.8   Source File: SAX2DTM.java    License: 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 Project: openjdk-jdk8u-backup   Source File: SAX2DTM.java    License: 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
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
/**
 * 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 Project: Bytecoder   Source File: FuncCurrent.java    License: 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
/**
 * 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 Project: jdk1.8-source-analysis   Source File: SAX2DTM.java    License: 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 Project: openjdk-jdk8u   Source File: XObject.java    License: 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 Project: openjdk-jdk9   Source File: NodeSequence.java    License: 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 Project: TencentKona-8   Source File: NodeSetDTM.java    License: 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 15
Source Project: openjdk-8-source   Source File: SAXImpl.java    License: 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 16
Source Project: jdk8u60   Source File: StepPattern.java    License: GNU General Public License v2.0 5 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 currentNode The currentNode.
 * @param dtm The DTM of the current node.
 * @param expType The expanded type ID of the current node.
 *
 * @return The result of the expression in the form of a <code>XObject</code>.
 *
 * @throws javax.xml.transform.TransformerException if a runtime exception
 *         occurs.
 */
public XObject execute(
        XPathContext xctxt, int currentNode, DTM dtm, int expType)
          throws javax.xml.transform.TransformerException
{

  if (m_whatToShow == NodeTest.SHOW_BYFUNCTION)
  {
    if (null != m_relativePathPattern)
    {
      return m_relativePathPattern.execute(xctxt);
    }
    else
      return NodeTest.SCORE_NONE;
  }

  XObject score;

  score = super.execute(xctxt, currentNode, dtm, expType);

  if (score == NodeTest.SCORE_NONE)
    return NodeTest.SCORE_NONE;

  if (getPredicateCount() != 0)
  {
    if (!executePredicates(xctxt, dtm, currentNode))
      return NodeTest.SCORE_NONE;
  }

  if (null != m_relativePathPattern)
    return m_relativePathPattern.executeRelativePathPattern(xctxt, dtm,
            currentNode);

  return score;
}
 
Example 17
Source Project: openjdk-8   Source File: DTMManagerDefault.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add a DTM to the DTM table.
 *
 * @param dtm Should be a valid reference to a DTM.
 * @param id Integer DTM ID to be bound to this DTM.
 * @param offset Integer addressing offset. The internal DTM Node ID is
 * obtained by adding this offset to the node-number field of the
 * public DTM Handle. For the first DTM ID accessing each DTM, this is 0;
 * for overflow addressing it will be a multiple of 1<<IDENT_DTM_NODE_BITS.
 */
synchronized public void addDTM(DTM dtm, int id, int offset)
{
              if(id>=IDENT_MAX_DTMS)
              {
                      // TODO: %REVIEW% Not really the right error message.
          throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_DTMIDS_AVAIL, null)); //"No more DTM IDs are available!");
              }

              // We used to just allocate the array size to IDENT_MAX_DTMS.
              // But we expect to increase that to 16 bits, and I'm not willing
              // to allocate that much space unless needed. We could use one of our
              // handy-dandy Fast*Vectors, but this will do for now.
              // %REVIEW%
              int oldlen=m_dtms.length;
              if(oldlen<=id)
              {
                      // Various growth strategies are possible. I think we don't want
                      // to over-allocate excessively, and I'm willing to reallocate
                      // more often to get that. See also Fast*Vector classes.
                      //
                      // %REVIEW% Should throw a more diagnostic error if we go over the max...
                      int newlen=Math.min((id+256),IDENT_MAX_DTMS);

                      DTM new_m_dtms[] = new DTM[newlen];
                      System.arraycopy(m_dtms,0,new_m_dtms,0,oldlen);
                      m_dtms=new_m_dtms;
                      int new_m_dtm_offsets[] = new int[newlen];
                      System.arraycopy(m_dtm_offsets,0,new_m_dtm_offsets,0,oldlen);
                      m_dtm_offsets=new_m_dtm_offsets;
              }

  m_dtms[id] = dtm;
              m_dtm_offsets[id]=offset;
  dtm.documentRegistration();
              // The DTM should have been told who its manager was when we created it.
              // Do we need to allow for adopting DTMs _not_ created by this manager?
}
 
Example 18
Source Project: openjdk-8   Source File: DOM2DTM.java    License: GNU General Public License v2.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 19
Source Project: JDKSourceCode1.8   Source File: SAXImpl.java    License: MIT License 5 votes vote down vote up
/**
 * Return the node identity for a given id String
 *
 * @param idString The id String
 * @return The identity of the node whose id is the given String.
 */
public int getElementById(String idString)
{
    Node node = _document.getElementById(idString);
    if (node != null) {
        Integer id = _node2Ids.get(node);
        return (id != null) ? id : DTM.NULL;
    }
    else {
        return DTM.NULL;
    }
}
 
Example 20
Source Project: openjdk-8-source   Source File: MultiDOM.java    License: GNU General Public License v2.0 5 votes vote down vote up
public int getDTMId(int nodeHandle)
{
    if (nodeHandle == DTM.NULL)
        return 0;

    int id = nodeHandle >>> DTMManager.IDENT_DTM_NODE_BITS;
    while (id >= 2 && _adapters[id] == _adapters[id-1]) {
        id--;
    }
    return id;
}
 
Example 21
Source Project: JDKSourceCode1.8   Source File: SAXImpl.java    License: MIT License 5 votes vote down vote up
/**
 * Returns the attribute node of a given type (if any) for an element
 */
public int getAttributeNode(final int type, final int element)
{
    for (int attr = getFirstAttribute(element);
       attr != DTM.NULL;
       attr = getNextAttribute(attr))
    {
        if (getExpandedTypeID(attr) == type) return attr;
    }
    return DTM.NULL;
}
 
Example 22
Source Project: openjdk-jdk8u   Source File: XNodeSet.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct a XNodeSet object for one node.
 *
 * @param n Node to add to the new XNodeSet object
 */
public XNodeSet(int n, DTMManager dtmMgr)
{

  super(new NodeSetDTM(dtmMgr));
  m_dtmMgr = dtmMgr;

  if (DTM.NULL != n)
  {
    ((NodeSetDTM) m_obj).addNode(n);
    m_last = 1;
  }
  else
      m_last = 0;
}
 
Example 23
Source Project: openjdk-jdk9   Source File: DOMAdapter.java    License: GNU General Public License v2.0 5 votes vote down vote up
public String getNamespaceName(final int node)
{
    if (node == DTM.NULL) {
        return "";
    }
    return _dom.getNamespaceName(node);
}
 
Example 24
Source Project: Bytecoder   Source File: XNodeSet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Directly call the
 * characters method on the passed ContentHandler for the
 * string-value. Multiple calls to the
 * ContentHandler's characters methods may well occur for a single call to
 * this method.
 *
 * @param ch A non-null reference to a ContentHandler.
 *
 * @throws org.xml.sax.SAXException
 */
public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
        throws org.xml.sax.SAXException
{
  int node = item(0);

  if(node != DTM.NULL)
  {
    m_dtmMgr.getDTM(node).dispatchCharactersEvents(node, ch, false);
  }

}
 
Example 25
public int getFirstChild(int nodeHandle)
{
    int nodeID = getNodeIdent(nodeHandle);
    if (nodeID == RTF_ROOT)
        return getNodeHandle(RTF_TEXT);
    else
        return DTM.NULL;
}
 
Example 26
/**
 *  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;

  int next;
  DTM dtm = m_cdtm;

  m_lastFetched = next = (DTM.NULL == m_lastFetched)
                         ? m_context
                         : DTM.NULL;

  // m_lastFetched = next;
  if (DTM.NULL != next)
  {
    m_pos++;

    return next;
  }
  else
  {
    m_foundLast = true;

    return DTM.NULL;
  }
}
 
Example 27
Source Project: openjdk-8   Source File: XPathContext.java    License: 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 28
/**
 *  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 Project: jdk1.8-source-analysis   Source File: DTMNodeProxy.java    License: 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 30
/**
 * 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;
}