refListPathDataElement = $ref; $this->pos = $pos; } function getPos() { return $this->pos; } function getData() { return $this->refListPathDataElement; } function getName() { return $this->refListPathDataElement->getName(); } function getValue() { if ($this->children[0] instanceof ListValueElement) return $this->children[0]->getValue(); else throw new Exception("This is no leaf node"); } function isExistingPos($comp) { foreach ($this->children as $child) { if ($child instanceof ListPathContentElement) if ($child->getPos() == $comp) return true; } return false; } //TODO function getChildByNamePos($name, $pos) { #echo "name: $name, pos: $pos"; foreach ($this->children as $child) { if ($child instanceof ListPathContentElement) { #print_r($child); #echo $child->getName()." ".$child->getPos()." ".get_class($child)."\n"; if ($child->getPos() == $pos && $child->getName() == $name) { #echo "found"; return $child; } } } } function getChildByPath($pathArray) { if (count($pathArray) > 0) { $removedElement = array_shift($pathArray); $removedPos = array_shift($pathArray); $match = $this->getChildByNamePos($removedElement, $removedPos); print_r($match); if ($match === false) throw new Exception("PathElement $removedElement couldn't be found"); else { return $match->getChildByPath($pathArray); } } else { return $this; } } function output($level = 0) { if ($level > 1) echo "_" . $this->pos . "_"; if(is_object($this->refListPathDataElement)) echo $this->getName(); foreach ($this->children as $key => $child) { $child->output($level +1); } } } ?>