Package loci.poi.poifs.filesystem
Class POIFSFileSystem
- java.lang.Object
-
- loci.poi.poifs.filesystem.POIFSFileSystem
-
- All Implemented Interfaces:
POIFSViewable
public class POIFSFileSystem extends Object implements POIFSViewable
This is the main class of the POIFS system; it manages the entire life cycle of the filesystem.- Author:
- Marc Johnson (mjohnson at apache dot org)
-
-
Constructor Summary
Constructors Constructor Description POIFSFileSystem()
Constructor, intended for writingPOIFSFileSystem(loci.common.RandomAccessInputStream stream, int size)
Create a POIFSFileSystem from an InputStream
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DirectoryEntry
createDirectory(String name)
create a new DirectoryEntry in the root directoryDocumentEntry
createDocument(String name, int size, POIFSWriterListener writer)
create a new DocumentEntry in the root entry; the data will be provided laterDocumentEntry
createDocument(loci.common.RandomAccessInputStream stream, String name)
Create a new document to be added to the root directoryDocumentInputStream
createDocumentInputStream(String documentName)
open a document in the root entry's list of entriesDirectoryEntry
getRoot()
get the root entryString
getShortDescription()
Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.Object[]
getViewableArray()
Get an array of objects, some of which may implement POIFSViewableIterator
getViewableIterator()
Get an Iterator of objects, some of which may implement POIFSViewablestatic void
main(String[] args)
read in a file and write it back out againboolean
preferArray()
Give viewers a hint as to whether to call getViewableArray or getViewableIteratorvoid
writeFilesystem(OutputStream stream)
Write the filesystem out
-
-
-
Constructor Detail
-
POIFSFileSystem
public POIFSFileSystem()
Constructor, intended for writing
-
POIFSFileSystem
public POIFSFileSystem(loci.common.RandomAccessInputStream stream, int size) throws IOException
Create a POIFSFileSystem from an InputStream- Parameters:
stream
- the InputStream from which to read the data- Throws:
IOException
- on errors reading, or on invalid data
-
-
Method Detail
-
createDocument
public DocumentEntry createDocument(loci.common.RandomAccessInputStream stream, String name) throws IOException
Create a new document to be added to the root directory- Parameters:
stream
- the InputStream from which the document's data will be obtainedname
- the name of the new POIFSDocument- Returns:
- the new DocumentEntry
- Throws:
IOException
- on error creating the new POIFSDocument
-
createDocument
public DocumentEntry createDocument(String name, int size, POIFSWriterListener writer) throws IOException
create a new DocumentEntry in the root entry; the data will be provided later- Parameters:
name
- the name of the new DocumentEntrysize
- the size of the new DocumentEntrywriter
- the writer of the new DocumentEntry- Returns:
- the new DocumentEntry
- Throws:
IOException
-
createDirectory
public DirectoryEntry createDirectory(String name) throws IOException
create a new DirectoryEntry in the root directory- Parameters:
name
- the name of the new DirectoryEntry- Returns:
- the new DirectoryEntry
- Throws:
IOException
- on name duplication
-
writeFilesystem
public void writeFilesystem(OutputStream stream) throws IOException
Write the filesystem out- Parameters:
stream
- the OutputStream to which the filesystem will be written- Throws:
IOException
- thrown on errors writing to the stream
-
main
public static void main(String[] args) throws IOException
read in a file and write it back out again- Parameters:
args
- names of the files; arg[ 0 ] is the input file, arg[ 1 ] is the output file- Throws:
IOException
-
getRoot
public DirectoryEntry getRoot()
get the root entry- Returns:
- the root entry
-
createDocumentInputStream
public DocumentInputStream createDocumentInputStream(String documentName) throws IOException
open a document in the root entry's list of entries- Parameters:
documentName
- the name of the document to be opened- Returns:
- a newly opened DocumentInputStream
- Throws:
IOException
- if the document does not exist or the name is that of a DirectoryEntry
-
getViewableArray
public Object[] getViewableArray()
Get an array of objects, some of which may implement POIFSViewable- Specified by:
getViewableArray
in interfacePOIFSViewable
- Returns:
- an array of Object; may not be null, but may be empty
-
getViewableIterator
public Iterator getViewableIterator()
Get an Iterator of objects, some of which may implement POIFSViewable- Specified by:
getViewableIterator
in interfacePOIFSViewable
- Returns:
- an Iterator; may not be null, but may have an empty back end store
-
preferArray
public boolean preferArray()
Give viewers a hint as to whether to call getViewableArray or getViewableIterator- Specified by:
preferArray
in interfacePOIFSViewable
- Returns:
- true if a viewer should call getViewableArray, false if a viewer should call getViewableIterator
-
getShortDescription
public String getShortDescription()
Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.- Specified by:
getShortDescription
in interfacePOIFSViewable
- Returns:
- short description
-
-