Package adams.data.io.input
Class ExcelStreamingSpreadSheetReader.SheetHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- adams.data.io.input.ExcelStreamingSpreadSheetReader.SheetHandler
-
- All Implemented Interfaces:
Stoppable,ContentHandler,DTDHandler,EntityResolver,ErrorHandler
- Enclosing class:
- ExcelStreamingSpreadSheetReader
public static class ExcelStreamingSpreadSheetReader.SheetHandler extends DefaultHandler implements Stoppable
For reading a sheet from XML.- Version:
- $Revision$
- Author:
- Apache Foundation (POI), fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected HashMap<String,Cell.ContentType>m_CellStringsthe cell-strings.protected HashMap<String,Cell.ContentType>m_CellTypesthe cell-types.protected Cell.ContentTypem_ContentTypewhat type the current cell is.protected intm_FirstRowthe first row.protected StringBuilderm_LastContentsthe assembled cell content.protected intm_LastRowthe last row.protected booleanm_LoggingAtLeastFinewhether logging is at least fine.protected ExcelStreamingSpreadSheetReaderm_Ownerthe reader this handler belongs to.protected Stringm_Referencethe cell reference.protected SpreadSheetm_Sheetthe spreadsheet to add the content to.protected org.apache.poi.xssf.model.SharedStringsm_SSTthe table for shared strings.protected booleanm_Stoppedwhether the parsing was stopped.protected gnu.trove.set.hash.TIntHashSetm_TextColumnsthe text columns.protected Stringm_UnknownCellStringthe current unknown cell-string.protected HashSet<String>m_UnknownCellStringsthe unknown cell-strings.protected HashMap<String,String>m_UnknownCellStringsExamplesexamples of the unknown cell-strings (string - example).protected Stringm_UnknownCellTypethe current unknown cell-types.protected HashSet<String>m_UnknownCellTypesthe unknown cell-type.protected HashMap<String,String>m_UnknownCellTypesExamplesexamples of the unknown cell-types (type - example).
-
Constructor Summary
Constructors Constructor Description SheetHandler(ExcelStreamingSpreadSheetReader owner, SpreadSheet sheet, org.apache.poi.xssf.model.SharedStrings sst)Initializes the SAX handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Receive notification of character data inside an element.voidendElement(String uri, String localName, String name)Receive notification of the end of an element.HashSet<String>getUnknownCellStrings()Returns the unknown cell strings that were encountered.HashMap<String,String>getUnknownCellStringsExamples()Returns examples of the unknown cell strings that were encountered.HashSet<String>getUnknownCellTypes()Returns the unknown cell types that were encountered.HashMap<String,String>getUnknownCellTypesExamples()Returns examples of the unknown cell types that were encountered.protected booleanisInRange(int row)Checks whether the 0-based row is in the window that we want to read in.voidstartElement(String uri, String localName, String name, Attributes attributes)Receive notification of the start of an element.voidstopExecution()Stops the parsing.-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
m_Owner
protected ExcelStreamingSpreadSheetReader m_Owner
the reader this handler belongs to.
-
m_Sheet
protected SpreadSheet m_Sheet
the spreadsheet to add the content to.
-
m_SST
protected org.apache.poi.xssf.model.SharedStrings m_SST
the table for shared strings.
-
m_LastContents
protected StringBuilder m_LastContents
the assembled cell content.
-
m_ContentType
protected Cell.ContentType m_ContentType
what type the current cell is.
-
m_Reference
protected String m_Reference
the cell reference.
-
m_Stopped
protected boolean m_Stopped
whether the parsing was stopped.
-
m_CellTypes
protected HashMap<String,Cell.ContentType> m_CellTypes
the cell-types.
-
m_CellStrings
protected HashMap<String,Cell.ContentType> m_CellStrings
the cell-strings.
-
m_UnknownCellType
protected String m_UnknownCellType
the current unknown cell-types.
-
m_UnknownCellTypesExamples
protected HashMap<String,String> m_UnknownCellTypesExamples
examples of the unknown cell-types (type - example).
-
m_UnknownCellString
protected String m_UnknownCellString
the current unknown cell-string.
-
m_UnknownCellStringsExamples
protected HashMap<String,String> m_UnknownCellStringsExamples
examples of the unknown cell-strings (string - example).
-
m_LoggingAtLeastFine
protected boolean m_LoggingAtLeastFine
whether logging is at least fine.
-
m_TextColumns
protected gnu.trove.set.hash.TIntHashSet m_TextColumns
the text columns.
-
m_FirstRow
protected int m_FirstRow
the first row.
-
m_LastRow
protected int m_LastRow
the last row.
-
-
Constructor Detail
-
SheetHandler
public SheetHandler(ExcelStreamingSpreadSheetReader owner, SpreadSheet sheet, org.apache.poi.xssf.model.SharedStrings sst)
Initializes the SAX handler.- Parameters:
owner- the reader this handler belongs tosheet- the spreadsheet to add the content tosst- the table for shared strings
-
-
Method Detail
-
startElement
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException
Receive notification of the start of an element.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Parameters:
uri- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName- The local name (without prefix), or the empty string if Namespace processing is not being performed.name- The qualified name (with prefix), or the empty string if qualified names are not available.attributes- The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.
-
isInRange
protected boolean isInRange(int row)
Checks whether the 0-based row is in the window that we want to read in.- Parameters:
row- the row to check- Returns:
- true if inside the window
-
endElement
public void endElement(String uri, String localName, String name) throws SAXException
Receive notification of the end of an element.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Parameters:
uri- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName- The local name (without prefix), or the empty string if Namespace processing is not being performed.name- The qualified name (with prefix), or the empty string if qualified names are not available.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.
-
characters
public void characters(char[] ch, int start, int length) throws SAXExceptionReceive notification of character data inside an element.By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Parameters:
ch- The characters.start- The start position in the character array.length- The number of characters to use from the character array.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.
-
stopExecution
public void stopExecution()
Stops the parsing.- Specified by:
stopExecutionin interfaceStoppable
-
getUnknownCellTypes
public HashSet<String> getUnknownCellTypes()
Returns the unknown cell types that were encountered.- Returns:
- the cell types
-
getUnknownCellTypesExamples
public HashMap<String,String> getUnknownCellTypesExamples()
Returns examples of the unknown cell types that were encountered.- Returns:
- the examples
-
getUnknownCellStrings
public HashSet<String> getUnknownCellStrings()
Returns the unknown cell strings that were encountered.- Returns:
- the cell strings
-
-