3 namespace Sabre\VObject;
6 * Base class for all nodes
8 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
9 * @author Evert Pot (http://www.rooftopsolutions.nl/)
10 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
12 abstract class Node implements \IteratorAggregate, \ArrayAccess, \Countable {
15 * Turns the object back into a serialized blob.
19 abstract function serialize();
26 protected $iterator = null;
29 * A link to the parent node
33 public $parent = null;
36 * Validates the node for correctness.
37 * An array is returned with warnings.
39 * Every item in the array has the following properties:
40 * * level - (number between 1 and 3 with severity information)
41 * * message - (human readable message)
42 * * node - (reference to the offending node)
46 public function validate() {
52 /* {{{ IteratorAggregator interface */
55 * Returns the iterator for this object
59 public function getIterator() {
61 if (!is_null($this->iterator))
62 return $this->iterator;
64 return new ElementList(array($this));
69 * Sets the overridden iterator
71 * Note that this is not actually part of the iterator interface
73 * @param ElementList $iterator
76 public function setIterator(ElementList $iterator) {
78 $this->iterator = $iterator;
84 /* {{{ Countable interface */
87 * Returns the number of elements
91 public function count() {
93 $it = $this->getIterator();
100 /* {{{ ArrayAccess Interface */
104 * Checks if an item exists through ArrayAccess.
106 * This method just forwards the request to the inner iterator
111 public function offsetExists($offset) {
113 $iterator = $this->getIterator();
114 return $iterator->offsetExists($offset);
119 * Gets an item through ArrayAccess.
121 * This method just forwards the request to the inner iterator
126 public function offsetGet($offset) {
128 $iterator = $this->getIterator();
129 return $iterator->offsetGet($offset);
134 * Sets an item through ArrayAccess.
136 * This method just forwards the request to the inner iterator
139 * @param mixed $value
142 public function offsetSet($offset,$value) {
144 $iterator = $this->getIterator();
145 $iterator->offsetSet($offset,$value);
150 * Sets an item through ArrayAccess.
152 * This method just forwards the request to the inner iterator
157 public function offsetUnset($offset) {
159 $iterator = $this->getIterator();
160 $iterator->offsetUnset($offset);