org.jfugue
Class Parser

java.lang.Object
  extended by org.jfugue.Parser
Direct Known Subclasses:
MidiParser, MusicStringParser

public class Parser
extends java.lang.Object

You may notice that there is no parse() method in the Parser class! That's because the parse() method may take any type of parameter, as well as any number of parameters, so it isn't something that can declared ahead of time.

Author:
David Koelle

Field Summary
protected  javax.swing.event.EventListenerList listenerList
          List of ParserListeners
protected  javax.swing.event.EventListenerList progressListenerList
          List of ParserProgressListeners
static int TRACING_OFF
          Pass this value to setTracing( ) to turn tracing off.
static int TRACING_ON
          Pass this value to setTracing( ) to turn tracing on.
 
Constructor Summary
Parser()
           
 
Method Summary
 void addParserListener(ParserListener l)
          Adds a ParserListener.
 void addParserProgressListener(ParserProgressListener l)
          Adds a ParserListener.
protected  void clearParserListeners()
           
protected  void clearParserProgressListeners()
           
protected  void fireChannelPressureEvent(ChannelPressure event)
          Tells all ParserListener interfaces that a controller event has been parsed.
protected  void fireControllerEvent(Controller event)
          Tells all ParserListener interfaces that a controller event has been parsed.
protected  void fireInstrumentEvent(Instrument event)
          Tells all ParserListener interfaces that an instrument event has been parsed.
protected  void fireKeySignatureEvent(KeySignature event)
          Tells all ParserListener interfaces that a key signature event has been parsed.
protected  void fireLayerEvent(Layer event)
          Tells all ParserListener interfaces that a layer event has been parsed.
protected  void fireMeasureEvent(Measure event)
          Tells all ParserListener interfaces that a measure event has been parsed.
protected  void fireNoteEvent(Note event)
          Tells all ParserListener interfaces that a note event has been parsed.
protected  void fireParallelNoteEvent(Note event)
          Tells all ParserListener interfaces that a parallel note event has been parsed.
protected  void firePitchBendEvent(PitchBend event)
          Tells all ParserListener interfaces that a controller event has been parsed.
protected  void firePolyphonicPressureEvent(PolyphonicPressure event)
          Tells all ParserListener interfaces that a controller event has been parsed.
protected  void fireProgressReported(java.lang.String description, long partComplete, long whole)
          Tells all ParserProgressListener interfaces that progress has occurred.
protected  void fireSequentialNoteEvent(Note event)
          Tells all ParserListener interfaces that a sequential note event has been parsed.
protected  void fireTempoEvent(Tempo event)
          Tells all ParserListener interfaces that a tempo event has been parsed.
protected  void fireTimeEvent(Time event)
          Tells all ParserListener interfaces that a time event has been parsed.
protected  void fireVoiceEvent(Voice event)
          Tells all ParserListener interfaces that a voice event has been parsed.
static int getTracing()
          Returns the current state of tracing.
 void removeParserListener(ParserListener l)
          Removes a ParserListener.
 void removeParserProgressListener(ParserProgressListener l)
          Removes a ParserListener.
static void setTracing(int tracing)
          Turns tracing on or off.
protected  void trace(java.lang.Object... sentenceFragments)
          Displays the passed String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACING_OFF

public static final int TRACING_OFF
Pass this value to setTracing( ) to turn tracing off. Tracing is off by default.

See Also:
Constant Field Values

TRACING_ON

public static final int TRACING_ON
Pass this value to setTracing( ) to turn tracing on. Tracing is off by default.

See Also:
Constant Field Values

progressListenerList

protected javax.swing.event.EventListenerList progressListenerList
List of ParserProgressListeners


listenerList

protected javax.swing.event.EventListenerList listenerList
List of ParserListeners

Constructor Detail

Parser

public Parser()
Method Detail

setTracing

public static void setTracing(int tracing)
Turns tracing on or off. If you're having trouble with your music string, or if you've added new tokens to the parser, turn tracing on to make sure that your new tokens are parsed correctly.

Parameters:
tracing - the state of tracing - on or off

getTracing

public static int getTracing()
Returns the current state of tracing.

Returns:
the state of tracing

trace

protected void trace(java.lang.Object... sentenceFragments)
Displays the passed String.

Parameters:
s - the String to display

addParserProgressListener

public void addParserProgressListener(ParserProgressListener l)
Adds a ParserListener. The listener will receive events when the parser interprets music string tokens.

Parameters:
listener - the listener that is to be notified of parser events

removeParserProgressListener

public void removeParserProgressListener(ParserProgressListener l)
Removes a ParserListener.

Parameters:
listener - the listener to remove

clearParserProgressListeners

protected void clearParserProgressListeners()

fireProgressReported

protected void fireProgressReported(java.lang.String description,
                                    long partComplete,
                                    long whole)
Tells all ParserProgressListener interfaces that progress has occurred.


addParserListener

public void addParserListener(ParserListener l)
Adds a ParserListener. The listener will receive events when the parser interprets music string tokens.

Parameters:
listener - the listener that is to be notified of parser events

removeParserListener

public void removeParserListener(ParserListener l)
Removes a ParserListener.

Parameters:
listener - the listener to remove

clearParserListeners

protected void clearParserListeners()

fireVoiceEvent

protected void fireVoiceEvent(Voice event)
Tells all ParserListener interfaces that a voice event has been parsed.


fireTempoEvent

protected void fireTempoEvent(Tempo event)
Tells all ParserListener interfaces that a tempo event has been parsed.


fireInstrumentEvent

protected void fireInstrumentEvent(Instrument event)
Tells all ParserListener interfaces that an instrument event has been parsed.


fireLayerEvent

protected void fireLayerEvent(Layer event)
Tells all ParserListener interfaces that a layer event has been parsed.


fireTimeEvent

protected void fireTimeEvent(Time event)
Tells all ParserListener interfaces that a time event has been parsed.


fireKeySignatureEvent

protected void fireKeySignatureEvent(KeySignature event)
Tells all ParserListener interfaces that a key signature event has been parsed.


fireMeasureEvent

protected void fireMeasureEvent(Measure event)
Tells all ParserListener interfaces that a measure event has been parsed.


fireControllerEvent

protected void fireControllerEvent(Controller event)
Tells all ParserListener interfaces that a controller event has been parsed.


fireChannelPressureEvent

protected void fireChannelPressureEvent(ChannelPressure event)
Tells all ParserListener interfaces that a controller event has been parsed.


firePolyphonicPressureEvent

protected void firePolyphonicPressureEvent(PolyphonicPressure event)
Tells all ParserListener interfaces that a controller event has been parsed.


firePitchBendEvent

protected void firePitchBendEvent(PitchBend event)
Tells all ParserListener interfaces that a controller event has been parsed.


fireNoteEvent

protected void fireNoteEvent(Note event)
Tells all ParserListener interfaces that a note event has been parsed.


fireSequentialNoteEvent

protected void fireSequentialNoteEvent(Note event)
Tells all ParserListener interfaces that a sequential note event has been parsed.


fireParallelNoteEvent

protected void fireParallelNoteEvent(Note event)
Tells all ParserListener interfaces that a parallel note event has been parsed.