core.options
Class Options

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by core.options.Options
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class Options
extends java.util.Properties

This class is used to handle options that a user makes, including file types to filter, the itunes xml file, the directory to search for duplicates,the directory to add tracks to iTunes from, whether or not to query a server for updates to iTunesDSM, and startup options.

See Also:
Serialized Form

Nested Class Summary
 class Options.FindITunesXMLFile
          This class locates the iTunes XML file in the background and reports the progress to a StatusProgressMonitor object.
 
Field Summary
static java.lang.String newLine
          The newline character that is system dependent.
static java.lang.String OPTIONS_FILE_NAME
          The string path for the options file.
static java.lang.String PROPERTY_FILE_COMMENT
          The comments given to the properties file when outputing.
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
Options()
          Creates a new Options object.
 
Method Summary
 void addMusicDirectory(java.io.File newMusicDir)
          Add a new music directory to the array of music directories.
 void addOptionsChangeListener(OptionsChangeListener listener)
          Adds an OptionsChangeListener to the options object.
static void checkFileExists()
          Checks that the options file exists.
 boolean equals(Options testOptions)
          Tests whether two options objects are equal.
 long getBackgroundDelay()
          Returns the set time delay for background monitoring the music directory folder.
 int getBackgroundDelayHours()
          Returns the set time delay for background monitoring in hours.
static java.io.File[] getChildDirectories(java.util.ArrayList<java.io.File> allFoldersToGetRoots)
          Returns an array of all the child folders given the array list of folders.
 java.lang.String[] getExtensions()
          Gets the file extensions to filter with.
 java.io.File getiTunesXMLFile()
          Returns the iTunes XML file.
 java.io.File getiTunesXMLMusicDir()
          Returns the music directory iTunes stores music to by reading the iTunes XML file.
 java.util.ArrayList<java.io.File> getMusicDirectories()
          Returns the music directories.
 boolean isAddTracksInBackgroundEnabled()
          Returns the boolean value as to whether or not iTunesDSM should monitor the music directory in the background for new tracks to add iTunes.
 boolean isAddTracksInBackgroundRunning()
          Returns whether or not the boolean for background monitoring is running.
 boolean isCheckForUpdate()
          Returns the boolean value for whether or not to check for an update when the application starts.
 boolean isiTunesCopiesToFolder()
          Returns the boolean value for whether or not iTunes copies music to the iTunes music folder when it is added to the library.
 boolean isiTunesKeepsOrganized()
          The boolean as to whether or not iTunes keeps the music folder organized.
 boolean isMinimizeToTrayWhenClose()
          If true, the iTunesDSM window will not exit the system, rather it will hide the window from the user.
 boolean isReady()
          Returns a boolean value that is found by checking whether file extensions have been set, a music directory has been set by the user or read from the options file, and the iTunes Music Directory is known.
 boolean isStartOnBoot()
          Sets whether or not to add the iTunesDSM.exe file shortcut to the startup folder in the user's start menu.
 boolean isStartVisible()
          If true, iTunesDSM will start with a window visible to the user.
static Options loadDefaultOptions()
          Returns a default options object.
static void main(java.lang.String[] args)
           
