byucc.edif
Class AbstractNameSpaceResolver

java.lang.Object
  extended by byucc.edif.AbstractNameSpaceResolver
All Implemented Interfaces:
java.io.Serializable

public abstract class AbstractNameSpaceResolver
extends java.lang.Object
implements java.io.Serializable

Abstract class that contains methods for name space resolvers. Other name space classes will call the methods of this one. If another data type is desired for the name space then in the constructor of the other name space object _names is instantiated. This class is abstract and doesn't and doesn't implement an interface because interface methods can't be declared abstract. TODO: this class supports both maps and collections. This should probably be split up.

Version:
$Id: AbstractNameSpaceResolver.java,v 1.20 2005/06/09 14:49:04 wirthlin Exp $
Author:
Eric Johnson, Tyler Anderson, Mike Wirthlin
See Also:
Serialized Form

Constructor Summary
AbstractNameSpaceResolver()
           
 
Method Summary
protected static char incrementDigit(char c)
          This method will perform an "increment" on a character.
protected static java.lang.String incrementString(java.lang.String str)
           
static void main(java.lang.String[] args)
           
static boolean nameClash(java.util.Collection list, java.lang.String newName)
          Returns true if name does not clash with name space.
static boolean nameClash(java.util.Map map, java.lang.String name)
          Returns true if name does not clash with name space.
static java.lang.String returnNextString(java.lang.String orig)
          The algorithm for creating a new unique name is as follows: - If the conflicting name does not have a "_", add one to the end as well as "a" - Change the last character and "increment" by one (i.e.
static java.lang.String returnUniqueName(java.util.Collection list, java.lang.String name)
          If the name is valid, return name.
static java.lang.String returnUniqueName(java.util.Map map, java.lang.String name)
          If the name is valid, return name.
static void test_string(java.lang.String str)
           
static java.lang.String toString(java.util.Collection list)
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractNameSpaceResolver

public AbstractNameSpaceResolver()
Method Detail

nameClash

public static boolean nameClash(java.util.Collection list,
                                java.lang.String newName)
Returns true if name does not clash with name space.

Parameters:
newName - Name to check if it already exists in the name space.
list - The name space passed to this method.
Returns:
True if the name clashes, false if it doesn't exist in the name space.

nameClash

public static boolean nameClash(java.util.Map map,
                                java.lang.String name)
Returns true if name does not clash with name space.

Parameters:
name - Name to check if it already exists in the name space.
map - The name space passed to this method.
Returns:
True if the name clashes, false if it doesn't exist in the name space.

returnNextString

public static java.lang.String returnNextString(java.lang.String orig)
The algorithm for creating a new unique name is as follows: - If the conflicting name does not have a "_", add one to the end as well as "a" - Change the last character and "increment" by one (i.e. "a->b") -


incrementString

protected static java.lang.String incrementString(java.lang.String str)

incrementDigit

protected static char incrementDigit(char c)
This method will perform an "increment" on a character. This method will sequence from 'a' to 'z' and then from '0' to '9'. After reaching '9', this method will return back to 'a'. This method will return 0 if the character is invalid. This method is case insensitive and will return a lower case incremented character.

Parameters:
c - The character to increment.
Returns:
The incremented character

returnUniqueName

public static java.lang.String returnUniqueName(java.util.Collection list,
                                                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.

Parameters:
name - Name to modify, and make unique for this name space.
list - The name space passed to this method.
Returns:
The string unique to this name space.

returnUniqueName

public static java.lang.String returnUniqueName(java.util.Map map,
                                                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.

Parameters:
name - Name to modify, and make unique for this name space.
map - The name space passed to this method.
Returns:
The string unique to this name space.

toString

public static java.lang.String toString(java.util.Collection list)
Returns a string representation of this object.

Returns:
String representing this name space object.

test_string

public static void test_string(java.lang.String str)

main

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