core
Class ITunesXML

java.lang.Object
  extended by core.ITunesXML

public class ITunesXML
extends java.lang.Object

This class provides an interface to the iTunes XML file that is maintained by iTunes. The iTunes XML file contains critical information for iTunesDSM such as the directory iTunes stores music to and the version of iTunes installed.


Field Summary
static java.lang.String DEFAULT_LOG_FILE_NAME
          The string name for the default log file.
static java.lang.String ITUNES_XML_FILE_NAME
          The file name of the iTunes XML file that iTunes automatically generates and maintains.
 
Constructor Summary
ITunesXML()
          Creates a new ITunesXML object with a null iTunes XML file.
ITunesXML(java.io.File iTunesXMLFile)
          Creates a new ITunesXML object with the given iTunes XML File.
 
Method Summary
 java.lang.String decodeXMLURLLocation(java.lang.String url)
          Converts UTF-8 encoded location strings from the iTunes XML file.
 java.io.File getITunesDirectory()
          Returns the directory that iTunes stores music to.
 java.util.ArrayList<java.io.File> getITunesTrackLocationsByLine()
          Reads the iTunesXML file by line and parses the locations of all iTunes tracks.
 java.lang.String getITunesVersion()
          Reads the iTunes XML file for the version number of the iTunes installation relating to the XML file.
 java.io.File getiTunesXMLFile()
          Returns the iTunes XML file
static void main(java.lang.String[] args)
           
 java.lang.String searchXMLForProperty(java.lang.String searchLine)
          Searches the iTunes XML file for a given string.
 void setiTunesXMLFile(java.io.File iTunesXMLFile)
          Sets the iTunes XML file to a given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ITUNES_XML_FILE_NAME

public static final java.lang.String ITUNES_XML_FILE_NAME
The file name of the iTunes XML file that iTunes automatically generates and maintains.

See Also:
Constant Field Values

DEFAULT_LOG_FILE_NAME

public static java.lang.String DEFAULT_LOG_FILE_NAME
The string name for the default log file. The default log file contains all of the log information from the GuiMain logger object.

Constructor Detail

ITunesXML

public ITunesXML(java.io.File iTunesXMLFile)
Creates a new ITunesXML object with the given iTunes XML File.

Parameters:
iTunesXMLFile - The iTunes XML File.

ITunesXML

public ITunesXML()
Creates a new ITunesXML object with a null iTunes XML file.

Method Detail

getITunesTrackLocationsByLine

public java.util.ArrayList<java.io.File> getITunesTrackLocationsByLine()
Reads the iTunesXML file by line and parses the locations of all iTunes tracks.

Returns:
locations The locations of existing files parsed by the iTunes XML file. If the file exists it is added to the ArrayList.

decodeXMLURLLocation

public java.lang.String decodeXMLURLLocation(java.lang.String url)
Converts UTF-8 encoded location strings from the iTunes XML file.

Parameters:
url - The string encoded in UTF-8 in the iTunes XML file that should be parsed to a standard file location string.
Returns:
url The decoded url string.

searchXMLForProperty

public java.lang.String searchXMLForProperty(java.lang.String searchLine)
Searches the iTunes XML file for a given string.

Parameters:
searchLine - The string to search the iTunes XML file for. Typically, one would search for a specific property of iTunes such as the version number or the iTunes music directory. In other words, a unique line of information in the iTunes XML file.
Returns:
The entire string containing the searched string. Typically, this line would then be parsed for the property within the tags.

getITunesDirectory

public java.io.File getITunesDirectory()
Returns the directory that iTunes stores music to. This option is set in iTunes under Edit > Preferences > Advanced.

Returns:
The directory that iTunes stores music in.

getITunesVersion

public java.lang.String getITunesVersion()
Reads the iTunes XML file for the version number of the iTunes installation relating to the XML file.

Returns:
The version of iTunes currently installed and relating to the parsed XML file. Null if the parse was unsuccessful.

getiTunesXMLFile

public java.io.File getiTunesXMLFile()
Returns the iTunes XML file

Returns:
the iTunes XML file

setiTunesXMLFile

public void setiTunesXMLFile(java.io.File iTunesXMLFile)
Sets the iTunes XML file to a given file.

Parameters:
iTunesXMLFile - the file to set the iTunes XML file to.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception