orbeon/orbeon-forms — pull request #307 by yankee42 (2012-06-12 10:03:44+00:00)
Title: Shortend StringConversions by making use of common-lang

I noticed that common-lang is a dependency of orbeon anyway. Thus I used it at no extra cost to shorten some methods that add objects in "array-maps" in StringConversions.

Additionally I added a unit test, proving that the code still works (at least for the string variant).

If commons-lang is upgraded to version 3 even the casts could be removed.

It would be possible to go one step further, generalizing the methods:

public static void addValueToArrayMap(Map map, String name, T value) {
map.put(name, (T[])ArrayUtils.add(map.get(name), value));
}

this will work with both Object and String, but creates an unsafe cast warning. But: From commons-lang version 3 on the cast is not needed anymore and the warning will go away.