All Packages  This Package  Class Hierarchy  Class Search  Index

Class edu.utah.janos.antsr.core.Xdr
java.lang.Object
   |
   +----edu.utah.janos.antsr.core.Xdr

  Summary

public final class  Xdr
     extends java.lang.Object
{
          // Fields 11
     public static final int BOOLEAN;
     public static final int BYTE;
     public static final int INT;
     public static final int LONG;
     public static final int SHORT;
     public static final int TYPEID;
     private byte[] buf;
     private int index;
     private int len;
     private int offset;
     private Xdr parent;

          // Constructors 8
     public Xdr(byte[]);
     public Xdr(byte[], int);
     public Xdr(byte[], int, int) throws IndexOutOfBoundsException;
     public Xdr(ByteArray, int);
     public Xdr(ByteArray, int, int) throws IndexOutOfBoundsException;
     Xdr(Xdr, int);
     Xdr(Xdr, int, int) throws IndexOutOfBoundsException;
     public Xdr(int);

          // Methods 25
     public static final int BYTEARRAY(ByteArray);
     public static final int STRING(String);

     public final boolean BOOLEAN();
     public final byte BYTE();
     public final ByteArray BYTEARRAY();
     public final void BYTES(byte[], int, int);
     public final int INT();
     public final long LONG();
     public final void PUT(boolean);
     public final void PUT(byte);
     public final void PUT(byte[], int, int);
     public final void PUT(ByteArray);
     public final void PUT(TypeID);
     public final void PUT(int);
     public final void PUT(String);
     public final void PUT(long);
     public final void PUT(short);
     public final short SHORT();
     public final String STRING();
     public final TypeID TYPEID();
     byte[] getBytes();
     int index();
     public final int length();
     Xdr reset();
     public final void skip(int);
}

An Xdr instance encapsulates an external, byte-oriented data structure (an "External Data Representation".) Xdr's can include Strings, byte arrays, booleans, bytes, shorts, ints, longs, TypeIDs. Elements must encoded/decoded serially to/from the Xdr.

Xdr's may be hierarchical. That is an xdr may subdivide its buffer space into child buffers.

Xdr's will allocate a byte[] when constructed, or alternatively they can use a given byte[], a ByteArray, another Xdr (parenting), or a Core Buffer.

These methods are declared final so that they can be inlined with optimization.

Author:
David Wetherall


  Cross Reference

Returned By:
Many





  Fields

· BOOLEAN

Summary  |  Top
   public static final int BOOLEAN

The length of a boolean in an xdr.


· BYTE

Summary  |  Top
   public static final int BYTE

The length of a byte in an xdr.


· SHORT

Summary  |  Top
   public static final int SHORT

The length of a short in an xdr.


· INT

Summary  |  Top
   public static final int INT

The length of a int in an xdr.


· LONG

Summary  |  Top
   public static final int LONG

The length of a long in an xdr.


· TYPEID

Summary  |  Top
   public static final int TYPEID

The length of a typeid in an xdr.


· buf

Summary  |  Top
   private byte[] buf

The byte array encoding. XXX final?


· offset

Summary  |  Top
   private int offset

Base offset in the buf. The "start" of the xdr encoding. XXX final?


· len

Summary  |  Top
   private int len

Internal buffer length. XXX final?


· index

Summary  |  Top
   private int index

Current index in the encoding. Serializing and deserialzing automatically increment this offset.


· parent

Summary  |  Top
   private Xdr parent

A parent xdr. A parent can subdivide is xdr buffer among child Xdrs. XXX final?


  Constructors

· Xdr

Summary  |  Top

   public Xdr(int len) 

Create a new xdr with a buffer of len bytes for encoding.

Parameter Description
len the size of the buffer to create.



· Xdr

Summary  |  Top
   public Xdr(byte[] buf) 

Create a new xdr using the given buffer. Does NOT copy the given buf.

XXX probably shouldn't be public.

Parameter Description
buf the buffer to use.



· Xdr

Summary  |  Top
   public Xdr(ByteArray buf, 
              int offset) 

Create a new xdr using the buffer in the given ByteArray.

Parameter Description
buf the ByteArray to steal the byte[] from
offset offset to start at in the ByteArray



· Xdr

