org.stanwood.media
Class Controller

java.lang.Object
  extended by org.stanwood.media.Controller

public class Controller
extends java.lang.Object

The controller is used to control access to the stores and and sources. This is a singleton class, and just first be setup using the @see initWithDefaults() or @see initFromConfigFile() methods. From then on, getInstance() can be called to a access the methods used to control stores and sources.


Constructor Summary
Controller(ConfigReader config)
          The constructor
 
Method Summary
 ExtensionInfo<? extends IAction> getActionInfo(java.lang.String id)
          Used to get information about a action
 java.util.List<ExtensionInfo<? extends IAction>> getAvalibaleActions()
          Used to get a list of possible actions that can be used with a media directory.
 java.util.List<ExtensionInfo<? extends ISource>> getAvalibaleSources()
          Used to get a list of possible sources that can be used with a media directory.
 java.util.List<ExtensionInfo<? extends IStore>> getAvalibaleStores()
          Used to get a list of possible stores that can be used with a media directory.
 java.io.File getConfigDir()
          Get the location of the media directory
 ExtensionInfo<? extends ISource> getDefaultSource(Mode mode)
          Used to get the default source information
 java.util.Collection<java.io.File> getMediaDirectories()
          Used to get a list of media directory locations
 java.util.List<MediaDirectory> getMediaDirectories(Mode type)
          Used to get a list of media directories of a given type
 MediaDirectory getMediaDirectory(java.io.File mediaDir)
          Used to convert a media directory location into the media directory object
 IMediaFileInfo getMediaFileInformation(java.io.File file)
          Used to get information on a media file
 java.io.File getNativeFolder()
          Used to find the native folder.
 SeenDatabase getSeenDB()
          Used to get the seen media file database
 ExtensionInfo<? extends ISource> getSourceInfo(java.lang.String id)
          Used to get information about a source
 ExtensionInfo<? extends IStore> getStoreInfo(java.lang.String id)
          Used to get information about a store
 java.util.Collection<WatchDirConfig> getWatchDirectories()
          Used to get a list of watch directory information
 XBMCAddonManager getXBMCAddonManager()
          Used to get the addon manager
 void init(boolean testMode)
          Used to setup the controller ready for use
 boolean isTestRun()
          Used to find out if test mode is been used.
 void registerExtension(ExtensionInfo<?> info)
          Used to register a extension.
static void setXBMCAddonManager(XBMCAddonManager xbmcAddonManager)
          Used to set the addon manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Controller

public Controller(ConfigReader config)
The constructor

Parameters:
config - The parsed configuration
Method Detail

init

public void init(boolean testMode)
          throws ConfigException
Used to setup the controller ready for use

Parameters:
testMode - If true then test mode is active and no changes are to be written to disk
Throws:
ConfigException - Thrown if their is a problem reading the configuration

registerExtension

public void registerExtension(ExtensionInfo<?> info)
Used to register a extension. Extensions can be sources, stores or actions.

Parameters:
info - The extension information

setXBMCAddonManager

public static void setXBMCAddonManager(XBMCAddonManager xbmcAddonManager)
Used to set the addon manager. Mostly used by tests

Parameters:
xbmcAddonManager - The addon manager

getXBMCAddonManager

public XBMCAddonManager getXBMCAddonManager()
Used to get the addon manager

Returns:
The addon manager

getMediaDirectory

public MediaDirectory getMediaDirectory(java.io.File mediaDir)
                                 throws ConfigException
Used to convert a media directory location into the media directory object

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

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 a list of watch directory information

Returns:
list of watch directory information

getSourceInfo

public ExtensionInfo<? extends ISource> getSourceInfo(java.lang.String id)
Used to get information about a source

Parameters:
id - The source id
Returns:
The extension information

getAvalibaleSources

public java.util.List<ExtensionInfo<? extends ISource>> getAvalibaleSources()
Used to get a list of possible sources that can be used with a media directory. This includes any that have been registered via plugins.

Returns:
The list of sources.

getAvalibaleStores

public java.util.List<ExtensionInfo<? extends IStore>> getAvalibaleStores()
Used to get a list of possible stores that can be used with a media directory. This includes any that have been registered via plugins.

Returns:
The list of sources.

getAvalibaleActions

public java.util.List<ExtensionInfo<? extends IAction>> getAvalibaleActions()
Used to get a list of possible actions that can be used with a media directory. This includes any that have been registered via plugins.

Returns:
The list of sources.

getStoreInfo

public ExtensionInfo<? extends IStore> getStoreInfo(java.lang.String id)
Used to get information about a store

Parameters:
id - The store id
Returns:
The extension information

getActionInfo

public ExtensionInfo<? extends IAction> getActionInfo(java.lang.String id)
Used to get information about a action

Parameters:
id - The action id
Returns:
The extension information

isTestRun

public boolean isTestRun()
Used to find out if test mode is been used. Test mode means that changes are not to be written to disk

Returns:
True if test mode, otherwise false

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

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

getDefaultSource

public ExtensionInfo<? extends ISource> getDefaultSource(Mode mode)
                                                  throws ConfigException
Used to get the default source information

Parameters:
mode - The mode to look for the source in
Returns:
The default source
Throws:
ConfigException - Thrown if unable to find a default source

getMediaDirectories

public java.util.List<MediaDirectory> getMediaDirectories(Mode type)
                                                   throws ConfigException
Used to get a list of media directories of a given type

Parameters:
type - The type
Returns:
The list of media Directories
Throws:
ConfigException - Thrown if their is a problem reading the config

getMediaFileInformation

public IMediaFileInfo getMediaFileInformation(java.io.File file)
                                       throws StanwoodException
Used to get information on a media file

Parameters:
file - The media file
Returns:
The information object. If this is a video file then it will be of type IVideoFileInfo.
Throws:
StanwoodException - Thrown if their are any problems

getSeenDB

public SeenDatabase getSeenDB()
                       throws ConfigException
Used to get the seen media file database

Returns:
The seen media file database
Throws:
ConfigException - Thrown if thier is a problem reading the database