edu.byu.ece.edif.core
Class ArrayListNameSpaceResolver

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList
              extended by edu.byu.ece.edif.core.ArrayListNameSpaceResolver
All Implemented Interfaces:
NameSpaceResolver, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess

public class ArrayListNameSpaceResolver
extends java.util.ArrayList
implements NameSpaceResolver

Implements a name space using an ArrayList.

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

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ArrayListNameSpaceResolver()
          Construct an ArrayListNameSpaceResolver Object with the default initial capacity of 10.
ArrayListNameSpaceResolver(int initialCapacity)
          Construct an ArrayListNameSpaceResolver Object with a specified initial capacity.
 
Method Summary
 boolean add(int position, NamedPropertyObject name)
          Return true if the name doesn't clash and was added to the name space at the specified position.
 boolean add(NamedPropertyObject name)
          Return true if the name doesn't clash and was added to the name space.
 java.lang.Object getNextValue(java.lang.Object o)
          This method will return the next object in the ordered list.
 java.util.Collection getNextValues(java.lang.Object o)
          This method will return a collection of Value objects in the ordered list that occur after the object parameter.
 java.lang.Object getPreviousValue(java.lang.Object o)
          This method will return the previous Value object in the ordered list.
 java.util.Collection getPreviousValues(java.lang.Object o)
          This method will return a collection of Value objects in the ordered list that occur before the object parameter.
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.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.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

ArrayListNameSpaceResolver

public ArrayListNameSpaceResolver()
Construct an ArrayListNameSpaceResolver Object with the default initial capacity of 10.


ArrayListNameSpaceResolver

public ArrayListNameSpaceResolver(int initialCapacity)
Construct an ArrayListNameSpaceResolver Object with a specified initial capacity.

Parameters:
initialCapacity - The initial capacity of the ArrayList
Method Detail

add

public boolean add(int position,
                   NamedPropertyObject name)
Return true if the name doesn't clash and was added to the name space at the specified position.

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

add

public boolean add(NamedPropertyObject name)
Return true if the name doesn't clash and was added to the name space.

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

getNextValue

public java.lang.Object getNextValue(java.lang.Object o)
This method will return the next object in the ordered list. This method will return null if the collection does not contain the object parameter or if the object parameter is the last member of the list.

Parameters:
o - The object to find the next value of
Returns:
The object immediately after the passed-in one in this ArrayList Object

getNextValues

public java.util.Collection getNextValues(java.lang.Object o)
This method will return a collection of Value objects in the ordered list that occur after the object parameter. This method will return null if the collection does not contain the object parameter. If the parameter is the last object in the list, it will return an empty Collection.

Parameters:
o - The object to find the next values of
Returns:
A Collection of all objects after the passed-in one in this ArrayList Object

getPreviousValue

public java.lang.Object getPreviousValue(java.lang.Object o)
This method will return the previous Value object in the ordered list. This method will return null if the collection does not contain the object parameter or if the object parameter is the first member of the list.

Parameters:
o - The object to find the previous value of
Returns:
The object immediately before the passed-in one in this ArrayList Object

getPreviousValues

public java.util.Collection getPreviousValues(java.lang.Object o)
This method will return a collection of Value objects in the ordered list that occur before the object parameter. This method will return null if the collection does not contain the object parameter. If the parameter is the first object in the list, it will return an empty Collection.

Parameters:
o - The object to find the previous values of
Returns:
A Collection of all objects before the passed-in one in this ArrayList Object

main

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

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