org.millscript.millscript.datatypes
Class MapAwareTools

java.lang.Object
  extended by org.millscript.millscript.datatypes.MapAwareTools

public final class MapAwareTools
extends java.lang.Object

This utility class implements list aware tools for MillScript. List aware means that these methods unify different datatypes in a list-like way. e.g. getting a specified item in a list.

These static methods provide a location to optimize Map-like operations for particular classes. Each one provides a general fallback defined in terms of MapFactory.make.


Method Summary
static java.lang.Object get(java.lang.Object obj, java.lang.Object key)
          Returns the value for the specified key from the specified map like object.
static void insert(java.lang.Object obj, java.lang.Object key, java.lang.Object val)
          Inserts a mapping for the specified key and value into the given map like object.
static org.millscript.commons.util.MapIterator mapIterator(java.lang.Object obj)
          Returns a map iterator to iterate over all the entries in the specified map like object.
static int size(java.lang.Object obj)
          Returns the size of the specified object, seen as a map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static java.lang.Object get(java.lang.Object obj,
                                   java.lang.Object key)
Returns the value for the specified key from the specified map like object.

Parameters:
obj - the map like object to index
key - the key to get a value for
Returns:
the value for the specified key

insert

public static void insert(java.lang.Object obj,
                          java.lang.Object key,
                          java.lang.Object val)
Inserts a mapping for the specified key and value into the given map like object.

Parameters:
obj - the map like object to insert a mapping into
key - the key to insert
val - the value to associate with the key

mapIterator

public static org.millscript.commons.util.MapIterator mapIterator(java.lang.Object obj)
Returns a map iterator to iterate over all the entries in the specified map like object.

Parameters:
obj - the map like object to get a map interator for
Returns:
a MapIterator to iterate over the entries in the map like object

size

public static int size(java.lang.Object obj)
Returns the size of the specified object, seen as a map. If the object cannot be understood directly, this method attempts to construct a new map from the specified object and then calculate it's size.

Parameters:
obj - the object to determine the size of
Returns:
an int for the size of the specified object
See Also:
CollectionFactory


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.