org.jibx.util
Class UniqueNameSet

java.lang.Object
  extended by org.jibx.util.UniqueNameSet

public class UniqueNameSet
extends java.lang.Object

Set of unique names for a context. This assures uniqueness as names are added to the set.

Author:
Dennis M. Sosnoski

Field Summary
private  java.util.Set m_nameSet
          Set of names used.
 
Constructor Summary
UniqueNameSet()
          Constructor.
UniqueNameSet(java.util.Collection base)
          Constructor from existing name collection.
UniqueNameSet(UniqueNameSet original)
          Copy constructor.
 
Method Summary
 java.lang.String add(java.lang.String base)
          Add name to set.
 void addAll(UniqueNameSet other)
          Add all the names from another name set to this set.
 boolean contains(java.lang.String name)
          Check if a name is already present in context.
 java.util.Iterator iterator()
          Get iterator for names in set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_nameSet

private final java.util.Set m_nameSet
Set of names used.

Constructor Detail

UniqueNameSet

public UniqueNameSet()
Constructor.


UniqueNameSet

public UniqueNameSet(java.util.Collection base)
Constructor from existing name collection. Creates a name set initialized to contain all the supplied names.

Parameters:
base -

UniqueNameSet

public UniqueNameSet(UniqueNameSet original)
Copy constructor. Creates a name set initialized to contain all the names from another name set.

Parameters:
original -
Method Detail

contains

public boolean contains(java.lang.String name)
Check if a name is already present in context.

Parameters:
name -
Returns:
true if present, false if not

addAll

public void addAll(UniqueNameSet other)
Add all the names from another name set to this set. This does not check for conflicts between the names in the two sets.

Parameters:
other -

add

public java.lang.String add(java.lang.String base)
Add name to set. If the supplied name is already present, it is modified by appending a variable suffix. If the supplied name ends with a digit, the suffix is generated starting with the letter 'a'; otherwise, it's generated starting at '1'. Either way, the suffix is incremented as many times as necessary to obtain a unique name.

Parameters:
base - name to try adding
Returns:
assigned name

iterator

public java.util.Iterator iterator()
Get iterator for names in set.

Returns:
iterator


Project Web Site