de.fesenmeyer.dbnormalizer.core
Class AttributeStringSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.TreeSet<String>
              extended by de.fesenmeyer.dbnormalizer.core.AttributeStringSet
All Implemented Interfaces:
Serializable, Cloneable, Comparable<AttributeStringSet>, Iterable<String>, Collection<String>, NavigableSet<String>, Set<String>, SortedSet<String>

public class AttributeStringSet
extends TreeSet<String>
implements Comparable<AttributeStringSet>

A Set implementation for handling a set of attribute names. The set is ordered (by the string which represents the attribute name) to allow fast comparison of two instances with the compareTo(AttributeStringSet) and equals(Object) methods.

Author:
DF
See Also:
Serialized Form

Constructor Summary
AttributeStringSet()
          Class constructor for creating an empty instance.
AttributeStringSet(AttributeStringSet attrStrSet)
          Class constructor for creating an instance by copying the AttributeStringSet given by the attrStrSet argument.
AttributeStringSet(Collection<String> attrStrs)
          Class constructor for creating an instance by copying the collection given by the attrStrs argument.
 
Method Summary
 int compareTo(AttributeStringSet attrStrSet)
          Compares this instance to another instance by comparing all attribute names (represented by strings) of the two instances.
 AttributeStringSet copy()
          Copies this instance.
 boolean equals(Object o)
          Compares this instance with the object specified by the o argument.
 int hashCode()
          Returns the hashCode for this instance, which is computed based on the attribute names.
 
Methods inherited from class java.util.TreeSet
add, addAll, ceiling, clear, clone, comparator, contains, descendingIterator, descendingSet, first, floor, headSet, headSet, higher, isEmpty, iterator, last, lower, pollFirst, pollLast, remove, size, subSet, subSet, tailSet, tailSet
 
Methods inherited from class java.util.AbstractSet
removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, removeAll, retainAll, toArray, toArray
 

Constructor Detail

AttributeStringSet

public AttributeStringSet(AttributeStringSet attrStrSet)
Class constructor for creating an instance by copying the AttributeStringSet given by the attrStrSet argument.

Parameters:
attrStrSet - the AttributeStringSet to be used to create a new instance

AttributeStringSet

public AttributeStringSet(Collection<String> attrStrs)
Class constructor for creating an instance by copying the collection given by the attrStrs argument.

Parameters:
attrStrs - the collection to be used to create a new instance

AttributeStringSet

public AttributeStringSet()
Class constructor for creating an empty instance.

Method Detail

compareTo

public int compareTo(AttributeStringSet attrStrSet)
Compares this instance to another instance by comparing all attribute names (represented by strings) of the two instances. This method can be used for ordering AttributeStringSet instances based on the alphabetical order of the attribute names contained in the instances. For example, {A} is smaller than {A,B}, and {A,B} is smaller than {A,C}.

Specified by:
compareTo in interface Comparable<AttributeStringSet>
Parameters:
attrStrSet - the instance to be compared with this instance
Returns:
Returns 0, if the attribute names in both instances are the same. Returns an integer smaller than or greater than 0 if the attribute names in both instances are not the same.

equals

public boolean equals(Object o)
Compares this instance with the object specified by the o argument.

Specified by:
equals in interface Collection<String>
Specified by:
equals in interface Set<String>
Overrides:
equals in class AbstractSet<String>
Parameters:
o - the object to compare this instance to.
Returns:
false, if the o argument is not an instance of AttributeStringSet, null and the compareTo(AttributeStringSet) method returns a value different from 0; true, if the compareTo(AttributeStringSet) method returns 0

hashCode

public int hashCode()
Returns the hashCode for this instance, which is computed based on the attribute names.

Specified by:
hashCode in interface Collection<String>
Specified by:
hashCode in interface Set<String>
Overrides:
hashCode in class AbstractSet<String>
Returns:
the computed hashCode

copy

public AttributeStringSet copy()
Copies this instance.

Returns:
the copy of this instance