org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements
Class BaseElementProcessor

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.BaseElementProcessor
All Implemented Interfaces:
Component, LogEnabled, ElementProcessor, POIFSElementProcessor
Direct Known Subclasses:
EP_Bottom, EP_Default_, EP_Draft, EP_EvenIfOnlyStyles, EP_Footer, EP_Grid, EP_HCenter, EP_Header, EP_Left, EP_Monochrome, EP_Name, EP_Order, EP_Orientation, EP_Paper, EP_RepeatLeft, EP_RepeatTop, EP_Right, EP_Titles, EP_Top, EP_Type, EP_ValString, EP_Value, EP_VCenter, EPAttribute, EPAttributes, EPBottom, EPButton, EPCell, EPCellComment, EPCells, EPCheckbox, EPColInfo, EPCols, EPConstr, EPContent, EPDiagonal, EPFont, EPFooter, EPFrame, EPGeometry, EPHeader, EPItem, EPLabel, EPLeft, EPMargins, EPMaxCol, EPMaxRow, EPMerge, EPMergedRegions, EPName, EPNames, EPObjects, EPPrintInformation, EPRev_Diagonal, EPRight, EPRowInfo, EPRows, EPSelection, EPSelections, EPSheet, EPSheetName, EPSheetNameIndex, EPSheetObjectBonobo, EPSheetObjectFilled, EPSheets, EPSolver, EPStyle, EPStyleBorder, EPStyleRegion, EPStyles, EPSummary, EPTop, EPUIData, EPWorkbook, EPZoom

public abstract class BaseElementProcessor
extends AbstractLogEnabled
implements POIFSElementProcessor

The BaseElementProcessor class provides default behavior for classes that can handle a particular XML element's content. It is intended that all ElementProcessors should extend this class. This class is declared Abstract although it has no abstract methods. It can be used 'as is' for a no-op ElementProcessor, and an ElementProcessor that chooses to simply extend this class with no overrides will be a no-op ElementProcessor.

Version:
CVS $Id: BaseElementProcessor.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Marc Johnson (marc_johnson27591@hotmail.com)

Field Summary
 
Fields inherited from interface org.apache.cocoon.components.elementprocessor.ElementProcessor
ROLE
 
Constructor Summary
protected BaseElementProcessor(Attribute[] implied_attributes)
          Constructor
 
Method Summary
 void acceptCharacters(char[] data)
          The data provided in this method call comes from the corresponding XML element's contents.
 void acceptWhitespaceCharacters(char[] data)
          The data provided in this method call comes from the corresponding XML element's contents.
 void endProcessing()
          This is the last method call executed by the POIFSSerializer.
protected  ElementProcessor getAncestor(Class theclass)
          get the nearest ancestor that happens to be an instance of the specified class
protected  Iterator getAttributes()
           
protected  org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.Cell getCell()
          get the current cell we're working on.
protected  String getData()
           
protected  org.apache.poi.poifs.filesystem.POIFSFileSystem getFilesystem()
           
protected  ElementProcessor getParent()
           
protected  org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.Sheet getSheet()
          get the current sheet we're working on.
protected  String getValue(String name)
          Get the value of an attribute
protected  org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.Workbook getWorkbook()
          get the workbook we're working on.
 void initialize(Attribute[] attributes, ElementProcessor parent)
          The implementation should walk the array of attributes and perform appropriate actions based on that data.
 void setFilesystem(org.apache.poi.poifs.filesystem.POIFSFileSystem fs)
          Set the POIFSFileSystem for the element processor
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseElementProcessor

protected BaseElementProcessor(Attribute[] implied_attributes)
Constructor

Parameters:
implied_attributes - an array of Attributes which might not appear in the initialization call because they are implied, and the SAX processor will not automatically generate them.
Method Detail

getAttributes

protected Iterator getAttributes()
Returns:
the Attributes managed by this ElementProcessor. May be empty, but never null

getValue

protected String getValue(String name)
Get the value of an attribute

Parameters:
name - the name of the attribute to look up
Returns:
the value of the specified attribute; will be null if the attribute doesn't exist

getFilesystem

protected org.apache.poi.poifs.filesystem.POIFSFileSystem getFilesystem()
Returns:
the POIFSFileSystem object

getParent

protected ElementProcessor getParent()
Returns:
the parent ElementProcessor; may be null

getAncestor

protected ElementProcessor getAncestor(Class theclass)
get the nearest ancestor that happens to be an instance of the specified class

Parameters:
theclass - the class we're looking for
Returns:
an ancestor of the specified class; null if no such ancestor exists

getData

protected String getData()
Returns:
the data, both regular characters and whitespace characters, collected so far

getWorkbook

protected org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.Workbook getWorkbook()
                                                                                             throws IOException
get the workbook we're working on. If it isn't in this instance, check the parent

Returns:
the workbook we're working on. Never null
Throws:
IOException - if the workbook is missing

getSheet

protected org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.Sheet getSheet()
                                                                                       throws IOException
get the current sheet we're working on. If it isn't in this instance, check the parent

Returns:
the current sheet we're working on. Never null
Throws:
IOException - if the sheet is missing

getCell

protected org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.Cell getCell()
                                                                                     throws IOException
get the current cell we're working on. If it isn't in this instance, check the parent

Returns:
the current cell we're working on. Never null
Throws:
IOException - if the cell is missing

initialize

public void initialize(Attribute[] attributes,
                       ElementProcessor parent)
                throws IOException
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.

Specified by:
initialize in interface ElementProcessor
Parameters:
attributes - the array of Attribute instances; may be empty, will never be null
parent - the parent ElementProcessor; may be null
Throws:
IOException - if anything is wrong

acceptCharacters

public void acceptCharacters(char[] data)
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.

Specified by:
acceptCharacters in interface ElementProcessor
Parameters:
data - the character data

acceptWhitespaceCharacters

public void acceptWhitespaceCharacters(char[] data)
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.

Specified by:
acceptWhitespaceCharacters in interface ElementProcessor
Parameters:
data - the whitespace characters

endProcessing

public void endProcessing()
                   throws IOException
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 and the filesystem, if necessary.
If the implementation cached the parent ElementProcessor reference, the filesystem reference, or both, when the initialize method was called, it should null out those references.

Specified by:
endProcessing in interface ElementProcessor
Throws:
IOException

setFilesystem

public void setFilesystem(org.apache.poi.poifs.filesystem.POIFSFileSystem fs)
Set the POIFSFileSystem for the element processor

Specified by:
setFilesystem in interface POIFSElementProcessor
Parameters:
fs - the POIFSFileSystem instance


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.