Package org.staccato

Class NoteSubparser

java.lang.Object
org.staccato.NoteSubparser
All Implemented Interfaces:
ChordProvider, NoteProvider, Subparser

public class NoteSubparser extends Object implements Subparser, NoteProvider, ChordProvider
  • Method Details

    • getInstance

      public static NoteSubparser getInstance()
    • matches

      public boolean matches(String music)
      Description copied from interface: Subparser
      Indicates whether the subparser should be responsible for parsing the given music string.
      Specified by:
      matches in interface Subparser
      Parameters:
      music - The Staccato music string to consider
      Returns:
      true if this subparser will accept the music string, false otherwise
    • getTokenType

      public Token.TokenType getTokenType(String tokenString)
      Description copied from interface: Subparser
      Asks the subparser to provide a TokenType for the given token.
      Specified by:
      getTokenType in interface Subparser
      Parameters:
      tokenString - The Staccato token to map to a type
    • parse

      public int parse(String s, StaccatoParserContext context)
      Description copied from interface: Subparser
      Parses the given music string.
      Specified by:
      parse in interface Subparser
      Parameters:
      s - The Staccato music string to parse
      context -
      Returns:
      index Updated parsing index into the Staccato music string.
    • parseNoteElement

      public int parseNoteElement(String s, int index, org.staccato.NoteSubparser.NoteContext noteContext, StaccatoParserContext parserContext)
      Parses a note element.
      Parameters:
      s - the token that contains a note element
    • createNote

      public Note createNote(String noteString)
      Specified by:
      createNote in interface NoteProvider
    • getMiddleC

      public Note getMiddleC()
      Specified by:
      getMiddleC in interface NoteProvider
    • getDurationForString

      public double getDurationForString(String s)
      Specified by:
      getDurationForString in interface NoteProvider
    • populateContext

      public static void populateContext(StaccatoParserContext context)
    • createChord

      public Chord createChord(String chordString)
      Specified by:
      createChord in interface ChordProvider