com.virtuosotechnologies.asaph.model
Interface FieldContainer

All Known Subinterfaces:
AddedSongBlock, ChordSet, Song, SongBlock, StandardSongBlock, Variation

public interface FieldContainer

This is a base interface for objects that contain Fields.


Method Summary
 BinaryField addBinaryField(String name, String type, byte[] value, UndoableEditListener undoListener)
          Add a binary field.
 BinaryListField addBinaryListField(String name, UndoableEditListener undoListener)
          Add a binary list field.
 StringField addStringField(String name, String str, UndoableEditListener undoListener)
          Add a string field.
 StringListField addStringListField(String name, UndoableEditListener undoListener)
          Add a string list field.
 int getFieldCount()
          Get the number of fields.
 Field getNamedField(String name)
          Search for the field with the given name.
 Field getNextField(Field reference)
          Get the next field following reference.
 Field getNthField(int n)
          Get the nth field
 Field getPreviousField(Field reference)
          Get the previous field preceding reference.
 void removeField(Field field, UndoableEditListener undoListener)
          Remove a Field.
 

Method Detail

getFieldCount

public int getFieldCount()
Get the number of fields.

Returns:
number of FieldStrings

getNthField

public Field getNthField(int n)
Get the nth field

Parameters:
n - index
Returns:
Field

getNextField

public Field getNextField(Field reference)
Get the next field following reference. If reference is null, returns the first field. If reference is the last field, returns null;

Parameters:
reference - reference Field
Returns:
next field
Throws:
IllegalArgumentException - reference is not a member

getPreviousField

public Field getPreviousField(Field reference)
Get the previous field preceding reference. If reference is null, returns the last field. If reference is the first field, returns null;

Parameters:
reference - reference Field
Returns:
previous field
Throws:
IllegalArgumentException - reference is not a member

getNamedField

public Field getNamedField(String name)
Search for the field with the given name. Returns null if there is no such field. Implementations of this method may be faster than doing a linear search with getNextField.

Parameters:
name - name to search for
Returns:
the field, or null if there is no such field
Throws:
NullPointerException - name is null

addStringField

public StringField addStringField(String name,
                                  String str,
                                  UndoableEditListener undoListener)
Add a string field. If a string field with the given name is already present, sets the value of the field and returns it. If a field of a different type is already present with the given name, replaces it with a new string field.

Parameters:
name - name String. The empty string is not an acceptable name.
str - value String. The empty string is acceptable.
undoListener - listener to notify if an undoable edit is generated, or null to suppress generation of undoable edits
Returns:
StringField
Throws:
NullPointerException - name or str was null
IllegalArgumentException - name was the empty string

addStringListField

public StringListField addStringListField(String name,
                                          UndoableEditListener undoListener)
Add a string list field. If a string list field with the given name is already present, returns the existing field and doesn't modify it. If a field of a different type is already present with the given name, replaces it with a new string list field.

Parameters:
name - name String. The empty string is not an acceptable name.
undoListener - listener to notify if an undoable edit is generated, or null to suppress generation of undoable edits
Returns:
StringListField
Throws:
NullPointerException - name or str was null
IllegalArgumentException - name was the empty string

addBinaryField

public BinaryField addBinaryField(String name,
                                  String type,
                                  byte[] value,
                                  UndoableEditListener undoListener)
Add a binary field. If a binary field with the given name is already present, returns the existing field and doesn't modify it. If a field of a different type is already present with the given name, replaces it with a new binary field.

Parameters:
name - name String. The empty string is not an acceptable name.
type - data type String. The empty string is acceptable.
value - initial value of the field. May be null, in which case the value will be set to the empty array.
undoListener - listener to notify if an undoable edit is generated, or null to suppress generation of undoable edits
Returns:
BinaryField
Throws:
NullPointerException - name, str or type was null
IllegalArgumentException - name was the empty string

addBinaryListField

public BinaryListField addBinaryListField(String name,
                                          UndoableEditListener undoListener)
Add a binary list field. If a binary list field with the given name is already present, returns the existing field and doesn't modify it. If a field of a different type is already present with the given name, replaces it with a new binary list field.

Parameters:
name - name String. The empty string is not an acceptable name.
undoListener - listener to notify if an undoable edit is generated, or null to suppress generation of undoable edits
Returns:
BinaryListField
Throws:
NullPointerException - name or str was null
IllegalArgumentException - name was the empty string

removeField

public void removeField(Field field,
                        UndoableEditListener undoListener)
Remove a Field.

Parameters:
field - Field to remove
undoListener - listener to notify if an undoable edit is generated, or null to suppress generation of undoable edits
Throws:
IllegalArgumentException - field is not present
NullPointerException - field was null