Source for file Composite.class.php
Documentation is available at Composite.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* Composite Pattern Interface
* The Composite Pattern is responsible for holding multi-tiered data into an
* easily accessible interface. This would be similar to accessing the elements
* of a multi-dimensional array. A Composite can hold other Composite objects.
* An Attribute is simply a key=>val pair of data used to provide more details
* about a particular Composite. The best example is an attribute inside an
* <xml id="value">data</xml>
* This feature is useless, unless the Composite is being used to read/write
* files with comments. This feature will allow the object to hold comments
* for a particular Composite, which can be used by a file writer to include
* in particular parts of the file.
* Look at the Tree-Branch-Leaf classes for more details on implementing a
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @desc Composite Pattern Interface
* Sets a Value, or adds a new Composite to a Branch
* @param int|string$name (for 'int', wrap in curly braces $comp->{0} = value)
public function __set ($name, $val);
* Returns the Value or a Composite referenced by the 'name'
* @param int|string$name (for 'int', wrap in curly braces $comp->{0})
public function __get ($name);
* Adds a Composite object to the Composite (for Branch use only)
* @param Gumbo_Interface_Composite $tree
* @param bool $replace replaces the original Composite object
public function add (Gumbo_Interface_Composite $tree, $replace=
false);
* Removes a Composite object based on the Composite name (for Branch use only)
public function remove ($name);
* Adds an attribute description to the Composite object
* @postcondition remove non-alphanumeric characters (excluding underscores) from $name
* @param string $name attribute name
* @param string|num|bool$val attribute value
* @param bool $replace replaces existing attribute
* Adds a comment to the Composite (A null comment will add a blank line)
* @postcondition !getComments()
* Sets the Composite value (for Leaf use only)
* @param mixed $val (primitive types only)
* Returns the corresponding Composite object or Value
public function get ($name=
null);
* Returns an attribute value
* @return mixed (primitive values only)
* Returns all attributes of the Composite