From: Jan T. <de...@us...> - 2001-12-11 22:22:36
|
Update of /cvsroot/net-script/netscript2/src/perl/XML/DOM2 In directory usw-pr-cvs1:/tmp/cvs-serv4065 Modified Files: NamedNodeMap.pm Log Message: * fixed all methods * added new method for removal of an item Index: NamedNodeMap.pm =================================================================== RCS file: /cvsroot/net-script/netscript2/src/perl/XML/DOM2/NamedNodeMap.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NamedNodeMap.pm 2001/10/03 19:52:23 1.3 --- NamedNodeMap.pm 2001/12/11 22:22:34 1.4 *************** *** 35,39 **** my $proto = shift; # get Prototype my $class = ref( $proto ) || $proto;# get the Classname - my %args = shift; # Create a Class using the Hash-As-An-Object-Idiom --- 35,38 ---- *************** *** 65,70 **** #*/ sub getNamedItem { ! my ( $this, %params ) = @_; ! my $name = $params{ name }; $this -> { m_nodeMap } -> { $name }; --- 64,69 ---- #*/ sub getNamedItem { ! my ( $this, $paramsRef ) = @_; ! my $name = $paramsRef -> { name }; $this -> { m_nodeMap } -> { $name }; *************** *** 82,88 **** #*/ sub getNamedItemNS { ! my ( $this , %params ) = @_; ! my $namespaceURI = $params{ namespaceURI }; ! my $localName = $params{ localName }; $this -> { m_nodeMap } -> { $namespaceURI.$localName }; --- 81,87 ---- #*/ sub getNamedItemNS { ! my ( $this , $paramsRef ) = @_; ! my $namespaceURI = $paramsRef -> { namespaceURI }; ! my $localName = $paramsRef -> { localName }; $this -> { m_nodeMap } -> { $namespaceURI.$localName }; *************** *** 99,104 **** #*/ sub item { ! my ( $this, %params ) = @_; ! my $index = $params{ "index" }; my @values = values( %{ $this -> { m_nodeMap } } ); @values[ $index ]; --- 98,103 ---- #*/ sub item { ! my ( $this, $paramsRef ) = @_; ! my $index = $paramsRef -> { "index" }; my @values = values( %{ $this -> { m_nodeMap } } ); @values[ $index ]; *************** *** 118,123 **** #*/ sub removeNamedItem { ! my ( $this, %params ) = @_; ! my $name = $params{ name }; delete $this -> { m_nodeMap } -> { $name }; } --- 117,122 ---- #*/ sub removeNamedItem { ! my ( $this, $paramsRef ) = @_; ! my $name = $paramsRef -> { name }; delete $this -> { m_nodeMap } -> { $name }; } *************** *** 125,128 **** --- 124,153 ---- #/** + # Removes the given node from the map. + # @param a hash containing the following key-value-pairs: + # node - the node to delete. + # @return the deleted node if the node could be removed or + # undef, if the node was not found in this NamedNodeMap. + # @public + # @not-standard + #*/ + sub removeItem { + my ($this, $paramsRef ) = @_; + my $node = $paramsRef -> { "node" }; + my $found = 0; + + for ( keys( $this -> { m_nodeMap} ) ) { + delete $this -> { m_nodeMap } -> { $_ }, $found = 1, last + if $this -> { m_nodeMap } -> { $_ } == $node ; + } + if ($found) { + $node; + } + else { + undef; + } + } + + #/** # Removes a node specified by namespaceURI and local names. # *************** *** 131,135 **** # localName - the local name of the node to remove. # @return the removed Node, if such a node exists, else undef. ! # # @FIXME: Default attributes are not automatically inserted if # they are deleted. This must be done in compliance with --- 156,160 ---- # localName - the local name of the node to remove. # @return the removed Node, if such a node exists, else undef. ! # # @FIXME: Default attributes are not automatically inserted if # they are deleted. This must be done in compliance with *************** *** 137,143 **** #*/ sub removeNamedItemNS { ! my ( $this, %params ) = @_; ! my $namespaceURI = $params{ namespaceURI }; ! my $localName = $params{ localName }; delete $this -> { m_nodeMap } -> { $namespaceURI.$localName }; } --- 162,168 ---- #*/ sub removeNamedItemNS { ! my ( $this, $paramsRef ) = @_; ! my $namespaceURI = $paramsRef -> { namespaceURI }; ! my $localName = $paramsRef -> { localName }; delete $this -> { m_nodeMap } -> { $namespaceURI.$localName }; } *************** *** 151,156 **** #*/ sub setNamedItem { ! my ( $this, %params ) = @_; ! my $node = $params{ node }; $this -> { m_nodeMap } -> { $node -> nodeName() } = $node; } --- 176,181 ---- #*/ sub setNamedItem { ! my ( $this, $paramsRef ) = @_; ! my $node = $paramsRef -> { node }; $this -> { m_nodeMap } -> { $node -> nodeName() } = $node; } *************** *** 163,168 **** #*/ sub setNamedItemNS { ! my ( $this, %params ) = @_; ! my $node = $params{ node }; $this -> { m_nodeMap } -> { $node -> namespaceURI() . $node -> localName() } = $node; --- 188,193 ---- #*/ sub setNamedItemNS { ! my ( $this, $paramsRef ) = @_; ! my $node = $paramsRef -> { node }; $this -> { m_nodeMap } -> { $node -> namespaceURI() . $node -> localName() } = $node; |