byucc.edif
Class HashMapNameSpaceResolver

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by byucc.edif.HashMapNameSpaceResolver
All Implemented Interfaces:
NameSpaceResolver, java.io.Serializable, java.lang.Cloneable, java.util.Map

public class HashMapNameSpaceResolver
extends java.util.HashMap
implements NameSpaceResolver, java.io.Serializable

Implements an unordered name space using a HashMap.

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

Constructor Summary
HashMapNameSpaceResolver()
          Constructs an empty HashMapNameSpaceResolver Object.
 
Method Summary
 boolean add(NamedPropertyObject name)
          Adds a name if it doesn't clash with an existing name and return true.
 java.lang.Object get(java.lang.String name)
          Returns the Object associated with the given String.
static void main(java.lang.String[] args)
           
 boolean nameClash(java.lang.String name)
          Returns true if name does not clash with name space.
 java.lang.Object remove(java.lang.String name)
          Removes the value mapped at the given String key.
 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.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

HashMapNameSpaceResolver

public HashMapNameSpaceResolver()
Constructs an empty HashMapNameSpaceResolver Object.

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.

get

public java.lang.Object get(java.lang.String name)
Returns the Object associated with the given String.

Parameters:
name - The key of the value to retrieve
Returns:
An Object mapped at the given String

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.

remove

public java.lang.Object remove(java.lang.String name)
Removes the value mapped at the given String key.

Parameters:
name - The key of the value to remove
Returns:
The Object mapped at the given String

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
Overrides:
toString in class java.util.AbstractMap
Returns:
String representing this name space object.

main

public static void main(java.lang.String[] args)