org.apache.qpid.transport.codec
Class AbstractEncoder

java.lang.Object
  extended by org.apache.qpid.transport.codec.AbstractEncoder
All Implemented Interfaces:
Encoder
Direct Known Subclasses:
BBEncoder

abstract class AbstractEncoder
extends Object
implements Encoder

AbstractEncoder


Constructor Summary
AbstractEncoder()
           
 
Method Summary
protected abstract  int beginSize16()
           
protected abstract  int beginSize32()
           
protected abstract  int beginSize8()
           
protected abstract  void doPut(byte b)
           
protected abstract  void doPut(ByteBuffer src)
           
protected abstract  void endSize16(int pos)
           
protected abstract  void endSize32(int pos)
           
protected abstract  void endSize8(int pos)
           
protected  void put(byte b)
           
protected  void put(byte[] bytes)
           
protected  void put(ByteBuffer src)
           
(package private) static Type resolve(Class klass)
           
 void writeArray(List<Object> array)
          An array is an ordered sequence of values of the same type.
protected  void writeArrayEntries(List<Object> array)
           
 void writeByteRanges(RangeSet ranges)
           
 void writeDatetime(long l)
          The datetime type encodes a date and time using the 64 bit POSIX time_t format.
 void writeList(List<Object> list)
          A list is an ordered sequence of (type, value) pairs.
protected  void writeListEntries(List<Object> list)
           
 void writeMap(Map<String,Object> map)
          A map is a set of distinct keys where each key has an associated (type,value) pair.
protected  void writeMapEntries(Map<String,Object> map)
           
 void writeSequenceNo(int i)
          The sequence-no type encodes, in network byte order, a serial number as defined in RFC-1982.
 void writeSequenceSet(RangeSet ranges)
           
 void writeStr16(String s)
          The str16 type encodes up to 65535 octets worth of UTF-8 unicode.
 void writeStr8(String s)
          The str8 type encodes up to 255 octets worth of UTF-8 unicode.
 void writeStruct(int type, Struct s)
          The struct32 type describes any coded struct with a 32-bit (4 octet) size.
 void writeStruct32(Struct s)
          The struct32 type describes any coded struct with a 32-bit (4 octet) size.
 void writeUint16(int s)
          The uint16 type is a 16-bit unsigned integral value encoded in network byte order.
 void writeUint32(long i)
          The uint32 type is a 32-bit unsigned integral value encoded in network byte order.
 void writeUint64(long l)
          The uint64 type is a 64-bit unsigned integral value encoded in network byte order.
 void writeUint8(short b)
          The uint8 type is an 8-bit unsigned integral value.
 void writeUuid(UUID uuid)
          The uuid type encodes a universally unique id as defined by RFC-4122.
 void writeVbin16(byte[] bytes)
          The vbin16 type encodes up to 65535 octets of opaque binary data.
 void writeVbin32(byte[] bytes)
          The vbin32 type encodes up to 4294967295 octets of opaque binary data.
 void writeVbin8(byte[] bytes)
          The vbin8 type encodes up to 255 octets of opaque binary data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.qpid.transport.codec.Encoder
writeBin128, writeDouble, writeFloat, writeInt16, writeInt32, writeInt64, writeInt8, writeMagicNumber
 

Constructor Detail

AbstractEncoder

AbstractEncoder()
Method Detail

doPut

protected abstract void doPut(byte b)

doPut

protected abstract void doPut(ByteBuffer src)

put

protected void put(byte b)

put

protected void put(ByteBuffer src)

put

protected void put(byte[] bytes)

beginSize8

protected abstract int beginSize8()

endSize8

protected abstract void endSize8(int pos)

beginSize16

protected abstract int beginSize16()

endSize16

protected abstract void endSize16(int pos)

beginSize32

protected abstract int beginSize32()

endSize32

protected abstract void endSize32(int pos)

writeUint8

public void writeUint8(short b)
Description copied from interface: Encoder
The uint8 type is an 8-bit unsigned integral value.

Specified by:
writeUint8 in interface Encoder
Parameters:
b - the unsigned integer to be encoded.

writeUint16

public void writeUint16(int s)
Description copied from interface: Encoder
The uint16 type is a 16-bit unsigned integral value encoded in network byte order.

