util
Class IDFactory

java.lang.Object
  |
  +--util.IDFactory

public class IDFactory
extends java.lang.Object

collection of string id's; all keys are lowerCase ascii7; createUniqueID() returns a string which is added to this collection length of keys can be limited by setMaxLength()


Field Summary
private  java.util.Map inUse
          map of id's in use @see setInUse( Map m )
private  int maxLength
           
 
Constructor Summary
IDFactory()
           
 
Method Summary
 void addToInUse(java.util.Collection l)
           
 void addToInUse(java.lang.String s)
           
 void addToInUse(java.lang.String s, java.lang.Object o)
           
 java.lang.String createUniqueID(IDObject io)
          create id and set id of id-object
 java.lang.String createUniqueID(java.util.Map mapInUse, java.lang.Object o)
          check a string against the keys of a map and return a string value unique to this map
 java.lang.String createUniqueID(java.lang.String val)
          create string unique in collection
static void doAddToInUse(java.util.Map m, java.lang.Object o)
          add entry with this id-factory key and given object Object could be instance of IDObject; in which case getID() is used for key; otherwise toString() is used;
 java.util.Map getInUseMap()
           
 int getMaxLength()
           
static java.lang.String idfKey(java.lang.String s)
          translate string to id-factory key: lowercase ascii string
 void setInUseMap(java.util.Map m)
           
 void setMaxLength(int i)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inUse

private java.util.Map inUse
map of id's in use @see setInUse( Map m )


maxLength

private int maxLength
Constructor Detail

IDFactory

public IDFactory()
Method Detail

setInUseMap

public void setInUseMap(java.util.Map m)
See Also:
addToInUse(java.util.Collection)

getInUseMap

public java.util.Map getInUseMap()
Returns:
Map inUse; HashMap is created if inUse is not set

setMaxLength

public void setMaxLength(int i)

getMaxLength

public int getMaxLength()

addToInUse

public void addToInUse(java.util.Collection l)

createUniqueID

public java.lang.String createUniqueID(java.lang.String val)
create string unique in collection

Returns:
String unique id string

createUniqueID

public java.lang.String createUniqueID(IDObject io)
create id and set id of id-object

Returns:
String new id

addToInUse

public void addToInUse(java.lang.String s)

addToInUse

public void addToInUse(java.lang.String s,
                       java.lang.Object o)

doAddToInUse

public static void doAddToInUse(java.util.Map m,
                                java.lang.Object o)
add entry with this id-factory key and given object

Object could be instance of IDObject; in which case getID() is used for key; otherwise toString() is used;

See Also:
idfKey(java.lang.String)

idfKey

public static java.lang.String idfKey(java.lang.String s)
translate string to id-factory key: lowercase ascii string


createUniqueID

public java.lang.String createUniqueID(java.util.Map mapInUse,
                                       java.lang.Object o)
check a string against the keys of a map and return a string value unique to this map

Returns:
val if val doesn't occur in m or val + '1', or '2' etc until val is unique