static Options read()
          Reads the xml properties file and loads a new Options object.
 void removeMusicDirectory(java.io.File musicDirToRemove)
          Removes a directory from the array of music directories.
 void removeOptionsChangeListener(OptionsChangeListener listener)
          Removes an OptionsChangeListener object from the Options object.
 void setAddTracksInBackgroundEnabled(boolean addTracksInBackground)
          Changes the boolean value to the desired boolean as to whether or not iTunesDSM should monitor the music directory for new tracks to add to iTunes in the background.
 void setAddTracksInBackgroundRunning(boolean addTracksInBackgroundRunning)
          Sets the boolean value for background monitoring running.
 void setBackgroundDelay(long millisecs)
          Changes the time delay to the specified value for background monitoring the music directory.
 void setBackgroundDelayHours(int hours)
          Sets the background folder watching delay time to the given time in hours.
 void setCheckForUpdate(boolean checkForUpdate)
          Sets the boolean value for whether or not to update check for an update to the application on start up.
 void setExtensions(java.lang.String str)
          Sets the extensions to a string that is parsed by an Extensions object.
 void setExtensions(java.lang.String[] ext)
          Sets the extensions to a known set of extensions.
 void setiTunesCopiesToFolder(boolean iTunesCopiesToFolder)
          Sets the boolean value for whether or not iTunes copies music to the iTunes music folder set in Edit > Preferences > Advanced.
 void setiTunesKeepsOrganized(boolean iTunesKeepsOrganized)
          Sets whether or not iTunes keeps the music folder organized.
 void setiTunesXMLFile()
          Sets the iTunes XML file to one that will be found by the user.
 void setiTunesXMLFile(java.io.File xmlFile)
          Sets the iTunes XML file.
 void setiTunesXMLMusicDir(java.io.File xmlMusicDir)
          Sets the music directory that iTunes stores music in to a new directory.
 void setMinimizeToTrayWhenClose(boolean minimizeToTrayWhenClose)
          Sets the closing behavior of iTunesDSM when the user closes the window.
 void setMusicDirectories(java.util.ArrayList<java.io.File> musicDirectories)
          Sets the music directories to the given array list of directories.
 void setStartOnBoot(boolean startOnBoot)
          Sets the boolean of starting iTunesDSM on boot.
 void setStartVisible(boolean startVisible)
          Sets the value to start the iTunesDSM window visible to the user.
 java.lang.String toString()
          Returns the Properties class toString method string.
 void write()
          Outputs the Options object to a properties xml file.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OPTIONS_FILE_NAME

public static final java.lang.String OPTIONS_FILE_NAME
The string path for the options file.


newLine

public static java.lang.String newLine
The newline character that is system dependent.


PROPERTY_FILE_COMMENT

public static java.lang.String PROPERTY_FILE_COMMENT
The comments given to the properties file when outputing.

Constructor Detail

Options

public Options()
Creates a new Options object. Usually one would create a new Options object but use the read method to initialize the object. Though creating a new object via constructor is also acceptable.

See Also:
read()
Method Detail

isiTunesCopiesToFolder

public boolean isiTunesCopiesToFolder()
Returns the boolean value for whether or not iTunes copies music to the iTunes music folder when it is added to the library. Currenlty, this must be set manually.

Returns:
If true, iTunes copies music to the iTunes music directory set in Edit > Preferences > Advanced. Currently, this is set manually.

setiTunesCopiesToFolder

public void setiTunesCopiesToFolder(boolean iTunesCopiesToFolder)
Sets the boolean value for whether or not iTunes copies music to the iTunes music folder set in Edit > Preferences > Advanced.

Parameters:
iTunesCopiesToFolder - If true, iTunes copies music to the iTunes music directory set in Edit > Preferences > Advanced. Currently, this must be set manually.

isiTunesKeepsOrganized

public boolean isiTunesKeepsOrganized()
The boolean as to whether or not iTunes keeps the music folder organized. If adding tracks to iTunes it is best this feature be enabled for the most so that the location the file is copied to is predicable.

Returns:
The boolean as to whether or no iTunes keeps the iTunes music directory organized. If adding tracks to iTunes it is best this be enabled in iTunes so that files that are copied to the music directory are placed in a predicatable folder.

setiTunesKeepsOrganized

public void setiTunesKeepsOrganized(boolean iTunesKeepsOrganized)
Sets whether or not iTunes keeps the music folder organized.

Parameters:
iTunesKeepsOrganized - The boolean value as to whether or no iTunes keeps the iTunes music directory organized.
See Also:
isiTunesKeepsOrganized()

getBackgroundDelay

public long getBackgroundDelay()
Returns the set time delay for background monitoring the music directory folder. It is initially set to the default value in the FolderWatcher class.

Returns:
The time delay for background monitoring of the music directory. It is defaulted to the FolderWatcher default time delay.

getBackgroundDelayHours

public int getBackgroundDelayHours()
Returns the set time delay for background monitoring in hours.

Returns:
The amount of time between folder watching in background monitoring in hours.

setBackgroundDelay

public void setBackgroundDelay(long millisecs)
Changes the time delay to the specified value for background monitoring the music directory.

Parameters:
millisecs - The new time delay for background monitoring the music directory.

setBackgroundDelayHours

public void setBackgroundDelayHours(int hours)
Sets the background folder watching delay time to the given time in hours.

Parameters:
hours - The amount of time in hours between background folder monitoring.

isStartVisible

public boolean isStartVisible()
If true, iTunesDSM will start with a window visible to the user. Otherwise, the window is not visible.

Returns:
The boolean value as to whether or not to display the iTunesDSM window to the user on startup.

setStartVisible

public void setStartVisible(boolean startVisible)
Sets the value to start the iTunesDSM window visible to the user.

Parameters:
startVisible - If true, iTunesDSM will start with the window visible to the user.

isMinimizeToTrayWhenClose

public boolean isMinimizeToTrayWhenClose()
If true, the iTunesDSM window will not exit the system, rather it will hide the window from the user.

Returns:
If true, the iTunesDSM window will not exit the system, rather it will hide the window from the user.

setMinimizeToTrayWhenClose

public void setMinimizeToTrayWhenClose(boolean minimizeToTrayWhenClose)
Sets the closing behavior of iTunesDSM when the user closes the window. If true, the window will hide from the user rather than exiting the system.

Parameters:
minimizeToTrayWhenClose - If true, iTunesDSM will hide from the user rather than exiting the system.

isStartOnBoot

public boolean isStartOnBoot()
Sets whether or not to add the iTunesDSM.exe file shortcut to the startup folder in the user's start menu.

Returns:
The boolean as to whether or not to add the iTunesDSM.exe file to the user's startup folder in the start menu.

setStartOnBoot

public void setStartOnBoot(boolean startOnBoot)
Sets the boolean of starting iTunesDSM on boot.

Parameters:
startOnBoot - The boolean for starting for iTunesDSM on start on a windows system.

isAddTracksInBackgroundRunning

public boolean isAddTracksInBackgroundRunning()
Returns whether or not the boolean for background monitoring is running.

Returns:
Whether or not background monitoring is running or was running on a previous execution.

setAddTracksInBackgroundRunning

public void setAddTracksInBackgroundRunning(boolean addTracksInBackgroundRunning)
Sets the boolean value for background monitoring running.

Parameters:
addTracksInBackgroundRunning - The boolean value for whether or not background monitoring is running.

isAddTracksInBackgroundEnabled

public boolean isAddTracksInBackgroundEnabled()
Returns the boolean value as to whether or not iTunesDSM should monitor the music directory in the background for new tracks to add iTunes. It is defaulted to false.

Returns:
The boolean value as to whether or not iTunesDSM should monitor the music directory in the background for new tracks to add to iTunes.

setAddTracksInBackgroundEnabled

public void setAddTracksInBackgroundEnabled(boolean addTracksInBackground)
Changes the boolean value to the desired boolean as to whether or not iTunesDSM should monitor the music directory for new tracks to add to iTunes in the background.

Parameters:
addTracksInBackground - The boolean value as to whether or not iTunesDSM should monitor the music directory for new tracks to add to iTunes in the background.

isCheckForUpdate

public boolean isCheckForUpdate()
Returns the boolean value for whether or not to check for an update when the application starts.

Returns:
The boolean value to determine whether or not to check for an update when the application starts.

setCheckForUpdate

public void setCheckForUpdate(boolean checkForUpdate)
Sets the boolean value for whether or not to update check for an update to the application on start up.

Parameters:
checkForUpdate - The boolean value to set whether or not the applicatio will check for an update startup.

getMusicDirectories

public java.util.ArrayList<java.io.File> getMusicDirectories()
Returns the music directories.

Returns:
The music directories.

setMusicDirectories

