org.stanwood.media.setup
Class ConfigReader

java.lang.Object
  extended by org.stanwood.media.xml.XMLParser
      extended by org.stanwood.media.setup.BaseConfigReader
          extended by org.stanwood.media.setup.ConfigReader

public class ConfigReader
extends BaseConfigReader

This is used to parse the XML configuration files. These are used to tell the application which stores and sources should be used. Strings in config file can contain variables which get evaulated with the configuration is read.


Field Summary
static java.lang.String CONFIG_NAME
          Default file name of config file
 
Fields inherited from class org.stanwood.media.xml.XMLParser
DTD_WEB_LOCATION, SCHEMA_WEB_LOCATION
 
Constructor Summary
ConfigReader(java.io.InputStream is)
          The constructor used to create a instance of the configuration reader
 
Method Summary
 java.io.File getConfigDir()
          Get the location of the media directory
static java.io.File getDefaultConfigDir()
          Used to get the default location of the media manager configuration directory
static java.io.File getDefaultConfigFile()
          Used to the default configuration filename
 java.util.Collection<java.io.File> getMediaDirectories()
          Used to get a list of media directory locations
 MediaDirConfig getMediaDirectory(java.io.File directory)
          Used to get the configuration for a root media directory
 java.io.File getNativeFolder()
          Used to find the native folder.
 java.util.List<Plugin> getPlugins()
          Used to get a list of plugins
 java.util.Collection<WatchDirConfig> getWatchDirectories()
          Used to get the watched directory configuration information
 java.io.File getXBMCAddonDir()
          Used to get the directory where XBMC addons are installed.
 java.lang.String getXBMCAddonSiteUrl()
          Used to get the addon site url
 java.util.Locale getXBMCLocale()
          Used to get the locale that should be used when fetching media information from XBMC Addons.
 java.util.List<IAction> loadActionsFromConfigFile(Controller controller, MediaDirConfig dirConfig)
          Used to read the actions from the configuration file
 java.util.List<ISource> loadSourcesFromConfigFile(Controller controller, MediaDirConfig dirConfig)
          Used to read the sources from the configuration file
 java.util.List<IStore> loadStoresFromConfigFile(Controller controller, MediaDirConfig dirConfig)
          Used to read the stores from the configuration file
 void parse()
          This will parse the configuration in the XML configuration file and store the results in this class.
protected  void witeBaseMediaDirSubItem(java.lang.StringBuilder document, SourceConfig subItem)
           
 void writeConfig(IProgressMonitor monitor, java.io.File file)
          Write the configuration to a file
 
Methods inherited from class org.stanwood.media.xml.XMLParser
createDocBuilder, createFactory, deleteNode, domToStr, encodeAttributeValue, firstChild, getAttribute, getElement, getFirstChildElement, getFloatFromXML, getIntegerFromXML, getLastChildElement, getLongFromXML, getSchema, getStringFromXML, getStringFromXMLOrNull, getURLFromXML, getURLFromXMLOrNull, hasNode, parse, parse, parse, quoteXPathQuery, selectChildNodes, selectNodeList, selectSingleNode, strToDom, strToDom, strToDom, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_NAME

public static final java.lang.String CONFIG_NAME
Default file name of config file

See Also:
Constant Field Values
Constructor Detail

ConfigReader

public ConfigReader(java.io.InputStream is)
The constructor used to create a instance of the configuration reader

Parameters:
is - The configuration file input stream
Method Detail

parse

public void parse()
           throws ConfigException
This will parse the configuration in the XML configuration file and store the results in this class.

Throws:
ConfigException - Thrown if their is a problem parsing the file

witeBaseMediaDirSubItem

protected void witeBaseMediaDirSubItem(java.lang.StringBuilder document,
                                       SourceConfig subItem)

getMediaDirectory

public MediaDirConfig getMediaDirectory(java.io.File directory)
                                 throws ConfigException
Used to get the configuration for a root media directory

Parameters:
directory - the root media directory
Returns:
The configuration
Throws:
ConfigException - Thrown if the configuration can't be found

loadSourcesFromConfigFile

public java.util.List<ISource> loadSourcesFromConfigFile(Controller controller,
                                                         MediaDirConfig dirConfig)
                                                  throws ConfigException
Used to read the sources from the configuration file

Parameters:
controller - The media controller
dirConfig - The media directory configuration
Returns:
Thrown if their are any problems
Throws:
ConfigException - Thrown if their are any problems

loadStoresFromConfigFile

public java.util.List<IStore> loadStoresFromConfigFile(Controller controller,
                                                       MediaDirConfig dirConfig)
                                                throws ConfigException
Used to read the stores from the configuration file

Parameters:
controller - The media controller
dirConfig - The media directory configuration
Returns:
The stores
Throws:
ConfigException - Thrown if their is any problems

loadActionsFromConfigFile

public java.util.List<IAction> loadActionsFromConfigFile(Controller controller,
                                                         MediaDirConfig dirConfig)
                                                  throws ConfigException
Used to read the actions from the configuration file

Parameters:
controller - The media controller
dirConfig - The media directory configuration
Returns:
The actions
Throws:
ConfigException - Thrown if their is any problems

getXBMCAddonDir

public java.io.File getXBMCAddonDir()
                             throws ConfigException
Used to get the directory where XBMC addons are installed. If one has not been specified in the configuration, then a default on is used instead of $HOME/.mediaManager/xbmc/addons.

Returns:
The XBMC addon directory
Throws:
ConfigException - Thrown if their is a problem

getConfigDir

public java.io.File getConfigDir()
                          throws ConfigException
Get the location of the media directory

Returns:
The location of the media directory
Throws:
ConfigException - Thrown if their is a problem

getDefaultConfigDir

public static java.io.File getDefaultConfigDir()
                                        throws ConfigException
Used to get the default location of the media manager configuration directory

Returns:
the default location of the media manager configuration directory
Throws:
ConfigException - Thrown if their is a problem

getXBMCLocale

public java.util.Locale getXBMCLocale()
Used to get the locale that should be used when fetching media information from XBMC Addons.

Returns:
The locale

getPlugins

public java.util.List<Plugin> getPlugins()
Used to get a list of plugins

Returns:
a list of plugins

getDefaultConfigFile

public static java.io.File getDefaultConfigFile()
                                         throws ConfigException
Used to the default configuration filename

Returns:
The default configuration filename
Throws:
ConfigException - Thrown if their are any problems

getMediaDirectories

public java.util.Collection<java.io.File> getMediaDirectories()
Used to get a list of media directory locations

Returns:
Media directory locations

getWatchDirectories

public java.util.Collection<WatchDirConfig> getWatchDirectories()
Used to get the watched directory configuration information

Returns:
The watched directories

getNativeFolder

public java.io.File getNativeFolder()
Used to find the native folder. Null is returend if it could not be found

Returns:
The native folder, or null if not found

getXBMCAddonSiteUrl

public java.lang.String getXBMCAddonSiteUrl()
Used to get the addon site url

Returns:
the addon site url

writeConfig

public void writeConfig(IProgressMonitor monitor,
                        java.io.File file)
                 throws ConfigException
Write the configuration to a file

Parameters:
monitor - The progress monitor
file - File to save the configuration to
Throws:
ConfigException - Thrown if their is a problem