/** * Creates a new instance with the given Document as target for marshalling. * * @param namespaces Namespaces list * @param document must not be null */ public JDOMWriter(String[] namespaces, Document document) { this(namespaces); this.document = document; if(document.hasRootElement()) { this.currentElement = document.getRootElement(); } }
/** * This will return all content for the <code>Document</code>. * The returned list is "live" in document order and changes to it * affect the document's actual content. * * <p> * Sequential traversal through the List is best done with a Iterator * since the underlying implement of List.size() may require walking the * entire list. * </p> * * @return <code>List</code> - all Document content * @throws IllegalStateException if the root element hasn't been set */ public List getContent() { if (!hasRootElement()) throw new IllegalStateException("Root element not set"); return content; }
/** * Return a filtered view of this <code>Document</code>'s content. * * <p> * Sequential traversal through the List is best done with a Iterator * since the underlying implement of List.size() may require walking the * entire list. * </p> * * @param filter <code>Filter</code> to apply * @return <code>List</code> - filtered Document content * @throws IllegalStateException if the root element hasn't been set */ public List getContent(Filter filter) { if (!hasRootElement()) throw new IllegalStateException("Root element not set"); return content.getView(filter); }
/** * This returns a <code>String</code> representation of the * <code>Document</code>, suitable for debugging. If the XML * representation of the <code>Document</code> is desired, * {@link org.jdom.output.XMLOutputter#outputString(Document)} * should be used. * * @return <code>String</code> - information about the * <code>Document</code> */ public String toString() { StringBuffer stringForm = new StringBuffer() .append("[Document: "); DocType docType = getDocType(); if (docType != null) { stringForm.append(docType.toString()) .append(", "); } else { stringForm.append(" No DOCTYPE declaration, "); } if (hasRootElement()) { stringForm.append("Root is ") .append(getRootElement().toString()); } else { stringForm.append(" No root element"); // shouldn't happen } stringForm.append("]"); return stringForm.toString(); }
if (!dom.hasRootElement()) { return dataFilesMap;
Document xmlDocument = builder.build(tempFile); if (xmlDocument != null && xmlDocument.hasRootElement()) { return xmlDocument.getRootElement(); } else {
if (doc.hasRootElement()) return doc.getRootElement(); else
if (doc.hasRootElement() == false) { doc = null;