| org.apache.cocoon.components.elementprocessor.ElementProcessor
ElementProcessor | public interface ElementProcessor extends org.apache.avalon.framework.component.Component(Code) | | The ElementProcessor interface defines behavior for classes that
can handle a particular XML element's content.
The life cycle of an ElementProcessor instance is:
- Creation
- Initialization via a call to initialize
- Acquisition of element data via calls to acceptCharacters
and acceptWhitespaceCharacters
- Completion of processing via a call to endProcessing
In response to a startElement event, the POIFSSerializer creates an
ElementProcessor, delegating the act of creation to an
ElementProcessorFactory, and then initializes the
ElementProcessor. In response to subsequent characters and
ignorableWhitespace events, the POIFSSerializer will pass data to
the ElementProcessor via the acceptCharacters or
acceptWhitespaceCharacters methods. Finally, in response to an
endElement event, the POIFSSerializer calls the ElementProcessor's
endProcessing method.
author: Marc Johnson (marc_johnson27591@hotmail.com) version: CVS $Id: ElementProcessor.java 433543 2006-08-22 06:22:54Z crossley $ |
Method Summary | |
public void | acceptCharacters(char[] data) The data provided in this method call comes from the
corresponding XML element's contents. | public void | acceptWhitespaceCharacters(char[] data) The data provided in this method call comes from the
corresponding XML element's contents. | public void | endProcessing() This is the last method call executed by the
POIFSSerializer. | public void | initialize(Attribute[] attributes, ElementProcessor parent) The implementation should walk the array of attributes and
perform appropriate actions based on that data. |
acceptCharacters | public void acceptCharacters(char[] data)(Code) | | The data provided in this method call comes from the
corresponding XML element's contents. The array is guaranteed
not to be null and will never be empty.
The POIFSSerializer will make 0 to many calls to this method;
all such calls will occur after the initialize method is called
and before the endProcessing method is called.
Calls to this method may be interleaved with calls to
acceptWhitespaceCharacters. All calls to acceptCharacters and
acceptWhitespaceCharacters are guaranteed to be in the same
order as their data is in the element.
Parameters: data - the character data |
acceptWhitespaceCharacters | public void acceptWhitespaceCharacters(char[] data)(Code) | | The data provided in this method call comes from the
corresponding XML element's contents. The array is guaranteed
not to be null and will never be empty.
The POIFSSerializer will make 0 to many calls to this method;
all such calls will occur after the initialize method is called
and before the endProcessing method is called.
Calls to this method may be interleaved with calls to
acceptCharacters. All calls to acceptCharacters and
acceptWhitespaceCharacters are guaranteed to be in the same
order as their data is in the element.
Parameters: data - the whitespace characters |
endProcessing | public void endProcessing() throws IOException(Code) | | This is the last method call executed by the
POIFSSerializer. When this method is called, the
ElementProcessor should finish its work and perform its final
interactions with its parent ElementProcessor.
If the implementation cached the parent ElementProcessor
reference, when the initialize method was called, it should
null out that reference.
exception: IOException - |
initialize | public void initialize(Attribute[] attributes, ElementProcessor parent) throws IOException(Code) | | The implementation should walk the array of attributes and
perform appropriate actions based on that data. The array of
attributes is guaranteed never to be null, but it can be
empty. An implementation can expect code like this to work
without throwing runtime exceptions:
for (int k = 0; k < attributes.length; k++)
{
Attribute attr = attributes[ k ];
// process attribute
}
NOTE: if the XML DTD or schema includes IMPLIED
attributes for an element, those attributes are not included in
the Attribute array - they're not in the data provided in the
startElement call. The constructor for the ElementProcessor
should set those implied attributes itself, and allow them to
be overridden if the XML source provided explicit values
for them.
The parent ElementProcessor is a reference to the
ElementProcessor whose corresponding XML element contains this
ElementProcessor's corresponding XML element. It will not be
null unless this ElementProcessor's corresponding XML element
is the top-level element in the XML document. Whether this
ElementProcessor needs to establish a containment relationship
with its parent or not, and whether it needs to do so at the
beginning, middle, or end of its life cycle, are private
matters left to the discretion of the individual
ElementProcessor implementation. If the ElementProcessor needs
to interact with its parent ElementProcessor, but is not ready
to do so when the initialize method is called, it must cache
the reference to its parent.
Parameters: attributes - the array of Attribute instances; may beempty, will never be null Parameters: parent - the parent ElementProcessor; may be null exception: IOException - if anything goes wrong |
|
|