byucc.edif
Class MultiTypeNameSpaceResolver

java.lang.Object
  extended bybyucc.edif.MultiTypeNameSpaceResolver
All Implemented Interfaces:
NameSpaceResolver, java.io.Serializable

public class MultiTypeNameSpaceResolver
extends java.lang.Object
implements NameSpaceResolver, java.io.Serializable

Implements a String name space that has the capability of switching between an ArrayList and a HashSet, depending on the size of the name space. The user can also specify which to use through the maximizeSpeed(), and minimizeSize() functions.

Version:
$Id: MultiTypeNameSpaceResolver.java,v 1.10 2004/08/27 19:16:42 tsa6 Exp $
Author:
Eric Johnson, Tyler Anderson
See Also:
Serialized Form

Field Summary
private  boolean _alwaysArrayList
          True if an ArrayList is always to be used, false otherwise.
private  java.util.HashSet _hashnames
          For the HashSet implementation of this name space.
private  java.util.ArrayList _listnames
          For the ArrayList implementation of this name space.
private  java.util.Collection _names
          For the HashSet implementation of this name space.
private  boolean _useArrayList
          True if an ArrayList is currently being used, HashSet otherwise.
 
Constructor Summary
MultiTypeNameSpaceResolver()
          Constructs a MultiTypeNameSpaceResolver Object and initializes _names to be an ArrayList.
 
Method Summary
 boolean add(NamedPropertyObject name)
          Adds a name if it doesn't clash with an existing name and return true.
 java.util.Collection getNames()
          Returns a Collection of the data structure holding all the Objects in the name space.
static void main(java.lang.String[] args)
          A method used to test this class
 void maximizeSpeed()
          Changes implementation from an arraylist to a hashset
 void minimizeSize()
          Changes implementation from hashset to arraylist
 boolean nameClash(java.lang.String name)
          Returns true if name does not clash with name space.
 java.lang.String returnUniqueName(java.lang.String name)
          If the name is valid, return name.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_useArrayList

private boolean _useArrayList
True if an ArrayList is currently being used, HashSet otherwise.


_alwaysArrayList

private boolean _alwaysArrayList
True if an ArrayList is always to be used, false otherwise.


_listnames

private java.util.ArrayList _listnames
For the ArrayList implementation of this name space.


_hashnames

private java.util.HashSet _hashnames
For the HashSet implementation of this name space.


_names

private java.util.Collection _names
For the HashSet implementation of this name space.

Constructor Detail

MultiTypeNameSpaceResolver

public MultiTypeNameSpaceResolver()
Constructs a MultiTypeNameSpaceResolver Object and initializes _names to be an ArrayList. The user has the ability to change it to a HashSet and back to an ArrayList.

Method Detail

add

public boolean add(NamedPropertyObject name)
Adds a name if it doesn't clash with an existing name and return true. If it does clash, return false and don't add.

Parameters:
name - Name to add to the name space.
Returns:
True if the name was added to the name space, otherwise, false.

getNames

public java.util.Collection getNames()
Returns a Collection of the data structure holding all the Objects in the name space.

Returns:
A Collection Object containg all the objects in this name space

maximizeSpeed

public void maximizeSpeed()
Changes implementation from an arraylist to a hashset


minimizeSize

public void minimizeSize()
Changes implementation from hashset to arraylist


nameClash

public boolean nameClash(java.lang.String name)
Returns true if name does not clash with name space.

Specified by:
nameClash in interface NameSpaceResolver
Parameters:
name - Name to check if it already exists in the name space.
Returns:
True if the name clashes, false if it doesn't exist in the name space.

returnUniqueName

public java.lang.String returnUniqueName(java.lang.String name)
If the name is valid, return name. If not, make it valid. It grabs a random element from an array and keeps appending it from the array.

Specified by:
returnUniqueName in interface NameSpaceResolver
Parameters:
name - Name to modify, and make unique for this name space.
Returns:
The string unique to this name space.

toString

public java.lang.String toString()
Returns a string representation of this object.

Specified by:
toString in interface NameSpaceResolver
Returns:
String representing this name space object.

main

public static void main(java.lang.String[] args)
A method used to test this class