public void setMusicDirectories(java.util.ArrayList<java.io.File> musicDirectories)
Sets the music directories to the given array list of directories.

Parameters:
musicDirectories - The music directories to set the Options object's music directories to.

addMusicDirectory

public void addMusicDirectory(java.io.File newMusicDir)
Add a new music directory to the array of music directories.

Parameters:
newMusicDir - The music directory to add to the array of music directories.

removeMusicDirectory

public void removeMusicDirectory(java.io.File musicDirToRemove)
Removes a directory from the array of music directories.

Parameters:
musicDirToRemove - The directory to remove from the array of music directories.

getChildDirectories

public static java.io.File[] getChildDirectories(java.util.ArrayList<java.io.File> allFoldersToGetRoots)
Returns an array of all the child folders given the array list of folders. This is useful for monitoring progress of a long task.

Parameters:
allFoldersToGetRoots - The array list of all directories to retrieve child folders from.
Returns:
Child folders of all the given directories. This is useful for monitoring progress in a long task.

getiTunesXMLMusicDir

public java.io.File getiTunesXMLMusicDir()
Returns the music directory iTunes stores music to by reading the iTunes XML file.

Returns:
The directory that iTunes stores music to.

setiTunesXMLMusicDir

public void setiTunesXMLMusicDir(java.io.File xmlMusicDir)
Sets the music directory that iTunes stores music in to a new directory.

Parameters:
xmlMusicDir - the new directory that iTunes stores music to.

setExtensions

public void setExtensions(java.lang.String[] ext)
Sets the extensions to a known set of extensions.

Parameters:
ext - the array of file extensions to set.

setExtensions

public void setExtensions(java.lang.String str)
Sets the extensions to a string that is parsed by an Extensions object. If the string fails to parse the extensions are set to null.

Parameters:
str - The string to parse file type extensions from.

getExtensions

public java.lang.String[] getExtensions()
Gets the file extensions to filter with.

Returns:
The array of extensions to filter files with.

getiTunesXMLFile

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

Returns:
The iTunes XML file.

setiTunesXMLFile

public void setiTunesXMLFile(java.io.File xmlFile)
Sets the iTunes XML file. The iTunes XML music directory is then set the location found within the XML file.

Parameters:
xmlFile - The iTunes XML file to set to.

setiTunesXMLFile

public void setiTunesXMLFile()
Sets the iTunes XML file to one that will be found by the user. The iTunes XML music directory is then updated with the new location in the xml file.


equals

public boolean equals(Options testOptions)
Tests whether two options objects are equal.

Parameters:
testOptions - The options object to test against.
Returns:
If true, the two options objects are equal.

isReady

public boolean isReady()
Returns a boolean value that is found by checking whether file extensions have been set, a music directory has been set by the user or read from the options file, and the iTunes Music Directory is known.

Returns:
the boolean value as to whether a music directory, file extensions, and the iTunes Music Directory have been set. This value is needed before adding or removing track tasks can be performed.

checkFileExists

public static void checkFileExists()
Checks that the options file exists. If it does not then a new options file is created.


toString

public java.lang.String toString()
Returns the Properties class toString method string.

Overrides:
toString in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Returns:
Returns the Properties class toString method string.

read

public static Options read()
Reads the xml properties file and loads a new Options object.

Returns:
The previously saved Options object stored to a properties xml file. If the file does not exists, the file is created but a new Options object is returned.

loadDefaultOptions

public static Options loadDefaultOptions()
Returns a default options object.

Returns:
A default options object.

write

public void write()
Outputs the Options object to a properties xml file.


addOptionsChangeListener

public void addOptionsChangeListener(OptionsChangeListener listener)
Adds an OptionsChangeListener to the options object.

Parameters:
listener - The listener to add to the Options object.

removeOptionsChangeListener

public void removeOptionsChangeListener(OptionsChangeListener listener)
Removes an OptionsChangeListener object from the Options object.

Parameters:
listener - The listener to remove from the Options object.

main

public static void main(java.lang.String[] args)