de.uds.cs.st.dd.core
Class TConfiguration

java.lang.Object
  |
  +--de.uds.cs.st.dd.core.TConfiguration
All Implemented Interfaces:
Collection

public class TConfiguration
extends Object
implements Collection

Stores a specific test configuration. This is the primary data structure the core operates on.

Author:
Philipp Bouillon

Field Summary
private  LinkedList list
          Internally, a linked list is used to store all deltas.
 
Constructor Summary
  TConfiguration()
          Creates a new (empty) TConfiguration.
private TConfiguration(List source)
          Creates a new TConfiguration that contains all elements of the source list.
  TConfiguration(TConfiguration source)
          Creates a new TConfiguration that contains all elements of the source TConfiguration.
 
Method Summary
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection c)
           
 TConfiguration copy()
          Returns a copy of this TConfiguration.
private  LinkedList deepListCopy()
          Returns a copy of the elements of this TConfiguration.
private  LinkedList deepListCopy(List source)
          Copies all elements of the source list into the list object of this TConfiguration.
 Object get(int index)
          Returns the element at the specified index.
 Object getShallow(int index)
          Returns the element at the specified index, regardless of its type.
 TConfiguration intersect(TConfiguration config)
          Returns all elements that are in this configuration and in the specified one.
 boolean isEmpty()
           
 boolean isSubsetEq(TConfiguration config)
          Returns true, if this object is a subset or equal to the passed argument, false otherwise.
 Iterator iterator()
           
 TConfiguration minus(TConfiguration config)
          Returns a TConfiguration containing all elements that are in this object but not in the passed parameter.
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 boolean retainAll(Collection c)
           
 Object set(int index, Object o)
           
 int size()
           
 void sort()
          Sorts this TConfiguration is ascending order.
 TConfiguration subSet(int startIndex, int endIndex)
          Returns a new TConfiguration that contains a subset of the original TConfiguration.
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 String toCharacterString()
          Returns a string representation of this configuration.
 String toSortedString()
          Returns a string representation of a sorted copy of this configuration.
 String toString()
           
 TConfiguration union(TConfiguration config)
          Returns a union of this configuration with the passed parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

list

private LinkedList list
Internally, a linked list is used to store all deltas. However, this can easily be changed, if neccessary.

Constructor Detail

TConfiguration

public TConfiguration()
Creates a new (empty) TConfiguration.


TConfiguration

public TConfiguration(TConfiguration source)
Creates a new TConfiguration that contains all elements of the source TConfiguration. Note that the elements are copied. Modifying the new TConfiguration does not affect the old TConfiguration (not even if the old TConfiguration contains other TConfigurations).

Parameters:
source - source TConfiguration to be copied.

TConfiguration

private TConfiguration(List source)
Creates a new TConfiguration that contains all elements of the source list. Note that the elements are copied. Modifying the new TConfiguration does not affect the old list (not even if the old list is a list of lists).

Parameters:
source - source list to be copied.
Method Detail

deepListCopy

private LinkedList deepListCopy(List source)
Copies all elements of the source list into the list object of this TConfiguration.

Parameters:
source - source list to be copied.
Returns:
LinkedList a new linked list that contains copies of the elements of the old list.

deepListCopy

private LinkedList deepListCopy()
Returns a copy of the elements of this TConfiguration.

Returns:
LinkedList a new linked list that contains copies of the elements of the old list.

copy

public TConfiguration copy()
Returns a copy of this TConfiguration.

Returns:
TConfiguration a new TConfiguration that contains copies of the elements of the old list.

size

public int size()
Specified by:
size in interface Collection

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection

iterator

public Iterator iterator()
Specified by:
iterator in interface Collection

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection

add

public boolean add(Object o)
Specified by:
add in interface Collection

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Collection

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection

clear

public void clear()
Specified by:
clear in interface Collection

get

public Object get(int index)
Returns the element at the specified index. If the object at the index is a TConfiguration, a copy of that TConfiguration is returned. So, modifying the contents of the returned TConfiguration does _not_ affect the contents of the original TConfiguration.

Parameters:
index - index of the element.
Returns:
Object element at the specified position. If Object is of type TConfiguration, it is a deep copy of that configuration.

getShallow

public Object getShallow(int index)
Returns the element at the specified index, regardless of its type. So, if the object at the specified index is of type TConfiguration, a reference to that object will be returned. Changing its contents will also change the contents of the original TConfiguration.

Parameters:
index - index of the element.
Returns:
Object element at the specified position.

set

public Object set(int index,
                  Object o)

toString

public String toString()
Overrides:
toString in class Object

toCharacterString

public String toCharacterString()
Returns a string representation of this configuration. * * @return String string representation of this configuration.


toSortedString

public String toSortedString()
Returns a string representation of a sorted copy of this configuration. So, this configuration is copied, sorted and then a string representation is returned.

Returns:
String string representation of the sorted copy.

sort

public void sort()
Sorts this TConfiguration is ascending order.


subSet

public TConfiguration subSet(int startIndex,
                             int endIndex)
Returns a new TConfiguration that contains a subset of the original TConfiguration.

Parameters:
startIndex - starting index of the subset.
endIndex - ending index of the subset.
Returns:
TConfiguration new TConfiguration that contains copies of the specified elements

minus

public TConfiguration minus(TConfiguration config)
Returns a TConfiguration containing all elements that are in this object but not in the passed parameter.

Parameters:
config - TConfiguration object that contains all the elements that are _not_ in the returned object.
Returns:
TConfiguration new object that contains this - config.

intersect

public TConfiguration intersect(TConfiguration config)
Returns all elements that are in this configuration and in the specified one.

Parameters:
config - TConfiguration object that is used for the operation.
Returns:
TConfiguration new object that contains all objects that are both in this object and in config.

union

public TConfiguration union(TConfiguration config)
Returns a union of this configuration with the passed parameter.

Parameters:
config - TConfiguration object that is used for the operation.
Returns:
TConfiguration new object that contains the union of this object and config.

isSubsetEq

public boolean isSubsetEq(TConfiguration config)
Returns true, if this object is a subset or equal to the passed argument, false otherwise.

Parameters:
config - TConfiguration object that is used for the operation.
Returns:
boolean true, if this object is a subset or equal to config, false otherwise.