Package org.jibx.util
Class UniqueNameSet
- java.lang.Object
-
- org.jibx.util.UniqueNameSet
-
public class UniqueNameSet extends Object
Set of unique names for a context. This assures uniqueness as names are added to the set.- Author:
- Dennis M. Sosnoski
-
-
Constructor Summary
Constructors Constructor Description UniqueNameSet()Constructor.UniqueNameSet(Collection base)Constructor from existing name collection.UniqueNameSet(UniqueNameSet original)Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringadd(String base)Add name to set.voidaddAll(UniqueNameSet other)Add all the names from another name set to this set.booleancontains(String name)Check if a name is already present in context.Iteratoriterator()Get iterator for names in set.
-
-
-
Constructor Detail
-
UniqueNameSet
public UniqueNameSet()
Constructor.
-
UniqueNameSet
public UniqueNameSet(Collection base)
Constructor from existing name collection. Creates a name set initialized to contain all the supplied names.- Parameters:
base- Collection
-
UniqueNameSet
public UniqueNameSet(UniqueNameSet original)
Copy constructor. Creates a name set initialized to contain all the names from another name set.- Parameters:
original- Name Set
-
-
Method Detail
-
contains
public boolean contains(String name)
Check if a name is already present in context.- Parameters:
name-- Returns:
trueif present,falseif 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- Unique Name Set
-
add
public String add(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 Iterator iterator()
Get iterator for names in set.- Returns:
- iterator
-
-