Specified by:
writeUint16 in interface Encoder
Parameters:
s - the unsigned integer to be encoded.

writeUint32

public void writeUint32(long i)
Description copied from interface: Encoder
The uint32 type is a 32-bit unsigned integral value encoded in network byte order.

Specified by:
writeUint32 in interface Encoder
Parameters:
i - the unsigned integer to be encoded.

writeSequenceNo

public void writeSequenceNo(int i)
Description copied from interface: Encoder
The sequence-no type encodes, in network byte order, a serial number as defined in RFC-1982.

Specified by:
writeSequenceNo in interface Encoder
Parameters:
i - the sequence number to be encoded.

writeUint64

public void writeUint64(long l)
Description copied from interface: Encoder
The uint64 type is a 64-bit unsigned integral value encoded in network byte order.

Specified by:
writeUint64 in interface Encoder

writeDatetime

public void writeDatetime(long l)
Description copied from interface: Encoder
The datetime type encodes a date and time using the 64 bit POSIX time_t format.

Specified by:
writeDatetime in interface Encoder
Parameters:
l - the datetime (as long) to be encoded.

writeStr8

public void writeStr8(String s)
Description copied from interface: Encoder
The str8 type encodes up to 255 octets worth of UTF-8 unicode. The number of octets of unicode is first encoded as an 8-bit unsigned integral value. This is followed by the actual UTF-8 unicode. Note that the encoded size refers to the number of octets of unicode, not necessarily the number of characters since the UTF-8 unicode may include multi-byte character sequences.

Specified by:
writeStr8 in interface Encoder
Parameters:
s - the string to be encoded.

writeStr16

public void writeStr16(String s)
Description copied from interface: Encoder
The str16 type encodes up to 65535 octets worth of UTF-8 unicode. The number of octets is first encoded as a 16-bit unsigned integral value in network byte order. This is followed by the actual UTF-8 unicode. Note that the encoded size refers to the number of octets of unicode, not necessarily the number of unicode characters since the UTF-8 unicode may include multi-byte character sequences.

Specified by:
writeStr16 in interface Encoder
Parameters:
s - the string to be encoded.

writeVbin8

public void writeVbin8(byte[] bytes)
Description copied from interface: Encoder
The vbin8 type encodes up to 255 octets of opaque binary data. The number of octets is first encoded as an 8-bit unsigned integral value. This is followed by the actual data.

Specified by:
writeVbin8 in interface Encoder
Parameters:
bytes - the byte array to be encoded.

writeVbin16

public void writeVbin16(byte[] bytes)
Description copied from interface: Encoder
The vbin16 type encodes up to 65535 octets of opaque binary data. The number of octets is first encoded as a 16-bit unsigned integral value in network byte order. This is followed by the actual data.

Specified by:
writeVbin16 in interface Encoder
Parameters:
bytes - the byte array to be encoded.

writeVbin32

public void writeVbin32(byte[] bytes)
Description copied from interface: Encoder
The vbin32 type encodes up to 4294967295 octets of opaque binary data. The number of octets is first encoded as a 32-bit unsigned integral value in network byte order. This is followed by the actual data.

Specified by:
writeVbin32 in interface Encoder
Parameters:
bytes - the byte array to be encoded.

writeSequenceSet

public void writeSequenceSet(RangeSet ranges)
Specified by:
writeSequenceSet in interface Encoder

writeByteRanges

public void writeByteRanges(RangeSet ranges)
Specified by:
writeByteRanges in interface Encoder

writeUuid

public void writeUuid(UUID uuid)
Description copied from interface: Encoder
The uuid type encodes a universally unique id as defined by RFC-4122. The format and operations for this type can be found in section 4.1.2 of RFC-4122.

Specified by:
writeUuid in interface Encoder
Parameters:
uuid - the uuid to be encoded.

writeStruct

public void writeStruct(int type,
                        Struct s)
