net.charlesames.music.ensemble
Class ContainerOfChoirsAndContours

java.lang.Object
  extended by net.charlesames.utility.common.Disposable
      extended by net.charlesames.utility.entity.Entity
          extended by net.charlesames.utility.entity.WriteableEntity
              extended by net.charlesames.music.ensemble.EnsembleEntity
                  extended by net.charlesames.music.ensemble.ContainerOfChoirsAndContours
All Implemented Interfaces:
EntityContainer
Direct Known Subclasses:
Ensemble, EnsembleChoir

public abstract class ContainerOfChoirsAndContours
extends EnsembleEntity

The abstract ContainerOfChoirsAndContours class implements functionality shared between Ensemble and EnsembleChoir objects.

Author:
Charles Ames

Nested Class Summary
 
Nested classes/interfaces inherited from class net.charlesames.music.ensemble.EnsembleEntity
EnsembleEntity.AttributeTable
 
Constructor Summary
ContainerOfChoirsAndContours(EnsembleEntity container, int id, java.lang.String name)
          Constructor for ContainerOfChoirsAndContours instances.
 
Method Summary
 boolean check(HtmlBuilder builder)
          Check this component for errors and inconsistencies
 void checkNewChoirID(int id)
          Check if the indicated id is usable for a new EnsembleChoir.
 void checkNewChoirName(java.lang.String name)
          Check if the indicated name is usable for a new EnsembleChoir.
abstract  void checkNewContourID(int id)
          Check if the indicated id is usable for a new EnsembleContour.
abstract  void checkNewContourIndex(int index)
          Check if the indicated index is usable for a new EnsembleContour.
abstract  void checkNewContourName(java.lang.String name)
          Check if the indicated name is usable for a new EnsembleContour.
 void clear()
          Clear the contents of this thing.
 EnsembleChoir createChoir(int id, java.lang.String name)
          Create a new child choir under the present Ensemble or Choir.
 boolean equals(EnsembleEntity other)
          Check if this entity has the same class and content as another entity.
