It wraps PSTObject.processArray() and getBlockOffsets() as well as
getOffsetIndexNode(). The same sequence is used in many places:
class PSTFileBlock{
byte[] data = null;
int[] blockOffsets = null;
}
public PSTFileBlockreadLeaf(long bid)
throws IOException, PSTException
{
PSTFileBlockret = new PSTFileBlock();
// get the index node for the descriptor index
OffsetIndexItem offsetItem = PSTObject.getOffsetIndexNode(in, bid);
boolean bInternal = (offsetItem.indexIdentifier & 0x02) != 0;
ret.data = new byte[offsetItem.size];
in.seek(offsetItem.fileOffset);
in.read(ret.data);
if ( bInternal &&
offsetItem.size >= 8 && // temporary, too short should throw an
exception
ret.data[0] == 1 )
{
// (X)XBLOCK
if ( ret.data[1] == 2 ) {
throw new PSTException("XXBLOCKS not supported yet!");
}
ret.blockOffsets = PSTObject.getBlockOffsets(in, ret.data);
ret.data = PSTObject.processArray(in, ret.data);
bInternal = false;
}
// (Internal blocks aren't compressed)
if ( !bInternal &&
encryptionType == PSTFile.ENCRYPTION_TYPE_COMPRESSIBLE)
{
ret.data = PSTObject.decode(ret.data);
}
return ret;
}
It could go in PSTObject as a static method instead - but would then
need the PSTFile as a parameter. I think both processArray and
getBlockOffsets could be combined into this function, but I haven't
looked at that yet - this method is a step in that direction though.
For tables in XBLOCKS, I've made the rgbiAlloc array two dimensional
so getNodeInfo() doesn't need to treat whichBlock > 0 specially.
Orin.
> > On Thu, Aug 12, 2010 at 3:30 AM, Richard Johnson <
rjohnson.id...@gmail.com
> > > wrote:
>
> >> Totally agree, I think that something like a PSTAttachmentInputStream
> >> would be the way to go.
>
> >> I do think however that we would be better off completely removing the
> >> getFileContents function rather than throwing a exception, as I feel that
> >> most users will forget to test for the exception, and given the rarity of
> >> the XXBlock (they weren't even in the docs I had originally) I wouldn't
> >> be surprised if it's not picked up. I concede it is inconvenient to change
> >> the API on people, but if people have to work in code to deal with
> >> exceptions, we may as well just make them move over to using an input
> >> stream.
>
> >> Thoughts? If we are happy with this I could probably look into it a bit
> >> over the weekend.
>
> >> Richard
>
> >> On Thu, Aug 12, 2010 at 3:55 AM, Orin <
orin.e...@gmail.com> wrote:
>
> >>> (See Issue 20.)
>
> >>> In my opinion, it would be impractical to read a very large message or
> >>> attachment into a byte array all at once, so I'd like to open
> >>> discussion on how we should handle such data.
>
> >>> I'm thinking some kind of stream interface that the user could read in
> >>> reasonably sized chunks so that all the data need not be in memory at
> >>> the same time.
>
> >>> There is the associated problem of informing the user to use the
> >>> stream interface rather than the existing interfaces that return a
> >>> byte array. I see a couple of options - an exception that says the
> >>> data is too large and a separate API to return a stream, or a special
> >>> exception that contains the stream - this wouldn't need any new APIs.
> >>> The transition between just returning a byte array and throwing the
> >>> exception would be when the data is in an XXBLOCK rather than an
> >>> XBLOCK or regular block - a little under 8MB by my quick calculations.
>
> >>> Orin.- Hide quoted text -
>
> - Show quoted text -