You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Thomas Vahrst (JIRA)" <ji...@apache.org> on 2013/01/19 16:52:12 UTC

[jira] [Comment Edited] (COLLECTIONS-322) Adds a Collections wrapper around the w3c NodeList

    [ https://issues.apache.org/jira/browse/COLLECTIONS-322?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13558035#comment-13558035 ] 

Thomas Vahrst edited comment on COLLECTIONS-322 at 1/19/13 3:50 PM:
--------------------------------------------------------------------

proposal for an implementation for NodeListAsList, with Junit Tests. 

NodeListAsList implements the Unmodifiable interface, because the org.w3c.NodeList has not support for adding/removing items. 
In most cases the org.w3c.NodeList is used to iterate over the children of a parent node. So it may be a better idea to provide a NodeListUtils class with methods like
{code}
  Iterable<Node> NodeListUtils.asIterable(org.w3c.NodeList)  
  Iterable<Node> NodeListUtils.getChildNodesAsIterable(org.w3c.NodeList)
{code}
instead of NodeListAsList. NodeListAsList could then be made a private inner class of NodeListUtils. 
                
      was (Author: t.vahrst):
    proposal for an implementation for NodeListAsList, with Junit Tests. 
                  
> Adds a Collections wrapper around the w3c NodeList
> --------------------------------------------------
>
>                 Key: COLLECTIONS-322
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-322
>             Project: Commons Collections
>          Issue Type: Improvement
>          Components: List
>            Reporter: Hasan Diwan
>            Priority: Minor
>             Fix For: 4.0
>
>         Attachments: NodeListAsCollection.java, TestNodeListAsCollection.java, vcs-diff2762905948687805364.patch
>
>
> org.w3c.dom.NodeList is defined as an "abstract collection of Nodes" and java.util.List is defined as "An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.". It seemed similar enough, so I did an implementation of the useful methods, while throwing the appropriate exception when the method wouldn't make sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira