gnu.iou
Class bbp

java.lang.Object
  |
  +--gnu.iou.bbuf
        |
        +--gnu.iou.bbp

public class bbp
extends bbuf

Pipe for `bbo' and `bbi' implements input blocking over `bbuf'.

Usage

 bbp pipe = new bbp();
 OutputStream pipeOut = new bbo(pipe);
 InputStream pipeIn = new bbi(pipe);
 

Thread safety

This class is multi- thread safe only in the standard I/O API defined here and used by `bbo' and `bbi'. Note that `bbuf' is not multi- thread safe.

The mutex locker is accessable via the `getLocker()' method.

Author:
John Pritchard (john@syntelos.org)
See Also:
bbo, bbi, dbo

Field Summary
protected  boolean apierrors
           
protected  lck locker
           
 
Constructor Summary
bbp()
           
bbp(boolean api_exc)
           
bbp(byte[] buffer)
           
bbp(int init)
           
 
Method Summary
 void close()
          Reset reading, writing and "read mark" to the start.
 void flush()
          Reset reading, writing and "read mark" to the head of the current buffer.
 lck getLocker()
           
 void mark(int readlimit)
          Sets "reset" (writing) mark to the current position, ignoring "readlimit" because this is a buffer -- we don't need a buffer size.
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
          Copy into buffer as many as buffer- length bytes, or available bytes.
 void reset()
          Reset writing back to first byte of the current buffer, or to the last marked position.
 long skip(long n)
          Skip bytes, or available bytes.
 int write(byte[] b)
           
 int write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class gnu.iou.bbuf
append, append, append, append, append, append, append, append, available, buf_gf, bufString, cat, copyOutArray, copyOutLoop, debugPrint, destroy, dump, growbuf, length, mark, markedBits, nwrite, print, println, println, println, println, read2, read4, read8, toByteArray, toByteArray, toByteArray, toByteArray, toByteArray, toString, write2, write4, write8
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

locker

protected final lck locker

apierrors

protected boolean apierrors
Constructor Detail

bbp

public bbp()

bbp

public bbp(boolean api_exc)
Parameters:
api_exc - If true, throw exceptions on I/O methods that shouldn't be used on the pipe.

bbp

public bbp(int init)

bbp

public bbp(byte[] buffer)
Method Detail

getLocker

public lck getLocker()

read

public int read()
Overrides:
read in class bbuf

read

public int read(byte[] b)
Overrides:
read in class bbuf

read

public int read(byte[] b,
                int off,
                int len)
Description copied from class: bbuf
Copy into buffer as many as buffer- length bytes, or available bytes.
Overrides:
read in class bbuf
Following copied from class: gnu.iou.bbuf
Parameters:
b - Non null buffer to copy into.
off - Valid offset in buffer `b' to copy to.
len - Valid number of bytes to copy into `b', usually `b.length'.

skip

public long skip(long n)
Description copied from class: bbuf
Skip bytes, or available bytes.
Overrides:
skip in class bbuf
Following copied from class: gnu.iou.bbuf
Parameters:
n - Number of bytes to skip.

mark

public void mark(int readlimit)
Description copied from class: bbuf
Sets "reset" (writing) mark to the current position, ignoring "readlimit" because this is a buffer -- we don't need a buffer size.
Overrides:
mark in class bbuf
Following copied from class: gnu.iou.bbuf
See Also:
The readlimit argument is ignored because this is a buffer

reset

public void reset()
Description copied from class: bbuf
Reset writing back to first byte of the current buffer, or to the last marked position. Also reset the writing mark to zero so that two (or more) calls to reset clears any mark.
Overrides:
reset in class bbuf

markSupported

public boolean markSupported()
Overrides:
markSupported in class bbuf

write

public void write(int b)
Overrides:
write in class bbuf
Following copied from class: gnu.iou.bbuf
Parameters:
b - Eight bit byte value

write

public int write(byte[] b)
Overrides:
write in class bbuf
Following copied from class: gnu.iou.bbuf
Parameters:
b - Non null buffer to copy into the internal buffer.

write

public int write(byte[] b,
                 int off,
                 int len)
Overrides:
write in class bbuf
Following copied from class: gnu.iou.bbuf
Parameters:
b - Non null input buffer to copy into the internal buffer.
off - Offset in input buffer `b' from which to copy
len - Number of bytes to copy from input buffer `b'.

flush

public void flush()
Description copied from class: bbuf
Reset reading, writing and "read mark" to the head of the current buffer. (Same as "close".)
Overrides:
flush in class bbuf

close

public void close()
Description copied from class: bbuf
Reset reading, writing and "read mark" to the start. (Same as "flush".)
Overrides:
close in class bbuf