GXml.Collection – GXml-0.20 Reference Manual

# Collection

## Object Hierarchy:

## Description:

public interface Collection : Object

A DOM4 interface to keep references to DomElement children of a element.

A collection should call initialize with the object's type to be added to the connection and, at construction time, set the element this collection should take its members from.

This way, you can have a property to access all child elements of a given type, the node will be added automatically to both as a child of your element and as a member of the collection.

      // This is your object definition and a collection one
      public class YourObject : GXml.Element {
       [Description (nick="::Name")]
       public string name { get; set; }
       construct {
         // This is the Element's node's name to be used
         try { initialize ("NodeName"); }
         catch (GLib.Error e ) {
           warning ("Error: "+e.message);
         }
       }
      }
      public class YourList : GXml.ArrayList {
       construct {
         // With this, your collection will find a add all elements
         // with the node's name 'NodeName' as declared to YourObject class
         try { initialize (typeof (YourObject)); }
         catch (GLib.Error e) {
           warning ("Initialization error for collection type: %s : %s"
                .printf (get_type ().name(), e.message));
         }
       }
      }
      // This is your element object definition with a collection of nodes
      // with the type YourObject
      public class YourElement : GXml.Element {
        public YourObject.YourList your_objects { get; set; }
        construct {
          // This is initializing the property 'your_objects' which is the type
          // YourList collection and set YourElement object as its element to
          // to take its members from. Use canonical names for properties as shown
          set_instance_property ('your-objects');
          // This is the node's name to use for YourElement class
           try { initialize ("YourElement"); }
           catch (GLib.Error e) {
             warning ("Initialization error for element type: %s", e.message));
           }
         }
       }

All known implementing classes:

- BaseCollection

All known sub-interfaces:

- CollectionParent
- IXsdList

- List
- Map

- PairedMap
- ThreeMap

Namespace: GXml
Package: GXml-0.20

## Content:

### Properties:

- public abstract DomElement element { get; set construct; }
  A GXml.DomElement with all child elements in collection.
- public abstract string items_name { get; }
  Local name of DomElement objects of element, which could be contained in this collection.
- public abstract Type items_type { get; set construct; }
  A GLib.Type of DomElement child objects of element, which could be contained in this collection.
- public virtual int length { get; }
  Number of items referenced in nodes_index
- public abstract Queue<int> nodes_index { get; }
  A list of child DomElement objects of element

### Methods:

- public abstract void append (DomElement node) throws Error
  Adds a DomElement node to this collection. Depending on type of collection, this method will take information from node to initialize how to find it.
- public abstract void clear () throws Error
  Clear this collection in preparation for a search
- public virtual DomElement? create_item ()
  Creates a new instance of items_type, with same DomNode.owner_document than element. New instance is not set as a child of collection's element; to do so, use append
- public virtual DomElement? get_item (int index) throws Error
  Gets a child DomElement of element referenced in nodes_index.
- public abstract void initialize (Type t) throws Error
  Initialize collection to use a given GXml.Collection derived type. Internally, this method create an instance of given type to initialize items_type and items_name.
- public abstract void search () throws Error
  Search and add references to all GXml.Object nodes as child of element with same, case insensitive, name of items_name
- public abstract bool validate_append (int index, DomElement element) throws Error
  Validate if given node and index, should be added to collection.

### Inherited Members:

All known members inherited from class GLib.Object

- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data

- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer

- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref