abc.parser
Class TuneBook

java.lang.Object
  extended byabc.parser.TuneBook

public class TuneBook
extends java.lang.Object

This class provides an object representation of a tunebook. It enables you to store tunes ordered by reference number.


Constructor Summary
TuneBook()
          Creates an empty tunebook.
TuneBook(java.io.BufferedReader stream)
          Creates a new tune book from the specified stream.
TuneBook(java.io.BufferedReader stream, AbcFileParserListenerInterface listener)
           
TuneBook(java.io.File abcFile)
          Creates a new tune book from the specified file.
TuneBook(java.io.File abcFile, AbcFileParserListenerInterface listener)
           
 
Method Summary
 void addListener(TuneBookListenerInterface l)
          Adds a listener to this tunebook to be aware of tunes changes.
 java.io.File getFile()
           
 int getHighestReferenceNumber()
           
 int[] getReferenceNumbers()
          Returns the reference numbers of tunes contained in this tunebook.
 Tune getTune(int referenceNumber)
          Returns the tune with the specified reference number
 java.lang.String getTuneHeader(int referenceNumber)
           
 java.lang.String getTuneNotation(int referenceNumber)
          Returns the notation of the tune corresponding to the specified reference number.
 Tune[] getTunesHeaders()
          Returns tunes header information of tunes contained in this tunebook.
 Tune putTune(java.lang.String tuneNotation)
          Puts the specified notation in this tunebook.
 void removeListener(TuneBookListenerInterface l)
          Removes a listener from this tunebook.
 Tune removeTune(int referenceNumber)
          Removes the tune with specified reference number.
 void save()
           
 void saveTo(java.io.File file)
          Saves this tunebook to the specified file.
 int size()
          Returns the number of tunes contained in this tunebook.
 java.util.Vector toVector()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TuneBook

public TuneBook(java.io.File abcFile)
         throws java.io.FileNotFoundException
Creates a new tune book from the specified file.

Parameters:
abcFile - The file that contains tunes in abc notation.
Throws:
java.io.FileNotFoundException - Thrown if the specified file doesn't exist.

TuneBook

public TuneBook(java.io.File abcFile,
                AbcFileParserListenerInterface listener)
         throws java.io.FileNotFoundException

TuneBook

public TuneBook(java.io.BufferedReader stream)
Creates a new tune book from the specified stream.

Parameters:
stream - The stream in abc notation.

TuneBook

public TuneBook(java.io.BufferedReader stream,
                AbcFileParserListenerInterface listener)

TuneBook

public TuneBook()
Creates an empty tunebook.

Method Detail

saveTo

public void saveTo(java.io.File file)
            throws java.io.IOException
Saves this tunebook to the specified file.

Parameters:
file - The file where all tunes notation should be stored.
Throws:
java.io.IOException - Thrown if the specified file doesn't exist.

getFile

public java.io.File getFile()

save

public void save()
          throws java.io.IOException
Throws:
java.io.IOException

putTune

public Tune putTune(java.lang.String tuneNotation)
Puts the specified notation in this tunebook. If a tune with the same reference number was already existing, it updates it. If it's a new tune, it adds it.

Parameters:
tuneNotation - A string that describes a tune using ABC notation.
Returns:
Header information of the added tune.

removeTune

public Tune removeTune(int referenceNumber)
Removes the tune with specified reference number.

Parameters:
referenceNumber - The reference number of the tune that has to be removed.
Returns:
The tune that has been removed, null if no tune with the corresponding reference number has been found.

getTune

public Tune getTune(int referenceNumber)
Returns the tune with the specified reference number

Parameters:
referenceNumber - The reference number of the tune that should be retrieved.
Returns:
The tune corresponding to the specified reference number, null if no tune found.

getTuneHeader

public java.lang.String getTuneHeader(int referenceNumber)

getTuneNotation

public java.lang.String getTuneNotation(int referenceNumber)
                                 throws NoSuchTuneException
Returns the notation of the tune corresponding to the specified reference number.

Parameters:
referenceNumber - A reference number.
Returns:
A tune notation in ABC format. null if no tune has been found.
Throws:
NoSuchTuneException - Thrown if the specified reference number doesn't exist in this tunebook.

getTunesHeaders

public Tune[] getTunesHeaders()
Returns tunes header information of tunes contained in this tunebook.

Returns:
An array containing Tune objects representing header information of tunes contained in this tunebook.

getReferenceNumbers

public int[] getReferenceNumbers()
Returns the reference numbers of tunes contained in this tunebook.

Returns:
An array containing the reference numbers of tunes contained in this tunebook, ordered in the way they were added in this tunebook.

getHighestReferenceNumber

public int getHighestReferenceNumber()

size

public int size()
Returns the number of tunes contained in this tunebook.

Returns:
The number of tunes contained in this tunebook.

toVector

public java.util.Vector toVector()

addListener

public void addListener(TuneBookListenerInterface l)
Adds a listener to this tunebook to be aware of tunes changes.

Parameters:
l - The listener to be added.

removeListener

public void removeListener(TuneBookListenerInterface l)
Removes a listener from this tunebook.

Parameters:
l - The listener to be removed.