|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jfugue.Parser
Parses music strings, and fires events for ParserListener
interfaces
when tokens are interpreted. The ParserListener
does intelligent things
with the resulting events, such as create music, draw sheet music, or
transform the data.
Field Summary | |
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()
Creates a new Parser object, and populates the dictionary with initial entries. |
Method Summary | |
void |
addParserListener(ParserListener listener)
Adds a ParserListener . |
protected int |
getTempo()
Returns the tempo for the current song. |
static int |
getTracing()
Returns the current state of tracing. |
boolean |
isValidToken(java.lang.String token)
Checks whether a token is valid. |
static void |
main(java.lang.String[] args)
main( ) is used for diagnostic purposes. |
void |
parse(Pattern pattern)
Parses a Pattern and fires events to subscribed ParserListener
interfaces. |
void |
removeParserListener(ParserListener listener)
Removes a ParserListener . |
protected void |
setTempo(int tempo)
Sets the tempo for the current song. |
static void |
setTracing(int tracing)
Turns tracing on or off. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int TRACING_OFF
public static final int TRACING_ON
Constructor Detail |
public Parser()
JFugueDefinitions
Method Detail |
public static void setTracing(int tracing)
tracing
- the state of tracing - on or offpublic static int getTracing()
public void addParserListener(ParserListener listener)
ParserListener
. The listener will receive events when the parser
interprets music string tokens.listener
- the listener that is to be notified of parser eventspublic void removeParserListener(ParserListener listener)
ParserListener
.listener
- the listener to removeprotected void setTempo(int tempo)
tempo
- the tempo for the current song, in pulses per quarter.protected int getTempo()
public void parse(Pattern pattern) throws java.lang.Exception
Pattern
and fires events to subscribed ParserListener
interfaces. As the Pattern is parsed, events are sent
to ParserLisener
interfaces, which are responsible for doing
something interesting with the music data, such as playing the music,
displaying it as sheet music, or transforming the pattern.
The parser breaks a music string into tokens, which are separated by spaces. It then determines the type of command based on the first character of the token. If the parser does not recognize the first character of the token, which is limited to the command letters (V, T, I, X, #), the notes (A, B, C, D, E, F, G), and the open-bracket character ( [ ), then the token will be ignored.
pattern
- the Pattern
to parsejava.lang.Exception
- if there is an error parsing the patternpublic boolean isValidToken(java.lang.String token)
token
- the token to test for validitytrue
is the token is valid; false
otherwise.public static void main(java.lang.String[] args)
args
- not used
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |