jfun.util.dict
Class DictFactory

java.lang.Object
  extended by jfun.util.dict.DictFactory

public class DictFactory
extends java.lang.Object

The factory to create Dict objects.

Author:
Ben Yu Jan 16, 2005

Constructor Summary
DictFactory()
           
 
Method Summary
static Dict instance()
          returns an empty instance of unsafe immutable dictionary.
static Dict instance(java.lang.Class impl_type)
          To create an empty Dict object with a specified subclass of java.util.HashMap as the underlying mutable data structure.
static Dict merge(Dict d1, Dict d2)
          Add the contents in the second Dict object into the first.
static Dict safeInstance()
          same as instance() except this is a thread-safe version
static Dict safeInstance(java.lang.Class impl_type)
          To create an empty and thread-safe Dict object with a specified subclass of java.util.HashMap as the underlying mutable data structure.
static Dict subtract(Dict d1, Dict d2)
          Remove the elements contained in the second Dict object from the first.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DictFactory

public DictFactory()
Method Detail

instance

public static Dict instance(java.lang.Class impl_type)
To create an empty Dict object with a specified subclass of java.util.HashMap as the underlying mutable data structure.

Parameters:
impl_type - the implementation class.
Returns:
the Dict object.

safeInstance

public static Dict safeInstance(java.lang.Class impl_type)
To create an empty and thread-safe Dict object with a specified subclass of java.util.HashMap as the underlying mutable data structure.

Parameters:
impl_type - the implementation class.
Returns:
the Dict object.

instance

public static Dict instance()
returns an empty instance of unsafe immutable dictionary.


safeInstance

public static Dict safeInstance()
same as instance() except this is a thread-safe version


merge

public static Dict merge(Dict d1,
                         Dict d2)
Add the contents in the second Dict object into the first. elements with the same key are overwritten.

Parameters:
d1 - the first Dict object.
d2 - the second Dict object.
Returns:
the new Dict object.

subtract

public static Dict subtract(Dict d1,
                            Dict d2)
Remove the elements contained in the second Dict object from the first.

Parameters:
d1 - the first Dict object.
d2 - the second Dict object.
Returns:
the new Dict object.