Packagecom.yworks.io.graphml
Classpublic class GraphMLContext
InheritanceGraphMLContext Inheritance Object
Implements ILookup, IContextLookup, ILookupDecorator
Subclasses GraphMLParseContext, GraphMLWriteContext

A Context object storing parameters and objects needed for GraphML writing oder parsing.



Public Properties
 PropertyDefined By
  containers : Iterator
[read-only] Returns a read-only view of the container objects stored in this context.
GraphMLContext
  count : int
[read-only] Return the number of elements on the element stack
GraphMLContext
  currentGraph : Object
[read-only] Returns the currently active graph object or null if there is none.
GraphMLContext
  lastContainer : Object
[read-only] Return the last container object stored in this context.
GraphMLContext
  nestingDepth : int
[read-only] Return the current depth of the graph nesting stack
GraphMLContext
  nextToLastContainer : Object
[read-only] Return the second-to-top element in the current element nesting
GraphMLContext
Protected Properties
 PropertyDefined By
  _containers : YList
A list of container objects.
GraphMLContext
  _myLookupChain : LookupChain
The lookup chain
GraphMLContext
  _properties : IMapper
The properties stored in this context.
GraphMLContext
Public Methods
 MethodDefined By
  
Creates a new instance.
GraphMLContext
  
addLookup(type:Class, lookup:IContextLookupChainLink):void
Adds a lookup chain element to the chain of lookups for a given type.
GraphMLContext
  
canDecorate(type:Class):Boolean
Determines whether this instance can be used to decorate the lookup for a certain type.
GraphMLContext
  
getContainer(clazz:Class):Object
Get the last container stored in the context that can be casted to the given class.
GraphMLContext
  
getProperty(name:String):Object
Retrieve a context property.
GraphMLContext
  
lookup(type:Class):Object
Returns an instance that implements the given type or null.
GraphMLContext
  
lookupForItem(item:Object, type:Class):Object
Tries to create or retrieve an implementation of the given type for a given item.
GraphMLContext
  
Remove the last container that was added to the container list.
GraphMLContext
  
pushGraphMLElement(element:Object):void
Append the given container object to the list of container objects.
GraphMLContext
  
removeLookup(type:Class, lookup:IContextLookupChainLink):void
Removes a previously registered lookup chain element from the chain of lookups for a given type.
GraphMLContext
  
setLookup(c:Class, o:Object):void
Map the given class to the given object.
GraphMLContext
  
setProperty(name:String, value:Object):void
Set a context property.
GraphMLContext
Property Detail
_containersproperty
protected var _containers:YList

A list of container objects.

_myLookupChainproperty 
protected var _myLookupChain:LookupChain

The lookup chain

_propertiesproperty 
protected var _properties:IMapper

The properties stored in this context.

containersproperty 
containers:Iterator  [read-only]

Returns a read-only view of the container objects stored in this context.


Implementation
    public function get containers():Iterator
countproperty 
count:int  [read-only]

Return the number of elements on the element stack


Implementation
    public function get count():int
currentGraphproperty 
currentGraph:Object  [read-only]

Returns the currently active graph object or null if there is none.


Implementation
    public function get currentGraph():Object
lastContainerproperty 
lastContainer:Object  [read-only]

Return the last container object stored in this context.


Implementation
    public function get lastContainer():Object
nestingDepthproperty 
nestingDepth:int  [read-only]

Return the current depth of the graph nesting stack


Implementation
    public function get nestingDepth():int
nextToLastContainerproperty 
nextToLastContainer:Object  [read-only]

Return the second-to-top element in the current element nesting


Implementation
    public function get nextToLastContainer():Object
Constructor Detail
GraphMLContext()Constructor
public function GraphMLContext()

Creates a new instance.

Method Detail
addLookup()method
public function addLookup(type:Class, lookup:IContextLookupChainLink):void

Adds a lookup chain element to the chain of lookups for a given type.

The lookup chain is context specific. This method will not generally decorate the lookup of all instances of type type, but only those that stand in context of this instance. This method will only succeed if canDecorate yields true for type.

Parameters

type:Class — The type to decorate the lookup.
 
lookup:IContextLookupChainLink — The chain element to add to the lookup of the given type.

canDecorate()method 
public function canDecorate(type:Class):Boolean

Determines whether this instance can be used to decorate the lookup for a certain type.

Parameters

type:Class — The type to decorate the lookup for.

Returns
Booleantrue if this instance can be used to decorate the lookup for the given type.
getContainer()method 
public function getContainer(clazz:Class):Object

Get the last container stored in the context that can be casted to the given class. If no such container is found, this method return null.

Parameters

clazz:Class — The class for whose instance the context will be searched.

Returns
Object — the last container stored in the context which is an instance of clazz. null if none is found.
getProperty()method 
public function getProperty(name:String):Object

Retrieve a context property.

Parameters

name:String — The key to which the property is mapped.

Returns
Object — The context which is mapped to the name.
lookup()method 
public function lookup(type:Class):Object

Returns an instance that implements the given type or null.

Typically, this method will be called in order to obtain a different view or aspect of the current instance. This is quite similar to casting or using a super type or interface of this instance, but is not limited to inheritance or compile time constraints. An instance implementing this method is not required to return non-null implementations for the types, nor does it have to return the same instance any time. Also it depends on the type and context whether the instance returned stays up to date or needs to be reobtained for subsequent use.

Parameters

type:Class — the type for which an instance shall be returned

Returns
Object — an instance that is assignable to type or null
lookupForItem()method 
public function lookupForItem(item:Object, type:Class):Object

Tries to create or retrieve an implementation of the given type for a given item.

Parameters

item:Object — the item to lookup a type for
 
type:Class — the type to look up

Returns
Object — an implementation or null
popGraphMLElement()method 
public function popGraphMLElement():void

Remove the last container that was added to the container list.

pushGraphMLElement()method 
public function pushGraphMLElement(element:Object):void

Append the given container object to the list of container objects.

Parameters

element:Object — container object to add.

removeLookup()method 
public function removeLookup(type:Class, lookup:IContextLookupChainLink):void

Removes a previously registered lookup chain element from the chain of lookups for a given type.

Parameters

type:Class — The type to remove the decorator from.
 
lookup:IContextLookupChainLink — The chain element to remove from the lookup of the given type.

setLookup()method 
public function setLookup(c:Class, o:Object):void

Map the given class to the given object. The object can be retrieved using lookup( c ).

Parameters

c:Class — The class to be mapped.
 
o:Object — The object to be mapped.

setProperty()method 
public function setProperty(name:String, value:Object):void

Set a context property.

Parameters

name:String — The property's name.
 
value:Object — The property.