public abstract class DocumentWriter extends DocumentReader
| Modifier and Type | Field and Description |
|---|---|
(package private) String |
publicId |
(package private) String |
systemId |
document, DTD_ERROR, DTD_ERROR_1_0, FILENOTFOUND, PUBLIC_ID_ERROR, PUBLIC_ID_ERROR_1_0, utilProperties| Constructor and Description |
|---|
DocumentWriter(InputSource source)
Constructs the document by reading it from a source.
|
DocumentWriter(InputSource source,
boolean validating,
Class<?> resolveBase)
Constructs the document by reading it from a source.
|
DocumentWriter(String qualifiedName,
String publicId,
String systemId)
Constructs the document writer.
|
DocumentWriter(String qualifiedName,
String publicId,
String systemId,
boolean schema)
Constructs the document writer.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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.
|
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.
|
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.
|
protected abstract void |
generate()
Generates the document.
|
Document |
generateDocument()
Generates the document if it hadn't be done so already.
|
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.
|
boolean |
includeComments()
Gets whether the document will include comments
|
void |
setIncludeComments(boolean value)
Sets whether the document will include comments
|
void |
write(StreamResult result)
Generates the document and writes it to the result object.
|
void |
writeToFile(String filename)
Generates the document and store it as a file in the given path.
|
void |
writeToStream(OutputStream out)
Generates the document and store it in the given stream.
|
String |
writeToString()
Generates the document and returns it as a string.
|
appendChild, getAttribute, getChildElements, getChildElements, getChildElements, getChildElements, getDocumentBuilder, getDocumentBuilder, getDocumentBuilder, getDocumentBuilder, getElementAttributeValue, getElementAttributeValue, getElementByPath, getElementByPath, getElementName, getElementValue, getElementValue, getNodeTextValue, getNodeTextValue, getRootElement, getSystemId, hasAttribute, main, registerPublicIDs, setNodeTextValue, setPrefix, setSystemId, toDocument, validate, validatepublic DocumentWriter(String qualifiedName, String publicId, String systemId) throws DOMException
generateDocument(), which is in turn called when
the document is first accessed through getDocument().qualifiedName - the qualified name of the document's root elementpublicId - the PUBLIC id of the document typesystemId - the SYSTEm id of the document typeDOMExceptionpublic DocumentWriter(String qualifiedName, String publicId, String systemId, boolean schema) throws DOMException
generateDocument(), which is in turn called when
the document is first accessed through getDocument().qualifiedName - the qualified name of the document's root elementpublicId - the PUBLIC id of the document typesystemId - the SYSTEm id of the document typeschema - should the publicId and systemId interpreted as XSD namespace and locationDOMExceptionpublic DocumentWriter(InputSource source)
source - the input source from which to read the documentpublic DocumentWriter(InputSource source, boolean validating, Class<?> resolveBase)
source - the input source from which to read the documentvalidating - whether to validate the documentresolveBase - the base class whose package is used to resolve dtds, set to null if unknownprotected void getMessageRetriever(String resourcelocation)
resourcelocation - Resource.protected String getMessage(String key)
key - the key of the messageprotected String getMessage(String key, String a1)
key - the key of the messagea1 - the first parameter to substitute in the messageprotected String getMessage(String key, String a1, String a2)
key - the key of the messagea1 - the first parameter to substitute in the messagea2 - the second parameter to substitute in the messageprotected String getMessage(String key, String a1, String a2, String a3)
key - the key of the messagea1 - the first parameter to substitute in the messagea2 - the second parameter to substitute in the messagea3 - the third parameter to substitute in the messageprotected Element addContentElement(String tagname, String content, Element out)
tagname - name of the new elementcontent - content of the new element as a stringout - the element to which to add the new Element.protected Comment addComment(String key, Element out)
key - the key of the comment to add as a stringout - the element to which to add the new Comment.setIncludeComments(boolean)protected Comment addComment(String key, String a1, Element out)
key - the key of the comment to add as a stringa1 - the first parameter to substitute in the commentout - the element to which to add the new Comment.setIncludeComments(boolean)protected Comment addComment(String key, String a1, String a2, Element out)
key - the comment to add as a stringa1 - the first parameter to substitute in the commenta2 - the second parameter to substitute in the commentout - the element to which to add the new Comment.setIncludeComments(boolean)protected abstract void generate()
throws DOMException
DOMException - when an error occurred during generationpublic final Document generateDocument() throws DOMException
DOMException - when an error occurred during generationDOMException - when the document was already constructedpublic Document getDocument() throws DOMException
getDocument in class DocumentReaderDOMException - when an error occurred during generationpublic void setIncludeComments(boolean value)
value - if true, the document will include commentspublic boolean includeComments()
public String writeToString() throws TransformerException
TransformerException - if the document is malformedpublic void writeToFile(String filename) throws IOException, TransformerException
filename - the filepath where the configuration is to be storedTransformerException - if the document is malformedIOException - if the file cannot be writtenpublic void writeToStream(OutputStream out) throws TransformerException
out - the output stream where the configuration is to be storedTransformerExceptionpublic void write(StreamResult result) throws TransformerException
result - the StreamResult object where to store the configuration'TransformerExceptionMMBase 1.9-SNAPSHOT - ${javadoctimestamp}