/** * Returns the index with which to start parsing the next part of the string, once this method is * done with its part */ private int parseChord(String s, int index, NoteContext context) { // Don't parse chord for a rest if (context.isRest) { return index; } int lengthOfChordString = 0; boolean chordFound = false; String[] chordNames = Chord.getChordNames(); for (String chordName : chordNames) { if (!chordFound && (s.length() >= index + chordName.length()) && chordName.equals(s.substring(index, index + chordName.length()))) { chordFound = true; lengthOfChordString = chordName.length(); context.isChord = true; context.intervals = Chord.getIntervals(chordName); context.chordName = chordName; logger.info( "Chord: " + chordName + " Interval Pattern: " + Chord.getIntervals(chordName)); break; } } return index + lengthOfChordString; }