|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.xml.DocumentReader
org.mmbase.util.xml.DocumentWriter
public abstract class DocumentWriter
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.
| Field Summary | |
|---|---|
(package private) String |
publicId
|
(package private) String |
systemId
|
| Fields inherited from class org.mmbase.util.xml.DocumentReader |
|---|
document, DTD_ERROR, DTD_ERROR_1_0, FILENOTFOUND, PUBLIC_ID_ERROR, PUBLIC_ID_ERROR_1_0, utilProperties |
| Constructor Summary | |
|---|---|
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. |
|
| 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. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
String publicId
String systemId
| Constructor Detail |
|---|
public 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 type
DOMException
public 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 location
DOMExceptionpublic DocumentWriter(InputSource source)
source - the input source from which to read the document
public 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 unknown| Method Detail |
|---|
protected void getMessageRetriever(String resourcelocation)
resourcelocation - Resource.protected String getMessage(String key)
key - the key of the message
protected String getMessage(String key,
String a1)
key - the key of the messagea1 - the first parameter to substitute in the message
protected 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 message
protected 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 message
protected 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 generation
public final Document generateDocument()
throws DOMException
DOMException - when an error occurred during generation
DOMException - when the document was already constructed
public 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 malformed
public void writeToFile(String filename)
throws IOException,
TransformerException
filename - the filepath where the configuration is to be stored
TransformerException - if the document is malformed
IOException - if the file cannot be written
public void writeToStream(OutputStream out)
throws TransformerException
out - the output stream where the configuration is to be stored
TransformerException
public void write(StreamResult result)
throws TransformerException
result - the StreamResult object where to store the configuration'
TransformerException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||