public List operate(Object node) { if (node instanceof Element) return((Element) node).getContent(); else if (node instanceof Document) return((Document) node).getContent(); // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_content can not be applied on " + node.getClass()); } }
public List cloneContent() { final int size = getContentSize(); final List list = new ArrayList(size); for (int i = 0; i < size; i++) { final Content child = getContent(i); list.add(child.clone()); } return list; }
@Override void getContent(Object node, List result) { if (node instanceof Element) result.addAll(((Element) node).getContent()); else if (node instanceof Document) result.addAll(((Document) node).getContent()); }
public Iterator getChildAxisIterator(Object contextNode) { if ( contextNode instanceof Element ) { return ((Element)contextNode).getContent().iterator(); } else if ( contextNode instanceof Document ) { return ((Document)contextNode).getContent().iterator(); } return JaxenConstants.EMPTY_ITERATOR; }
public String getElementStringValue(Object obj) { Element elem = (Element) obj; StringBuffer buf = new StringBuffer(); List content = elem.getContent(); Iterator contentIter = content.iterator(); Object each = null; while ( contentIter.hasNext() ) { each = contentIter.next(); if ( each instanceof Text ) { buf.append( ((Text)each).getText() ); } else if ( each instanceof CDATA ) { buf.append( ((CDATA)each).getText() ); } else if ( each instanceof Element ) { buf.append( getElementStringValue( each ) ); } } return buf.toString(); }
protected String getXmlInnerText(Element e) { StringBuffer sb = new StringBuffer(); XMLOutputter xo = new XMLOutputter(); List children = e.getContent(); sb.append(xo.outputString(children)); return sb.toString(); } }
protected String getXmlInnerText(Element e) { StringBuffer sb = new StringBuffer(); XMLOutputter xo = new XMLOutputter(); List children = e.getContent(); sb.append(xo.outputString(children)); return sb.toString(); } }
public boolean isLeaf() { if (node instanceof Element) { return ((Element) node).getContent().size() == 0; } if (node instanceof Document) { return ((Document) node).getContent().size() == 0; } return true; }
private static String toString(final Element element) { final XMLOutputter outp = new XMLOutputter(); final StringBuilder buffer = new StringBuilder(1024); final List<?> children = element.getContent(); final String string = outp.outputString(children); buffer.append(string); return buffer.toString().trim(); }
private Element getFirstContent(Element element, String name) { List filterList = element.getContent(new ContentFilter(name)); Element firstContent = null; if ((filterList != null) && (filterList.size() > 0)) { firstContent = (Element) filterList.get(0); } return firstContent; }
public List operate(Object node) { if (node instanceof Element) return((Element)node).getContent(); else if (node instanceof Document) return((Document)node).getContent(); // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_content can not be applied on " + node.getClass()); } }
public List operate(Object node) { if (node instanceof Element) return((Element) node).getContent(); else if (node instanceof Document) return((Document) node).getContent(); // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_content can not be applied on " + node.getClass()); } }
private Element getFirstContent(Element element, String name) { List filterList = element.getContent(new ContentFilter(name)); Element firstContent = null; if ((filterList != null) && (filterList.size() > 0)) { firstContent = (Element) filterList.get(0); } return firstContent; }
@SuppressWarnings("unchecked") public static List<Comment> getCommentsInContent(Element element) { return element.getContent(new ContentFilter( ContentFilter.COMMENT)); } }
public static String loadMetaInf(String key, String defValue) { try { InputStream in = CommonUtil.class.getClassLoader().getResourceAsStream("/META-INF/plugin.xml"); SAXBuilder builder = new SAXBuilder(); org.jdom.Document document = builder.build(in); return document.getRootElement().getChild(key).getContent().get(0).getValue(); } catch (JDOMException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return defValue; }
public void remove() { Element parent = nodeParent(node); if (parent == null) { throw new JXPathException("Cannot remove root JDOM node"); } parent.getContent().remove(node); }
private String getTextContent(Element elem) { String text = elem.getContent().toString(); final List<Element> children = elem.getChildElements(); for (Element child : children) { text = text.replace(child.toString(), ""); } return text; }
public static Element cdr (final Content c) { final Element elt = toElement(c); if (elt.getContent().size() < 1) throw new IllegalArgumentException("cannot cdr an empty element"); Element result = (Element)elt.clone(); //log.debug("cdr() before \n"+XmlUtils.toString(result)); result = removeFirstChild(result); //log.debug("cdr() after \n"+XmlUtils.toString(result)); return result; }
@Override protected ElementFrame<Element, Integer> getChildFrame() { int currentChild = getCurrentFrame().getCurrentChild(); return new ElementFrame<Element, Integer>((Element)getCurrentElement().getContent(currentChild), getCurrentFrame(), -1); }
@Override protected ElementFrame<Element, Integer> getChildFrame() { int currentChild = getCurrentFrame().getCurrentChild(); return new ElementFrame<Element, Integer>((Element)getCurrentElement().getContent(currentChild), getCurrentFrame(), -1); }