org.ws4d.java.types
Class QNameSet

java.lang.Object
  extended by org.ws4d.java.types.QNameSet

public class QNameSet
extends java.lang.Object

Type-safe QualifiedNameSet. Class is not synchronized.


Constructor Summary
QNameSet()
          Constructor.
QNameSet(int initialCapacity)
          Constructor.
QNameSet(QName qn)
          Constructor, adds qualified name element.
QNameSet(QNameSet set)
          Copy Constructor.
 
Method Summary
 void add(QName qn)
          Adds a QualifiedName to this QualifiedNameSet.
 void addAll(QNameSet qnsNewQNames)
          Adds a QualifiedName to this QualifiedNameSet.
static QNameSet construct(java.lang.String nsAndTypes)
          Constructs a QNameSet from a String containing namespaces and types.
 boolean contains(QName qn)
          Returns true if this qualified name set contains the specified element.
 boolean containsAll(QNameSet qnames)
          Checks if this contains the given QNameSet.
 boolean equals(java.lang.Object obj)
          Compares this qualified name data structure to the specified object.
 int hashCode()
           
 boolean isContainedBy(Iterator qNames)
          FIXME the other way round!!
 boolean isEmpty()
          Returns if data structure is empty.
 boolean isReadOnly()
          Checks if the QNameSet must not be changed anymore
 Iterator iterator()
          Gets Iterator
static QNameSet newInstance(Set qnames)
          Creates instance of a QNameSet from a Set containing QNames.
static QNameSet newInstanceReadOnly(Set qnames)
          Creates instance of QNameSet by wrapping a set of qnames.
 boolean remove(QName qn)
          Removes a QualifiedName from this QualifiedNameSet.
 void setReadOnly()
          Sets this QualifiedNameSet to readOnly.
 int size()
          Returns size of list.
static QNameSet sortPriorities(QNameSet qnames)
          Simple bubble sort for QNameSet.
static QName[] sortPrioritiesAsArray(QNameSet qnames)
          Simple bubble sort for QNameSet.
 QName[] toArray()
          Gets copied entries of data structure as array.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QNameSet

public QNameSet()
Constructor.


QNameSet

public QNameSet(int initialCapacity)
Constructor.


QNameSet

public QNameSet(QName qn)
Constructor, adds qualified name element.

Parameters:
qn - QualifiedName element to be added to new QualifiedNameSet

QNameSet

public QNameSet(QNameSet set)
Copy Constructor. Copies the elements in the QNameSet to the new.

Method Detail

newInstanceReadOnly

public static QNameSet newInstanceReadOnly(Set qnames)
Creates instance of QNameSet by wrapping a set of qnames. Changes on the instance will throw a UnsupportedOperationException. Set will be used, not cloned.

Parameters:
qnames - set of qnames
Returns:
wrapped set of qnames

newInstance

public static QNameSet newInstance(Set qnames)
Creates instance of a QNameSet from a Set containing QNames. Set will be cloned.

Parameters:
qnames - Set of QNames
Returns:
The constructed QNameSet

construct

public static QNameSet construct(java.lang.String nsAndTypes)
Constructs a QNameSet from a String containing namespaces and types.

Parameters:
nsAndTypes - String with list of namespace + '/' + local part elements divided by ' '.
Returns:
The constructed QNameSet.

toArray

public QName[] toArray()
Gets copied entries of data structure as array.

Returns:
QualifiedName array.

iterator

public Iterator iterator()
Gets Iterator

Returns:
Iterator
See Also:
DataStructure.iterator()

contains

public boolean contains(QName qn)
Returns true if this qualified name set contains the specified element.

Parameters:
qn - QualifiedName whose presence in the qualified name set is checked
Returns:
true if the argument is a component of this QNameSet; false otherwise.

containsAll

public boolean containsAll(QNameSet qnames)
Checks if this contains the given QNameSet.

Parameters:
qnames - Qualified Names which must all be included.
Returns:
true if all qnames are included, false otherwise.

isContainedBy

public boolean isContainedBy(Iterator qNames)
FIXME the other way round!! Checks if qNames contains all QNames stored within this set.

Parameters:
qNames - an iterator over Qualified Names
Returns:
true if qNames includes all of this set's entries, false otherwise

size

public int size()
Returns size of list.

Returns:
size of list
See Also:
List.size()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compares this qualified name data structure to the specified object. The result is true if and only if the argument is not null and is a QNameSet object that represents the same set of characteristics as this qualified name data structure.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Object to compare this qualified name data structure against.
Returns:
true if the qualified name set are equal; false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isReadOnly

public boolean isReadOnly()
Checks if the QNameSet must not be changed anymore

Returns:
true if it must not be changed.

isEmpty

public boolean isEmpty()
Returns if data structure is empty.

Returns:
true if data structure is empty, false otherwise.

add

public void add(QName qn)
         throws UnsupportedOperationException
Adds a QualifiedName to this QualifiedNameSet. A UnsupportedOperationException is thrown if this QNL is readOnly.

Parameters:
qn - The QualifiedName to be added.
Throws:
UnsupportedOperationException
See Also:
List.add(Object)

addAll

public void addAll(QNameSet qnsNewQNames)
Adds a QualifiedName to this QualifiedNameSet. A UnsupportedOperationException is thrown if this QNS is readOnly.

Parameters:
qnsNewQNames -

remove

public boolean remove(QName qn)
               throws UnsupportedOperationException
Removes a QualifiedName from this QualifiedNameSet. A UnsupportedOperationException is thrown if this QNL is readOnly.

Parameters:
qn - The QualifiedName to be removed.
Returns:
true if the argument was a component of this QualifiedNameSet; false otherwise.
Throws:
UnsupportedOperationException
See Also:
DataStructure.remove(Object)

setReadOnly

public void setReadOnly()
Sets this QualifiedNameSet to readOnly.


sortPrioritiesAsArray

public static QName[] sortPrioritiesAsArray(QNameSet qnames)
Simple bubble sort for QNameSet.

Sorts the qualified names by priorities.

Parameters:
qnames - the set of qualified of to sort.
Returns:
a sorted array of qualified names.

sortPriorities

public static QNameSet sortPriorities(QNameSet qnames)
Simple bubble sort for QNameSet.

Sorts the qualified names by priorities.

Parameters:
qnames - the set of qualified of to sort.
Returns:
a sorted set of qualified names.