org.jconfig.handler
Class InputStreamHandler

java.lang.Object
  extended byorg.jconfig.handler.AbstractHandler
      extended byorg.jconfig.handler.BaseXMLHandler
          extended byorg.jconfig.handler.InputStreamHandler
All Implemented Interfaces:
ConfigurationHandler, java.util.EventListener, FileListener

public class InputStreamHandler
extends BaseXMLHandler
implements ConfigurationHandler

This class is an implementation of the ConfigurationHandler interface. It tries to find the file with the given name inside the classpath with getClassLoader().getResourceAsStream(fileName). This handler is used as default by the ConfigurationManager.

Author:
Andreas Mecky andreas.mecky@xcom.de, Terry Dye terry.dye@xcom.de

Constructor Summary
InputStreamHandler()
          Default constructor
InputStreamHandler(java.lang.String filename)
          Constructor with filename
 
Method Summary
 java.io.File getFile()
          The File that should be "watched" for changes.
 Configuration load(java.lang.String configurationName)
          Loads the configuration from a xml file.
 Configuration load(java.lang.String configurationName, ConfigurationParser parser)
          This method will read in a file and generate the properties
 void setFileName(java.lang.String fileName)
          Sets the filename
 void setValidation(boolean validate)
          Defines if the xml file should be validated using a DTD or not.
 void store(Configuration configuration)
          This method should store all categories and properties.
 
Methods inherited from class org.jconfig.handler.BaseXMLHandler
getEncodingType, setEncoding, store
 
Methods inherited from class org.jconfig.handler.AbstractHandler
addFileListener, fileChanged, fireFireChangedEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputStreamHandler

public InputStreamHandler()
Default constructor


InputStreamHandler

public InputStreamHandler(java.lang.String filename)
Constructor with filename

Parameters:
filename -
Method Detail

setFileName

public void setFileName(java.lang.String fileName)
Sets the filename


setValidation

public void setValidation(boolean validate)
Defines if the xml file should be validated using a DTD or not. The default setting is false.


load

public Configuration load(java.lang.String configurationName)
                   throws ConfigurationManagerException
Loads the configuration from a xml file.

Specified by:
load in interface ConfigurationHandler
Parameters:
configurationName - the name of the configuration
Returns:
the Configuration
Throws:
ConfigurationManagerException

load

public Configuration load(java.lang.String configurationName,
                          ConfigurationParser parser)
                   throws ConfigurationManagerException
This method will read in a file and generate the properties

Specified by:
load in interface ConfigurationHandler
Parameters:
configurationName - the name of the configuration
parser - the parser that should be used
Returns:
the Configuration
Throws:
ConfigurationManagerException - if the file cannot be processed

store

public void store(Configuration configuration)
           throws ConfigurationManagerException
This method should store all categories and properties.

Specified by:
store in interface ConfigurationHandler
Parameters:
configuration - the Configuration that should be saved
Throws:
ConfigurationManagerException

getFile

public java.io.File getFile()
Description copied from class: AbstractHandler
The File that should be "watched" for changes.

Specified by:
getFile in class AbstractHandler
Returns:
The File object
See Also:
org.jconfig.handler.ConfigurationHandler#getFile()


Copyright © 2001-2005 Andreas Mecky, Terry Dye. All Rights Reserved.