|
xelem.3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nl.fountain.xelem.lex.ExcelReader
public class ExcelReader
Basic class for reading xml-spreadsheets of type spreadsheetML.
An ExcelReader
can deliver the contents of an xml-file or an xml-InputSource as a
fully populated Workbook
.
Furthermore, it can dispatch events, values and instances of
XLElements
to listeners
registered at this ExcelReader while parsing an xml-file or
xml-InputSource.
Constructor Summary | |
---|---|
ExcelReader()
Constructs a new ExcelReader. |
|
ExcelReader(SAXParser parser)
Constructs a new ExcelReader. |
Method Summary | |
---|---|
void |
addExcelReaderListener(ExcelReaderListener listener)
Registers the given listener on this ExcelReader. |
void |
clearExcelReaderListeners()
Remove all listeners on this ExcelReader |
void |
clearReadArea()
Clears the read area. |
List<ExcelReaderListener> |
getListeners()
Gets a list of registered listeners on this ExcelReader. |
Map<String,String> |
getPrefixMap()
Gets a map of prefixes (keys) and uri's recieved while reading. |
Area |
getReadArea()
Gets the area that restricts reading on this ExcelReader. |
SAXParser |
getSaxParser()
Returns the SAXParser that is used by this ExcelReader. |
Workbook |
getWorkbook(InputSource source)
Delivers the contents of the given InputSource as a fully populated Workbook. |
Workbook |
getWorkbook(String fileName)
Delivers the contents of the specified file as a fully populated Workbook. |
boolean |
hasReadArea()
Specifies whether reading is restricted on this ExcelReader. |
void |
read(InputSource source)
Reads the stream of the given InputSource and dispatches events to registered ExcelReaderListeners . |
void |
read(String fileName)
Reads the file with the given name and dispatches events to registered ExcelReaderListeners . |
boolean |
removeExcelReaderListener(ExcelReaderListener listener)
Removes the passed listener on this ExcelReader. |
void |
setReadArea(Area area)
Sets the area that is to be read. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExcelReader() throws ParserConfigurationException, SAXException
SAXParser
from an instance of
SAXParserFactory
to do the parsing.
There is no need to configure factory parameters.
ParserConfigurationException
- if a parser cannot be created
which satisfies the current configuration
SAXException
- for SAX errorspublic ExcelReader(SAXParser parser) throws ParserConfigurationException
parser
- a SAXParser that is namespace aware
ParserConfigurationException
- if the parser is not namespace awareMethod Detail |
---|
public SAXParser getSaxParser()
Under Java 1.4 we might see a org.apache.crimson.jaxp.SAXParserImpl, it could be a com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl under Java 1.5.
public void setReadArea(Area area)
area
- the area to readpublic void clearReadArea()
public Area getReadArea()
public boolean hasReadArea()
public List<ExcelReaderListener> getListeners()
public void addExcelReaderListener(ExcelReaderListener listener)
listener
- the ExcelReaderListener to be registeredpublic boolean removeExcelReaderListener(ExcelReaderListener listener)
listener
- the ExcelReaderListener to be removed
true
if the passed listener was registered,
false
otherwisepublic void clearExcelReaderListeners()
public Workbook getWorkbook(String fileName) throws IOException, SAXException
fileName
- the name of the file to be read
IOException
- signals a failed or interrupted I/O operation
SAXException
- signals a general SAX error or warningread(String)
public Workbook getWorkbook(InputSource source) throws IOException, SAXException
source
- the Inputsource streaming spreadsheetML
IOException
- signals a failed or interrupted I/O operation
SAXException
- signals a general SAX error or warningread(InputSource)
public void read(String fileName) throws IOException, SAXException
ExcelReaderListeners
. If a read area was set
on this ExcelReader, only events occuring within the limits of the
area are dispatched.
When trying to read non-xml files, under java 1.5 a
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException
might be thrown. The MalformedByteSequenceException is unknown
under java 1.4 and previous releases. Releases prior to java 1.5
will throw a org.xml.sax.SAXParseException
under these
adverse conditions.
fileName
- the name of the file to be read
IOException
- signals a failed or interrupted I/O operation
SAXException
- signals a general SAX error or warningpublic void read(InputSource source) throws IOException, SAXException
ExcelReaderListeners
. If a read area was set
on this ExcelReader, only events occuring within the limits of the
area are dispatched.
When trying to read non-xml streams, under java 1.5 a
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException
might be thrown. The MalformedByteSequenceException is unknown
under java 1.4 and previous releases. Releases prior to java 1.5
will throw a org.xml.sax.SAXParseException
under these
adverse conditions.
source
- the Inputsource streaming spreadsheetML
IOException
- signals a failed or interrupted I/O operation
SAXException
- signals a general SAX error or warningpublic Map<String,String> getPrefixMap()
|
xelem.3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |