edu.byu.ece.edif.core
Class EdifNameSpaceList<E extends NamedPropertyObject>

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

public class EdifNameSpaceList<E extends NamedPropertyObject>
extends java.util.ArrayList<E>
implements EdifNameSpace<E>

A List implementation of the EdifNameSpace interface.

Version:
$Id:EdifNameSpaceList.java 198 2008-04-16 21:14:21Z jamesfcarroll $
See Also:
Serialized Form

Field Summary
private  EdifNameSpaceUtils _util
          Contains methods common to all EdifNameSpace implementations.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
EdifNameSpaceList(EdifNameClashPolicy clashPolicy)
          Construct an EdifNameSpaceList with the given EdifNameClashPolicy.
EdifNameSpaceList(EdifNameClashPolicy clashPolicy, int size)
          Construct an EdifNameSpaceList with the given EdifNameClashPolicy and size.
 
Method Summary
 void addElement(E element)
          Add an EdifNameable object to the name space.
 boolean contains(E element)
          Indicate whether the given EdifNameable object is a member of the name space.
 boolean containsName(java.lang.String name)
           
 boolean containsNew(java.lang.String str)
          Indicate whether the name space contains a new name (part of a RenamedObject) that matches the given string.
 boolean containsOld(java.lang.String str)
          Indicate whether the name space contains an old name (part of a RenamedObject) that matches the given string.
 boolean containsSingle(java.lang.String str)
          Indicate whether the name space contains a single name (as a NamedObject) that matches the given string.
 E get(java.lang.String str)
          Return the Nameable object associated with this name space that matches the given String name.
 EdifNameable getUniqueNameable(E element)
          Determine a name based on the name of the given element that will not clash with any names already in the name space.
 EdifNameable getUniqueNameable(EdifNameable en)
          Determine a name based on the given name that will not clash with any names already in the name space.
 boolean nameClash(E element)
          Determine if the given elements name will clash with the names already in the name space.
 boolean nameClash(EdifNameable en)
          Determine if the given name will clash with the names in this given EdifNameSpace.
 
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, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.byu.ece.edif.core.EdifNameSpace
iterator, size
 
Methods inherited from interface edu.byu.ece.edif.core.Trimable
trimToSize
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Field Detail

_util

private EdifNameSpaceUtils _util
Contains methods common to all EdifNameSpace implementations.

Constructor Detail

EdifNameSpaceList

public EdifNameSpaceList(EdifNameClashPolicy clashPolicy)
Construct an EdifNameSpaceList with the given EdifNameClashPolicy.

Parameters:
clashPolicy - the clash policy to use for determining if two names clash

EdifNameSpaceList

public EdifNameSpaceList(EdifNameClashPolicy clashPolicy,
                         int size)
Construct an EdifNameSpaceList with the given EdifNameClashPolicy and size.

Parameters:
clashPolicy - the clash policy to use for determining if two names clash
size - the original size of the list
Method Detail

addElement

public void addElement(E element)
                throws EdifNameConflictException
Description copied from interface: EdifNameSpace
Add an EdifNameable object to the name space. This method will check to see if there is a conflict and throw an exception if there is a conflict.

Specified by:
addElement in interface EdifNameSpace<E extends NamedPropertyObject>
Throws:
EdifNameConflictException - This exception is thrown when a name conflict occurs during the add.

contains

public boolean contains(E element)
Description copied from interface: EdifNameSpace
Indicate whether the given EdifNameable object is a member of the name space. The search is performed using the name of the object.

Specified by:
contains in interface EdifNameSpace<E extends NamedPropertyObject>
Returns:
true if the object is a member of the space. false if it is not a member of the space.

containsName

public boolean containsName(java.lang.String name)

get

public E get(java.lang.String str)
Description copied from interface: EdifNameSpace
Return the Nameable object associated with this name space that matches the given String name.

Specified by:
get in interface EdifNameSpace<E extends NamedPropertyObject>
Returns:
The Nameable object within this name space. This will return a null if an object of the given name does not exist.

getUniqueNameable

public EdifNameable getUniqueNameable(E element)
Description copied from interface: EdifNameSpace
Determine a name based on the name of the given element that will not clash with any names already in the name space.

Specified by:
getUniqueNameable in interface EdifNameSpace<E extends NamedPropertyObject>
Parameters:
element - the element whose name will be used as a basis for a unique name
Returns:
a unique name

getUniqueNameable

public EdifNameable getUniqueNameable(EdifNameable en)
Description copied from interface: EdifNameSpace
Determine a name based on the given name that will not clash with any names already in the name space.

Specified by:
getUniqueNameable in interface EdifNameSpace<E extends NamedPropertyObject>
Parameters:
en - the name to use as a basis for a unique name.
Returns:
a unique name

nameClash

public boolean nameClash(E element)
Description copied from interface: EdifNameSpace
Determine if the given elements name will clash with the names already in the name space.

Specified by:
nameClash in interface EdifNameSpace<E extends NamedPropertyObject>
Parameters:
element - the element whose name will be compared with the name space
Returns:
a boolean indicating whether there will be a clash

nameClash

public boolean nameClash(EdifNameable en)
Description copied from interface: EdifNameSpace
Determine if the given name will clash with the names in this given EdifNameSpace.

Specified by:
nameClash in interface EdifNameSpace<E extends NamedPropertyObject>
Parameters:
en - the name that will be compared with the name space
Returns:
a boolean indicating whether there will be a clash

containsNew

public boolean containsNew(java.lang.String str)
Description copied from interface: EdifNameSpace
Indicate whether the name space contains a new name (part of a RenamedObject) that matches the given string.

Specified by:
containsNew in interface EdifNameSpace<E extends NamedPropertyObject>
Parameters:
str - the string to match against
Returns:
a boolean indicating whether a match was found

containsOld

public boolean containsOld(java.lang.String str)
Description copied from interface: EdifNameSpace
Indicate whether the name space contains an old name (part of a RenamedObject) that matches the given string.

Specified by:
containsOld in interface EdifNameSpace<E extends NamedPropertyObject>
Parameters:
str - the string to match against
Returns:
a boolean indicating whether a match was found

containsSingle

public boolean containsSingle(java.lang.String str)
Description copied from interface: EdifNameSpace
Indicate whether the name space contains a single name (as a NamedObject) that matches the given string.

Specified by:
containsSingle in interface EdifNameSpace<E extends NamedPropertyObject>
Parameters:
str - the string to match against
Returns:
a boolean indicating whether a match was found