commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject [lang] ArrayUtils toMap asMap, [was Re: [collections] [PATCH] MapUtil]
Date Sun, 13 Oct 2002 22:44:08 GMT
Life is never simple....I started applying the patch, but hit some problems

By comparison with the JDK, the method asList(Object[]) is on Arrays. Thus I
have applied the patch to ArrayUtils in [lang] instead of [collections].

toMap(Object[]) fitted fine.

When I looked at asMap(Object[]) I discovered certain problems that we
hadn't considered:
- the array doesn't behave like a Map when looking up keys because its not
hashed
- what happens if someone changes the underlying array, to put an illegal
object type or null into the array
- the implementation didn't correctly handle the values(), entrySet() or
keySet() methods which should provide a view onto the real data (which would
actually be tricky to implement).

So, there is either a lot more work on asMap(), or we say that toMap covers
most cases anyway.

Stephen

----- Original Message -----
From: "Moritz Petersen" <moritzpetersen@mac.com>
To: "Commons Dev" <commons-dev@jakarta.apache.org>
Sent: Sunday, October 13, 2002 2:34 PM
Subject: [collections] [PATCH] MapUtil


> The patch contains:
>
> MapUtil#toMap(Object[]) - converts the array to a Map
> MapUtil#asMap(Object[]) - wraps an ArrayMap around the array
> MapUtil.ArrayMap        - inner class for #asMap(Object[])
>
> TestMapUtil#testToMap()
> TestMapUtil#testAsMap()
>
>
> Patch was applied:
>
> diff -u -r1.13 MapUtils.java
> diff -u -r1.2 TestMapUtils.java
>
>
>
> -Moritz.
>
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message