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
  • Field Details

    • m_nameSet

      private final Set m_nameSet
      Set of names used.
  • Constructor Details

    • 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 -
    • UniqueNameSet

      public UniqueNameSet(UniqueNameSet original)
      Copy constructor. Creates a name set initialized to contain all the names from another name set.
      Parameters:
      original -
  • Method Details

    • contains

      public boolean contains(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 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