Package loci.poi.poifs.filesystem
Class POIFSDocument
- java.lang.Object
-
- loci.poi.poifs.filesystem.POIFSDocument
-
- All Implemented Interfaces:
POIFSViewable
,BATManaged
,BlockWritable
public class POIFSDocument extends Object implements BATManaged, BlockWritable, POIFSViewable
This class manages a document in the POIFS filesystem.- Author:
- Marc Johnson (mjohnson at apache dot org)
-
-
Constructor Summary
Constructors Constructor Description POIFSDocument(String name, int size, POIFSDocumentPath path, POIFSWriterListener writer, int blockSize)
ConstructorPOIFSDocument(String name, loci.common.RandomAccessInputStream stream, int size)
ConstructorPOIFSDocument(String name, ListManagedBlock[] blocks, int length, int size)
Constructor from small blocksPOIFSDocument(String name, RawDataBlock[] blocks, int length)
Constructor from large blocksPOIFSDocument(String name, SmallDocumentBlock[] blocks, int length)
Constructor from small blocks
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
countBlocks()
Return the number of BigBlock's this instance usesDocumentBlock[]
getBigBlocks()
int
getBigBlockSize()
String
getShortDescription()
Provides a short description of the object, to be used when a POIFSViewable object has not provided its contents.int
getSize()
BlockWritable[]
getSmallBlocks()
return the array of SmallDocumentBlocks usedObject[]
getViewableArray()
Get an array of objects, some of which may implement POIFSViewableIterator
getViewableIterator()
Get an Iterator of objects, some of which may implement POIFSViewableboolean
preferArray()
Give viewers a hint as to whether to call getViewableArray or getViewableIteratorvoid
setStartBlock(int index)
Set the start block for this instancevoid
writeBlocks(OutputStream stream)
Write the storage to an OutputStream
-
-
-
Constructor Detail
-
POIFSDocument
public POIFSDocument(String name, RawDataBlock[] blocks, int length) throws IOException
Constructor from large blocks- Parameters:
name
- the name of the POIFSDocumentblocks
- the big blocks making up the POIFSDocumentlength
- the actual length of the POIFSDocument- Throws:
IOException
-
POIFSDocument
public POIFSDocument(String name, SmallDocumentBlock[] blocks, int length)
Constructor from small blocks- Parameters:
name
- the name of the POIFSDocumentblocks
- the small blocks making up the POIFSDocumentlength
- the actual length of the POIFSDocument
-
POIFSDocument
public POIFSDocument(String name, ListManagedBlock[] blocks, int length, int size) throws IOException
Constructor from small blocks- Parameters:
name
- the name of the POIFSDocumentblocks
- the small blocks making up the POIFSDocumentlength
- the actual length of the POIFSDocument- Throws:
IOException
-
POIFSDocument
public POIFSDocument(String name, loci.common.RandomAccessInputStream stream, int size) throws IOException
Constructor- Parameters:
name
- the name of the POIFSDocumentstream
- the InputStream we read data from- Throws:
IOException
- thrown on read errors
-
POIFSDocument
public POIFSDocument(String name, int size, POIFSDocumentPath path, POIFSWriterListener writer, int blockSize) throws IOException
Constructor- Parameters:
name
- the name of the POIFSDocumentsize
- the length of the POIFSDocumentpath
- the path of the POIFSDocumentwriter
- the writer who will eventually write the document contents- Throws:
IOException
- thrown on read errors
-
-
Method Detail
-
getSmallBlocks
public BlockWritable[] getSmallBlocks()
return the array of SmallDocumentBlocks used- Returns:
- array of SmallDocumentBlocks; may be empty, cannot be null
-
getBigBlocks
public DocumentBlock[] getBigBlocks()
-
getSize
public int getSize()
- Returns:
- size of the document
-
getBigBlockSize
public int getBigBlockSize()
-
writeBlocks
public void writeBlocks(OutputStream stream) throws IOException
Write the storage to an OutputStream- Specified by:
writeBlocks
in interfaceBlockWritable
- Parameters:
stream
- the OutputStream to which the stored data should be written- Throws:
IOException
- on problems writing to the specified stream
-
countBlocks
public int countBlocks()
Return the number of BigBlock's this instance uses- Specified by:
countBlocks
in interfaceBATManaged
- Returns:
- count of BigBlock instances
-
setStartBlock
public void setStartBlock(int index)
Set the start block for this instance- Specified by:
setStartBlock
in interfaceBATManaged
- Parameters:
index
- index into the array of blocks making up the filesystem
-
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
-
-