net.charlesames.music.ensemble
Class EnsembleEntity

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
All Implemented Interfaces:
EntityContainer
Direct Known Subclasses:
ContainerOfChoirsAndContours, ContainerOfInstrumentLinks, EnsembleChoirMidiData, EnsembleChoirMusicXmlData, EnsembleContour, EnsembleContourNoteListData, EnsembleCredit, EnsembleInstrumentMidiData, EnsembleInstrumentMusicXmlData, EnsembleInstrumentNoteListData, EnsembleInstrumentVoice, EnsembleMidiData, EnsembleMusicXmlData, EnsembleNativeData, EnsembleNoteListData, EnsembleVoice, EnsembleVoiceMidiData, EnsembleVoiceMusicXmlData, EnsembleVoiceMusicXmlStaff, MidiControl, MusicXmlPart, MusicXmlStaff, NoteListInstrument, NoteListInstrumentContour, NoteListInstrumentLink, NoteListOpcode, NoteListParameter, NoteListParameterLink, TuningElement, TuningMap, UnpitchedIndication, UnpitchedSoundMidiData, UnpitchedSoundMusicXmlData, UnpitchedSoundNoteListData

public abstract class EnsembleEntity
extends WriteableEntity

The abstract EnsembleEntity class provides a base for all Ensemble components. This base class implements common features such as numeric identifiers, names, and containers.

Author:
Charles Ames

Nested Class Summary
 class EnsembleEntity.AttributeTable
          Generates an HTML-formated list of attributes, each represented as a name-value pair.
 
Constructor Summary
EnsembleEntity(EnsembleEntity container, int id)
          Constructor for EnsembleEntity instances
EnsembleEntity(EnsembleEntity container, int id, java.lang.String name)
          Constructor for EnsembleEntity instances
 
Method Summary
 void buildDescription(HtmlBuilder builder, int level)
          Build an HTML-formatted description of this Ensemble component.
 void copyToClipboard(Clipboard clipboard)
          Convert this component into its XML data representation and post the result to the clipboard.
static void createIndentCell(HtmlBuilder builder, int level)
           
static XmlSpec createXmlSpec(java.lang.Class<? extends EnsembleEntity> entityClass, java.lang.String tag, java.lang.String description)
          Create an XML specification for the indicated entity class.
static void describeFeature(HtmlBuilder builder, int level, java.lang.String cellAttributes, java.lang.String feature)
          Build an HTML-formatted description of a component feature.
 boolean equals(EnsembleEntity other)
          Check if this entity has the same class and content as another entity.
 EnsembleEntity getContainer()
          Getter for the Container property.
 Ensemble getEnsemble()
          Get the Ensemble which sits on top of the current object hierarchy.
 void logError(org.w3c.dom.Element element, java.lang.Exception e)
          Handle an exception encountered while loading this component of the Ensemble.
 EnsembleEntity predecessor(java.util.SortedMap<java.lang.Integer,? extends EnsembleEntity> entities)
           
 java.lang.String toString()
           
 
Methods inherited from class net.charlesames.utility.entity.WriteableEntity
check, 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, wipe
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EnsembleEntity

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

Parameters:
container - The EnsembleEntity which will contain this new instance. Only Ensemble instances may have null containers.
id - The entity id.
name - The entity name.

EnsembleEntity

public EnsembleEntity(EnsembleEntity container,
                      int id)
Constructor for EnsembleEntity instances

Parameters:
container - The EnsembleEntity which will contain this new instance. Only Ensemble instances may have null containers.
id - The entity id.
Method Detail

getContainer

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

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

getEnsemble

public Ensemble getEnsemble()
Get the Ensemble which sits on top of the current object hierarchy.

Returns:
The Ensemble which sits on top of the current object hierarchy.

toString

public java.lang.String toString()
Overrides:
toString in class Entity

copyToClipboard

public final void copyToClipboard(Clipboard clipboard)
Convert this component into its XML data representation and post the result to the clipboard.

Parameters:
clipboard - The clipboard receiving the new XML content.

logError

public void logError(org.w3c.dom.Element element,
                     java.lang.Exception e)
Handle an exception encountered while loading this component of the Ensemble.

Parameters:
element - The XML element during the processing of which the exception was thrown.
e - The exception.

predecessor

public final EnsembleEntity predecessor(java.util.SortedMap<java.lang.Integer,? extends EnsembleEntity> entities)
Parameters:
entities - An id-indexed collection which includes the present entity.
Returns:
This entity's predecessor in the entities collection.

buildDescription

public final void buildDescription(HtmlBuilder builder,
                                   int level)
Build an HTML-formatted description of this Ensemble component.

Parameters:
builder - The HTML formatter which accumulates nested descriptions.
level - The number of parent-child generations between the top-level Ensemble instance and this component.
Throws:
java.lang.Exception

describeFeature

public static void describeFeature(HtmlBuilder builder,
                                   int level,
                                   java.lang.String cellAttributes,
                                   java.lang.String feature)
                            throws java.lang.Exception
Build an HTML-formatted description of a component feature.

Parameters:
builder - The HTML formatter which accumulates nested descriptions.
level - The number of parent-child generations between the top-level Ensemble instance and this component.
cellAttributes - An HTML fragment specifying how the cell should be formatted.
feature - Text describing the feature.
Throws:
java.lang.Exception

createIndentCell

public static void createIndentCell(HtmlBuilder builder,
                                    int level)
                             throws java.lang.Exception
Parameters:
builder - The HTML formatter which accumulates nested descriptions.
level - The number of parent-child generations between the top-level Ensemble instance and this component.
Throws:
java.lang.Exception

createXmlSpec

public static XmlSpec createXmlSpec(java.lang.Class<? extends EnsembleEntity> entityClass,
                                    java.lang.String tag,
                                    java.lang.String description)
Create an XML specification for the indicated entity class.

Parameters:
entityClass - The indicated entity class.
tag - The node name for an XML Element which describes an instance of the entity class.
description - A text description for the XSD element.
Returns:
The newly created XmlSpec instance.
Throws:
java.lang.RuntimeException - when an XmlSpec instance already exists for the indicated entity class.

equals

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

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