org.niffty
Class ScoreData

java.lang.Object
  |
  +--org.niffty.HeirarchyNode
        |
        +--org.niffty.ScoreData

public class ScoreData
extends HeirarchyNode

A ScoreData object encapsulates the data section of a NIFF file. A ScoreData has zero or more of Page.

See Also:
Page

Constructor Summary
ScoreData()
          Creates a new ScoreData with an empty page list.
 
Method Summary
 void addPage(Page page)
          Add the given Page to the page list.
 Page getPage(int index)
          Return the Page in the page list at the given index.
 int getPageCount()
          Return the number of pages in the page list.
 Score getParentScore()
          Return the parent Score, or null if this hasn't been added to a Score object yet.
 void invalidate()
          This is automatically called after the object is modified to force this and all child objects to recompute their values when the "get" method is called for the value.
 void print(java.lang.String indent, java.io.PrintStream output)
          This prints the score data info including all pages.
protected  void setParentScore(Score parentScore)
          Set the parent score.
 
Methods inherited from class org.niffty.HeirarchyNode
addChild, getChild, getChildCount, getIndex, getParentNode, nextInHeirarchy, previousInHeirarchy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScoreData

public ScoreData()
Creates a new ScoreData with an empty page list. The parent Score pointer will be set when this is added to a Score.

Method Detail

addPage

public void addPage(Page page)
Add the given Page to the page list. After adding, this also calls invalidate().

Parameters:
page - the Page to add. It is an error if this is already the child of an object.
Throws:
HeirarchyException - if the page has already been added as a child to another object.
See Also:
invalidate()

setParentScore

protected void setParentScore(Score parentScore)
Set the parent score. This is a protected method because only Score (which is in the same package) should call this.

Parameters:
parentScore - the parentScore.getData() must already be this ScoreData, and this ScoreData cannot already have a parent. In this way, we ensure that only the Score can call this.

getParentScore

public Score getParentScore()
Return the parent Score, or null if this hasn't been added to a Score object yet.


getPageCount

public int getPageCount()
Return the number of pages in the page list.


getPage

public Page getPage(int index)
Return the Page in the page list at the given index.

Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index is negative or not less than the number of nodes in the child node list.

invalidate

public void invalidate()
This is automatically called after the object is modified to force this and all child objects to recompute their values when the "get" method is called for the value.


print

public void print(java.lang.String indent,
                  java.io.PrintStream output)
This prints the score data info including all pages.

Parameters:
indent - A string such as " " to print at the beginning of the line
output - the PrintStream to print to, such as System.out