Package ftclib.archive
Class FtcSongXml
java.lang.Object
ftclib.archive.FtcSongXml
This class implements a parser of notated song in an xml file.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFtcSongXml
(String instanceName, InputStream input) Constructor: Create an instance of this object. -
Method Summary
Modifier and TypeMethodDescriptionTrcSong[]
The method returns the song collection parsed from the XML file.int
This method returns the number of songs in the collection xml.getSong
(int index) The method returns the song from the collection with the specified song index.The method returns the song from the collection with the specified song name.getSongName
(int index) This method returns the name of the song with the specified song index in the collection.private void
This method parses the song collection in the XML file.private void
parseSection
(TrcSong song) This method parses the song section in the XML file.private void
parseSequence
(TrcSong song) This method parses the song sequence in the XML file.private TrcSong
This method parses the song in the XML file.private void
skipTag()
This method parses and skips section in the XML file.toString()
This method returns the song name.
-
Field Details
-
instanceName
-
parser
private final org.xmlpull.v1.XmlPullParser parser -
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
This method returns the song name. -
getNumSongs
public int getNumSongs()This method returns the number of songs in the collection xml.- Returns:
- number of songs in the collection.
-
getSongName
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
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
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
The method returns the song collection parsed from the XML file.- Returns:
- song collection.
-
parseCollection
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
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
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
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
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.
-