public function setAttribute($name, $value) { $this->attributes[$name] = $value; }
public function getAttribute($name=null) { return $name==null? $this->attributes: $this->attributes[$name]; }
public function removeAttribute($name) { unset($this->attributes["$name"]); }
public function getNodesSize() { return sizeof($this->nodes); }
protected function setNode($name, $nodeId) { $this->nodes[$name] = $nodeId; }
public abstract function createNode($name, $attributes);
public abstract function removeNode($name);
public abstract function getNode($name=null);
protected function getNodeId($name=null) { return $name==null? $this->nodes: $this->nodes[$name]; }
protected function createNodeByName($rootNodeObj, $name, $attributes, $pId) { $tmpObject = $rootNodeObj->createNodeObject($pId, $name, $attributes); $key = isset($attributes[id])? $name.'_'.$attributes[id]: $name.'_'.$this->getNodesSize(); $this->setNode($key, $tmpObject->getSeq()); return $tmpObject; }
protected function removeNodeByName($rootNodeObj, $name) { $rootNodeObj->removeNodeById($this->getNodeId($name)); if(sizeof($this->nodes)==1) $this->nodes = array(); else unset($this->nodes[$name]); }
protected function getNodeByName($rootNodeObj, $name=null) { if($name==null) { $tmpList = array(); $tmpIds = $this->getNodeId(); foreach($tmpIds as $key=>$id) $tmpList[$key] = $rootNodeObj->getNodeById($id); return $tmpList; } else { $id = $this->getNodeId($name); if($id===null) { $tmpIds = $this->getNodeId();
foreach($tmpIds as $tkey=>$tid) { if(strpos($key, $name)==0) { $id = $tid; break; } } } return $rootNodeObj->getNodeById($id); } }
(编辑:焦作站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|