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