All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class orbasec.corba.CDRBuffer

java.lang.Object
   |
   +----orbasec.corba.CDRBuffer

public class CDRBuffer
extends Object
Lightweight CDR Buffer Encoder Decoder

This is a simple class used for decoding and encoding SECIOP and GIOP messages, without any's and type codes.

This object is used in conjunction with CDREncoder and CDRDecoder. This object handles the endian and conversion to byte arrays. The CDRDecoder and CDREncoder implement the CROBA portable InputStream and InputStream respectively.

Example:

   // Create a Kerberos security component.
   org.omg.SECIOP.KerberosV5 krbcomp = .....;
   // Get a big endian buffer and encoder 
   CDRBuffer  buf = new CDRBuffer();
   CDREncoder enc = new CDREncoder(buf);
   buf.writeEndian(); // writes front enidan boolean for Big endian.
   // Write the security component into the buffer.
   org.omg.SECIOP.KerberosV5Helper.write(enc,krbcomp);
   // Convert the buffer to a byte array.
   byte[] component_data = buf.toByteArray();
 

For decoding:

  // Get Kerberos Security Component Data
  byte[] component_data = ...........;
  // Get a buffer and decoder
  CDRBuffer  buf = new CDRBuffer(component_data,0,component_data.length);
  CDRDecoder dec = new CDRDecoder(buf);
  buf.readEndian(); // Reads the endian boolean at the front. Set's up
                    // for big or little endian based on it.
  // Read the security comonent.
  org.omg.SECIOP.KerberosV5 krb5 =
                 org.omg.SECIOP.KerberosV5Helper.read(dec);
 


Constructor Index

 o CDRBuffer()
Used for creating an empty buffer for encoding.
 o CDRBuffer(byte[])
CDRBuffer(data,0,data.length);
 o CDRBuffer(byte[], int, int)
CDRBuffer(data,start,length,false);
 o CDRBuffer(byte[], int, int, boolean)
Creates a CDR Buffer using the given byte buffer and endian for decoding.
 o CDRBuffer(int)
This ensures capacity.

Method Index

 o advance(int)
Advances the pointer ahead by delta.
 o alloc(int)
Allocated a new internal byte array of the given length.
 o data()
Returns the raw internal byte array.
 o data(byte[])
Sets data as the internal buffer.
 o data(byte[], int)
Sets data as the internal buffer from its start to the specified length.
 o data(byte[], int, int)
Sets data as the internal buffer from the given start position to the specified length.
 o data(byte[], int, int, boolean)
Sets data as the internal buffer from the given start position to the specified length, setting the endian as well.
 o in_length()
Returns the length of data that has been read from the buffer, i.e.
 o is_empty()
In the context of reading, if the current position is upto the length of the buffer, it is empty.
 o is_full()
In the context of writing, if the current position is upto the length of the buffer, it is full.
 o len()
Returns the logical length of the buffer.
 o len(int)
Sets the length of the buffer.
 o length()
Returns the logical length of the buffer.
 o out_length()
Returns the length of data that has been written into the buffer, i.e.
 o pos()
Returns the read position or write position in the buffer.
 o pos(int)
Sets the read/write position of the buffer.
 o read_any()
Not implemented
 o read_boolean()
 o read_boolean_array(boolean[], int, int)
 o read_char()
 o read_char_array(char[], int, int)
 o read_double()
 o read_double_array(double[], int, int)
 o read_float()
 o read_float_array(float[], int, int)
 o read_long()
 o read_long_array(int[], int, int)
 o read_longlong()
 o read_longlong_array(long[], int, int)
 o read_Object()
Not implemented
 o read_octet()
 o read_octet_array(byte[], int, int)
 o read_Principal()
Not implemented
 o read_short()
 o read_short_array(short[], int, int)
 o read_string()
 o read_TypeCode()
Not implemented
 o read_ulong()
 o read_ulong_array(int[], int, int)
 o read_ulonglong()
 o read_ulonglong_array(long[], int, int)
 o read_ushort()
 o read_ushort_array(short[], int, int)
 o read_wchar()
 o read_wchar_array(char[], int, int)
 o read_wstring()
 o readEndian()
Reads and sets the endian from the buffer.
 o realloc(int)
This call will create a new internal data buffer of a new capacity, copying the current internal data buffer into the new one.
 o remainder()
In teh context of reading, this call returns the remainder of the buffer not read as a byte array.
 o rest_length()
Returns the amount left in the buffer, such as during a decoding.
 o start()
Returns the logical start of the buffer.
 o start(int)
Sets the start position of the buffer.
 o swap(boolean)
Sets the endian.
 o toByteArray()
Returns the logical buffer as a byte array.
 o toString()
This method prints out diagnostic information about the buffer.
 o write_any(Any)
Not implemented
 o write_boolean(boolean)
 o write_boolean_array(boolean[], int, int)
 o write_char(char)
 o write_char_array(char[], int, int)
 o write_double(double)
 o write_double_array(double[], int, int)
 o write_float(float)
 o write_float_array(float[], int, int)
 o write_long(int)
 o write_long_array(int[], int, int)
 o write_longlong(long)
 o write_longlong_array(long[], int, int)
 o write_Object(Object)
Not implemented
 o write_octet(byte)
 o write_octet_array(byte[], int, int)
 o write_Principal(Principal)
Principal should be deprecated, but we need it here for the GIOP Request Header.
 o write_short(short)
 o write_short_array(short[], int, int)
 o write_string(String)
 o write_TypeCode(TypeCode)
Not implemented
 o write_ulong(int)
 o write_ulong_array(int[], int, int)
 o write_ulonglong(long)
 o write_ulonglong_array(long[], int, int)
 o write_ushort(short)
 o write_ushort_array(short[], int, int)
 o write_wchar(char)
 o write_wchar_array(char[], int, int)
 o write_wstring(String)
 o writeEndian()
This writes a boolean to the buffer to signify the endian.

Constructors

 o CDRBuffer
 public CDRBuffer(byte data[],
                  int start,
                  int length,
                  boolean endian)
Creates a CDR Buffer using the given byte buffer and endian for decoding.

Parameters:
data - The byte buffer.
start - The position at which the start of the buffer is to logically begin.
length - The logical length of the buffer.
endian - False is big endian.
 o CDRBuffer
 public CDRBuffer(byte data[],
                  int start,
                  int length)
CDRBuffer(data,start,length,false);

 o CDRBuffer
 public CDRBuffer(byte data[])
CDRBuffer(data,0,data.length);

 o CDRBuffer
 public CDRBuffer(int capacity)
This ensures capacity.

 o CDRBuffer
 public CDRBuffer()
Used for creating an empty buffer for encoding.

Methods

 o toString
 public String toString()
This method prints out diagnostic information about the buffer. It has no bearing on the representation of the buffer as a string.

Overrides:
toString in class Object
 o data
 public byte[] data()
Returns the raw internal byte array.

 o length
 public int length()
Returns the logical length of the buffer.

 o rest_length
 public int rest_length()
Returns the amount left in the buffer, such as during a decoding.

 o pos
 public int pos()
Returns the read position or write position in the buffer.

 o start
 public int start()
Returns the logical start of the buffer.

 o pos
 public void pos(int pos)
Sets the read/write position of the buffer.

 o len
 public int len()
Returns the logical length of the buffer.

 o len
 public void len(int pos)
Sets the length of the buffer.

 o start
 public void start(int pos)
Sets the start position of the buffer.

 o advance
 public void advance(int delta)
Advances the pointer ahead by delta. Ensures that buffer has capacity, which means that raw data byte array may change.

 o out_length
 public int out_length()
Returns the length of data that has been written into the buffer, i.e. current position - start position.

 o in_length
 public int in_length()
Returns the length of data that has been read from the buffer, i.e. current position - start position.

 o toByteArray
 public byte[] toByteArray()
Returns the logical buffer as a byte array. If the internal buffer has exactly the same start and size as the logical buffer, the internal array is returned, for efficiency), otherwise a copy is made.

 o is_full
 public boolean is_full()
In the context of writing, if the current position is upto the length of the buffer, it is full.

 o is_empty
 public boolean is_empty()
In the context of reading, if the current position is upto the length of the buffer, it is empty.

 o remainder
 public byte[] remainder()
In teh context of reading, this call returns the remainder of the buffer not read as a byte array.

 o alloc
 public void alloc(int n)
Allocated a new internal byte array of the given length.

 o swap
 public void swap(boolean swap)
Sets the endian. False is big endian

 o realloc
 public void realloc(int n)
This call will create a new internal data buffer of a new capacity, copying the current internal data buffer into the new one.

 o data
 public void data(byte data[])
Sets data as the internal buffer. The edian is not changed.

 o data
 public void data(byte data[],
                  int n)
Sets data as the internal buffer from its start to the specified length. The endian is not changed.

 o data
 public void data(byte data[],
                  int pos,
                  int n)
Sets data as the internal buffer from the given start position to the specified length. The edian is not changed.

 o data
 public void data(byte data[],
                  int pos,
                  int n,
                  boolean swap)
