org.ipdr.xdr
Class XDRMarshaller

java.lang.Object
  extended by java.io.OutputStream
      extended by org.ipdr.xdr.XDRMarshaller
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class XDRMarshaller
extends java.io.OutputStream

This class will write object to OutputStream in the XDR format.


Field Summary
protected static byte FALSE
          Byte containing FALSE value
protected  java.lang.String ipdrVersion_
          String containing IPDR Version
protected  java.io.OutputStream targetStream_
          To store the object of the Output Stream
protected static byte TRUE
          Byte containing TRUE value
 
Constructor Summary
XDRMarshaller(java.io.OutputStream os)
          Constructor for the XDRMarshaller object.
 
Method Summary
 void close()
          Method to close the output stream.
static void displayByteArray(byte[] byteArray)
          A simple utility to format a byte array in hexadecimal for easy inspection.
 void flush()
          Method to flush the output stream.
 java.lang.String getVersion()
          Method to get the IPDR Version.
static void main(java.lang.String[] args)
          Simple demonstration entry point.
 void setVersion(java.lang.String ver)
          Method to set the IPDR Version.
 void write_boolean(boolean b)
          Method to write a 'boolean' to the output stream.
 void write_byte(byte v)
          Method to write a 'byte' to the output stream.
 void write_double(double v)
          Method to write a 'double' to the output stream.
 void write_float(float v)
          Method to write a 'float' to the output stream.
 void write_long(int v)
          Method to write an 'int' to the output stream.
 void write_longlong(long v)
          Method to write a 'long' to the output stream.
 void write_octet_array(byte[] array, int off, int len)
          Method to write a 'octet array' to the output stream.
 void write_short(short v)
          Method to write a 'short' to the output stream.
 void write_u_long(long v)
          Method to write an 'unsigned int' to the output stream.
 void write_wstring(java.lang.String v)
          Method to write a 'string' to the output stream.
 void write(int b)
          Method to write a 'byte' to the output stream.
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targetStream_

protected java.io.OutputStream targetStream_
To store the object of the Output Stream


TRUE

protected static final byte TRUE
Byte containing TRUE value

See Also:
Constant Field Values

FALSE

protected static final byte FALSE
Byte containing FALSE value

See Also:
Constant Field Values

ipdrVersion_

protected java.lang.String ipdrVersion_
String containing IPDR Version

Constructor Detail

XDRMarshaller

public XDRMarshaller(java.io.OutputStream os)
Constructor for the XDRMarshaller object. Sets the output stream.

Parameters:
os - Output stream
Method Detail

setVersion

public void setVersion(java.lang.String ver)
Method to set the IPDR Version.

Parameters:
ver - IPDR Version.

getVersion

public java.lang.String getVersion()
Method to get the IPDR Version.


write

public void write(int b)
           throws java.io.IOException
Method to write a 'byte' to the output stream.

Specified by:
write in class java.io.OutputStream
Parameters:
b - the 'byte' to write
Throws:
java.io.IOException - when an exception occurs while writing

write_long

public void write_long(int v)
                throws java.io.IOException
Method to write an 'int' to the output stream.

Parameters:
v - the 'int' to write
Throws:
java.io.IOException - when an exception occurs while writing

write_u_long

public void write_u_long(long v)
                  throws java.io.IOException
Method to write an 'unsigned int' to the output stream.

Parameters:
v - the 'unsigned int' to write
Throws:
java.io.IOException - when an exception occurs while writing

write_longlong

public void write_longlong(long v)
                    throws java.io.IOException
Method to write a 'long' to the output stream.

Parameters:
v - the 'long' to write
Throws:
java.io.IOException - when an exception occurs while writing

write_float

public void write_float(float v)
                 throws java.io.IOException
Method to write a 'float' to the output stream.

Parameters:
v - the 'float' to write
Throws:
java.io.IOException - when an exception occurs while writing

write_double

public void write_double(double v)
                  throws java.io.IOException
Method to write a 'double' to the output stream.

Parameters:
v - the 'double' to write
Throws:
java.io.IOException - when an exception occurs while writing

write_octet_array

public void write_octet_array(byte[] array,
                              int off,
                              int len)
                       throws java.io.IOException
Method to write a 'octet array' to the output stream.

Parameters:
array - the data
off - the start offset in the data
len - the number of bytes to write
Throws:
java.io.IOException - when an exception occurs while writing

write_wstring

public void write_wstring(java.lang.String v)
                   throws java.io.IOException
Method to write a 'string' to the output stream. Use the convention of encoding the string in its UTF-8 format. For a good description of UTF-8 encoding see:

http://www1.tip.nl/~t876506/utf8tbl.html

Parameters:
v - the 'string' to write
Throws:
java.io.IOException - when an exception occurs while writing

write_byte

public void write_byte(byte v)
                throws java.io.IOException
Method to write a 'byte' to the output stream.

Parameters:
v - the 'byte' to write
Throws:
java.io.IOException - when an exception occurs while writing

write_boolean

public void write_boolean(boolean b)
                   throws java.io.IOException
Method to write a 'boolean' to the output stream.

Parameters:
b - the 'boolean' to write
Throws:
java.io.IOException - when an exception occurs while writing

write_short

public void write_short(short v)
                 throws java.io.IOException
Method to write a 'short' to the output stream.

Parameters:
v - the 'short' to write
Throws:
java.io.IOException - when an exception occurs while writing

flush

public void flush()
           throws java.io.IOException
Method to flush the output stream.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - when an exception occurs while flushing

close

public void close()
           throws java.io.IOException
Method to close the output stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - when an exception occurs while closing

main

public static void main(java.lang.String[] args)
Simple demonstration entry point.


displayByteArray

public static void displayByteArray(byte[] byteArray)
A simple utility to format a byte array in hexadecimal for easy inspection. Writes to stdout.

Parameters:
byteArray - the byte array to write