1.2.1. Bag definitionsΒΆ

  1. definition - Bag: A Bag is a collection of BagNodes. You can use a Bag as a flat Bag or as a hierarchical Bag.

  2. definition - BagNode: a BagNode (or “node”) is a Genro class composed by three metadata:

    • a single label.
    • a single value (or item).
    • one or more attributes.

    Where:

    • The “value” contains the value of the Bagnode.

    • The “attributes” allow to insert other metadata (for more information, check the attributes page).

      Note

      The couple label:value carries many analogies with the key:value couple Dictionary, so you can think to the Bag label as a transposition of the Dictionary key (for example, with the keys() method you will get all the Bag labels) but for its nature a key is unique, while Bag label can be unique or not

    Let’s see a scheme of a BagNode:

    ../_images/bag-bagnode.png

    A BagNode value can be a Bag, so a Bag is a recursive and hierarchical container.

    We now introduce the two definitions of a Bag:

  1. definition - flat Bag: it is a Bag in which all of its BagNodes don’t have a Bag as their value.
  1. definition - hierarchical Bag: it is a nested Bag with complex path, including Bags as a value of some BagNodes (check Bag’s path section for more explanation).

    Note

    there is no syntax difference in the two definitions, as you can see in the How to instantiate a Bag section.

    Each Bag may access directly to its inner elements using a path.

  2. definition - path: it is a concatenation of traversed Bag labels separated by a dot (.) (For more information, check Bag’s path section).