Package pyamf :: Module amf3 :: Class Encoder
[hide private]
[frames] | no frames]

Class Encoder

source code


Encodes an AMF3 data stream.

Nested Classes [hide private]
type or types.ClassType context_class
Holds the class that will create context objects for the implementing Encoder.
Instance Methods [hide private]
 
writeElement(self, data, use_references=True)
Writes the data.
source code
 
writeType(self, type)
Writes the data type to the stream.
source code
 
writeUndefined(self, d, use_references=True)
Writes an pyamf.Undefined value to the stream.
source code
 
writeNull(self, n, use_references=True)
Writes a null value to the stream.
source code
 
writeBoolean(self, n, use_references=True)
Writes a Boolean to the stream.
source code
 
_writeInteger(self, n)
AMF3 integers are encoded.
source code
 
writeInteger(self, n, use_references=True)
Writes an integer to the stream.
source code
 
writeNumber(self, n, use_references=True)
Writes a non integer to the stream.
source code
 
_writeString(self, n, use_references=True)
Writes a raw string to the stream.
source code
 
writeString(self, n, use_references=True)
Writes a string to the stream.
source code
 
writeDate(self, n, use_references=True)
Writes a datetime instance to the stream.
source code
 
writeList(self, n, use_references=True)
Writes a tuple, set or list to the stream.
source code
 
writeDict(self, n, use_references=True)
Writes a dict to the stream.
source code
 
_getClassDefinition(self, obj)
Builds a class definition based on the obj.
source code
 
writeInstance(self, obj, use_references=True)
Read class definition.
source code
 
writeObject(self, obj, use_references=True)
Writes an object to the stream.
source code
 
writeByteArray(self, n, use_references=True)
Writes a ByteArray to the data stream.
source code
 
writeXML(self, n, use_references=True)
Writes a XML string to the data stream.
source code

Inherited from BaseEncoder: __init__

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
list type_map = [((<type 'builtin_function_or_method'>, <type 'buil...
A list of types -> functions.
Instance Variables [hide private]

Inherited from BaseEncoder: context, stream

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

writeElement(self, data, use_references=True)

source code 

Writes the data.

Parameters:
  • data (mixed) - The data to be encoded to the AMF3 data stream.
  • use_references (bool)
Raises:
Overrides: BaseEncoder.writeElement

writeType(self, type)

source code 

Writes the data type to the stream.

Parameters:
  • type - ActionScript type.
Raises:

writeUndefined(self, d, use_references=True)

source code 

Writes an pyamf.Undefined value to the stream.

Parameters:
  • use_references (bool)

writeNull(self, n, use_references=True)

source code 

Writes a null value to the stream.

Parameters:
  • n () - null data.
  • use_references (bool)

writeBoolean(self, n, use_references=True)

source code 

Writes a Boolean to the stream.

Parameters:
  • n (boolean data)
  • use_references (bool)

_writeInteger(self, n)

source code 

AMF3 integers are encoded.

See Also: Parsing Integers on OSFlash for more info.

writeInteger(self, n, use_references=True)

source code 

Writes an integer to the stream.

Parameters:
  • n () - integer data.
  • use_references (bool)

writeNumber(self, n, use_references=True)

source code 

Writes a non integer to the stream.

Parameters:
  • n () - number data.
  • use_references (bool)

_writeString(self, n, use_references=True)

source code 

Writes a raw string to the stream.

Parameters:
  • n (str or unicode) - string data.
  • use_references (bool)

writeString(self, n, use_references=True)

source code 

Writes a string to the stream. If n is not a unicode string, an attempt will be made to convert it.

Parameters:
  • n (basestring) - string data.
  • use_references (bool)

writeDate(self, n, use_references=True)

source code 

Writes a datetime instance to the stream.

Parameters:
  • n (datetime) - Date data.
  • use_references (bool)

writeList(self, n, use_references=True)

source code 

Writes a tuple, set or list to the stream.

Parameters:
  • n (One of __builtin__.tuple, __builtin__.set or __builtin__.list) - list data.
  • use_references (bool)

writeDict(self, n, use_references=True)

source code 

Writes a dict to the stream.

Parameters:
  • n (__builtin__.dict) - dict data.
  • use_references (bool)
Raises:
  • ValueError - Non int/str key value found in the dict
  • EncodeError - dict contains empty string keys.

writeInstance(self, obj, use_references=True)

source code 

Read class definition.

Parameters:
  • use_references (bool)

writeObject(self, obj, use_references=True)

source code 

Writes an object to the stream.

Parameters:
  • use_references (bool)
Raises:

writeByteArray(self, n, use_references=True)

source code 

Writes a ByteArray to the data stream.

Parameters:
  • n (ByteArray) - Data.
  • use_references (bool)

writeXML(self, n, use_references=True)

source code 

Writes a XML string to the data stream.

Parameters:
  • n (ET) - XML Document to encode.
  • use_references (bool)

Class Variable Details [hide private]

type_map

A list of types -> functions. The types is a list of possible instances or functions to call (that return a bool) to determine the correct function to call to encode the data.
Type:
list
Value:
[((<type 'builtin_function_or_method'>,
   <type 'builtin_function_or_method'>),
  'writeUnsupported'),
 ((<type 'bool'>), 'writeBoolean'),
 ((<type 'NoneType'>), 'writeNull'),
 ((<type 'int'>, <type 'long'>), 'writeInteger'),
 ((<type 'float'>), 'writeNumber'),
 (((<type 'str'>, <type 'unicode'>)), 'writeString'),
...