edu.byu.ece.edif.core
Class HashMapNameSpaceResolver

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

public class HashMapNameSpaceResolver
extends java.util.LinkedHashMap
implements NameSpaceResolver

Implements an unordered name space using a HashMap.

Version:
$Id: HashMapNameSpaceResolver.java 130 2008-03-31 16:23:42Z jamesfcarroll $
See Also:
AbstractNameSpaceResolver, NameSpaceResolver, Serialized Form

Constructor Summary
HashMapNameSpaceResolver()
          Construct an empty HashMapNameSpaceResolver Object.
 
Method Summary
 boolean add(NamedPropertyObject name)
          Add a name if it doesn't clash with an existing name and return true.
 java.lang.Object get(java.lang.String name)
          Return the Object associated with the given String.
static void main(java.lang.String[] args)
           
 boolean nameClash(java.lang.String name)
          Return true if name does not clash with name space.
 java.lang.Object remove(java.lang.String name)
          Remove 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()
          Return a string representation of this object.
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get, removeEldestEntry
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, 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
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

HashMapNameSpaceResolver

public HashMapNameSpaceResolver()
Construct an empty HashMapNameSpaceResolver Object.

Method Detail

add

public boolean add(NamedPropertyObject name)
Add 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)
Return the Object associated with the given String.

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

main

public static void main(java.lang.String[] args)
                 throws EdifNameConflictException
Throws:
EdifNameConflictException

nameClash

public boolean nameClash(java.lang.String name)
Return 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)
Remove 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()
Return 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.