Class AbstractModule
- java.lang.Object
-
- org.jfree.base.modules.DefaultModuleInfo
-
- org.jfree.base.modules.AbstractModule
-
- All Implemented Interfaces:
Module,ModuleInfo
- Direct Known Subclasses:
DefaultLogModule
public abstract class AbstractModule extends DefaultModuleInfo implements Module
The abstract module provides a default implementation of the module interface.The module can be specified in an external property file. The file name of this specification defaults to "module.properties". This file is no real property file, it follows a more complex rule set.
Lines starting with '#' are considered comments. Section headers start at the beginning of the line, section properties are indented with at least one whitespace.
The first section is always the module info and contains the basic module properties like name, version and a short description.
module-info: name: xls-export-gui producer: The JFreeReport project - www.jfree.org/jfreereport description: A dialog component for the Excel table export. version.major: 0 version.minor: 84 version.patchlevel: 0
The properties name, producer and description are simple strings. They may span multiple lines, but may not contain a colon (':'). The version properties are integer values.This section may be followed by one or more "depends" sections. These sections describe the base modules that are required to be active to make this module work. The package manager will enforce this policy and will deactivate this module if one of the base modules is missing.
depends: module: org.jfree.report.modules.output.table.xls.XLSTableModule version.major: 0 version.minor: 84
The property module references to the module implementation of the module package.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAbstractModule.ReaderHelperThe reader helper provides a pushback interface for the reader to read and buffer complete lines.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringdescriptionA short description of the module.private java.lang.StringnameThe name of the module.private ModuleInfo[]optionalModulesThe list of optional modules.private java.lang.StringproducerThe name of the module producer.private ModuleInfo[]requiredModulesThe list of required modules.private java.lang.StringsubsystemThe modules subsystem.
-
Constructor Summary
Constructors Constructor Description AbstractModule()Default Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidconfigure(SubSystem subSystem)Configures the module by loading the configuration properties and adding them to the package configuration.java.lang.StringgetDescription()Returns the module description.java.lang.StringgetName()Returns the name of this module.ModuleInfo[]getOptionalModules()Returns a copy of the required modules array.java.lang.StringgetProducer()Returns the producer of the module.ModuleInfo[]getRequiredModules()Returns a copy of the required modules array.java.lang.StringgetSubSystem()Returns the modules subsystem.protected static booleanisClassLoadable(java.lang.String name)Deprecated.use the method that passes in a context-class.protected static booleanisClassLoadable(java.lang.String name, java.lang.Class context)Tries to load a class to indirectly check for the existence of a certain library.private booleanisNextLineValueLine(AbstractModule.ReaderHelper reader)Checks, whether the next line in the reader is a value line.protected voidloadModuleInfo()Loads the default module description from the file "module.properties".protected voidloadModuleInfo(java.io.InputStream in)Loads the module descriptiong from the given input stream.private java.lang.StringparseKey(java.lang.String line)Parses an string to find the key section of the line.private java.lang.StringparseValue(java.lang.String line)Parses the value section of the given line.protected voidperformExternalInitialize(java.lang.String classname)Deprecated.Use the method that provides a class-context instead.protected voidperformExternalInitialize(java.lang.String classname, java.lang.Class context)???.private DefaultModuleInforeadExternalModule(AbstractModule.ReaderHelper reader)Reads an external module description.private voidreadModuleInfo(AbstractModule.ReaderHelper reader)Reads the module definition header.private java.lang.StringreadValue(AbstractModule.ReaderHelper reader, java.lang.String firstLine)Reads a multiline value the stream.protected voidsetDescription(java.lang.String description)Defines the description of the module.protected voidsetName(java.lang.String name)Defines the name of the module.voidsetOptionalModules(ModuleInfo[] optionalModules)Defines the optional module descriptions for this module.protected voidsetProducer(java.lang.String producer)Defines the producer of the module.protected voidsetRequiredModules(ModuleInfo[] requiredModules)Defines the required module descriptions for this module.protected voidsetSubSystem(java.lang.String name)Defines the subsystem name for this module.java.lang.StringtoString()Returns a string representation of this module.-
Methods inherited from class org.jfree.base.modules.DefaultModuleInfo
equals, getMajorVersion, getMinorVersion, getModuleClass, getPatchLevel, hashCode, setMajorVersion, setMinorVersion, setModuleClass, setPatchLevel
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jfree.base.modules.Module
initialize
-
Methods inherited from interface org.jfree.base.modules.ModuleInfo
getMajorVersion, getMinorVersion, getModuleClass, getPatchLevel
-
-
-
-
Field Detail
-
requiredModules
private ModuleInfo[] requiredModules
The list of required modules.
-
optionalModules
private ModuleInfo[] optionalModules
The list of optional modules.
-
name
private java.lang.String name
The name of the module.
-
description
private java.lang.String description
A short description of the module.
-
producer
private java.lang.String producer
The name of the module producer.
-
subsystem
private java.lang.String subsystem
The modules subsystem.
-
-
Method Detail
-
loadModuleInfo
protected void loadModuleInfo() throws ModuleInitializeExceptionLoads the default module description from the file "module.properties". This file must be in the same package as the implementing class.- Throws:
ModuleInitializeException- if an error occurs.
-
loadModuleInfo
protected void loadModuleInfo(java.io.InputStream in) throws ModuleInitializeExceptionLoads the module descriptiong from the given input stream. The module description must conform to the rules define in the class description. The file must be encoded with "ISO-8859-1" (like property files).- Parameters:
in- the input stream from where to read the file- Throws:
ModuleInitializeException- if an error occurs.
-
readValue
private java.lang.String readValue(AbstractModule.ReaderHelper reader, java.lang.String firstLine) throws java.io.IOException
Reads a multiline value the stream. This will read the stream until a new key is found or the end of the file is reached.- Parameters:
reader- the reader from where to read.firstLine- the first line (which was read elsewhere).- Returns:
- the complete value, never null
- Throws:
java.io.IOException- if an IO error occurs.
-
isNextLineValueLine
private boolean isNextLineValueLine(AbstractModule.ReaderHelper reader) throws java.io.IOException
Checks, whether the next line in the reader is a value line.- Parameters:
reader- from where to read the lines.- Returns:
- true, if the next line is a value line, false otherwise.
- Throws:
java.io.IOException- if an IO error occurs.
-
readModuleInfo
private void readModuleInfo(AbstractModule.ReaderHelper reader) throws java.io.IOException
Reads the module definition header. This header contains information about the module itself.- Parameters:
reader- the reader from where to read the content.- Throws:
java.io.IOException- if an error occures
-
parseKey
private java.lang.String parseKey(java.lang.String line)
Parses an string to find the key section of the line. This section ends with an colon.- Parameters:
line- the line which to parse- Returns:
- the key or null if no key is found.
-
parseValue
private java.lang.String parseValue(java.lang.String line)
Parses the value section of the given line.- Parameters:
line- the line that should be parsed- Returns:
- the value, never null
-
readExternalModule
private DefaultModuleInfo readExternalModule(AbstractModule.ReaderHelper reader) throws java.io.IOException
Reads an external module description. This describes either an optional or a required module.- Parameters:
reader- the reader from where to read the module- Returns:
- the read module, never null
- Throws:
java.io.IOException- if an error occures.
-
getName
public java.lang.String getName()
Returns the name of this module.- Specified by:
getNamein interfaceModule- Returns:
- the module name
- See Also:
Module.getName()
-
setName
protected void setName(java.lang.String name)
Defines the name of the module.- Parameters:
name- the module name.
-
getDescription
public java.lang.String getDescription()
Returns the module description.- Specified by:
getDescriptionin interfaceModule- Returns:
- the description of the module.
- See Also:
Module.getDescription()
-
setDescription
protected void setDescription(java.lang.String description)
Defines the description of the module.- Parameters:
description- the module's desciption.
-
getProducer
public java.lang.String getProducer()
Returns the producer of the module.- Specified by:
getProducerin interfaceModule- Returns:
- the producer.
- See Also:
Module.getProducer()
-
setProducer
protected void setProducer(java.lang.String producer)
Defines the producer of the module.- Parameters:
producer- the producer.
-
getRequiredModules
public ModuleInfo[] getRequiredModules()
Returns a copy of the required modules array. This array contains all description of the modules that need to be present to make this module work.- Specified by:
getRequiredModulesin interfaceModule- Returns:
- an array of all required modules.
- See Also:
Module.getRequiredModules()
-
getOptionalModules
public ModuleInfo[] getOptionalModules()
Returns a copy of the required modules array. This array contains all description of the optional modules that may improve the modules functonality.- Specified by:
getOptionalModulesin interfaceModule- Returns:
- an array of all required modules.
- See Also:
Module.getRequiredModules()
-
setRequiredModules
protected void setRequiredModules(ModuleInfo[] requiredModules)
Defines the required module descriptions for this module.- Parameters:
requiredModules- the required modules.
-
setOptionalModules
public void setOptionalModules(ModuleInfo[] optionalModules)
Defines the optional module descriptions for this module.- Parameters:
optionalModules- the optional modules.
-
toString
public java.lang.String toString()
Returns a string representation of this module.- Overrides:
toStringin classDefaultModuleInfo- Returns:
- the string representation of this module for debugging purposes.
- See Also:
Object.toString()
-
isClassLoadable
protected static boolean isClassLoadable(java.lang.String name)
Deprecated.use the method that passes in a context-class.Tries to load a class to indirectly check for the existence of a certain library.- Parameters:
name- the name of the library class.- Returns:
- true, if the class could be loaded, false otherwise.
-
isClassLoadable
protected static boolean isClassLoadable(java.lang.String name, java.lang.Class context)Tries to load a class to indirectly check for the existence of a certain library.- Parameters:
name- the name of the library class.context- the context class to get a classloader from.- Returns:
- true, if the class could be loaded, false otherwise.
-
configure
public void configure(SubSystem subSystem)
Configures the module by loading the configuration properties and adding them to the package configuration.
-
performExternalInitialize
protected void performExternalInitialize(java.lang.String classname) throws ModuleInitializeExceptionDeprecated.Use the method that provides a class-context instead.Tries to load an module initializer and uses this initializer to initialize the module.- Parameters:
classname- the class name of the initializer.- Throws:
ModuleInitializeException- if an error occures
-
performExternalInitialize
protected void performExternalInitialize(java.lang.String classname, java.lang.Class context) throws ModuleInitializeException???.- Parameters:
classname- ?context- ?- Throws:
ModuleInitializeException- if there is an initialisation error.
-
getSubSystem
public java.lang.String getSubSystem()
Returns the modules subsystem. If this module is not part of an subsystem then return the modules name, but never null.- Specified by:
getSubSystemin interfaceModule- Returns:
- the name of the subsystem.
-
setSubSystem
protected void setSubSystem(java.lang.String name)
Defines the subsystem name for this module.- Parameters:
name- the new name of the subsystem.
-
-