private static boolean isWhitespaceOnly(String str) { for (int i=str.length(); --i >= 0; ) { if (!isWhitespace(str.charAt(i))) return false; } return true; }
if (childFactory == null) childFactory = XOMUtil.getIgnoreWhitespaceOnlyTextNodeFactory(); return new StreamingPathFilterNodeFactory(_localNames, _namespaceURIs, childFactory, transform);
if (childFactory == null) childFactory = XOMUtil.getIgnoreWhitespaceOnlyTextNodeFactory(); return new StreamingPathFilterNodeFactory(_localNames, _namespaceURIs, childFactory, transform);
public Nodes finishMakingElement(Element elem) { // if (DEBUG) System.err.println("finishlevel=" + level + ", name="+ elem.getLocalName()); if (level == 0) { // root element must always be present; // a document without root element is illegal in XOM mismatch = null; // help gc level--; return super.finishMakingElement(elem); } if (elem == mismatch) { // reset state mismatch = null; level--; return NONE; } if (level == localNames.length - 1) { // we've found an element matching the full path expression return transformMatch(elem); } level--; if (level < localNames.length - 1 && !hasChildElements(elem)) { // prune tree if mismatch or empty return NONE; } return super.finishMakingElement(elem); }
public Nodes finishMakingElement(Element elem) { // if (DEBUG) System.err.println("finishlevel=" + level + ", name="+ elem.getLocalName()); if (level == 0) { // root element must always be present; // a document without root element is illegal in XOM mismatch = null; // help gc level--; return super.finishMakingElement(elem); } if (elem == mismatch) { // reset state mismatch = null; level--; return NONE; } if (level == localNames.length - 1) { // we've found an element matching the full path expression return transformMatch(elem); } level--; if (level < localNames.length - 1 && !hasChildElements(elem)) { // prune tree if mismatch or empty return NONE; } return super.finishMakingElement(elem); }
public Element startMakingElement(String qname, String namespaceURI) { level++; // if (DEBUG) System.err.println("startlevel=" + level + ", name="+ qname); // check against path, if needed if (mismatch == null && level < localNames.length) { if (!isMatch(qname, namespaceURI)) { // build this element despite mismatch; // so we can reset state in finishMakingElement() mismatch = super.startMakingElement(qname, namespaceURI); return mismatch; } } if (mismatch == null) { // no mismatch so far, build this element return super.startMakingElement(qname, namespaceURI); } else { // mismatch; no need to build this element level--; return null; } }
public Element startMakingElement(String qname, String namespaceURI) { level++; // if (DEBUG) System.err.println("startlevel=" + level + ", name="+ qname); // check against path, if needed if (mismatch == null && level < localNames.length) { if (!isMatch(qname, namespaceURI)) { // build this element despite mismatch; // so we can reset state in finishMakingElement() mismatch = super.startMakingElement(qname, namespaceURI); return mismatch; } } if (mismatch == null) { // no mismatch so far, build this element return super.startMakingElement(qname, namespaceURI); } else { // mismatch; no need to build this element level--; return null; } }
private static boolean isWhitespaceOnly(String str) { for (int i=str.length(); --i >= 0; ) { if (!isWhitespace(str.charAt(i))) return false; } return true; }
public Nodes makeText(String data) { // return mismatch == null ? child.makeText(data) : NONE; if (mismatch == null) { if (level == 0 && isWhitespaceOnly(data)) return NONE; // avoid accumulating whitespace garbage in root element (i.e. avoid hidden memory leak) else return child.makeText(data); } return NONE; }
public Nodes makeText(String data) { // return mismatch == null ? child.makeText(data) : NONE; if (mismatch == null) { if (level == 0 && isWhitespaceOnly(data)) return NONE; // avoid accumulating whitespace garbage in root element (i.e. avoid hidden memory leak) else return child.makeText(data); } return NONE; }