org.openorb.orb.io
Class AbstractInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--org.omg.CORBA.portable.InputStream
              |
              +--org.omg.CORBA_2_3.portable.InputStream
                    |
                    +--org.openorb.orb.io.AbstractInputStream
All Implemented Interfaces:
ExtendedInputStream
Direct Known Subclasses:
CDRInputStream

public abstract class AbstractInputStream
extends org.omg.CORBA_2_3.portable.InputStream
implements ExtendedInputStream

This class can be used as a base class for buffer input stream implementations. It handles buffer management.

Author:
Chris Wood, Michael Rumpf

Constructor Summary
AbstractInputStream(BufferSource source)
          Constructor.
AbstractInputStream(StorageBuffer buf)
          Constructor.
 
Method Summary
 int available()
          Available bytes in the input buffer.
protected  void cancel(org.omg.CORBA.SystemException ex)
          Notify source of cancelation of input.
protected  void force_skip(int len)
          Try to force skipping a number of bytes.
 java.lang.String get_codebase()
          Get codebase associated with stream.
 void mark(int readlimit)
          Set a mark at the current buffer position.
 boolean markSupported()
          Check if the buffer supports position demarcation.
protected  int next(org.omg.CORBA.OctetSeqHolder dst, org.omg.CORBA.IntHolder off, org.omg.CORBA.IntHolder len)
          Handles obtaining new buffer if old one is empty.
 int read()
          Read a single octet from a stream.
 int read(byte[] val)
          Read array from stream.
 int read(byte[] val, int off, int len)
          Read array from stream.
 void reset()
          Reset the current position to the latest mark.
 long skip(long count)
          Skip over bytes in the input buffer.
 
Methods inherited from class org.omg.CORBA_2_3.portable.InputStream
read_abstract_interface, read_abstract_interface, read_value, read_value, read_value, read_value, read_value
 
Methods inherited from class org.omg.CORBA.portable.InputStream
orb, read_any, read_boolean_array, read_boolean, read_char_array, read_char, read_Context, read_double_array, read_double, read_fixed, read_fixed, read_float_array, read_float, read_long_array, read_long, read_longlong_array, read_longlong, read_Object, read_Object, read_octet_array, read_octet, read_Principal, read_short_array, read_short, read_string, read_TypeCode, read_ulong_array, read_ulong, read_ulonglong_array, read_ulonglong, read_ushort_array, read_ushort, read_wchar_array, read_wchar, read_wstring
 
Methods inherited from class java.io.InputStream
close
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openorb.orb.io.ExtendedInputStream
orb, read_fixed, read_fixed
 

Constructor Detail

AbstractInputStream

public AbstractInputStream(StorageBuffer buf)
Constructor. Use the passed buffer to perform the stream IO operations on.
Parameters:
buf - The storage buffer used as input source,

AbstractInputStream

public AbstractInputStream(BufferSource source)
Constructor.
Parameters:
source - The source of buffers for this input stream.
Method Detail

get_codebase

public java.lang.String get_codebase()
Get codebase associated with stream.
Specified by:
get_codebase in interface ExtendedInputStream
Returns:
The contents of any TAG_JAVA_CODEBASE service context when unmarshaling, or otherwise return null.

read

public int read()
         throws java.io.IOException
Read a single octet from a stream.
Overrides:
read in class org.omg.CORBA.portable.InputStream
Returns:
The actual number of bytes read or -1 for the end of the stream rather than throwing an exception.

read

public int read(byte[] val)
Read array from stream.
Overrides:
read in class java.io.InputStream
Parameters:
val - The array into which to read the data.
Returns:
The actual number of bytes read or -1 for end of stream rather than throwing an exception.

read

public int read(byte[] val,
                int off,
                int len)
Read array from stream.
Overrides:
read in class java.io.InputStream
Parameters:
val - The array into which to read the data.
off - The offset to skip from the beginning.
len - The requested number of bytes to read.
Returns:
The actual number of bytes read or -1 for end of stream rather than throwing an exception.

force_skip

protected void force_skip(int len)
Try to force skipping a number of bytes. Throw a MARSHAL exception if skipping fails.
Parameters:
len - The number of bytes to skip.

cancel

protected void cancel(org.omg.CORBA.SystemException ex)
Notify source of cancelation of input.
Parameters:
ex - The exception which is used for notification.

available

public int available()
Available bytes in the input buffer. This can change upwards as fragments arrive.
Overrides:
available in class java.io.InputStream
Returns:
The number of available bytes.

markSupported

public boolean markSupported()
Check if the buffer supports position demarcation.
Overrides:
markSupported in class java.io.InputStream
Returns:
Always true.

mark

public void mark(int readlimit)
Set a mark at the current buffer position.
Overrides:
mark in class java.io.InputStream
Parameters:
readlimit - NOT USED

reset

public void reset()
           throws java.io.IOException
Reset the current position to the latest mark.
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException - An IOException is thrown when there is no mark where the buffer can be reset to.

skip

public long skip(long count)
Skip over bytes in the input buffer.
Overrides:
skip in class java.io.InputStream
Parameters:
count - The number of bytes to skip.

next

protected int next(org.omg.CORBA.OctetSeqHolder dst,
                   org.omg.CORBA.IntHolder off,
                   org.omg.CORBA.IntHolder len)
Handles obtaining new buffer if old one is empty.
Parameters:
dst - The destination where the bytes should be copied to.
off - The offset to skip on the source buffer.
len - The request number of bytes from the buffer.
Returns:
The number of actual bytes.