/** * Consumes and returns all child elements selected by the interpreter. Note * that text nodes are not elements, and so are not presented for * interpretation, and are not consumed. * * @param interpreter Should return true for any child that should be consumed * and returned by the consumeChildElements call * @throws UnableToCompleteException */ public Collection<XMLElement> consumeChildElements(Interpreter<Boolean> interpreter) throws UnableToCompleteException { List<XMLElement> elements = new ArrayList<XMLElement>(); List<Node> doomed = new ArrayList<Node>(); NodeList childNodes = elem.getChildNodes(); for (int i = 0; i < childNodes.getLength(); ++i) { Node childNode = childNodes.item(i); if (childNode.getNodeType() == Node.ELEMENT_NODE) { XMLElement childElement = provider.get((Element) childNode); if (interpreter.interpretElement(childElement)) { elements.add(childElement); doomed.add(childNode); } } } for (Node n : doomed) { elem.removeChild(n); } return elements; }
/** * Consumes and returns all child elements selected by the interpreter. Note * that text nodes are not elements, and so are not presented for * interpretation, and are not consumed. * * @param interpreter Should return true for any child that should be consumed * and returned by the consumeChildElements call * @throws UnableToCompleteException */ public Collection<XMLElement> consumeChildElements(Interpreter<Boolean> interpreter) throws UnableToCompleteException { List<XMLElement> elements = new ArrayList<XMLElement>(); List<Node> doomed = new ArrayList<Node>(); NodeList childNodes = elem.getChildNodes(); for (int i = 0; i < childNodes.getLength(); ++i) { Node childNode = childNodes.item(i); if (childNode.getNodeType() == Node.ELEMENT_NODE) { XMLElement childElement = provider.get((Element) childNode); if (interpreter.interpretElement(childElement)) { elements.add(childElement); doomed.add(childNode); } } } for (Node n : doomed) { elem.removeChild(n); } return elements; }
/** * Consumes and returns all child elements selected by the interpreter. Note * that text nodes are not elements, and so are not presented for * interpretation, and are not consumed. * * @param interpreter Should return true for any child that should be consumed * and returned by the consumeChildElements call * @throws UnableToCompleteException */ public Collection<XMLElement> consumeChildElements(Interpreter<Boolean> interpreter) throws UnableToCompleteException { List<XMLElement> elements = new ArrayList<XMLElement>(); List<Node> doomed = new ArrayList<Node>(); NodeList childNodes = elem.getChildNodes(); for (int i = 0; i < childNodes.getLength(); ++i) { Node childNode = childNodes.item(i); if (childNode.getNodeType() == Node.ELEMENT_NODE) { XMLElement childElement = provider.get((Element) childNode); if (interpreter.interpretElement(childElement)) { elements.add(childElement); doomed.add(childNode); } } } for (Node n : doomed) { elem.removeChild(n); } return elements; }
/** * Consumes and returns all child elements selected by the interpreter. Note * that text nodes are not elements, and so are not presented for * interpretation, and are not consumed. * * @param interpreter Should return true for any child that should be consumed * and returned by the consumeChildElements call * @throws UnableToCompleteException */ public Collection<XMLElement> consumeChildElements(Interpreter<Boolean> interpreter) throws UnableToCompleteException { List<XMLElement> elements = new ArrayList<XMLElement>(); List<Node> doomed = new ArrayList<Node>(); NodeList childNodes = elem.getChildNodes(); for (int i = 0; i < childNodes.getLength(); ++i) { Node childNode = childNodes.item(i); if (childNode.getNodeType() == Node.ELEMENT_NODE) { XMLElement childElement = provider.get((Element) childNode); if (interpreter.interpretElement(childElement)) { elements.add(childElement); doomed.add(childNode); } } } for (Node n : doomed) { elem.removeChild(n); } return elements; }
@Override public String interpretElement(XMLElement elem) throws UnableToCompleteException { fieldAndComputed.interpretElement(elem); if (isDomPlaceholder(elem)) { MessagesWriter mw = uiWriter.getMessages(); String name = mw.consumeMessageAttribute("ph", elem); if ("".equals(name)) { name = "htmlElement" + (++serial); } String openTag = elem.consumeOpeningTag(); String openPlaceholder = nextOpenPlaceholder(name + "Begin", uiWriter.detokenate(openTag)); /* * This recursive innerHtml call has already been escaped. Hide it in a * token to avoid double escaping */ String body = tokenator.nextToken(elem.consumeInnerHtml(this)); String closeTag = elem.getClosingTag(); String closePlaceholder = nextClosePlaceholder(name + "End", closeTag); return openPlaceholder + body + closePlaceholder; } return super.interpretElement(elem); }
@Override public String interpretElement(XMLElement elem) throws UnableToCompleteException { fieldAndComputed.interpretElement(elem); if (isDomPlaceholder(elem)) { MessagesWriter mw = uiWriter.getMessages(); String name = mw.consumeMessageAttribute("ph", elem); if ("".equals(name)) { name = "htmlElement" + (++serial); } String openTag = elem.consumeOpeningTag(); String openPlaceholder = nextOpenPlaceholder(name + "Begin", uiWriter.detokenate(openTag)); /* * This recursive innerHtml call has already been escaped. Hide it in a * token to avoid double escaping */ String body = tokenator.nextToken(elem.consumeInnerHtml(this)); String closeTag = elem.getClosingTag(); String closePlaceholder = nextClosePlaceholder(name + "End", closeTag); return openPlaceholder + body + closePlaceholder; } return super.interpretElement(elem); }
/** * Interpreters are fired in the order they were handed to the constructor. If * an interpreter gives a non-null result, downstream interpreters don't * fire. * * @return The T or null returned by the last pipelined interpreter to run * @throws UnableToCompleteException on error */ public T interpretElement(XMLElement elem) throws UnableToCompleteException { T rtn = null; for (XMLElement.Interpreter<T> i : pipe) { rtn = i.interpretElement(elem); if (null != rtn) { break; } } return rtn; }
/** * Interpreters are fired in the order they were handed to the constructor. If * an interpreter gives a non-null result, downstream interpreters don't * fire. * * @return The T or null returned by the last pipelined interpreter to run * @throws UnableToCompleteException on error */ public T interpretElement(XMLElement elem) throws UnableToCompleteException { T rtn = null; for (XMLElement.Interpreter<T> i : pipe) { rtn = i.interpretElement(elem); if (null != rtn) { break; } } return rtn; }
@Override public void visitElement(Element elem) throws UnableToCompleteException { XMLElement xmlElement = elementProvider.get(elem); String replacement = interpreter.interpretElement(xmlElement); if (replacement != null) { buffer.append(replacement); return; } // TODO(jgw): Ditch the closing tag when there are no children. buffer.append(xmlElement.consumeOpeningTag()); getEscapedInnerHtml(elem, buffer, interpreter, elementProvider); buffer.append(xmlElement.getClosingTag()); } }
@Override public void visitElement(Element elem) throws UnableToCompleteException { XMLElement xmlElement = elementProvider.get(elem); String replacement = interpreter.interpretElement(xmlElement); if (replacement != null) { buffer.append(replacement); return; } // TODO(jgw): Ditch the closing tag when there are no children. buffer.append(xmlElement.consumeOpeningTag()); getEscapedInnerHtml(elem, buffer, interpreter, elementProvider); buffer.append(xmlElement.getClosingTag()); } }
public void visitElement(Element e) throws UnableToCompleteException { String replacement = interpreter.interpretElement(elementProvider.get(e)); if (replacement != null) { buffer.append(replacement); } }
public void visitElement(Element e) throws UnableToCompleteException { String replacement = interpreter.interpretElement(elementProvider.get(e)); if (replacement != null) { buffer.append(replacement); } }
@Override public String interpretElement(XMLElement elem) throws UnableToCompleteException { fieldAndComputed.interpretElement(elem); if (isDomPlaceholder(elem)) { MessagesWriter mw = uiWriter.getMessages(); String name = mw.consumeMessageAttribute("ph", elem); if ("".equals(name)) { name = "htmlElement" + (++serial); } String openTag = elem.consumeOpeningTag(); String openPlaceholder = nextOpenPlaceholder(name + "Begin", uiWriter.detokenate(openTag)); /* * This recursive innerHtml call has already been escaped. Hide it in a * token to avoid double escaping */ String body = tokenator.nextToken(elem.consumeInnerHtml(this)); String closeTag = elem.getClosingTag(); String closePlaceholder = nextClosePlaceholder(name + "End", closeTag); return openPlaceholder + body + closePlaceholder; } return super.interpretElement(elem); }
/** * Interpreters are fired in the order they were handed to the constructor. If * an interpreter gives a non-null result, downstream interpreters don't * fire. * * @return The T or null returned by the last pipelined interpreter to run * @throws UnableToCompleteException on error */ public T interpretElement(XMLElement elem) throws UnableToCompleteException { T rtn = null; for (XMLElement.Interpreter<T> i : pipe) { rtn = i.interpretElement(elem); if (null != rtn) { break; } } return rtn; }