當前位置: 首頁>>代碼示例>>Java>>正文


Java NodeFilter類代碼示例

本文整理匯總了Java中org.w3c.dom.traversal.NodeFilter的典型用法代碼示例。如果您正苦於以下問題:Java NodeFilter類的具體用法?Java NodeFilter怎麽用?Java NodeFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NodeFilter類屬於org.w3c.dom.traversal包,在下文中一共展示了NodeFilter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getParentNode

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/** Internal function.
 *  Return the parent Node, from the input node
 *  after applying filter, whatToshow.
 *  The current node is not consulted or set.
 */
Node getParentNode(Node node) {
    
    if (node == null || isSameNode(node, fRoot)) return null;
    
    Node newNode = node.getParentNode();
    if (newNode == null)  return null; 
                    
    int accept = acceptNode(newNode);
    
    if (accept == NodeFilter.FILTER_ACCEPT)
        return newNode;
    else 
    //if (accept == NodeFilter.SKIP_NODE) // and REJECT too.
    {
        return getParentNode(newNode);
    }
    
    
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:25,代碼來源:TwsTreeWalker.java

示例2: getParentNode

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/** Internal function.
 *  Return the parent Node, from the input node
 *  after applying filter, whatToshow.
 *  The current node is not consulted or set.
 */
Node getParentNode(Node node) {

    if (node == null || node == fRoot) return null;

    Node newNode = node.getParentNode();
    if (newNode == null)  return null;

    int accept = acceptNode(newNode);

    if (accept == NodeFilter.FILTER_ACCEPT)
        return newNode;
    else
    //if (accept == NodeFilter.SKIP_NODE) // and REJECT too.
    {
        return getParentNode(newNode);
    }


}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:TreeWalkerImpl.java

示例3: createNodeIterator

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/**
 * Create and return a NodeIterator. The NodeIterator is
 * added to a list of NodeIterators so that it can be
 * removed to free up the DOM Nodes it references.
 *
 * @param root The root of the iterator.
 * @param whatToShow The whatToShow mask.
 * @param filter The NodeFilter installed. Null means no filter.
 * @param entityReferenceExpansion true to expand the contents of
 *                                 EntityReference nodes
 * @since WD-DOM-Level-2-19990923
 */
public NodeIterator createNodeIterator(Node root,
                                       int whatToShow,
                                       NodeFilter filter,
                                       boolean entityReferenceExpansion)
{

    if (root == null) {
              String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
              throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
    }

    NodeIterator iterator = new NodeIteratorImpl(this,
                                                 root,
                                                 whatToShow,
                                                 filter,
                                                 entityReferenceExpansion);
    if (iterators == null) {
        iterators = new ArrayList<>();
    }

    iterators.add(iterator);

    return iterator;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:37,代碼來源:DocumentImpl.java

示例4: serializeComment

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/**
 * Serializes a Comment Node.
 *
 * @param node The Comment Node to serialize
 */
protected void serializeComment(Comment node) throws SAXException {
    // comments=true
    if ((fFeatures & COMMENTS) != 0) {
        String data = node.getData();

        // well-formed=true
        if ((fFeatures & WELLFORMED) != 0) {
            isCommentWellFormed(data);
        }

        if (fLexicalHandler != null) {
            // apply the LSSerializer filter after the operations requested by the
            // DOMConfiguration parameters have been applied
            if (!applyFilter(node, NodeFilter.SHOW_COMMENT)) {
                return;
            }

            fLexicalHandler.comment(data.toCharArray(), 0, data.length());
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:DOM3TreeWalker.java

示例5: serializePI

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/**
 * Serializes an ProcessingInstruction Node.
 *
 * @param node The ProcessingInstruction Node to serialize
 */
protected void serializePI(ProcessingInstruction node)
    throws SAXException {
    ProcessingInstruction pi = node;
    String name = pi.getNodeName();

    // well-formed=true
    if ((fFeatures & WELLFORMED) != 0) {
        isPIWellFormed(node);
    }

    // apply the LSSerializer filter
    if (!applyFilter(node, NodeFilter.SHOW_PROCESSING_INSTRUCTION)) {
        return;
    }

    // String data = pi.getData();
    if (name.equals("xslt-next-is-raw")) {
        fNextIsRaw = true;
    } else {
        this.fSerializer.processingInstruction(name, pi.getData());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:DOM3TreeWalker.java

示例6: accept

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
public short accept(Element element) {
    if (isEqualById(element, elementId)) {
        if (element.getNextSibling() != null && element.getNextSibling().getNodeType() == Node.TEXT_NODE) {
            element.getParentNode().removeChild(element.getNextSibling());
        }
        
        markChildElementsForDeletion(element);
        return NodeFilter.FILTER_REJECT;
    }
    
    if (shouldDeleteNode(element)) {
        return NodeFilter.FILTER_REJECT;
    }
    
    return NodeFilter.FILTER_ACCEPT;
}
 
開發者ID:christophd,項目名稱:citrus-admin,代碼行數:20,代碼來源:RemoveSpringBeanFilter.java

示例7: accept

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
public short accept(Element element) {
    if (added == null && (isEqualById(element, elementId))) {
        if (element.getNextSibling() != null) {
            added = element.getParentNode().insertBefore(element.getOwnerDocument().importNode(beanDefinition, true), element.getNextSibling());
        } else {
            added = element.getParentNode().appendChild(element.getOwnerDocument().importNode(beanDefinition, true));
        }

        updatedBeans++;
    }
    
    if (element.equals(added)) {
        return NodeFilter.FILTER_ACCEPT; 
    }
    
    return super.accept(element);
}
 
開發者ID:christophd,項目名稱:citrus-admin,代碼行數:21,代碼來源:UpdateSpringBeanFilter.java

示例8: createNodeIterator

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/**
 * Creates a new node iterator.
 */
public NodeIterator createNodeIterator(AbstractDocument doc,
                                       Node root,
                                       int whatToShow, 
                                       NodeFilter filter, 
                                       boolean entityReferenceExpansion)
    throws DOMException {
    if (root == null) {
        throw doc.createDOMException
            (DOMException.NOT_SUPPORTED_ERR, "null.root",  null);
    }
    NodeIterator result = new DOMNodeIterator(doc, root, whatToShow,
                                              filter,
                                              entityReferenceExpansion);
    if (iterators == null) {
        iterators = new LinkedList();
    }
    iterators.add(result);

    return result;
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:24,代碼來源:TraversalSupport.java

示例9: firstChild

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/**
 * Returns the first child of the given node.
 */
protected Node firstChild(Node n) {
    if (n.getNodeType() == Node.ENTITY_REFERENCE_NODE &&
        !expandEntityReferences) {
        return null;
    }
    Node result = n.getFirstChild();
    if (result == null) {
        return null;
    }
    switch (acceptNode(result)) {
    case NodeFilter.FILTER_ACCEPT:
        return result;
    case NodeFilter.FILTER_SKIP:
        Node t = firstChild(result);
        if (t != null) {
            return t;
        }
        // Fall through
    default: // NodeFilter.FILTER_REJECT
        return nextSibling(result, n);
    }
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:26,代碼來源:DOMTreeWalker.java

示例10: lastChild

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/**
 * Returns the last child of the given node.
 */
protected Node lastChild(Node n) {
    if (n.getNodeType() == Node.ENTITY_REFERENCE_NODE &&
        !expandEntityReferences) {
        return null;
    }
    Node result = n.getLastChild();
    if (result == null) {
        return null;
    }
    switch (acceptNode(result)) {
    case NodeFilter.FILTER_ACCEPT:
        return result;
    case NodeFilter.FILTER_SKIP:
        Node t = lastChild(result);
        if (t != null) {
            return t;
        }
        // Fall through
    default: // NodeFilter.FILTER_REJECT
        return previousSibling(result, n);
    }
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:26,代碼來源:DOMTreeWalker.java

示例11: getElementById

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
public Element getElementById(String elementId)
{
  Element element = xmljGetElementById(elementId);
  if (element == null)
    {
      TreeWalker walker = createTreeWalker(this, NodeFilter.SHOW_ELEMENT,
                                           null, false);
      for (Node node = walker.nextNode(); node != null;
           node = walker.nextNode())
        {
          GnomeElement e = (GnomeElement) node;
          if (e.userIdAttrs != null)
            {
              for (Iterator i = e.userIdAttrs.iterator(); i.hasNext(); )
                {
                  Attr attr = (Attr) i.next();
                  if (attr.getNodeValue().equals(elementId))
                    {
                      return e;
                    }
                }
            }
        }
    }
  return element;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:27,代碼來源:GnomeDocument.java

示例12: TwsTreeWalker

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/** Public constructor */
public TwsTreeWalker(Node root, 
                      int whatToShow, 
                      NodeFilter nodeFilter,
                      boolean entityReferenceExpansion) {
    fCurrentNode = root;
    fRoot = root;
    fUseIsSameNode = useIsSameNode(root);
    fWhatToShow = whatToShow;
    fNodeFilter = nodeFilter;
    fEntityReferenceExpansion = entityReferenceExpansion;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:13,代碼來源:TwsTreeWalker.java

示例13: getPreviousSibling

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/** Internal function.
   *  Return the previousSibling Node, from the input node
   *  after applying filter, whatToshow.
*  NEVER TRAVERSES ABOVE THE SPECIFIED ROOT NODE. 
   *  The current node is not consulted or set.
   */
  Node getPreviousSibling(Node node, Node root) {
      
      if (node == null || isSameNode(node, root)) return null;
      
      Node newNode = node.getPreviousSibling();
      if (newNode == null) {
              
          newNode = node.getParentNode();
          if (newNode == null || isSameNode(newNode, root)) return null; 
              
          int parentAccept = acceptNode(newNode);
              
          if (parentAccept==NodeFilter.FILTER_SKIP) {
              return getPreviousSibling(newNode, root);
          }
          
          return null;
      }
      
      int accept = acceptNode(newNode);
      
      if (accept == NodeFilter.FILTER_ACCEPT)
          return newNode;
      else 
      if (accept == NodeFilter.FILTER_SKIP) {
          Node fChild =  getLastChild(newNode);
          if (fChild == null) {
              return getPreviousSibling(newNode, root);
          }
          return fChild;
      }
      else 
      //if (accept == NodeFilter.REJECT_NODE) 
      {
          return getPreviousSibling(newNode, root);
      }
      
  }
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:45,代碼來源:TwsTreeWalker.java

示例14: getFirstChild

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/** Internal function.
 *  Return the first child Node, from the input node
 *  after applying filter, whatToshow.
 *  The current node is not consulted or set.
 */
Node getFirstChild(Node node) {
    if (node == null) return null;
    
    if ( !fEntityReferenceExpansion
         && node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
        return null;
    Node newNode = node.getFirstChild();
    if (newNode == null)  return null;
    int accept = acceptNode(newNode);
    
    if (accept == NodeFilter.FILTER_ACCEPT)
        return newNode;
    else 
    if (accept == NodeFilter.FILTER_SKIP
        && newNode.hasChildNodes()) 
    {
        Node fChild = getFirstChild(newNode);
        
        if (fChild == null) {
            return getNextSibling(newNode, node);
        }
        return fChild;
    }
    else 
    //if (accept == NodeFilter.REJECT_NODE) 
    {
        return getNextSibling(newNode, node);
    }
    
    
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:37,代碼來源:TwsTreeWalker.java

示例15: getLastChild

import org.w3c.dom.traversal.NodeFilter; //導入依賴的package包/類
/** Internal function.
 *  Return the last child Node, from the input node
 *  after applying filter, whatToshow.
 *  The current node is not consulted or set.
 */
Node getLastChild(Node node) {
    
    if (node == null) return null;
    
    if ( !fEntityReferenceExpansion
         && node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
        return null;
        
    Node newNode = node.getLastChild();
    if (newNode == null)  return null; 
    
    int accept = acceptNode(newNode);
    
    if (accept == NodeFilter.FILTER_ACCEPT)
        return newNode;
    else 
    if (accept == NodeFilter.FILTER_SKIP
        && newNode.hasChildNodes()) 
    {
        Node lChild = getLastChild(newNode);
        if (lChild == null) {
            return getPreviousSibling(newNode, node);
        }
        return lChild;
    }
    else 
    //if (accept == NodeFilter.REJECT_NODE) 
    {
        return getPreviousSibling(newNode, node);
    }
    
    
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:39,代碼來源:TwsTreeWalker.java


注:本文中的org.w3c.dom.traversal.NodeFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。