summaryrefslogtreecommitdiff
path: root/framework/Data
diff options
context:
space:
mode:
authorxue <>2006-01-31 00:01:49 +0000
committerxue <>2006-01-31 00:01:49 +0000
commit01bc363ac789cfb9d644ce82a949da5cd7e1c220 (patch)
treea059046856645d59cf0cb1badee83eb5c73671e9 /framework/Data
parent265b7e85766ba403ca0a8b58648dd091e483cf38 (diff)
Modified TList and TMap implementation so that they can be more easily extended.
Diffstat (limited to 'framework/Data')
-rw-r--r--framework/Data/TXmlDocument.php47
1 files changed, 26 insertions, 21 deletions
diff --git a/framework/Data/TXmlDocument.php b/framework/Data/TXmlDocument.php
index 0b37258d..bb22b254 100644
--- a/framework/Data/TXmlDocument.php
+++ b/framework/Data/TXmlDocument.php
@@ -416,36 +416,41 @@ class TXmlElementList extends TList
return $this->_o;
}
- /**
- * Overrides the parent implementation with customized processing of the newly added item.
- * @param mixed the newly added item
- */
- protected function addedItem($item)
- {
- if($item->getParent()!==null)
- $item->getParent()->getElements()->remove($item);
- $item->setParent($this->_o);
- }
/**
- * Overrides the parent implementation with customized processing of the removed item.
- * @param mixed the removed item
+ * Inserts an item at the specified position.
+ * This overrides the parent implementation by performing additional
+ * operations for each newly added TXmlElement object.
+ * @param integer the speicified position.
+ * @param mixed new item
+ * @throws TInvalidDataTypeException if the item to be inserted is not a TXmlElement object.
*/
- protected function removedItem($item)
+ public function insertAt($index,$item)
{
- $item->setParent(null);
+ if($item instanceof TXmlElement)
+ {
+ parent::insertAt($index,$item);
+ if($item->getParent()!==null)
+ $item->getParent()->getElements()->remove($item);
+ $item->setParent($this->_o);
+ }
+ else
+ throw new TInvalidDataTypeException('xmlelementlist_xmlelement_required');
}
/**
- * This method is invoked before adding an item to the map.
- * If it returns true, the item will be added to the map, otherwise not.
- * You can override this method to decide whether a specific can be added.
- * @param mixed item to be added
- * @return boolean whether the item can be added to the map
+ * Removes an item at the specified position.
+ * This overrides the parent implementation by performing additional
+ * cleanup work when removing a TXmlElement object.
+ * @param integer the index of the item to be removed.
+ * @return mixed the removed item.
*/
- protected function canAddItem($item)
+ public function removeAt($index)
{
- return ($item instanceof TXmlElement);
+ $item=parent::removeAt($index);
+ if($item instanceof TXmlElement)
+ $item->setParent(null);
+ return $item;
}
}