Class FtcSongXml

java.lang.Object
ftclib.archive.FtcSongXml

public class FtcSongXml extends Object
This class implements a parser of notated song in an xml file.
  • Field Details

    • instanceName

      private final String instanceName
    • parser

      private final org.xmlpull.v1.XmlPullParser parser
    • collection

      private final ArrayList<TrcSong> collection
  • Constructor Details

    • FtcSongXml

      public FtcSongXml(String instanceName, InputStream input) throws org.xmlpull.v1.XmlPullParserException, IOException
      Constructor: Create an instance of this object.
      Parameters:
      instanceName - specifies the instance name.
      input - specifies the input stream from which the notated song is read.
      Throws:
      org.xmlpull.v1.XmlPullParserException
      IOException
  • Method Details

    • toString

      @NonNull public String toString()
      This method returns the song name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • getNumSongs

      public int getNumSongs()
      This method returns the number of songs in the collection xml.
      Returns:
      number of songs in the collection.
    • getSongName

      public String getSongName(int index)
      This method returns the name of the song with the specified song index in the collection.
      Parameters:
      index - specifies the song index in the collection.
      Returns:
      song name.
    • getSong

      public TrcSong getSong(int index)
      The method returns the song from the collection with the specified song index.
      Parameters:
      index - specifies the song index in the collection.
      Returns:
      song in the collection with the specified index.
    • getSong

      public TrcSong getSong(String name)
      The method returns the song from the collection with the specified song name.
      Parameters:
      name - specifies the song name to look for..
      Returns:
      song in the collection with the specified name, null if none found.
    • getCollection

      public TrcSong[] getCollection()
      The method returns the song collection parsed from the XML file.
      Returns:
      song collection.
    • parseCollection

      private void parseCollection() throws org.xmlpull.v1.XmlPullParserException, IOException
      This method parses the song collection in the XML file. The collection starts with a collection tag and contains multiple song tags.
      Throws:
      org.xmlpull.v1.XmlPullParserException - if there is a parse error.
      IOException - if there is file access error.
    • parseSong

      private TrcSong parseSong() throws org.xmlpull.v1.XmlPullParserException, IOException
      This method parses the song in the XML file. The song starts with a song tag and contains one sequence tag and multiple section tags.
      Throws:
      org.xmlpull.v1.XmlPullParserException - if there is a parse error.
      IOException - if there is file access error.
    • parseSequence

      private void parseSequence(TrcSong song) throws org.xmlpull.v1.XmlPullParserException, IOException
      This method parses the song sequence in the XML file. The song sequence starts with a sequence tag and contains a sequence of section names separated by commas.
      Parameters:
      song - specifies the song object that the sequence belongs to.
      Throws:
      org.xmlpull.v1.XmlPullParserException - if there is a parse error.
      IOException - if there is file access error.
    • parseSection

      private void parseSection(TrcSong song) throws org.xmlpull.v1.XmlPullParserException, IOException
      This method parses the song section in the XML file. The song section starts with a section tag and contains a sequence of notated notes separated by commas.
      Parameters:
      song - specifies the song object that the section belongs to.
      Throws:
      org.xmlpull.v1.XmlPullParserException - if there is a parse error.
      IOException - if there is file access error.
    • skipTag

      private void skipTag() throws org.xmlpull.v1.XmlPullParserException, IOException
      This method parses and skips section in the XML file. The song section starts with a section tag and contains a sequence of notated notes separated by commas.
      Throws:
      org.xmlpull.v1.XmlPullParserException - if there is a parse error.
      IOException - if there is file access error.