You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Don Brown (JIRA)" <ji...@apache.org> on 2006/11/17 08:46:59 UTC
[jira] Closed: (WW-456) SingleValueMap.entrySet() is broken
[ http://issues.apache.org/struts/browse/WW-456?page=all ]
Don Brown closed WW-456.
------------------------
Resolution: Not A Problem
> SingleValueMap.entrySet() is broken
> -----------------------------------
>
> Key: WW-456
> URL: http://issues.apache.org/struts/browse/WW-456
> Project: Struts 2
> Issue Type: Bug
> Components: Actions
> Affects Versions: WW 1.4, WW 1.3
> Reporter: Attila Szegedi
>
> SingleValueMap.entrySet() returns multivalue entries instead of single value ones. There's a "//TODO: NYI" comment in there...
> Here's a patch that makes it right, coded to be similar to how values() is implemented:
> public Set entrySet()
> {
> Set entries = m.entrySet();
> Set realEntries = new HashSet(entries.size() * 4/3, .75f);
> for (Iterator iterator = entries.iterator(); iterator.hasNext();)
> {
> realEntries.add(new SingleValueEntry((Map.Entry)iterator.next()));
> }
> return realEntries;
> }
>
> private static class SingleValueEntry implements Map.Entry
> {
> private final Map.Entry entry;
>
> SingleValueEntry(Map.Entry entry)
> {
> this.entry = entry;
> }
> public Object getKey()
> {
> return entry.getKey();
> }
>
> public Object getValue()
> {
> Object o = entry.getValue();
> return o == null ? null : ((Object[])o)[0];
> }
>
> public void setValue(Object value)
> {
> Object o = entry.getValue();
> if(o instanceof Object[])
> {
> Object[] ao = (Object[])o;
> if(ao.length > 0)
> {
> ao[0] = value;
> return;
> }
> }
> entry.setValue(new Object[] { value });
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira