| java.lang.Object org.apache.commons.betwixt.io.AbstractBeanWriter
All known Subclasses: org.apache.commons.betwixt.io.BeanWriter, org.apache.commons.betwixt.io.SAXBeanWriter,
AbstractBeanWriter | abstract public class AbstractBeanWriter (Code) | | Abstract superclass for bean writers.
This class encapsulates the processing logic.
Subclasses provide implementations for the actual expression of the xml.
SAX Inspired Writing API
This class is intended to be used by subclassing:
concrete subclasses perform the actual writing by providing
suitable implementations for the following methods inspired
by SAX:
Note that this class contains many deprecated
versions of the writing API. These will be removed soon so care
should be taken to use the latest version.
Note that this class is designed to be used
in a single threaded environment. When used in multi-threaded
environments, use of a common XMLIntrospector
and pooled writer instances should be considered.
author: Robert Burrell Donkin |
Method Summary | |
protected void | bodyText(WriteContext context, String text) | protected void | bodyText(String text) | public void | end() Marks the start of the bean writing. | protected void | endElement(WriteContext context, String uri, String localName, String qName) | protected void | endElement(String uri, String localName, String qName) | protected void | expressAttribute(String qualifiedName, String value) | protected void | expressAttribute(String namespaceUri, String localName, String qualifiedName, String value) | protected void | expressBodyText(String text) | protected void | expressElementEnd(String qualifiedName) | protected void | expressElementEnd(String uri, String localName, String qualifiedName) | protected void | expressElementEnd() Express an empty element end. | protected void | expressElementStart(String qualifiedName) Express an element tag start using given qualified name. | protected void | expressElementStart(String uri, String localName, String qualifiedName) Express an element tag start using given qualified name. | protected void | expressTagClose() Express a closing tag. | final public Log | getAbstractBeanWriterLog() | public BindingConfiguration | getBindingConfiguration() Gets the dynamic configuration setting to be used for bean reading. | public IDGenerator | getIdGenerator() Get IDGenerator implementation used to
generate ID attribute values . | protected int | getIndentLevel() Get the indentation for the current element. | public boolean | getWriteEmptyElements() Gets whether empty elements should be written into the output.
An empty element is one that has no attributes, no child elements
and no body text. | public boolean | getWriteIDs() | public XMLIntrospector | getXMLIntrospector() Gets the introspector used.
The
XMLBeanInfo used to map each bean is
created by the XMLIntrospector .
One way in which the mapping can be customized is
by altering the XMLIntrospector . | protected Object | popBean() | protected void | pushBean(Object bean) Pushes the bean onto the ancestry stack. | final public void | setAbstractBeanWriterLog(Log log) Set the current logging implementation. | public void | setBindingConfiguration(BindingConfiguration bindingConfiguration) Sets the dynamic configuration setting to be used for bean reading. | public void | setIdGenerator(IDGenerator idGenerator) Set IDGenerator implementation
used to generate ID attribute values. | public void | setWriteEmptyElements(boolean writeEmptyElements) Sets whether empty elements should be written into the output.
An empty element is one that has no attributes, no child elements
and no body text. | public void | setWriteIDs(boolean writeIDs) Set whether generated ID attribute values should be added to the elements
If this property is set to false, then CyclicReferenceException
will be thrown whenever a cyclic occurs in the bean graph. | public void | setXMLIntrospector(XMLIntrospector introspector) Sets the introspector to be used.
The
XMLBeanInfo used to map each bean is
created by the XMLIntrospector .
One way in which the mapping can be customized is by
altering the XMLIntrospector . | public void | start() Marks the start of the bean writing. | protected void | startElement(WriteContext context, String uri, String localName, String qName, Attributes attr) Writes the start tag for an element. | protected void | startElement(String uri, String localName, String qName, Attributes attr) Writes the start tag for an element. | public void | write(Object bean) | public void | write(String qualifiedName, Object bean) | public void | write(Object bean, InputSource source) Writes the bean using the mapping specified in the InputSource .
Note: that the custom mapping will not
be registered for later use. | protected void | write(String qualifiedName, ElementDescriptor elementDescriptor, Context context) | protected void | write(String qualifiedName, ElementDescriptor elementDescriptor, Context context, String idAttribute, String idValue) | protected void | writeAttribute(AttributeDescriptor attributeDescriptor, Context context) | protected void | writeAttributes(ElementDescriptor elementDescriptor, Context context) | protected boolean | writeContent(ElementDescriptor elementDescriptor, Context context) Writes the element content. | protected void | writeIDREFElement(String qualifiedName, String idrefAttributeName, String idrefAttributeValue) | protected void | writeIndent() Writes an indentation. | protected void | writePrintln() Writes a empty line. | protected void | writeRestOfElement(String qualifiedName, ElementDescriptor elementDescriptor, Context context) |
end | public void end() throws IOException, SAXException(Code) | | Marks the start of the bean writing.
By default doesn't do anything, but can be used
to do extra end processing
throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
endElement | protected void endElement(WriteContext context, String uri, String localName, String qName) throws IOException, SAXException(Code) | | Writes the end tag for an element
Parameters: uri - the element's namespace uri Parameters: localName - the element's local name Parameters: qName - the element's qualified name throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing since: 0.5 |
expressAttribute | protected void expressAttribute(String qualifiedName, String value) throws IOException, SAXException(Code) | | Express an attribute
Parameters: qualifiedName - the qualified name of the attribute Parameters: value - the attribute value throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
expressAttribute | protected void expressAttribute(String namespaceUri, String localName, String qualifiedName, String value) throws IOException, SAXException(Code) | | Express an attribute
Parameters: namespaceUri - the namespace uri Parameters: localName - the local name Parameters: qualifiedName - the qualified name of the attribute Parameters: value - the attribute value throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
expressBodyText | protected void expressBodyText(String text) throws IOException, SAXException(Code) | | Express body text
Parameters: text - the string to write out as the body of the current element throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
expressElementEnd | protected void expressElementEnd(String qualifiedName) throws IOException, SAXException(Code) | | Express an element end tag (with given name)
Parameters: qualifiedName - the qualified name for the element to be closed throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
expressElementEnd | protected void expressElementEnd(String uri, String localName, String qualifiedName) throws IOException, SAXException(Code) | | Express an element end tag (with given name)
Parameters: uri - the namespace uri of the element close tag Parameters: localName - the local name of the element close tag Parameters: qualifiedName - the qualified name for the element to be closed throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
expressElementStart | protected void expressElementStart(String qualifiedName) throws IOException, SAXException(Code) | | Express an element tag start using given qualified name.
Parameters: qualifiedName - the qualified name of the element to be expressed throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
expressElementStart | protected void expressElementStart(String uri, String localName, String qualifiedName) throws IOException, SAXException(Code) | | Express an element tag start using given qualified name.
Parameters: uri - the namespace uri Parameters: localName - the local name for this element Parameters: qualifiedName - the qualified name of the element to be expressed throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
getAbstractBeanWriterLog | final public Log getAbstractBeanWriterLog()(Code) | | Gets the current logging implementation.
the Log implementation which this class logs to |
getBindingConfiguration | public BindingConfiguration getBindingConfiguration()(Code) | | Gets the dynamic configuration setting to be used for bean reading.
the BindingConfiguration settings, not null since: 0.5 |
getIdGenerator | public IDGenerator getIdGenerator()(Code) | | Get IDGenerator implementation used to
generate ID attribute values .
implementation used for ID attribute generation |
getIndentLevel | protected int getIndentLevel()(Code) | | Get the indentation for the current element.
Used for pretty priting.
the amount that the current element is indented |
getWriteEmptyElements | public boolean getWriteEmptyElements()(Code) | | Gets whether empty elements should be written into the output.
An empty element is one that has no attributes, no child elements
and no body text.
For example, <element/> is an empty element but
<element attr='value'/> is not.
true if empty elements will be written into the output since: 0.5 |
getWriteIDs | public boolean getWriteIDs()(Code) | | Should generated ID attribute values be added to the elements?
If IDs are not being written then if a cycle is encountered in the bean graph,
then a
CyclicReferenceException will be thrown by the write method.
true if ID and IDREF attributes are to be writtenBindingConfiguration.getMapIDs |
getXMLIntrospector | public XMLIntrospector getXMLIntrospector()(Code) | | Gets the introspector used.
The
XMLBeanInfo used to map each bean is
created by the XMLIntrospector .
One way in which the mapping can be customized is
by altering the XMLIntrospector .
the XMLIntrospector used for introspection |
popBean | protected Object popBean()(Code) | | Pops the top bean off from the ancestry stack
the last object pushed onto the ancester stack |
pushBean | protected void pushBean(Object bean)(Code) | | Pushes the bean onto the ancestry stack.
If IDs are not being written, then check for cyclic references.
Parameters: bean - push this bean onto the ancester stack |
setAbstractBeanWriterLog | final public void setAbstractBeanWriterLog(Log log)(Code) | | Set the current logging implementation.
Parameters: log - Log implementation to use |
setBindingConfiguration | public void setBindingConfiguration(BindingConfiguration bindingConfiguration)(Code) | | Sets the dynamic configuration setting to be used for bean reading.
Parameters: bindingConfiguration - the BindingConfiguration settings, not null since: 0.5 |
setIdGenerator | public void setIdGenerator(IDGenerator idGenerator)(Code) | | Set IDGenerator implementation
used to generate ID attribute values.
This property can be used to customize the algorithm used for generation.
Parameters: idGenerator - use this implementation for ID attribute generation |
setWriteEmptyElements | public void setWriteEmptyElements(boolean writeEmptyElements)(Code) | | Sets whether empty elements should be written into the output.
An empty element is one that has no attributes, no child elements
and no body text.
For example, <element/> is an empty element but
<element attr='value'/> is not.
Parameters: writeEmptyElements - true if empty elements should be written into the output since: 0.5 |
setWriteIDs | public void setWriteIDs(boolean writeIDs)(Code) | | Set whether generated ID attribute values should be added to the elements
If this property is set to false, then CyclicReferenceException
will be thrown whenever a cyclic occurs in the bean graph.
Parameters: writeIDs - true if ID 's and IDREF 's should be writtenBindingConfiguration.setMapIDs |
setXMLIntrospector | public void setXMLIntrospector(XMLIntrospector introspector)(Code) | | Sets the introspector to be used.
The
XMLBeanInfo used to map each bean is
created by the XMLIntrospector .
One way in which the mapping can be customized is by
altering the XMLIntrospector .
Parameters: introspector - use this introspector |
start | public void start() throws IOException, SAXException(Code) | | Marks the start of the bean writing.
By default doesn't do anything, but can be used
to do extra start processing
throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
startElement | protected void startElement(WriteContext context, String uri, String localName, String qName, Attributes attr) throws IOException, SAXException(Code) | | Writes the start tag for an element.
Parameters: uri - the element's namespace uri Parameters: localName - the element's local name Parameters: qName - the element's qualified name Parameters: attr - the element's attributes throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing since: 0.5 |
write | public void write(Object bean) throws IOException, SAXException, IntrospectionException(Code) | | Writes the given bean to the current stream using the XML introspector.
This writes an xml fragment representing the bean to the current stream.
This method will throw a CyclicReferenceException when a cycle
is encountered in the graph only if the getMapIDs()
setting of the BindingConfiguration is false.
throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing throws: IntrospectionException - if a java beans introspection problem occurs Parameters: bean - write out representation of this bean |
write | public void write(String qualifiedName, Object bean) throws IOException, SAXException, IntrospectionException(Code) | | Writes the given bean to the current stream
using the given qualifiedName .
This method will throw a CyclicReferenceException when a cycle
is encountered in the graph only if the getMapIDs()
setting of the BindingConfiguration is false.
Parameters: qualifiedName - the string naming root element Parameters: bean - the Object to write out as xml throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing throws: IntrospectionException - if a java beans introspection problem occurs |
write | protected void write(String qualifiedName, ElementDescriptor elementDescriptor, Context context, String idAttribute, String idValue) throws IOException, SAXException, IntrospectionException(Code) | | Writes the given element adding an ID attribute
Parameters: qualifiedName - qualified name to use for the element Parameters: elementDescriptor - the ElementDescriptor describing the element Parameters: context - the Context to use to evaluate the bean expressions Parameters: idAttribute - the qualified name of the ID attribute Parameters: idValue - the value for the ID attribute throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing throws: IntrospectionException - if a java beans introspection problem occurs |
writeAttribute | protected void writeAttribute(AttributeDescriptor attributeDescriptor, Context context) throws IOException, SAXException(Code) | | Writes an attribute declaration
Parameters: attributeDescriptor - the AttributeDescriptor to be written as xml Parameters: context - the Context to use to evaluation bean expressions throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
writeAttributes | protected void writeAttributes(ElementDescriptor elementDescriptor, Context context) throws IOException, SAXException(Code) | | Writes the attribute declarations
Parameters: elementDescriptor - the ElementDescriptor to be written out as xml Parameters: context - the Context to use to evaluation bean expressions throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing |
writeIDREFElement | protected void writeIDREFElement(String qualifiedName, String idrefAttributeName, String idrefAttributeValue) throws IOException, SAXException, IntrospectionException(Code) | | Writes an element with a IDREF attribute
Parameters: qualifiedName - of the element with IDREF attribute Parameters: idrefAttributeName - the qualified name of the IDREF attribute Parameters: idrefAttributeValue - the value for the IDREF attribute throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing throws: IntrospectionException - if a java beans introspection problem occurs |
writeIndent | protected void writeIndent() throws IOException(Code) | | Writes an indentation.
This implementation does nothing but can be overridden by subclasses.
throws: IOException - if the indent cannot be written |
writePrintln | protected void writePrintln() throws IOException(Code) | | Writes a empty line.
This implementation does nothing but can be overridden by subclasses.
throws: IOException - if the line cannot be written |
writeRestOfElement | protected void writeRestOfElement(String qualifiedName, ElementDescriptor elementDescriptor, Context context) throws IOException, SAXException, IntrospectionException(Code) | | Write attributes, child elements and element end
Parameters: qualifiedName - qualified name to use for the element Parameters: elementDescriptor - the ElementDescriptor describing the element Parameters: context - the Context to use to evaluate the bean expressions throws: IOException - if an IO problem occurs during writing throws: SAXException - if an SAX problem occurs during writing throws: IntrospectionException - if a java beans introspection problem occurs |
|
|