|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jfugue.Parser
org.jfugue.MusicStringParser
public final class MusicStringParser
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.
As of Version 3.0, the Parser supports turning MIDI Sequences into JFugue Patterns with the parse(Sequence)
method. In this case, the ParserListeners established by a ParserBuilder use the parsed
events to construct the Pattern string.
| Field Summary |
|---|
| Fields inherited from class org.jfugue.Parser |
|---|
TRACING_OFF, TRACING_ON |
| Constructor Summary | |
|---|---|
MusicStringParser()
Creates a new Parser object, and populates the dictionary with initial entries. |
|
| Method Summary | |
|---|---|
static Note |
getNote(Pattern pattern)
Parses a pattern which presumably contains one token, which is a note. |
static Note |
getNote(java.lang.String string)
Parses a string which presumably contains one token, which is a note. |
boolean |
isValidToken(java.lang.String token)
Checks whether a token is valid. |
static void |
main(java.lang.String[] args)
Used for diagnostic purposes. |
void |
parse(Pattern pattern)
Parses a Pattern and fires events to subscribed ParserListener
interfaces. |
void |
verifyToken(java.lang.String token,
java.lang.String verifyString)
|
| Methods inherited from class org.jfugue.Parser |
|---|
addParserListener, addParserProgressListener, getTracing, removeParserListener, removeParserProgressListener, setTracing |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MusicStringParser()
JFugueDefinitions| Method Detail |
|---|
public void parse(Pattern pattern)
throws JFugueException
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 (K, V, T, I, L, X, #, $, @, &, +, *, |), the notes (A, B, C, D, E, F, G, R), and the open-bracket character ( [ ), then the token will be ignored.
pattern - the Pattern to parse
java.lang.Exception - if there is an error parsing the pattern
JFugueExceptionpublic boolean isValidToken(java.lang.String token)
token - the token to test for validity
true is the token is valid; false otherwise.
public void verifyToken(java.lang.String token,
java.lang.String verifyString)
public static Note getNote(java.lang.String string)
string - The String that contains one token with a note, like "C5"
public static Note getNote(Pattern pattern)
pattern - The Pattern that contains one token with a note, like "C5"
public static void main(java.lang.String[] args)
args - not used
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||