This class manages a document in the POIFS filesystem.
| Constructor: |
public Document(String name,
InputStream stream) throws IOException {
List blocks = new ArrayList();
int size = 0;
while (true)
{
DocumentBlock block = new DocumentBlock(stream);
int blockSize = block.size();
if (blockSize > 0)
{
blocks.add(block);
size += blockSize;
}
if (block.partiallyRead())
{
break;
}
}
_blocks =
( DocumentBlock [] ) blocks.toArray(new DocumentBlock[ 0 ]);
_property = new DocumentProperty(name, size);
_property.setDocument(this);
if (_property.shouldUseSmallBlocks())
{
_small_blocks = SmallDocumentBlock.convert(_blocks, size);
_blocks = new DocumentBlock[ 0 ];
}
else
{
_small_blocks = new BlockWritable[ 0 ];
}
}
Parameters:
name - the name of the Document
stream - the InputStream we read data from
Throws:
IOException - thrown on read errors
- exception:
IOException - thrown on read errors
|
public Document(String name,
RawDataBlock[] blocks,
int length) throws IOException {
_blocks = new DocumentBlock[ blocks.length ];
for (int j = 0; j < blocks.length; j++)
{
_blocks[ j ] = new DocumentBlock(blocks[ j ]);
}
_property = new DocumentProperty(name, length);
_small_blocks = new BlockWritable[ 0 ];
_property.setDocument(this);
}
Constructor from large blocks Parameters:
name - the name of the Document
blocks - the big blocks making up the Document
length - the actual length of the Document
Throws:
IOException -
- exception:
IOException -
|
public Document(String name,
SmallDocumentBlock[] blocks,
int length) {
_blocks = new DocumentBlock[ 0 ];
_property = new DocumentProperty(name, length);
_small_blocks = blocks;
_property.setDocument(this);
}
Constructor from small blocks Parameters:
name - the name of the Document
blocks - the small blocks making up the Document
length - the actual length of the Document
|
public Document(String name,
ListManagedBlock[] blocks,
int length) throws IOException {
_property = new DocumentProperty(name, length);
_property.setDocument(this);
if (Property.isSmall(length))
{
_blocks = new DocumentBlock[ 0 ];
_small_blocks = new SmallDocumentBlock[ blocks.length ];
for (int j = 0; j < blocks.length; j++)
{
_small_blocks[ j ] = ( SmallDocumentBlock ) blocks[ j ];
}
}
else
{
_blocks = new DocumentBlock[ blocks.length ];
for (int j = 0; j < blocks.length; j++)
{
_blocks[ j ] =
new DocumentBlock(( RawDataBlock ) blocks[ j ]);
}
_small_blocks = new BlockWritable[ 0 ];
}
}
Constructor from small blocks Parameters:
name - the name of the Document
blocks - the small blocks making up the Document
length - the actual length of the Document
Throws:
IOException -
- exception:
IOException -
|
| Method from org.apache.cocoon.poi.poifs.filesystem.Document Detail: |
public int countBlocks() {
return _blocks.length;
}
Return the number of BigBlock's this instance uses |
DocumentProperty getDocumentProperty() {
return _property;
}
|
public BlockWritable[] getSmallBlocks() {
return _small_blocks;
}
return the array of SmallDocumentBlocks used |
void read(byte[] buffer,
int offset) {
if (_property.shouldUseSmallBlocks())
{
SmallDocumentBlock.read(_small_blocks, buffer, offset);
}
else
{
DocumentBlock.read(_blocks, buffer, offset);
}
}
read data from the internal stores |
public void setStartBlock(int index) {
_property.setStartBlock(index);
}
Set the start block for this instance |
public void writeBlocks(OutputStream stream) throws IOException {
for (int k = 0; k < _blocks.length; k++)
{
_blocks[ k ].writeBlocks(stream);
}
}
Write the storage to an OutputStream |