Description copied from interface: Encoder
The struct32 type describes any coded struct with a 32-bit (4 octet) size. The type is restricted to be only coded structs with a 32-bit size, consequently the first six octets of any encoded value for this type MUST always contain the size, class-code, and struct-code in that order. The size is encoded as a 32-bit unsigned integral value in network byte order that is equal to the size of the encoded field-data, packing-flags, class-code, and struct-code. The class-code is a single octet that may be set to any valid class code. The struct-code is a single octet that may be set to any valid struct code within the given class-code. The first six octets are then followed by the packing flags and encoded field data. The presence and quantity of packingflags, as well as the specific fields are determined by the struct definition identified with the encoded class-code and struct-code.

Specified by:
writeStruct in interface Encoder
Parameters:
type - the type of the struct.
s - the struct to be encoded.

writeStruct32

public void writeStruct32(Struct s)
Description copied from interface: Encoder
The struct32 type describes any coded struct with a 32-bit (4 octet) size. The type is restricted to be only coded structs with a 32-bit size, consequently the first six octets of any encoded value for this type MUST always contain the size, class-code, and struct-code in that order. The size is encoded as a 32-bit unsigned integral value in network byte order that is equal to the size of the encoded field-data, packing-flags, class-code, and struct-code. The class-code is a single octet that may be set to any valid class code. The struct-code is a single octet that may be set to any valid struct code within the given class-code. The first six octets are then followed by the packing flags and encoded field data. The presence and quantity of packingflags, as well as the specific fields are determined by the struct definition identified with the encoded class-code and struct-code.

Specified by:
writeStruct32 in interface Encoder
Parameters:
s - the struct to be encoded.

resolve

static final Type resolve(Class klass)

writeMap

public void writeMap(Map<String,Object> map)
Description copied from interface: Encoder
A map is a set of distinct keys where each key has an associated (type,value) pair. The triple of the key, type, and value, form an entry within a map. Each entry within a given map MUST have a distinct key. A map is encoded as a size in octets, a count of the number of entries, followed by the encoded entries themselves. An encoded map may contain up to (4294967295 - 4) octets worth of encoded entries. The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of encoded entries plus 4. (The extra 4 octets is added for the entry count.) The size is then followed by the number of entries encoded as a 32-bit unsigned integral value in network byte order. Finally the entries are encoded sequentially. An entry is encoded as the key, followed by the type, and then the value. The key is always a string encoded as a str8. The type is a single octet that may contain any valid AMQP type code. The value is encoded according to the rules defined by the type code for that entry.

Specified by:
writeMap in interface Encoder
Parameters:
map - the map to be encoded.

writeMapEntries

protected void writeMapEntries(Map<String,Object> map)

writeList

public void writeList(List<Object> list)
Description copied from interface: Encoder
A list is an ordered sequence of (type, value) pairs. The (type, value) pair forms an item within the list. The list may contain items of many distinct types. A list is encoded as a size in octets, followed by a count of the number of items, followed by the items themselves encoded in their defined order. An encoded list may contain up to (4294967295 - 4) octets worth of encoded items. The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of encoded items plus 4. (The extra4 octets is added for the item count.) The size is then followed by the number of items encoded as a 32-bit unsigned integral value in network byte order. Finally the items are encoded sequentially in their defined order. An item is encoded as the type followed by the value. The type is a single octet that may contain any valid AMQP type code. The value is encoded according to the rules defined by the type code for that item.

Specified by:
writeList in interface Encoder
Parameters:
list - the list to be encoded.

writeListEntries

protected void writeListEntries(List<Object> list)

writeArray

public void writeArray(List<Object> array)
Description copied from interface: Encoder
An array is an ordered sequence of values of the same type. The array is encoded in as a size in octets, followed by a type code, then a count of the number values in the array, and finally the values encoded in their defined order. An encoded array may contain up to (4294967295 - 5) octets worth of encoded values. The size is encoded as a 32-bit unsigned integral value in network byte order equal to the number of octets worth of encoded values plus 5. (The extra 5 octets consist of 4 octets for the count of the number of values, and one octet to hold the type code for the items inthe array.) The size is then followed by a single octet that may contain any valid AMQP type code. The type code is then followed by the number of values encoded as a 32-bit unsigned integral value in network byte order. Finally the values are encoded sequentially in their defined order according to the rules defined by the type code for the array.

Specified by:
writeArray in interface Encoder
Parameters:
array - the array to be encoded.

writeArrayEntries

protected void writeArrayEntries(List<Object> array)


Licensed to the Apache Software Foundation