Top Description Fields Constructors Methods
org.apache.poi.poifs.eventfilesystem

public Class POIFSReader

extends Object
Class Inheritance
Imports
java.io.File, .IOException, .InputStream, org.apache.poi.poifs.filesystem.DocumentInputStream, .POIFSDocument, .POIFSDocumentPath, .POIFSFileSystem, org.apache.poi.poifs.property.DirectoryProperty, .DocumentProperty, .Property, .PropertyTable, .RootProperty, org.apache.poi.util.IOUtils

An event-driven reader for POIFS file systems. Users of this class first create an instance of it, then use the registerListener methods to register POIFSReaderListener instances for specific documents. Once all the listeners have been registered, the read() method is called, which results in the listeners being notified as their documents are read.

Field Summary

Modifier and TypeField and Description
private boolean
private final POIFSReaderRegistry
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
main(String[]
names of the files
args
)

read in files

private void
public void
read(final InputStream
the InputStream from which to read the data
stream
)

Read from an InputStream and process the documents we get

public void
read(final File
the file from which to read the data
poifsFile
)

Read from a File and process the documents we get

public void
read(final POIFSFileSystem
the POIFSFileSystem from which to read the data
poifs
)

Read from a POIFSFileSystem and process the documents we get

private static void
public void
registerListener(final POIFSReaderListener
the listener to be registered
listener
)

Register a POIFSReaderListener for all documents

public void
registerListener(final POIFSReaderListener
the listener to be registered
listener
,
final String
the document name
name
)

Register a POIFSReaderListener for a document in the root directory

public void
registerListener(final POIFSReaderListener
the listener to be registered
listener
,
final POIFSDocumentPath
the document path; if null, the root directory is assumed
path
,
final String
the document name
name
)

Register a POIFSReaderListener for a document in the specified directory

public void
setNotifyEmptyDirectories(boolean
if true, empty directories will be notified
notifyEmptyDirectories
)

Activates the notification of empty directories.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

notifyEmptyDirectoriesback to summary
private boolean notifyEmptyDirectories
registryback to summary
private final POIFSReaderRegistry registry
registryClosedback to summary
private boolean registryClosed

Constructor Detail

POIFSReaderback to summary
public POIFSReader()

Method Detail

mainback to summary
public static void main(String[] args) throws IOException

read in files

Parameters
args:String[]

names of the files

Exceptions
IOException:
if the files can't be read or have invalid content
processPropertiesback to summary
private void processProperties(final POIFSFileSystem poifs, DirectoryProperty dir, final POIFSDocumentPath path)
readback to summary
public void read(final InputStream stream) throws IOException

Read from an InputStream and process the documents we get

Parameters
stream:InputStream

the InputStream from which to read the data

Exceptions
IOException:
on errors reading, or on invalid data
readback to summary
public void read(final File poifsFile) throws IOException

Read from a File and process the documents we get

Parameters
poifsFile:File

the file from which to read the data

Exceptions
IOException:
on errors reading, or on invalid data
readback to summary
public void read(final POIFSFileSystem poifs) throws IOException

Read from a POIFSFileSystem and process the documents we get

Parameters
poifs:POIFSFileSystem

the POIFSFileSystem from which to read the data

Exceptions
IOException:
on errors reading, or on invalid data
readEntryback to summary
private static void readEntry(POIFSReaderEvent event)
registerListenerback to summary
public void registerListener(final POIFSReaderListener listener)

Register a POIFSReaderListener for all documents

Parameters
listener:POIFSReaderListener

the listener to be registered

Exceptions
NullPointerException:
if listener is null
IllegalStateException:
if read() has already been called
registerListenerback to summary
public void registerListener(final POIFSReaderListener listener, final String name)

Register a POIFSReaderListener for a document in the root directory

Parameters
listener:POIFSReaderListener

the listener to be registered

name:String

the document name

Exceptions
NullPointerException:
if listener is null or name is null or empty
IllegalStateException:
if read() has already been called
registerListenerback to summary
public void registerListener(final POIFSReaderListener listener, final POIFSDocumentPath path, final String name)

Register a POIFSReaderListener for a document in the specified directory

Parameters
listener:POIFSReaderListener

the listener to be registered

path:POIFSDocumentPath

the document path; if null, the root directory is assumed

name:String

the document name

Exceptions
NullPointerException:
if listener is null or name is null or empty
IllegalStateException:
if read() has already been called
setNotifyEmptyDirectoriesback to summary
public void setNotifyEmptyDirectories(boolean notifyEmptyDirectories)

Activates the notification of empty directories.

If this flag is activated, the listener receives POIFSReaderEvents with nulled name and stream

Parameters
notifyEmptyDirectories:boolean

if true, empty directories will be notified