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

public void add ( Gumbo_Interface_Composite $tree, [bool $replace] ) [line 80]

Adds a Composite object to the Composite (for Branch use only)

Parameter(s):


[ Top ]
public void addAttribute ( string $name, string|num|bool $val, [bool $replace] ) [line 98]

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 array getAttributes ( ) [line 160]

Returns all attributes of the Composite


[ Top ]
public array getComments ( ) [line 166]

Returns all comments


[ Top ]
public int|string getName ( ) [line 141]

Returns the Name


[ Top ]
public mixed getValue ( ) [line 147]

Returns the Value


[ 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 ]
public void resetComments ( ) [line 116]

Resets all comments

  • postcondition:  !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 ]
public void __set ( int|string $name, mixed $val ) [line 63]

Sets a Value, or adds a new Composite to a Branch

Parameter(s):

  • (int|string) $name :: (for 'int', wrap in curly braces $comp->{0} = value)
  • (mixed) $val

[ Top ]