com.marringtons.util
Class Maps

java.lang.Object
  extended bycom.marringtons.util.Maps

public class Maps
extends Object

Maps is a helper class of static methods for working on and with maps (name/value pairs) and sets - primarily to allow convenient static programatic loading.

Author:
Paul Marrington

Method Summary
static Map load(Map map, Object[] with)
          Load a map from a static array.
static Map load(Object[] with)
          Load a HashMap from a static array.
static Map loadSet(Map map, Object[] with)
          Load a map as a set from a static array.
static Map loadSet(Object[] with)
          Load a map as a set from a static array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

load

public static Map load(Object[] with)
Load a HashMap from a static array. This allows maps to be created in code.
   Map map = Maps.load( new Object[]
     {
       "keyOne", "valueOne",
       "key2", value2Object,
     }); 
 

Parameters:
with - Array of key/value object pairs to load with
Returns:
map provided for convenience.

load

public static Map load(Map map,
                       Object[] with)
Load a map from a static array. This allows maps to be created in code.
   Map map = Maps.load( new HashMap(), new Object[]
     {
       "keyOne", "valueOne",
       "key2", value2Object,
     }); 
 

Parameters:
map - to load
with - Array of key/value object pairs to load with
Returns:
map provided for convenience.

loadSet

public static Map loadSet(Object[] with)
Load a map as a set from a static array. This allows maps to be initialise. Use containsKey() to find entries as by default they will point to a null item.
   Map map = Maps.loadSet( new Object[]
     { "keyOne", "key2" }); 
 

Parameters:
with - Array of keys to load with
Returns:
map provided for convenience.

loadSet

public static Map loadSet(Map map,
                          Object[] with)
Load a map as a set from a static array. This allows maps to be initialise. Use containsKey() to find entries as by default they will point to a null item.
   Map map = Maps.loadSet( new HashMap(), new Object[]
     { "keyOne", "key2" }); 
 

Parameters:
map - to load
with - Array of keys to load with
Returns:
map provided for convenience.


Copyright © 2005 Paul Marrington http://library.marringtons.com