org.netbeans.mdr.persistence.btreeimpl.btreestorage
Class CachedPageInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byorg.netbeans.mdr.persistence.btreeimpl.btreestorage.CachedPageInputStream

public class CachedPageInputStream
extends java.io.InputStream

A stream composed of segments stored in CachedPages. The pages are pinned while members of a CachedPageInputStream. When done with the stream, close it to unpin the pages.


Constructor Summary
CachedPageInputStream()
           
 
Method Summary
 void addPage(CachedPage pg, int offst, int len)
          Add a page to the stream
 int available()
          report how many bytes are still unread
 void close()
          close the stream.
protected  void finalize()
          if the stream was never closed, unpin the pages now
 void mark(int readlimit)
          mark a spot in the stream, which reset will return to
 boolean markSupported()
          this class supports mark (since it's easy)
 int read()
          read a byte from the stream
 int read(byte[] b)
          read bytes into an array
 int read(byte[] b, int offset, int length)
          read bytes into an array
 void reset()
          return to where mark was last called, or to the beginning if mark was never called.
 
Methods inherited from class java.io.InputStream
skip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachedPageInputStream

public CachedPageInputStream()
Method Detail

addPage

public void addPage(CachedPage pg,
                    int offst,
                    int len)
Add a page to the stream

Parameters:
pg - the page to add
offst - the offset in the page where the stream data begins

close

public void close()
           throws java.io.IOException
close the stream. This unpins all of the pages from the cache.

Throws:
java.io.IOException - if there is an error unpinning the pages.

read

public int read()
read a byte from the stream

Returns:
The next byte in the stream, or -1 if at EOF.

read

public int read(byte[] b)
read bytes into an array

Parameters:
b - up to b.length bytes are read into this array
Returns:
The number of bytes read. If at EOF, -1 is returned

read

public int read(byte[] b,
                int offset,
                int length)
read bytes into an array

Parameters:
b - up to length bytes are read into this array
offset - the offset into the array at whch to start storing bytes
Returns:
The number of bytes read. If at EOF, -1 is returned

markSupported

public boolean markSupported()
this class supports mark (since it's easy)

Returns:
true, since we support mark

mark

public void mark(int readlimit)
mark a spot in the stream, which reset will return to

Parameters:
readlimit - ignored

available

public int available()
report how many bytes are still unread

Returns:
number of bytes left in stream

reset

public void reset()
return to where mark was last called, or to the beginning if mark was never called.


finalize

protected void finalize()
                 throws StorageException
if the stream was never closed, unpin the pages now

Throws:
StorageException


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.