Home | Trees | Indices | Help |
---|
|
The Data class provides an interface for decoding, extracting, creating, and encoding arbitrary AMQP data. A Data object contains a tree of AMQP values. Leaf nodes in this tree correspond to scalars in the AMQP type system such as ints or strings. Non-leaf nodes in this tree correspond to compound values in the AMQP type system such as lists, maps, arrays, or described values. The root node of the tree is the Data object itself and can have an arbitrary number of children.
A Data object maintains the notion of the current sibling node and a current parent node. Siblings are ordered within their parent. Values are accessed and/or added by using the next, prev, enter, and exit methods to navigate to the desired location in the tree and using the supplied variety of put_*/get_* methods to access or add a value of the desired type.
The put_* methods will always add a value after the current node in the tree. If the current node has a next sibling the put_* method will overwrite the value on this node. If there is no current node or the current node has no next sibling then one will be added. The put_* methods always set the added/modified node to the current node. The get_* methods read the value of the current node and do not change which node is current.
The following types of scalar values are supported:
The following types of compound values are supported:
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Class Methods | |||
|
Class Variables | |
ARRAY = 23
|
|
BINARY = 19
|
|
BOOL = 2
|
|
BYTE = 4
|
|
CHAR = 9
|
|
DECIMAL128 = 17
|
|
DECIMAL32 = 15
|
|
DECIMAL64 = 16
|
|
DESCRIBED = 22
|
|
DOUBLE = 14
|
|
FLOAT = 13
|
|
INT = 8
|
|
LIST = 24
|
|
LONG = 11
|
|
MAP = 25
|
|
NULL = 1
|
|
SHORT = 6
|
|
STRING = 20
|
|
SYMBOL = 21
|
|
TIMESTAMP = 12
|
|
UBYTE = 3
|
|
UINT = 7
|
|
ULONG = 10
|
|
USHORT = 5
|
|
UUID = 18
|
|
get_mappings =
|
|
put_mappings =
|
|
type_names =
|
Method Details |
Decodes the first value from supplied AMQP data and returns the number of bytes consumed.
|
Sets the parent node to the current node and clears the current node. Clearing the current node sets it _before_ the first child, call next() advances to the first child. |
If the current node is an array, return a tuple of the element count, a boolean indicating whether the array is described, and the type of each element, otherwise return (0, False, None). Array data can be accessed by entering the array. >>> # read an array of strings with a symbolic descriptor >>> count, described, type = data.get_array() >>> data.enter() >>> data.next() >>> print "Descriptor:", data.get_symbol() >>> for i in range(count): ... data.next() ... print "Element:", data.get_string() >>> data.exit() |
If the current node is a list, return the number of elements, otherwise return zero. List elements can be accessed by entering the list. >>> count = data.get_list() >>> data.enter() >>> for i in range(count): ... type = data.next() ... if type == Data.STRING: ... print data.get_string() ... elif type == ...: ... ... >>> data.exit() |
If the current node is a map, return the number of child elements, otherwise return zero. Key value pairs can be accessed by entering the map. >>> count = data.get_map() >>> data.enter() >>> for i in range(count/2): ... type = data.next() ... if type == Data.STRING: ... print data.get_string() ... elif type == ...: ... ... >>> data.exit() |
If the current node is an array, return an Array object representing the array and its contents. Otherwise return None. This is a convenience wrapper around get_array, enter, etc. |
Checks if the current node is a described value. The descriptor and value may be accessed by entering the described value. >>> # read a symbolically described string >>> assert data.is_described() # will error if the current node is not described >>> data.enter() >>> data.next() >>> print data.get_symbol() >>> data.next() >>> print data.get_string() >>> data.exit() |
Advances the current node to its next sibling and returns its type. If there is no next sibling the current node remains unchanged and None is returned. |
Advances the current node to its previous sibling and returns its type. If there is no previous sibling the current node remains unchanged and None is returned. |
Puts an array value. Elements may be filled by entering the array node and putting the element values. The values must all be of the specified array element type. If an array is described then the first child value of the array is the descriptor and may be of any type. >>> data = Data() >>> >>> data.put_array(False, Data.INT) >>> data.enter() >>> data.put_int(1) >>> data.put_int(2) >>> data.put_int(3) >>> data.exit() >>> >>> data.put_array(True, Data.DOUBLE) >>> data.enter() >>> data.put_symbol("array-descriptor") >>> data.put_double(1.1) >>> data.put_double(1.2) >>> data.put_double(1.3) >>> data.exit()
|
Puts a binary value.
|
Puts a boolean value.
|
Puts a signed byte value.
|
Puts a char value.
|
Puts a decimal128 value.
|
Puts a decimal32 value.
|
Puts a decimal64 value.
|
Puts a described value. A described node has two children, the descriptor and the value. These are specified by entering the node and putting the desired values. >>> data = Data() >>> data.put_described() >>> data.enter() >>> data.put_symbol("value-descriptor") >>> data.put_string("the value") >>> data.exit() |
Puts a double value.
|
Puts a float value.
|
Puts a signed int value.
|
Puts a list value. Elements may be filled by entering the list node and putting element values. >>> data = Data() >>> data.put_list() >>> data.enter() >>> data.put_int(1) >>> data.put_int(2) >>> data.put_int(3) >>> data.exit() |
Puts a signed long value.
|
Puts a map value. Elements may be filled by entering the map node and putting alternating key value pairs. >>> data = Data() >>> data.put_map() >>> data.enter() >>> data.put_string("key") >>> data.put_string("value") >>> data.exit() |
Puts a signed short value.
|
Puts a unicode value.
|
Puts a symbolic value.
|
Puts a timestamp value.
|
Puts an unsigned byte value.
|
Puts an unsigned int value.
|
Puts an unsigned long value.
|
Puts an unsigned short value.
|
Puts a UUID value.
|
Clears current node and sets the parent to the root node. Clearing the current node sets it _before_ the first node, calling next() will advance to the first node. |
Class Variable Details |
get_mappings
|
put_mappings
|
type_names
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sun Apr 10 14:46:39 2016 | http://epydoc.sourceforge.net |