Summary  |  Top
   public Xdr(ByteArray buf, 
              int offset, 
              int len)  throws IndexOutOfBoundsException

Create a new xdr using the buffer in the given ByteArray.

Parameter Description
buf the ByteArray to steal the byte[] from
offset offset to start at in the ByteArray
len length of ByteArray to use



· Xdr

Summary  |  Top
   public Xdr(byte[] buf, 
              int offset) 

Create a new xdr using the given portion of the given buffer.

Parameter Description
buf the buffer to use.
offset only encode in the portion of the buffer starting at offset.



· Xdr

Summary  |  Top
   public Xdr(byte[] buf, 
              int offset, 
              int len)  throws IndexOutOfBoundsException

Create a new xdr using the given portion of the given buffer.

Parameter Description
buf the buffer to use.
offset only encode in the portion of the buffer starting at offset.
len only encode using len bytes of the buffer.



· Xdr

Summary  |  Top
   Xdr(Xdr parent, 
       int offset) 

Package-only constructor for creating an xdr as a subsequence of a parent xdr. New xdr will manage remainder of parent xdr's buffer.

Parameter Description
parent Xdr to steal buffer space from.
offset Offset in parent buffer to start.



· Xdr

Summary  |  Top
   Xdr(Xdr parent, 
       int offset, 
       int len)  throws IndexOutOfBoundsException

Package-only constructor for creating an xdr as a subsequence of a parent xdr. New xdr will manage only the given portion of parent's buffer.

Parameter Description
parent Xdr to steal buffer space from.
offset Offset in parent buffer to start.
len Length of the buffer to manage.



  Methods

· reset

Summary  |  Top
   Xdr reset() 

Reset an xdr stream.

Package-access only.

Returns:
For convenience, return Xdr stream that was reset.


· index

Summary  |  Top
   int index() 

Return the current index in the xdr.



· STRING

Summary  |  Top
   public static final int STRING(String x) 

Return the number of bytes required t encode x in the xdr. Does not actually encode the string. Handles null strings just fine.

The string had best be less than 256 characters long.

The string had best be in ASCII. (Or some other one-to-one encoding of characters into bytes.)

Parameter Description
x the string to check

Returns:
the number of bytes required in the xdr


· BYTEARRAY

Summary  |  Top
   public static final int BYTEARRAY(ByteArray x) 

Return the number of bytes required to encode a ByteArray in the xdr. Does not actually encode the ByteArray. Handles null just fine.

The ByteArray must be less than 65,535 bytes.

Parameter Description
x the ByteArray to check

Returns:
the number of bytes required in the xdr.


· length

Summary  |  Top
   public final int length() 

Return the size of the buffer used by this xdr.

Returns:
the size of the buffer used by this xdr.


· PUT

Summary  |  Top
   public final void PUT(boolean x) 

Encode the given boolean into this xdr. There must be sufficient space in this xdr preallocated.



· PUT

Summary  |  Top
   public final void PUT(byte x) 


· PUT

Summary  |  Top
   public final void PUT(short x) 


· PUT

Summary  |  Top
   public final void PUT(int x) 


· PUT

Summary  |  Top
   public final void PUT(long x) 


· PUT

Summary  |  Top
   public final void PUT(TypeID t) 


· PUT

Summary  |  Top
   public final void PUT(String x) 


· PUT

Summary  |  Top
   public final void PUT(ByteArray x) 


· PUT

Summary  |  Top
   public final void PUT(byte[] x, 
                         int start, 
                         int length) 


· BOOLEAN

Summary  |  Top
   public final boolean BOOLEAN() 


· BYTE

Summary  |  Top
   public final byte BYTE() 


· SHORT

Summary  |  Top
   public final short SHORT() 


· INT

Summary  |  Top
   public final int INT() 


· LONG

Summary  |  Top
   public final long LONG() 


· TYPEID

Summary  |  Top
   public final TypeID TYPEID() 


· STRING

Summary  |  Top
   public final String STRING() 


· BYTEARRAY

Summary  |  Top
   public final ByteArray BYTEARRAY() 


· BYTES

Summary  |  Top
   public final void BYTES(byte[] x, 
                           int start, 
                           int length) 


· skip

Summary  |  Top
   public final void skip(int count) 


· getBytes

Summary  |  Top
   byte[] getBytes() 


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7