jeters.core
Class NamedDataSet

java.lang.Object
  extended by jeters.core.NamedDataSet
All Implemented Interfaces:
java.lang.Iterable<NamedDataSet.NamedElement>

public class NamedDataSet
extends java.lang.Object
implements java.lang.Iterable<NamedDataSet.NamedElement>

Storage for objects of any type. Individual objects can be accessed using String identifiers.


Nested Class Summary
static class NamedDataSet.NamedElement
          a value together with a String identifier
 
Constructor Summary
NamedDataSet()
          creates an empty NamedDataSet
NamedDataSet(java.lang.String[] nameArray, java.lang.Object[] dataArray)
          creates a NamedDataSet with one element, same effect as using(NamedDataSet) and then calling add(nameArray,dataArray)
NamedDataSet(java.lang.String name, java.lang.Object data)
          creates a NamedDataSet with one element, same effect as using(NamedDataSet) and then calling add(name,data)
 
Method Summary
 void add(java.lang.String[] nameArray, java.lang.Object[] dataArray)
          add an array of objects to the list
 void add(java.lang.String name, java.lang.Object data)
          add one object to the list
 void clear()
          empties the NamedDataSet
<T> T
get(java.lang.String name)
          returns an element of the list identified by a given String casted to type parameter T
 java.util.Iterator<NamedDataSet.NamedElement> iterator()
          
 void remove(java.lang.String name)
          removes all objects identified by the given name from the NamedDataSet
 int size()
          returns the number of elements of this NamedDataSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedDataSet

public NamedDataSet()
creates an empty NamedDataSet


NamedDataSet

public NamedDataSet(java.lang.String name,
                    java.lang.Object data)
creates a NamedDataSet with one element, same effect as using(NamedDataSet) and then calling add(name,data)

Parameters:
name - String identifier. Use unique strings for each Object added to the same instance of NamedDataSet!
data - the object to be added to the NamedDataSet

NamedDataSet

public NamedDataSet(java.lang.String[] nameArray,
                    java.lang.Object[] dataArray)
creates a NamedDataSet with one element, same effect as using(NamedDataSet) and then calling add(nameArray,dataArray)

Parameters:
nameArray - array of String identifiers (nameArray[i] is identifier for dataArray[i]). The length of nameArray must equal the length of dataArray. Use unique strings for each Object added to the same instance of NamedDataSet!
dataArray - array of objects to be added to the NamedDataSet. The length of nameArray must equal the length of dataArray.
Method Detail

iterator

public java.util.Iterator<NamedDataSet.NamedElement> iterator()

Specified by:
iterator in interface java.lang.Iterable<NamedDataSet.NamedElement>

get

public <T> T get(java.lang.String name)
      throws NamedDataNotAvailableException
returns an element of the list identified by a given String casted to type parameter T

Parameters:
name - the String identifier of the requested object
Returns:
the first object which (1.) has a String identifier matching the given name and (2.) can be casted to T. Not null (needs not to be checked).
Throws:
NamedDataNotAvailableException

add

public void add(java.lang.String name,
                java.lang.Object data)
add one object to the list

Parameters:
name - String identifier, not null. Use unique strings for each Object added to the same instance of NamedDataSet!
data - the object to be added to the NamedDataSet

add

public void add(java.lang.String[] nameArray,
                java.lang.Object[] dataArray)
add an array of objects to the list

Parameters:
nameArray - array of String identifiers (nameArray[i] is identifier for dataArray[i]), not null, no element null. The length of nameArray must equal the length of dataArray. Use unique strings for each Object added to the same instance of NamedDataSet!
dataArray - array of objects to be added to the NamedDataSet, not null, no element null. The length of nameArray must equal the length of dataArray.

remove

public void remove(java.lang.String name)
removes all objects identified by the given name from the NamedDataSet

Parameters:
name - objects whose String identifier equals name will be removed

clear

public void clear()
empties the NamedDataSet


size

public int size()
returns the number of elements of this NamedDataSet

Returns:
the number of elements