You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Lluís Martínez (JIRA)" <ji...@apache.org> on 2008/12/24 00:32:44 UTC

[jira] Created: (COLLECTIONS-308) CollectionUtils.transform fails when collection is HashMap$Values

CollectionUtils.transform fails when collection is HashMap$Values
-----------------------------------------------------------------

                 Key: COLLECTIONS-308
                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-308
             Project: Commons Collections
          Issue Type: Bug
          Components: Collection
    Affects Versions: 3.2
         Environment: Ubuntu
            Reporter: Lluís Martínez
            Priority: Minor


I'm trying to apply a transformation to all values in a map :

		Collection values = map.values();
		CollectionUtils.transform((Collection)values, this);

Gives a java.lang.UnsupportedOperationException in CollectionUtils line 439.

According to Javadoc the method values of Hashmap "does not support the add or addAll operations.".




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (COLLECTIONS-308) CollectionUtils.transform fails when collection is HashMap$Values

Posted by "Lluís Martínez (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COLLECTIONS-308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lluís Martínez closed COLLECTIONS-308.
--------------------------------------

    Resolution: Won't Fix

I agree with Stephen's explanation, proceeding to close.
James: I need the map updated as well. I will iterate the keyset, get the value, transform and put.
Thanks for your comments.

> CollectionUtils.transform fails when collection is HashMap$Values
> -----------------------------------------------------------------
>
>                 Key: COLLECTIONS-308
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-308
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Collection
>    Affects Versions: 3.2
>         Environment: Ubuntu
>            Reporter: Lluís Martínez
>            Priority: Minor
>
> I'm trying to apply a transformation to all values in a map :
> 		Collection values = map.values();
> 		CollectionUtils.transform(values, transformer);
> Gives a java.lang.UnsupportedOperationException in CollectionUtils line 439.
> According to Javadoc the method values of Hashmap "does not support the add or addAll operations.".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (COLLECTIONS-308) CollectionUtils.transform fails when collection is HashMap$Values

Posted by "Lluís Martínez (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COLLECTIONS-308?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lluís Martínez updated COLLECTIONS-308:
---------------------------------------

    Description: 
I'm trying to apply a transformation to all values in a map :

		Collection values = map.values();
		CollectionUtils.transform(values, transformer);

Gives a java.lang.UnsupportedOperationException in CollectionUtils line 439.

According to Javadoc the method values of Hashmap "does not support the add or addAll operations.".




  was:
I'm trying to apply a transformation to all values in a map :

		Collection values = map.values();
		CollectionUtils.transform((Collection)values, this);

Gives a java.lang.UnsupportedOperationException in CollectionUtils line 439.

According to Javadoc the method values of Hashmap "does not support the add or addAll operations.".





> CollectionUtils.transform fails when collection is HashMap$Values
> -----------------------------------------------------------------
>
>                 Key: COLLECTIONS-308
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-308
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Collection
>    Affects Versions: 3.2
>         Environment: Ubuntu
>            Reporter: Lluís Martínez
>            Priority: Minor
>
> I'm trying to apply a transformation to all values in a map :
> 		Collection values = map.values();
> 		CollectionUtils.transform(values, transformer);
> Gives a java.lang.UnsupportedOperationException in CollectionUtils line 439.
> According to Javadoc the method values of Hashmap "does not support the add or addAll operations.".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COLLECTIONS-308) CollectionUtils.transform fails when collection is HashMap$Values

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COLLECTIONS-308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12659012#action_12659012 ] 

James Carman commented on COLLECTIONS-308:
------------------------------------------

Do you need the transformation to be visible via the map?  Or, are you just looking to take the values from the map, transform them in some way, and then do something with them?  If so, then try:

Collection values = new HashSet(map.values());

and play around with that values collection.  Of course, you can use whatever type of collection you wish (LinkedList, ArrayList, TreeSet, etc.).

> CollectionUtils.transform fails when collection is HashMap$Values
> -----------------------------------------------------------------
>
>                 Key: COLLECTIONS-308
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-308
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Collection
>    Affects Versions: 3.2
>         Environment: Ubuntu
>            Reporter: Lluís Martínez
>            Priority: Minor
>
> I'm trying to apply a transformation to all values in a map :
> 		Collection values = map.values();
> 		CollectionUtils.transform(values, transformer);
> Gives a java.lang.UnsupportedOperationException in CollectionUtils line 439.
> According to Javadoc the method values of Hashmap "does not support the add or addAll operations.".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COLLECTIONS-308) CollectionUtils.transform fails when collection is HashMap$Values

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COLLECTIONS-308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12659074#action_12659074 ] 

Stephen Colebourne commented on COLLECTIONS-308:
------------------------------------------------

There is no way to 'fix' this in commons-collections - its the nature of transform() to alter the input collection.

The only change to make is to add some javadoc.

> CollectionUtils.transform fails when collection is HashMap$Values
> -----------------------------------------------------------------
>
>                 Key: COLLECTIONS-308
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-308
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Collection
>    Affects Versions: 3.2
>         Environment: Ubuntu
>            Reporter: Lluís Martínez
>            Priority: Minor
>
> I'm trying to apply a transformation to all values in a map :
> 		Collection values = map.values();
> 		CollectionUtils.transform(values, transformer);
> Gives a java.lang.UnsupportedOperationException in CollectionUtils line 439.
> According to Javadoc the method values of Hashmap "does not support the add or addAll operations.".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.