abstract  EnsembleVoice getAnyVoice()
          Searches for any voice specification defined under this Ensemble or Choir, or from any sub-choir.
 EnsembleChoir getChoir(java.lang.String path)
          Use the path as a guide to work down through nested sub-choir lists until the desired choir is located.
 java.util.SortedMap<java.lang.Integer,EnsembleChoir> getChoirsByID()
          Get the list of sub-choirs in id order
 java.util.SortedMap<java.lang.String,EnsembleChoir> getChoirsByName()
          Get the list of sub-choirs in name order
 ContainerOfChoirsAndContours getContainer()
          Getter for the Container property.
 int getDefaultChoirID()
          Get the next unused choir id.
 java.lang.String getDefaultVoiceName()
          Generate a voice name which a user interface can use in the name field of an entity-creation dialog.
 Ensemble getEnsemble()
          Get the Ensemble which sits on top of the current object hierarchy.
 boolean hasChoirName(java.lang.String name)
          Check if the indicated name is already used.
 void removeChoir(java.lang.String name)
          Remove the choir with the indicated name from this component's immediate list of sub-choirs.
 void resequenceChoirs()
          Rebuild the sequence of choir id's so that the first id is 1 and the sequence proceeds without gaps.
 void resolve()
           
 void shiftChoirDown(int id)
          Move a specified EnsembleChoir down within the collection (i.e.
 void shiftChoirsDown(int id, int increment)
          Move a block of EnsembleChoirs down within the collection.
 void shiftChoirUp(int id)
          Move a specified EnsembleChoir up within the collection (i.e.
 void wipe()
          Clear all data in this Entity instance.
 
Methods inherited from class net.charlesames.music.ensemble.EnsembleEntity
buildDescription, copyToClipboard, createIndentCell, createXmlSpec, describeFeature, logError, predecessor, toString
 
Methods inherited from class net.charlesames.utility.entity.WriteableEntity
clearXmlSpecs, createXmlSpec, getTagName, getXmlData, getXmlSpec, getXmlSpec, initializeXsd, isPersistent, logError, logError, makeDirty, putXmlData, save, setID, setName, setPersistent, setStatus, toXmlNode
 
Methods inherited from class net.charlesames.utility.entity.Entity
decrementReferenceCount, dereferenceHandle, dispose, equals, getHandle, getID, getName, getPath, getReferenceCount, getStatus, getText, hasContainer, incrementReferenceCount, isModifiable, methodHasOverride, predecessor, resequenceEntities, setContainer, setModifiable, shiftEntitiesDown, shiftEntityDown, shiftEntityUp, successor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContainerOfChoirsAndContours

public ContainerOfChoirsAndContours(EnsembleEntity container,
                                    int id,
                                    java.lang.String name)
Constructor for ContainerOfChoirsAndContours instances.

Parameters:
container - For a choir, this can either be an Ensemble or a Choir. For an Ensemble, this must be null.
id - The entity ID.
name - The entity name.
Method Detail

getEnsemble

public Ensemble getEnsemble()
Description copied from class: EnsembleEntity
Get the Ensemble which sits on top of the current object hierarchy.

Overrides:
getEnsemble in class EnsembleEntity
Returns:
The Ensemble which sits on top of the current object hierarchy.

getContainer

public ContainerOfChoirsAndContours getContainer()
Description copied from class: Entity
Getter for the Container property.

Overrides:
getContainer in class EnsembleEntity
Returns:
The assigned Container value.

getAnyVoice

public abstract EnsembleVoice getAnyVoice()
Searches for any voice specification defined under this Ensemble or Choir, or from any sub-choir.

Returns:
The first voice specification found.

getChoirsByID

public java.util.SortedMap<java.lang.Integer,EnsembleChoir> getChoirsByID()
Get the list of sub-choirs in id order

Returns:
An id-indexed collection of choirs, which are immediate children of the current Choir or Ensemble.

getChoirsByName

public java.util.SortedMap<java.lang.String,EnsembleChoir> getChoirsByName()
Get the list of sub-choirs in name order

Returns:
A name-indexed collection of choirs, which are immediate children of the current Choir or Ensemble.

getChoir

public EnsembleChoir getChoir(java.lang.String path)
Use the path as a guide to work down through nested sub-choir lists until the desired choir is located.

Parameters:
path - Text detailing the chain of parent-child choir relationships leading down to the desired choir.
Returns:
The desired choir.

hasChoirName

public boolean hasChoirName(java.lang.String name)
Check if the indicated name is already used.

Parameters:
name - The desired choir name.
Returns:
True if this choir or any of its ancestors contains a choir with the desired name. False otherwise.

createChoir

public EnsembleChoir createChoir(int id,
                                 java.lang.String name)
Create a new child choir under the present Ensemble or Choir.

Parameters:
id - The desired choir id. May not be already used by this instance or by any parent.
name - The desired choir name. May not be already used by this instance or by any parent.
Returns:
The newly created Choir instance.
Throws:
java.lang.IllegalArgumentException - when the choir name is already used.

checkNewChoirID

public void checkNewChoirID(int id)
Check if the indicated id is usable for a new EnsembleChoir.

Parameters:
id - The indicated id.

checkNewChoirName

public void checkNewChoirName(java.lang.String name)
Check if the indicated name is usable for a new EnsembleChoir.

Parameters:
name - The indicated name.

checkNewContourName

public abstract void checkNewContourName(java.lang.String name)
Check if the indicated name is usable for a new EnsembleContour.

Parameters:
name - The indicated name.

checkNewContourID

public abstract void checkNewContourID(int id)
Check if the indicated id is usable for a new EnsembleContour.

Parameters:
id - The indicated id.

checkNewContourIndex

public abstract void checkNewContourIndex(int index)
Check if the indicated index is usable for a new EnsembleContour.

Parameters:
index - The indicated index.

removeChoir

public void removeChoir(java.lang.String name)
Remove the choir with the indicated name from this component's immediate list of sub-choirs.

Parameters:
name - The indicated name.

resolve

public void resolve()

check

public boolean check(HtmlBuilder builder)
Description copied from class: WriteableEntity
Check this component for errors and inconsistencies

Overrides:
check in class WriteableEntity
Parameters:
builder - Accumulates an HTML formatted record of each error or inconsistency found.
Returns:
False if any errors or inconsistencies are found; true otherwise.

getDefaultVoiceName

public java.lang.String getDefaultVoiceName()
Generate a voice name which a user interface can use in the name field of an entity-creation dialog. The new voice name should not conflict with any existing voice name.

Returns:
The suggested name.

resequenceChoirs

public void resequenceChoirs()
Rebuild the sequence of choir id's so that the first id is 1 and the sequence proceeds without gaps.


shiftChoirUp

public void shiftChoirUp(int id)
Move a specified EnsembleChoir up within the collection (i.e. decrement its id).

Parameters:
id - The current part id

shiftChoirDown

public void shiftChoirDown(int id)
Move a specified EnsembleChoir down within the collection (i.e. increment its id).

Parameters:
id - The current instrument id

shiftChoirsDown

public void shiftChoirsDown(int id,
                            int increment)
Move a block of EnsembleChoirs down within the collection.

Parameters:
id - All EnsembleChoirs in the collection with id's greater than or equal to the startingID will be shifted down.
increment - Number of positions to shift.

clear

public void clear()
Clear the contents of this thing.


wipe

public void wipe()
Description copied from class: Entity
Clear all data in this Entity instance.

Overrides:
wipe in class Entity

equals

public boolean equals(EnsembleEntity other)
Description copied from class: EnsembleEntity
Check if this entity has the same class and content as another entity.

Overrides:
equals in class EnsembleEntity
Parameters:
other - The other entity.
Returns:
True if the two entities have the same class and content; false otherwise.

getDefaultChoirID

public int getDefaultChoirID()
Get the next unused choir id.

Returns:
The next unused choir id.