Package org.jibx.extras
Class JDOMWriter
- java.lang.Object
-
- org.jibx.runtime.impl.XMLWriterNamespaceBase
-
- org.jibx.extras.JDOMWriter
-
- All Implemented Interfaces:
IXMLWriter
public class JDOMWriter extends XMLWriterNamespaceBase
JDOM implementation of XML writer interface. TheDocumentthat is created can be accessed by usinggetDocument().- Version:
- 1.0
- Author:
- Andreas Brenk
-
-
Field Summary
Fields Modifier and Type Field Description private ElementcurrentElementThe currently openElementthat is used for add* methods.private DocumentdocumentThe JDOMDocumentthis writer is creating.-
Fields inherited from class org.jibx.runtime.impl.XMLWriterNamespaceBase
m_prefixes, m_uris
-
-
Constructor Summary
Constructors Constructor Description JDOMWriter(java.lang.String[] namespaces)Creates a new instance with the given namespace URIs.JDOMWriter(java.lang.String[] namespaces, Document document)Creates a new instance with the given Document as target for marshalling.JDOMWriter(java.lang.String[] namespaces, Element currentElement)Creates a new instance with the given Element as target for marshalling.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(int index, java.lang.String name, java.lang.String value)Add attribute to current open start tag.voidclose()Does nothing.voidcloseEmptyTag()Close the current open start tag as an empty element.voidcloseStartTag()Close the current open start tag.protected voiddefineNamespace(int index, java.lang.String prefix)Does nothing.voidendTag(int index, java.lang.String name)Generate end tag.voidflush()Does nothing.DocumentgetDocument()private NamespacegetNamespace(int index)This will retrieve (if in existence) or create (if not) aNamespacefor the supplied namespace index.voidindent()Does nothing.voidinit()Does nothing.voidreset()Reset to initial state for reuse.voidsetIndentSpaces(int count, java.lang.String newline, char indent)Does nothing.voidstartTagClosed(int index, java.lang.String name)Generate closed start tag.voidstartTagNamespaces(int index, java.lang.String name, int[] nums, java.lang.String[] prefs)Generate start tag for element with namespaces.voidstartTagOpen(int index, java.lang.String name)Generate open start tag.protected voidundefineNamespace(int index)Does nothing.voidwriteCData(java.lang.String text)Write CDATA text to document.voidwriteComment(java.lang.String text)Write comment to document.voidwriteDocType(java.lang.String name, java.lang.String sys, java.lang.String pub, java.lang.String subset)Write DOCTYPE declaration to document.voidwriteEntityRef(java.lang.String name)Write entity reference to document.voidwritePI(java.lang.String target, java.lang.String data)Write processing instruction to document.voidwriteTextContent(java.lang.String text)Write ordinary character data text content to document.voidwriteXMLDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone)Does nothing.-
Methods inherited from class org.jibx.runtime.impl.XMLWriterNamespaceBase
decrementNesting, getExtensionNamespaces, getNamespaceCount, getNamespacePrefix, getNamespaces, getNamespaceUri, getNestingDepth, getPrefixIndex, growArray, incrementNesting, internalNamespacePrefix, internalNamespaceUri, internalSetUris, openNamespaces, popExtensionNamespaces, popTranslationTable, pushExtensionNamespaces, pushTranslationTable, shrinkArray, translateNamespace
-
-
-
-
Constructor Detail
-
JDOMWriter
public JDOMWriter(java.lang.String[] namespaces)
Creates a new instance with the given namespace URIs.
-
JDOMWriter
public JDOMWriter(java.lang.String[] namespaces, Document document)Creates a new instance with the given Document as target for marshalling.- Parameters:
document- must not be null
-
JDOMWriter
public JDOMWriter(java.lang.String[] namespaces, Element currentElement)Creates a new instance with the given Element as target for marshalling.- Parameters:
currentElement- must not be null
-
-
Method Detail
-
init
public void init()
Does nothing.
-
setIndentSpaces
public void setIndentSpaces(int count, java.lang.String newline, char indent)Does nothing.- Parameters:
count- number of character to indent per level, or disable indentation if negative (zero means new line only)newline- sequence of characters used for a line ending (nullmeans use the single character '\n')indent- whitespace character used for indentation
-
writeXMLDecl
public void writeXMLDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone) throws java.io.IOExceptionDoes nothing.- Parameters:
version- XML version textencoding- text for encoding attribute (unspecified ifnull)standalone- text for standalone attribute (unspecified ifnull)- Throws:
java.io.IOException- on error writing to document
-
startTagOpen
public void startTagOpen(int index, java.lang.String name) throws java.io.IOExceptionDescription copied from interface:IXMLWriterGenerate open start tag. This allows attributes and/or namespace declarations to be added to the start tag, but must be followed by aIXMLWriter.closeStartTag()call.- Parameters:
index- namespace URI index numbername- unqualified element name- Throws:
java.io.IOException- on error writing to document
-
startTagNamespaces
public void startTagNamespaces(int index, java.lang.String name, int[] nums, java.lang.String[] prefs) throws java.io.IOExceptionDescription copied from interface:IXMLWriterGenerate start tag for element with namespaces. This creates the actual start tag, along with any necessary namespace declarations. Previously active namespace declarations are not duplicated. The tag is left incomplete, allowing other attributes to be added.- Parameters:
index- namespace URI index numbername- element namenums- array of namespace indexes defined by this element (must be constant, reference is kept until end of element)prefs- array of namespace prefixes mapped by this element (nonullvalues, use "" for default namespace declaration)- Throws:
java.io.IOException- on error writing to document
-
addAttribute
public void addAttribute(int index, java.lang.String name, java.lang.String value) throws java.io.IOExceptionDescription copied from interface:IXMLWriterAdd attribute to current open start tag. This is only valid after a call toIXMLWriter.startTagOpen(int, java.lang.String)and before the corresponding call toIXMLWriter.closeStartTag().- Parameters:
index- namespace URI index numbername- unqualified attribute namevalue- text value for attribute- Throws:
java.io.IOException- on error writing to document
-
closeStartTag
public void closeStartTag() throws java.io.IOExceptionDescription copied from interface:IXMLWriterClose the current open start tag. This is only valid after a call toIXMLWriter.startTagOpen(int, java.lang.String).- Throws:
java.io.IOException- on error writing to document
-
closeEmptyTag
public void closeEmptyTag() throws java.io.IOExceptionDescription copied from interface:IXMLWriterClose the current open start tag as an empty element. This is only valid after a call toIXMLWriter.startTagOpen(int, java.lang.String).- Throws:
java.io.IOException- on error writing to document
-
startTagClosed
public void startTagClosed(int index, java.lang.String name) throws java.io.IOExceptionDescription copied from interface:IXMLWriterGenerate closed start tag. No attributes or namespaces can be added to a start tag written using this call.- Parameters:
index- namespace URI index numbername- unqualified element name- Throws:
java.io.IOException- on error writing to document
-
endTag
public void endTag(int index, java.lang.String name) throws java.io.IOExceptionDescription copied from interface:IXMLWriterGenerate end tag.- Parameters:
index- namespace URI index numbername- unqualified element name- Throws:
java.io.IOException- on error writing to document
-
writeTextContent
public void writeTextContent(java.lang.String text) throws java.io.IOExceptionDescription copied from interface:IXMLWriterWrite ordinary character data text content to document.- Parameters:
text- content value text (must not benull)- Throws:
java.io.IOException- on error writing to document
-
writeCData
public void writeCData(java.lang.String text) throws java.io.IOExceptionDescription copied from interface:IXMLWriterWrite CDATA text to document.- Parameters:
text- content value text (must not benull)- Throws:
java.io.IOException- on error writing to document
-
writeComment
public void writeComment(java.lang.String text) throws java.io.IOExceptionDescription copied from interface:IXMLWriterWrite comment to document.- Parameters:
text- comment text (must not benull)- Throws:
java.io.IOException- on error writing to document
-
writeEntityRef
public void writeEntityRef(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:IXMLWriterWrite entity reference to document.- Parameters:
name- entity name (must not benull)- Throws:
java.io.IOException- on error writing to document
-
writeDocType
public void writeDocType(java.lang.String name, java.lang.String sys, java.lang.String pub, java.lang.String subset) throws java.io.IOExceptionDescription copied from interface:IXMLWriterWrite DOCTYPE declaration to document.- Parameters:
name- root element namesys- system ID (nullif none, must be non-nullfor public ID to be used)pub- public ID (nullif none)subset- internal subset (nullif none)- Throws:
java.io.IOException- on error writing to document
-
writePI
public void writePI(java.lang.String target, java.lang.String data) throws java.io.IOExceptionDescription copied from interface:IXMLWriterWrite processing instruction to document.- Parameters:
target- processing instruction target name (must not benull)data- processing instruction data (must not benull)- Throws:
java.io.IOException- on error writing to document
-
indent
public void indent() throws java.io.IOExceptionDoes nothing.- Throws:
java.io.IOException- on error writing to document
-
flush
public void flush() throws java.io.IOExceptionDoes nothing.- Throws:
java.io.IOException- on error writing to document
-
close
public void close() throws java.io.IOExceptionDoes nothing.- Throws:
java.io.IOException- on error writing to document
-
reset
public void reset()
Description copied from class:XMLWriterNamespaceBaseReset to initial state for reuse. Subclasses overriding this method need to call this base class implementation during their processing.- Specified by:
resetin interfaceIXMLWriter- Overrides:
resetin classXMLWriterNamespaceBase
-
getDocument
public Document getDocument()
- Returns:
- the JDOM
Documentthis writer created.
-
defineNamespace
protected void defineNamespace(int index, java.lang.String prefix) throws java.io.IOExceptionDoes nothing.- Specified by:
defineNamespacein classXMLWriterNamespaceBase- Parameters:
index- post-translation namespace URI index numberprefix- prefix used for namespace- Throws:
java.io.IOException- if error writing to document
-
undefineNamespace
protected void undefineNamespace(int index)
Does nothing.- Specified by:
undefineNamespacein classXMLWriterNamespaceBase- Parameters:
index- post-translation namespace URI index number
-
getNamespace
private Namespace getNamespace(int index)
This will retrieve (if in existence) or create (if not) aNamespacefor the supplied namespace index.
-
-