private NodeListImpl internalGetElementsByTagName(String tagName) { // System.out.println("getElementsByTagname: " + tagName); NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false); if (it == null) return new NodeListImpl(); NodeListImpl elements = new NodeListImpl(); if (tagName.length() == 1 && tagName.charAt(0) == '*') { tagName = null; // do not care } for (Node node = it.nextNode(); node != null; node = it.nextNode()) { if (node.getNodeType() != ELEMENT_NODE) continue; if (tagName != null) { ElementImpl element = (ElementImpl) node; if (!element.matchTagName(tagName)) continue; } elements.appendNode(node); } if (usetagnamecache) { tagNameCache.addItem(tagName, elements); } return elements; }
/** * getElementsByTagName method * * @return org.w3c.dom.NodeList * @param tagName * java.lang.String */ public NodeList getElementsByTagName(String tagName) { if (tagName == null) return new NodeListImpl(); NodeListImpl elements = null; if (usetagnamecache) { elements = tagNameCache.getItem(tagName); } if (elements == null) { elements = internalGetElementsByTagName(tagName); } return elements; }
/** * @param b */ void activateTagNameCache(boolean b) { tagNameCache.activate(b); }
/** * DocumentImpl constructor * * @param that * DocumentImpl */ protected DocumentImpl(DocumentImpl that) { super(that); if (usetagnamecache) { tagNameCache = new TagNameCache(); } }
/** * @param b */ public void activate(boolean b) { active = b; if (!b) clear(); }
/** * DocumentImpl constructor */ protected DocumentImpl() { super(); if (usetagnamecache) { tagNameCache = new TagNameCache(); } }