Class OOXMLStreamReader
java.lang.Object
java.io.Reader
com.nomagic.magicreport.engine.ooxml.OOXMLStreamReader
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
This class implements a reader that can be used for OOXML. The reader reader data from content.xml by default.
An OOXMLStreamReader is also provide a bridge from byte streams to characters streams: It reads bytes and
decodes them into characters using a specified charset
- Since:
- Oct 19, 2009
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected OOXMLEntryKeep the entry for content reader.protected InputStreamReaderAn internal reader for specified content entry.protected ZipInputStreamAn internal input stream for ZIP file. -
Constructor Summary
ConstructorsConstructorDescriptionOOXMLStreamReader(InputStream in, String entryName) Create an OOXMLStreamReader that uses the named charset.OOXMLStreamReader(InputStream in, String entryName, String charsetName) Create an OOXMLStreamReader that uses the named charset and entry. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the stream.protected voidCheck to make sure that the stream has not been closed.Returns the OOXML file entry for the reader, or null if not found.Reads the next OOXML file entry and positions the stream at the beginning of the entry data.voidInitialize ODF stream.intread(byte[] b, int off, int len) Reads from the current OOXML entry into an array of bytes.intread(char[] cbuf, int offset, int length) Read characters from content.xml into a portion of an array.Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo
-
Field Details
-
zipInputStream
An internal input stream for ZIP file. -
contentReader
An internal reader for specified content entry. -
contentEntry
Keep the entry for content reader.
-
-
Constructor Details
-
OOXMLStreamReader
Create an OOXMLStreamReader that uses the named charset.- Parameters:
in- An InputStreamentryName- target entry name- Throws:
UnsupportedEncodingException- If the named charset is not supportedIOException- if an I/O error has occurred
-
OOXMLStreamReader
Create an OOXMLStreamReader that uses the named charset and entry.- Parameters:
in- An InputStreamentryName- target entry namecharsetName- The name of a supportedjava.nio.charset.Charsetcharset- Throws:
UnsupportedEncodingException- If the named charset is not supportedIOException- if an I/O error has occurred
-
-
Method Details
-
init
Initialize ODF stream.- Parameters:
entryName- name of target reading entry.- Throws:
IOException- If an I/O error occurs
-
getContentEntry
Returns the OOXML file entry for the reader, or null if not found.- Returns:
- the OOXML file entry, or null if not found
-
ensureOpen
Check to make sure that the stream has not been closed.- Throws:
IOException- If stream has been closed
-
close
Close the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classReader- Throws:
IOException- If an I/O error occurs
-
read
Read characters from content.xml into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.- Specified by:
readin classReader- Parameters:
cbuf- Destination bufferoffset- Offset at which to start storing characterslength- Maximum number of characters to read- Returns:
- The number of characters read, or -1 if the end of the stream has been reached
- Throws:
IOException- If an I/O error occurs
-
read
Reads from the current OOXML entry into an array of bytes. Blocks until some input is available.- Parameters:
b- the buffer into which the data is readoff- the start offset of the datalen- the maximum number of bytes read- Returns:
- the actual number of bytes read, or -1 if the end of the entry is reached
- Throws:
IOException- if an I/O error has occurred
-
getNextEntry
Reads the next OOXML file entry and positions the stream at the beginning of the entry data.- Returns:
- the next OOXML file entry, or null if there are no more entries
- Throws:
IOException- if an I/O error has occurred
-