net.talvi.puffinplot.data
Class CustomFields<T>

java.lang.Object
  extended by net.talvi.puffinplot.data.CustomFields<T>
Type Parameters:
T - the type of data to be stored in the fields

public class CustomFields<T>
extends java.lang.Object

Represents a set of custom fields for sample annotation. The field list is indexed by a non-negative integer, and contains values (objects) of a specified type.


Constructor Summary
CustomFields()
          Creates an empty set of custom fields.
CustomFields(java.util.List<T> initialValues)
          Creates a set of custom fields with the specified values.
 
Method Summary
 void add(int position, T value)
          Adds a new value to this custom field list.
 java.lang.String exportAsString()
          Returns a string representation of the list of values.
 T get(int number)
          Gets the value of a specified custom field.
 void remove(int position)
          Removes a value from this custom field list.
 void set(int number, T value)
          Sets a specified custom field to a specified value.
 void setSize(int newSize, T fillWith)
          Sets the size of the list of custom fields.
 int size()
          Returns the number of values in this list.
 void swapAdjacent(int position)
          Swaps the values in two adjacent positions within this custom field list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomFields

public CustomFields(java.util.List<T> initialValues)
Creates a set of custom fields with the specified values.

Parameters:
initialValues - the values with which to initialize the fields

CustomFields

public CustomFields()
Creates an empty set of custom fields.

Method Detail

set

public void set(int number,
                T value)
Sets a specified custom field to a specified value. If the specified index is outside the range of available custom fields, nothing happens.

Parameters:
number - the index of the field to set
value - the value to which to set the field

get

public T get(int number)
Gets the value of a specified custom field. If the index is outside the range of available custom fields, null is returned

Parameters:
number - the index of a field
Returns:
the value of the field with the specified index, or null if there is no such field

setSize

public void setSize(int newSize,
                    T fillWith)
Sets the size of the list of custom fields. The current contents are deleted, and the list is filled with a specified value.

Parameters:
newSize - the new size of the custom field list
fillWith - the value with which to fill the list

add

public void add(int position,
                T value)
Adds a new value to this custom field list.

Parameters:
position - the position at which to insert the new value
value - the value to insert

remove

public void remove(int position)
Removes a value from this custom field list.

Parameters:
position - the index of the value to remove

swapAdjacent

public void swapAdjacent(int position)
Swaps the values in two adjacent positions within this custom field list.

Parameters:
position - the first of the positions to swap; its value will be swapped with the next value

exportAsString

public java.lang.String exportAsString()
Returns a string representation of the list of values.

Returns:
a string representation of the list of values

size

public int size()
Returns the number of values in this list.

Returns:
the number of values in this list