| java.lang.Object org.mmbase.util.xml.DocumentReader org.mmbase.util.xml.DocumentWriter
All known Subclasses: org.mmbase.util.xml.ApplicationWriter, org.mmbase.util.xml.ModuleWriter, org.mmbase.util.xml.BuilderWriter,
DocumentWriter | abstract public class DocumentWriter extends DocumentReader (Code) | | Abstract class for creating xml documents.
Use this class as the base class for writers that construct and export DOM documents.
The document can then be used internally or serialized using a number of
utility methods.
since: MMBase-1.6 author: Pierre van Rooden version: $Id: DocumentWriter.java,v 1.11 2007/02/24 21:57:50 nklasens Exp $ |
Constructor Summary | |
public | DocumentWriter(String qualifiedName, String publicId, String systemId) Constructs the document writer. | public | DocumentWriter(InputSource source) Constructs the document by reading it from a source. | public | DocumentWriter(InputSource source, boolean validating, Class> resolveBase) Constructs the document by reading it from a source.
You can pass a resolve class to this constructor, allowing you to indicate the package in which the dtd
of the document read is to be found. |
Method Summary | |
protected Comment | addComment(String key, Element out) Creates a Comment (provided comments should be included), and adds it to the
specified node as a child.
The comment is retrieved from a resource bundle - if no resource was specified,
no comments are added.
Parameters: key - the key of the comment to add as a string Parameters: out - the element to which to add the new Comment. | protected Comment | addComment(String key, String a1, Element out) Creates a Comment (provided comments should be included), and adds it to the
specified node as a child.
The comment is retrieved from a resource bundle - if no resource was specified,
no comments are added.
Parameters: key - the key of the comment to add as a string Parameters: a1 - the first parameter to substitute in the comment Parameters: out - the element to which to add the new Comment. | protected Comment | addComment(String key, String a1, String a2, Element out) Creates a Comment (provided comments should be included), and adds it to the
specified node as a child.
The comment is retrieved from a resource bundle - if no resource was specified,
no comments are added.
Parameters: key - the comment to add as a string Parameters: a1 - the first parameter to substitute in the comment Parameters: a2 - the second parameter to substitute in the comment Parameters: out - the element to which to add the new Comment. | protected Element | addContentElement(String tagname, String content, Element out) Creates a DOM element which contains a Text Node, and adds it to the
specified node as a child.
Parameters: tagname - name of the new element Parameters: content - content of the new element as a string Parameters: out - the element to which to add the new Element. | abstract protected void | generate() Generates the document. | final public Document | generateDocument() Generates the document if it hadn't be done so already. | public Document | getDocument() Returns the completed document representation;
If the document was not yet generated, it is generated by calling generateDocument(). | protected String | getMessage(String key) Retrieves a message from the resource bundle. | protected String | getMessage(String key, String a1) Retrieves a message from the resource bundle. | protected String | getMessage(String key, String a1, String a2) Retrieves a message from the resource bundle. | protected String | getMessage(String key, String a1, String a2, String a3) Retrieves a message from the resource bundle. | protected void | getMessageRetriever(String resourcelocation) Initialize the ResourceBundle with the given resource. | public boolean | includeComments() | public void | setIncludeComments(boolean value) | public void | write(StreamResult result) Generates the document and writes it to the result object. | public void | writeToFile(String filename) Generates the document and store it as a file in the given path. | public void | writeToStream(OutputStream out) Generates the document and store it in the given stream. | public String | writeToString() Generates the document and returns it as a string. |
DocumentWriter | public DocumentWriter(String qualifiedName, String publicId, String systemId) throws DOMException(Code) | | Constructs the document writer.
The constructor creates a basic document with a root element based on the specified document type parameters.
The document is empty after construction.
It is actually filled with a call to
DocumentWriter.generateDocument() , which is in turn called when
the document is first accessed through
DocumentWriter.getDocument() .
Parameters: qualifiedName - the qualified name of the document's root element Parameters: publicId - the PUBLIC id of the document type Parameters: systemId - the SYSTEm id of the document type |
DocumentWriter | public DocumentWriter(InputSource source)(Code) | | Constructs the document by reading it from a source.
Parameters: source - the input source from which to read the document since: MMBase-1.7 |
DocumentWriter | public DocumentWriter(InputSource source, boolean validating, Class> resolveBase)(Code) | | Constructs the document by reading it from a source.
You can pass a resolve class to this constructor, allowing you to indicate the package in which the dtd
of the document read is to be found. The dtd sould be in the resources package under the package of the class passed.
Parameters: source - the input source from which to read the document Parameters: validating - whether to validate the document Parameters: resolveBase - the base class whose package is used to resolve dtds, set to null if unknown since: MMBase-1.7 |
addComment | protected Comment addComment(String key, Element out)(Code) | | Creates a Comment (provided comments should be included), and adds it to the
specified node as a child.
The comment is retrieved from a resource bundle - if no resource was specified,
no comments are added.
Parameters: key - the key of the comment to add as a string Parameters: out - the element to which to add the new Comment. the newly created comment or null if nothing was added See Also: DocumentWriter.setIncludeComments |
addComment | protected Comment addComment(String key, String a1, Element out)(Code) | | Creates a Comment (provided comments should be included), and adds it to the
specified node as a child.
The comment is retrieved from a resource bundle - if no resource was specified,
no comments are added.
Parameters: key - the key of the comment to add as a string Parameters: a1 - the first parameter to substitute in the comment Parameters: out - the element to which to add the new Comment. the newly created comment or null if nothing was added See Also: DocumentWriter.setIncludeComments |
addComment | protected Comment addComment(String key, String a1, String a2, Element out)(Code) | | Creates a Comment (provided comments should be included), and adds it to the
specified node as a child.
The comment is retrieved from a resource bundle - if no resource was specified,
no comments are added.
Parameters: key - the comment to add as a string Parameters: a1 - the first parameter to substitute in the comment Parameters: a2 - the second parameter to substitute in the comment Parameters: out - the element to which to add the new Comment. the newly created comment or null if nothing was added See Also: DocumentWriter.setIncludeComments |
addContentElement | protected Element addContentElement(String tagname, String content, Element out)(Code) | | Creates a DOM element which contains a Text Node, and adds it to the
specified node as a child.
Parameters: tagname - name of the new element Parameters: content - content of the new element as a string Parameters: out - the element to which to add the new Element. the newly created element |
generate | abstract protected void generate() throws DOMException(Code) | | Generates the document.
You need to override this class with the code that constructs your document.
throws: DOMException - when an error occurred during generation |
generateDocument | final public Document generateDocument() throws DOMException(Code) | | Generates the document if it hadn't be done so already.
If not, an exception is thrown.
Use getDocument() to safely retrive a generated coeumnt.
throws: DOMException - when an error occurred during generation throws: DOMException - when the document was already constructed |
getDocument | public Document getDocument() throws DOMException(Code) | | Returns the completed document representation;
If the document was not yet generated, it is generated by calling generateDocument().
the generated document throws: DOMException - when an error occurred during generation |
getMessage | protected String getMessage(String key)(Code) | | Retrieves a message from the resource bundle.
Parameters: key - the key of the message |
getMessage | protected String getMessage(String key, String a1)(Code) | | Retrieves a message from the resource bundle.
Parameters: key - the key of the message Parameters: a1 - the first parameter to substitute in the message |
getMessage | protected String getMessage(String key, String a1, String a2)(Code) | | Retrieves a message from the resource bundle.
Parameters: key - the key of the message Parameters: a1 - the first parameter to substitute in the message Parameters: a2 - the second parameter to substitute in the message |
getMessage | protected String getMessage(String key, String a1, String a2, String a3)(Code) | | Retrieves a message from the resource bundle.
Parameters: key - the key of the message Parameters: a1 - the first parameter to substitute in the message Parameters: a2 - the second parameter to substitute in the message Parameters: a3 - the third parameter to substitute in the message |
getMessageRetriever | protected void getMessageRetriever(String resourcelocation)(Code) | | Initialize the ResourceBundle with the given resource.
You need a respource to use the addfCOmment() and getMessage() methods.
Parameters: resourcelocation - Resource. |
includeComments | public boolean includeComments()(Code) | | Gets whether the document will include comments
if true, the document will include comments |
setIncludeComments | public void setIncludeComments(boolean value)(Code) | | Sets whether the document will include comments
Parameters: value - if true, the document will include comments |
write | public void write(StreamResult result) throws TransformerException(Code) | | Generates the document and writes it to the result object.
Parameters: result - the StreamResult object where to store the configuration' |
writeToStream | public void writeToStream(OutputStream out) throws TransformerException(Code) | | Generates the document and store it in the given stream.
Parameters: out - the output stream where the configuration is to be stored |
Methods inherited from org.mmbase.util.xml.DocumentReader | public static void appendChild(Element parent, Element newChild, String path)(Code)(Java Doc) public static String getAttribute(Element element, String nameSpace, String localName)(Code)(Java Doc) public List<Element> getChildElements(String path)(Code)(Java Doc) public List<Element> getChildElements(Element e)(Code)(Java Doc) public List<Element> getChildElements(String path, String tag)(Code)(Java Doc) public List<Element> getChildElements(Element e, String tag)(Code)(Java Doc) public static DocumentBuilder getDocumentBuilder()(Code)(Java Doc) public static DocumentBuilder getDocumentBuilder(boolean validating)(Code)(Java Doc) public static DocumentBuilder getDocumentBuilder(boolean validating, ErrorHandler handler, EntityResolver resolver)(Code)(Java Doc) public static DocumentBuilder getDocumentBuilder(boolean validating, boolean xsd, ErrorHandler handler, EntityResolver resolver)(Code)(Java Doc) public String getElementAttributeValue(String path, String attr)(Code)(Java Doc) public String getElementAttributeValue(Element e, String attr)(Code)(Java Doc) public Element getElementByPath(String path)(Code)(Java Doc) public Element getElementByPath(Element e, String path)(Code)(Java Doc) public String getElementName(Element e)(Code)(Java Doc) public String getElementValue(String path)(Code)(Java Doc) public String getElementValue(Element e)(Code)(Java Doc) public static String getNodeTextValue(Node n)(Code)(Java Doc) public static String getNodeTextValue(Node n, boolean trim)(Code)(Java Doc) public Element getRootElement()(Code)(Java Doc) public String getSystemId()(Code)(Java Doc) public static boolean hasAttribute(Element element, String nameSpace, String localName)(Code)(Java Doc) public static void main(String argv) throws Exception(Code)(Java Doc) public static void registerPublicIDs()(Code)(Java Doc) public static void setNodeTextValue(Node n, String value)(Code)(Java Doc) public static void setPrefix(Document d, String ns, String prefix)(Code)(Java Doc) public void setSystemId(String url)(Code)(Java Doc) public static Document toDocument(Element element)(Code)(Java Doc) final protected static boolean validate()(Code)(Java Doc) final protected static boolean validate(boolean requested)(Code)(Java Doc)
|
|
|