Sets data as the internal buffer from the given start position to the specified length, setting the endian as well.

 o write_boolean
 public synchronized void write_boolean(boolean value)
 o write_char
 public synchronized void write_char(char value)
 o write_wchar
 public synchronized void write_wchar(char value)
 o write_octet
 public synchronized void write_octet(byte value)
 o write_short
 public synchronized void write_short(short value)
 o write_ushort
 public synchronized void write_ushort(short value)
 o write_long
 public synchronized void write_long(int value)
 o write_ulong
 public synchronized void write_ulong(int value)
 o write_longlong
 public synchronized void write_longlong(long value)
 o write_ulonglong
 public synchronized void write_ulonglong(long value)
 o write_float
 public synchronized void write_float(float value)
 o write_double
 public synchronized void write_double(double value)
 o write_string
 public synchronized void write_string(String value)
 o write_wstring
 public synchronized void write_wstring(String value)
 o write_boolean_array
 public synchronized void write_boolean_array(boolean value[],
                                              int offset,
                                              int length)
 o write_char_array
 public synchronized void write_char_array(char value[],
                                           int offset,
                                           int length)
 o write_wchar_array
 public synchronized void write_wchar_array(char value[],
                                            int offset,
                                            int length)
 o write_octet_array
 public synchronized void write_octet_array(byte value[],
                                            int offset,
                                            int length)
 o write_short_array
 public synchronized void write_short_array(short value[],
                                            int offset,
                                            int length)
 o write_ushort_array
 public synchronized void write_ushort_array(short value[],
                                             int offset,
                                             int length)
 o write_long_array
 public synchronized void write_long_array(int value[],
                                           int offset,
                                           int length)
 o write_ulong_array
 public synchronized void write_ulong_array(int value[],
                                            int offset,
                                            int length)
 o write_longlong_array
 public synchronized void write_longlong_array(long value[],
                                               int offset,
                                               int length)
 o write_ulonglong_array
 public synchronized void write_ulonglong_array(long value[],
                                                int offset,
                                                int length)
 o write_float_array
 public synchronized void write_float_array(float value[],
                                            int offset,
                                            int length)
 o write_double_array
 public synchronized void write_double_array(double value[],
                                             int offset,
                                             int length)
 o write_Object
 public synchronized void write_Object(Object value)
Not implemented

 o write_TypeCode
 public synchronized void write_TypeCode(TypeCode tc)
Not implemented

 o write_any
 public synchronized void write_any(Any value)
Not implemented

 o write_Principal
 public synchronized void write_Principal(Principal value)
Principal should be deprecated, but we need it here for the GIOP Request Header.

 o writeEndian
 public synchronized void writeEndian()
This writes a boolean to the buffer to signify the endian. This call is usually used at the begining of the buffer. It always writes false. False means big endian, and we always use big endian in Java.

 o read_boolean
 public synchronized boolean read_boolean()
 o read_char
 public synchronized char read_char()
 o read_wchar
 public synchronized char read_wchar()
 o read_octet
 public synchronized byte read_octet()
 o read_short
 public synchronized short read_short()
 o read_ushort
 public synchronized short read_ushort()
 o read_long
 public synchronized int read_long()
 o read_ulong
 public synchronized int read_ulong()
 o read_longlong
 public synchronized long read_longlong()
 o read_ulonglong
 public synchronized long read_ulonglong()
 o read_float
 public synchronized float read_float()
 o read_double
 public synchronized double read_double()
 o read_string
 public synchronized String read_string()
 o read_wstring
 public synchronized String read_wstring()
 o read_boolean_array
 public synchronized void read_boolean_array(boolean value[],
                                             int offset,
                                             int length)
 o read_char_array
 public synchronized void read_char_array(char value[],
                                          int offset,
                                          int length)
 o read_wchar_array
 public synchronized void read_wchar_array(char value[],
                                           int offset,
                                           int length)
 o read_octet_array
 public synchronized void read_octet_array(byte value[],
                                           int offset,
                                           int length)
 o read_short_array
 public synchronized void read_short_array(short value[],
                                           int offset,
                                           int length)
 o read_ushort_array
 public synchronized void read_ushort_array(short value[],
                                            int offset,
                                            int length)
 o read_long_array
 public synchronized void read_long_array(int value[],
                                          int offset,
                                          int length)
 o read_ulong_array
 public synchronized void read_ulong_array(int value[],
                                           int offset,
                                           int length)
 o read_longlong_array
 public synchronized void read_longlong_array(long value[],
                                              int offset,
                                              int length)
 o read_ulonglong_array
 public synchronized void read_ulonglong_array(long value[],
                                               int offset,
                                               int length)
 o read_float_array
 public synchronized void read_float_array(float value[],
                                           int offset,
                                           int length)
 o read_double_array
 public synchronized void read_double_array(double value[],
                                            int offset,
                                            int length)
 o read_Object
 public synchronized Object read_Object()
Not implemented

 o read_TypeCode
 public synchronized TypeCode read_TypeCode()
Not implemented

 o read_any
 public synchronized Any read_any()
Not implemented

 o read_Principal
 public synchronized Principal read_Principal()
Not implemented

 o readEndian
 public void readEndian()
Reads and sets the endian from the buffer. Usually a boolean written to the beginning of the buffer signifies the endian. False means big endian.


All Packages  Class Hierarchy  This Package  Previous  Next  Index