4 * 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 Sabre_VObject_Node implements IteratorAggregate, ArrayAccess, Countable {
15 * Turns the object back into a serialized blob.
19 abstract function serialize();
24 * @var Sabre_VObject_ElementList
26 protected $iterator = null;
29 * A link to the parent node
31 * @var Sabre_VObject_Node
33 public $parent = null;
35 /* {{{ IteratorAggregator interface */
38 * Returns the iterator for this object
40 * @return Sabre_VObject_ElementList
42 public function getIterator() {
44 if (!is_null($this->iterator))
45 return $this->iterator;
47 return new Sabre_VObject_ElementList(array($this));
52 * Sets the overridden iterator
54 * Note that this is not actually part of the iterator interface
56 * @param Sabre_VObject_ElementList $iterator
59 public function setIterator(Sabre_VObject_ElementList $iterator) {
61 $this->iterator = $iterator;
67 /* {{{ Countable interface */
70 * Returns the number of elements
74 public function count() {
76 $it = $this->getIterator();
83 /* {{{ ArrayAccess Interface */
87 * Checks if an item exists through ArrayAccess.
89 * This method just forwards the request to the inner iterator
94 public function offsetExists($offset) {
96 $iterator = $this->getIterator();
97 return $iterator->offsetExists($offset);
102 * Gets an item through ArrayAccess.
104 * This method just forwards the request to the inner iterator
109 public function offsetGet($offset) {
111 $iterator = $this->getIterator();
112 return $iterator->offsetGet($offset);
117 * Sets an item through ArrayAccess.
119 * This method just forwards the request to the inner iterator
122 * @param mixed $value
125 public function offsetSet($offset,$value) {
127 $iterator = $this->getIterator();
128 $iterator->offsetSet($offset,$value);
133 * Sets an item through ArrayAccess.
135 * This method just forwards the request to the inner iterator
140 public function offsetUnset($offset) {
142 $iterator = $this->getIterator();
143 $iterator->offsetUnset($offset);