Xinf API Reference
Back | Index
class xinf.xml.Binding<T>
implements IBinding

Represents a Binding of XML content to instantiated Nodes.

Node classes can be bound either by simple TagName-to-Class association (add()) or more complex Instantiators (addInstantiator()).

Used primarily (if not only) by the Document class.

function new( ) :Void
Create a new, initially empty, Binding
function add( nodeName:String, cl:Class<T> ) :Void

Bind the given nodeName (or tag name) to the class cl.

The class must have a constructor with only one, dynamic argument, like Element, or instantiation will fail.

function addInstantiator( i:Instantiator<T> ) :Void
Add the given Instantiator i to this Binding.
function instantiate( xml:Xml ) :Node

Instantiate (unmarshal/deserialize) the given xml, and returns the instantiated Node.

Looks through all added Instantiators first, then through the list of nodeNames, and tries to construct the Object. If nothing is bound to the given xml, null is returned. If instantiation fails (for example, because the bound class' constructor has less or more than one argument), an exception is thrown.

The returned Node will yet be empty (fromXml is not yet called).

You shouldn't use this function directly. Instead, use Document.instantiate() or .load().

Back | Index