Gumbo_Interface_Composite
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.
Attributes 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 element.
data
Comments 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 Composite.
Author(s): |
Michael Luster <mluster79@yahoo.com> |
License: | New BSD License |
Copyright: | Copyright (c) 2007, iBayou, Michael Luster |
Link: | http://sourceforge.net/projects/phpgumbo |
Version: | 0.0.1 |
Interface Methods
Adds a Composite object to the Composite (for Branch use only)
Parameter(s):
- (Gumbo_Interface_Composite) $tree
- (bool) $replace :: replaces the original Composite object
[ Top ]
Adds an attribute description to the Composite object
Parameter(s):
- (string) $name :: attribute name
- (string|num|bool) $val :: attribute value
- (bool) $replace :: replaces existing attribute
- postcondition:
remove non-alphanumeric characters (excluding underscores) from $name
[ Top ]public void addComment ( [string $comment] ) [line 110]Adds a comment to the Composite (A null comment will add a blank line)
Parameter(s):
- (string) $comment
[ Top ]public mixed get ( [int|string $name] ) [line 135]Returns the corresponding Composite object or Value
Parameter(s):
- (int|string) $name
[ Top ]public mixed getAttribute ( string $name ) [line 154]Returns an attribute value
Parameter(s):
- (string) $name
- return:
(primitive values only)
[ Top ]public void remove ( int|string $name ) [line 86]Removes a Composite object based on the Composite name (for Branch use only)
Parameter(s):
- (int|string) $name
[ Top ]public void removeAttribute ( string $name ) [line 104]Removes an attribute
Parameter(s):
- (string) $name
[ Top ]!getComments()
[ Top ]public void setValue ( mixed $val ) [line 125]Sets the Composite value (for Leaf use only)
Parameter(s):
- (mixed) $val :: (primitive types only)
[ Top ]public mixed __get ( int|string $name ) [line 70]Returns the Value or a Composite referenced by the 'name'
Parameter(s):
- (int|string) $name :: (for 'int', wrap in curly braces $comp->{0})
[ Top ]