Package Peach :: Package Engine :: Module dom :: Class DataElement
[hide private]

Class DataElement

source code


Data elements compose the Data Modle. This is the base class for String, Number, Block, Template, etc.

When iterating over the Peach DOM if an element isinstance(obj, DataElement) it is part of a data model.

Instance Methods [hide private]
 
__init__(self, name=None, parent=None) source code
 
get_minOccurs(self) source code
 
set_minOccurs(self, value) source code
 
get_maxOccurs(self) source code
 
set_maxOccurs(self, value) source code
 
genAllChildDataElements(self)
Yield all children data elements.
source code
 
_HasSizeofRelation(self, node=None) source code
 
_HasOffsetRelation(self, node=None) source code
 
_GetOffsetRelation(self, node=None) source code
 
_GetSizeofRelation(self, node=None) source code
 
GetWhenRelation(self, node=None) source code
 
HasWhenRelation(self, node=None) source code
 
_HasCountofRelation(self, node=None) source code
 
_GetCountofRelation(self, node=None) source code
 
getFullnameInDataModel(self)
This will get fully qualified name of this element starting with the root node of the data model.
source code
 
getRootOfDataMap(self)
Return the root of this data map.
source code
DataElement
findArrayByName(self, name)
Will find first element in array named "name".
source code
 
_findArrayByName(self, node, name)
A generator that returns each instance of name in a data model.
source code
DataElement
findDataElementByName(self, name)
Will find a data element in this data map by name.
source code
DataElement
find(self, name)
Alias for findDataElementByName.
source code
 
_findAllBlocksGoingUp(self)
Generator that locates all blocks by walking up our tree.
source code
 
_findDataElementByName(self, node, name)
A generator that returns each instance of name in a data model.
source code
 
_checkDottedName(self, node, names)
Internal helper method, not for use!
source code
 
getRelationOfThisElement(self)
Locate and return a relation of this element.
source code
 
_genRelationsInDataModelFromHere(self, node=None)
Instead of returning all relations starting with root we will walk up looking for relations.
source code
 
_getAllRelationsInDataModel(self, node=None, history=None)
Generator that gets all relations in data model.
source code
 
isArray(self)
Check if this data element is part of an array.
source code
 
getArrayCount(self)
Return number of elements in array.
source code
 
getArrayElementAt(self, num)
Return array element at position num.
source code
 
getCount(self)
Return how many times this element occurs.
source code
 
getInternalValue(self)
Return the internal value of this date element.
source code
string or number
getRelationValue(self, value)
This is common logic that was being duplicated across several data elements.
source code
 
getRawValue(self)
Get the value of this data element pre-transformers.
source code
 
getValue(self)
Get the value of this data element.
source code
 
setDefaultValue(self, value)
Set the default value for this data element.
source code
 
setValue(self, value)
Set the current value for this data element
source code
 
reset(self)
Reset the value of this data element back to the default.
source code
 
resetDataModel(self, node=None)
Reset the entire data model.
source code
 
_fixRealParent(self, node) source code
 
_unFixRealParent(self, node) source code
 
calcLength(self)
Calculate length
source code

Inherited from ElementWithChildren: __contains__, __delitem__, __getitem__, __iter__, __len__, __setitem__, append, firstChild, genElementsByType, has_key, index, insert, lastChild, printDomMap, setDefaults, toXmlDom, updateFromXmlDom, verifyDomMap

Inherited from Element: copy, getFullDataName, getFullname, getRoot, hasChildNode, nextSibling, previousSibling

Static Methods [hide private]

Inherited from Element: getUniqueName

Class Variables [hide private]
  minOccurs = property(get_minOccurs, set_minOccurs)
Minimum occurences (property)
  maxOccurs = property(get_maxOccurs, set_maxOccurs)
Maximum occurences (property)

Inherited from Element: GuidRegex

Instance Variables [hide private]
  onArrayNext
Event that occurs prior to parsing the next array element.
  transformer
Transformers to apply
  fixup
Fixup if any
  relations
Relations this element has
  _minOccurs
Minimum occurences
  _maxOccurs
Maximum occurences
  defaultValue
Default value to use
  currentValue
Override default value
  value
Current value
  when
Expression used by data cracker to determin if element should be included in cracking.
  _inInternalValue
Used to prevent recursion
  array
Name of array.
  arrayPosition
Our position in the array.
  arrayMinOccurs
The min occurences in the array
  arrayMaxOccurs
The max occurences in the array
  pos
Position in data stream item was parsed at
  rating
Parse rating for element
  isStatic
Is this element a static token?
  relationStringBuffer
A StringBuffer used to determin offset relations

Inherited from ElementWithChildren: children

Inherited from ElementWithChildren (private): _children, _childrenHash

Inherited from Element: elementType, hasChildren, name, node, parent, ref

Method Details [hide private]

__init__(self, name=None, parent=None)
(Constructor)

source code 
Overrides: Element.__init__

genAllChildDataElements(self)

source code 

Yield all children data elements. Recursive

getRootOfDataMap(self)

source code 

Return the root of this data map. This should always return a Template object.

findArrayByName(self, name)

source code 

Will find first element in array named "name".

This method should allow for more natural reuse of Blocks/Templates w/o the user needing to think about it.

Parameters:
  • name (string) - Array to find. Does not support dotted name.
Returns: DataElement
DataElement or None

findDataElementByName(self, name)

source code 

Will find a data element in this data map by name. The search pattern we use is to locate each block we are a member of starting with the nearest. At each block we look down to see if we can resolve the name. If not we move closer towards the root of the data model.

This method should allow for more natural reuse of Blocks/Templates w/o the user needing to think about it.

Parameters:
  • name (string) - Name of element to find. Can be full or relative.
Returns: DataElement
DataElement or None

find(self, name)

source code 

Alias for findDataElementByName.

Will find a data element in this data map by name. The search pattern we use is to locate each block we are a member of starting with the nearest. At each block we look down to see if we can resolve the name. If not we move closer towards the root of the data model.

This method should allow for more natural reuse of Blocks/Templates w/o the user needing to think about it.

Parameters:
  • name (string) - Name of element to find. Can be full or relative.
Returns: DataElement
DataElement or None

getCount(self)

source code 

Return how many times this element occurs. If it is part of an array the array size is returned, otherwise we will look at the min/max and any count relations.

getInternalValue(self)

source code 

Return the internal value of this date element. This value comes before any modifications such as packing, padding, truncating, etc.

For Numbers this is the python int or long value.

getRelationValue(self, value)

source code 

This is common logic that was being duplicated across several data elements. The logic is used in getInternalValue() to check if a relation of size-of or count-of should modify the value.

Returns: string or number
the value passed in or an integer if the value needed to be changed.

Instance Variable Details [hide private]

array

Name of array. The origional name of the data element.