|
ANTS v2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ants.core.Xdr
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.
Field Summary | |
static int |
BOOLEAN
The length of a boolean in an xdr. |
static int |
BYTE
The length of a byte in an xdr. |
static int |
INT
The length of a int in an xdr. |
static int |
LONG
The length of a long in an xdr. |
static int |
SHORT
The length of a short in an xdr. |
static int |
TYPEID
The length of a typeid in an xdr. |
Constructor Summary | |
Xdr(byte[] buf)
Create a new xdr using the given buffer. |
|
Xdr(byte[] buf,
int offset)
Create a new xdr using the given portion of the given buffer. |
|
Xdr(byte[] buf,
int offset,
int len)
Create a new xdr using the given portion of the given buffer. |
|
Xdr(ByteArray buf,
int offset)
Create a new xdr using the buffer in the given ByteArray. |
|
Xdr(ByteArray buf,
int offset,
int len)
Create a new xdr using the buffer in the given ByteArray. |
|
Xdr(int len)
Create a new xdr with a buffer of len bytes for encoding. |
Method Summary | |
boolean |
BOOLEAN()
|
byte |
BYTE()
|
ByteArray |
BYTEARRAY()
|
static int |
BYTEARRAY(ByteArray x)
Return the number of bytes required to encode a ByteArray in the xdr. |
void |
BYTES(byte[] x,
int start,
int length)
|
int |
INT()
|
int |
length()
Return the size of the buffer used by this xdr. |
long |
LONG()
|
void |
PUT(boolean x)
Encode the given boolean into this xdr. |
void |
PUT(byte x)
|
void |
PUT(byte[] x,
int start,
int length)
|
void |
PUT(ByteArray x)
|
void |
PUT(int x)
|
void |
PUT(long x)
|
void |
PUT(short x)
|
void |
PUT(java.lang.String x)
|
void |
PUT(TypeID t)
|
short |
SHORT()
|
void |
skip(int count)
|
java.lang.String |
STRING()
|
static int |
STRING(java.lang.String x)
Return the number of bytes required t encode x in the xdr. |
TypeID |
TYPEID()
|
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int BOOLEAN
public static final int BYTE
public static final int SHORT
public static final int INT
public static final int LONG
public static final int TYPEID
Constructor Detail |
public Xdr(int len)
len
- the size of the buffer to create.public Xdr(byte[] buf)
XXX probably shouldn't be public.
buf
- the buffer to use.public Xdr(ByteArray buf, int offset)
buf
- the ByteArray to steal the byte[] fromoffset
- offset to start at in the ByteArraypublic Xdr(ByteArray buf, int offset, int len) throws java.lang.IndexOutOfBoundsException
buf
- the ByteArray to steal the byte[] fromoffset
- offset to start at in the ByteArraylen
- length of ByteArray to usepublic Xdr(byte[] buf, int offset)
buf
- the buffer to use.offset
- only encode in the portion of the buffer starting at offset.public Xdr(byte[] buf, int offset, int len) throws java.lang.IndexOutOfBoundsException
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.Method Detail |
public static final int STRING(java.lang.String x)
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.)
x
- the string to checkpublic static final int BYTEARRAY(ByteArray x)
The ByteArray must be less than 65,535 bytes.
x
- the ByteArray to checkpublic final int length()
public final void PUT(boolean x)
public final void PUT(byte x)
public final void PUT(short x)
public final void PUT(int x)
public final void PUT(long x)
public final void PUT(TypeID t)
public final void PUT(java.lang.String x)
public final void PUT(ByteArray x)
public final void PUT(byte[] x, int start, int length)
public final boolean BOOLEAN()
public final byte BYTE()
public final short SHORT()
public final int INT()
public final long LONG()
public final TypeID TYPEID()
public final java.lang.String STRING()
public final ByteArray BYTEARRAY()
public final void BYTES(byte[] x, int start, int length)
public final void skip(int count)
|
ANTS v2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |