org.fuin.kickstart4j
Class Config

java.lang.Object
  extended by org.fuin.kickstart4j.Config
All Implemented Interfaces:
SimpleAttributesEqualsCapable, org.fuin.utils4j.ToDebugStringCapable

public final class Config
extends Object
implements org.fuin.utils4j.ToDebugStringCapable, SimpleAttributesEqualsCapable

Configuration for the application. The cmdLineOptions map contains all arguments from the command line that are not known standard arguments. This way it's possible to add application specific parameters for the installation process. The entries userHome and destDir are predefined values.


Constructor Summary
Config()
          Default constructor.
 
Method Summary
 void check()
          Checks if the configuration is valid.
 SrcDir findSrcDir(String path)
          Find a source directory by it's path.
 SrcFile findSrcFile(String path, String filename)
          Find a source file by it's path and filename.
 Map getCmdLineOptions()
          Returns the options form the command line.
 String getConfigFileUrl()
          Returns the URL of the configuration file (only used when lazyLoading=true).
 URL getConfigFileURL()
          Returns the URL of the configuration file (only used when lazyLoading=true).
 String getDescription()
          Returns a short description of the application.
 File getDestDir()
          Returns the local destination path where the files should be copied to.
 String getDestPath()
          Returns the local destination path where the files should be copied to.
 String getIdFilename()
          Returns the unique id filename for the application.
 String getJavaArgs()
          Returns the command line arguments.
 String getJavaExe()
          Returns the Java executable.
 Locale getLocale()
          Returns the locale to use.
 String getLogFilename()
          Returns the name and path of the log file.
 String getLookAndFeelClassName()
          Returns the name of the LookAndFeel class.
 MessagesWrapper getMessages()
          Returns the message properties needed for the installer.
 List getMkDirs()
          Returns the list of directories to create.
 String getMsgFileUrl()
          Returns the file containing the localized installation messages.
 URL getMsgFileURL()
          Returns the file containing the localized installation messages.
 List getSrcDirs()
          Returns the list of known source directories.
 List getSrcFiles()
          Returns the list of known source files.
 int getStartFrameDelaySeconds()
          Show the start frame for N seconds after application has started.
 String getTitle()
          Returns the title of the application.
 String getVendor()
          Returns the vendor information.
 String getVersion()
          Returns the target application version.
 String getXmlEncoding()
          Returns the encoding to use for XML out.
 boolean isExitAfterExecute()
          Returns whether the program should terminate after executing.
 boolean isFirstInstallation()
          Determines if this is the first installation.
 boolean isLazyLoading()
          Returns if lazy loading is active.
 boolean isShowStartFrame()
          Show a "starting application" frame?
 boolean isSilentInstall()
          Determines if the user should be prompted for the destination directory.
 boolean isSilentUpdate()
          Determines if the user should be asked if an update is available.
 void replace(SrcFile oldSrcFile, SrcFile newSrcFile)
          Replaces a source file with another one.
 void setConfigFileUrl(String configFileUrl)
          Sets the URL of the configuration file (only used when lazyLoading=true).
 void setDescription(String description)
          Sets the short description of the application.
 void setDestPath(String destPath)
          Sets the local destination path where the files should be copied to.
 void setExitAfterExecute(boolean exitAfterExecute)
          Sets whether the program should terminate after executing.
 void setFirstInstallation(boolean firstInstallation)
          Determines if this is the first installation.
 void setIdFilename(String id)
          Sets the unique id filename for the application.
 void setJavaArgs(String javaArgs)
          Sets the command line arguments.
 void setJavaExe(String javaExe)
          Sets the Java executable.
 void setLazyLoading(boolean lazyLoading)
          Sets the information if lazy loading is active.
 void setLocale(Locale locale)
          Sets the locale to use.
 void setLocale(String locale)
          Sets the locale to use as a String.
 void setLogFilename(String logFilename)
          Sets the name and path of the log file.
 void setLookAndFeelClassName(String lnfClassName)
          Sets the name of the Look and Feel class.
 void setMsgFileUrl(String msgFileUrl)
          Sets the file containing the localized installation messages.
 void setShowStartFrame(boolean b)
          Show a "starting application" frame?
 void setSilentInstall(boolean silentInstall)
          Determines if the user should be prompted for the destination directory.
 void setSilentUpdate(boolean silentUpdate)
          Determines if the user should be asked if an update is available.
 void setStartFrameDelaySeconds(int seconds)
          Show the start frame for N seconds after application has started.
 void setTitle(String title)
          Sets the title of the application.
 void setVendor(String vendor)
          Sets the vendor information.
 void setVersion(String version)
          Sets the target application version.
 void setXmlEncoding(String encoding)
          Sets the encoding to use for XML out.
 boolean simpleAttributesEquals(Object obj)
          Determines if all simple attributes ( boolean, byte, short, int, long, float, double, char Boolean, Byte, Short, Integer, Long, Float, Double, Character and String ) of the object are equal to the fields of the other object (using the Object.equals(Object) method).
 String toDebugString()
          
 String toStaticXML()
          Returns the configuration as XML with all variables replaced with their values.
 String toString()
          
 String toVarXML()
          Returns the configuration as XML with no variables replaced.
 void writeToStaticXML(File configFile, boolean backup)
          Writes this configuration to an XML file with all variables replaced with their values.
 void writeToVarXML(File configFile, boolean backup)
          Writes this configuration to an XML file with no variables replaced.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Config

public Config()
Default constructor.

Method Detail

getLookAndFeelClassName

public final String getLookAndFeelClassName()
Returns the name of the LookAndFeel class.

Returns:
Fully qualified LnF class name - Always non-null.

setLookAndFeelClassName

public final void setLookAndFeelClassName(String lnfClassName)
Sets the name of the Look and Feel class.

Parameters:
lnfClassName - Full qualified Java LookAndFeel class name - System LookAndFeel is used when null.

isExitAfterExecute

public final boolean isExitAfterExecute()
Returns whether the program should terminate after executing.

Returns:
If the program terminates with System.exit(..) true (DEFAULT) else false.

setExitAfterExecute

public final void setExitAfterExecute(boolean exitAfterExecute)
Sets whether the program should terminate after executing.

Parameters:
exitAfterExecute - If the program should terminate with System.exit(..) true (DEFAULT) else false.

getDestDir

public final File getDestDir()
Returns the local destination path where the files should be copied to.

Returns:
Local path - Always non-null if check() throws no exceptions.

getDestPath

public final String getDestPath()
Returns the local destination path where the files should be copied to.

Returns:
Path.

setDestPath

public final void setDestPath(String destPath)
Sets the local destination path where the files should be copied to.

Parameters:
destPath - Path - Cannot be null

getIdFilename

public final String getIdFilename()
Returns the unique id filename for the application.

Returns:
Name of the application ID file - Always non-null if check() throws no exceptions.

setIdFilename

public final void setIdFilename(String id)
Sets the unique id filename for the application.

Parameters:
id - Unique ID - Must be a valid filename on the target system - A null value is not allowed!

isSilentInstall

public final boolean isSilentInstall()
Determines if the user should be prompted for the destination directory.

Returns:
If "destDir" should be used without asking the user true else false.

setSilentInstall

public final void setSilentInstall(boolean silentInstall)
Determines if the user should be prompted for the destination directory.

Parameters:
silentInstall - If "destDir" should be used without asking the user true else false.

isSilentUpdate

public final boolean isSilentUpdate()
Determines if the user should be asked if an update is available.

Returns:
If updates should be executed without asking the user true else false.

setSilentUpdate

public final void setSilentUpdate(boolean silentUpdate)
Determines if the user should be asked if an update is available.

Parameters:
silentUpdate - If updates should be executed without asking the user true else false.

isFirstInstallation

public final boolean isFirstInstallation()
Determines if this is the first installation.

Returns:
If this is the first installation true else false.

setFirstInstallation

public final void setFirstInstallation(boolean firstInstallation)
Determines if this is the first installation.

Parameters:
firstInstallation - If this is the first installation true else false.

getLocale

public final Locale getLocale()
Returns the locale to use.

Returns:
Locale - Always non-null.

setLocale

public final void setLocale(Locale locale)
Sets the locale to use.

Parameters:
locale - Locale to set - A null value resets the property to Locale.getDefault().

setLocale

public final void setLocale(String locale)
Sets the locale to use as a String.

Parameters:
locale - Locale "lang" or "lang,country" or "lang,country,variant" - A null value resets the property to Locale.getDefault().

getMsgFileUrl

public final String getMsgFileUrl()
Returns the file containing the localized installation messages.

Returns:
Message file URL - If null the internal default messages will be used.

getMsgFileURL

public final URL getMsgFileURL()
Returns the file containing the localized installation messages. A MalformedURLException is wrapped into a RuntimeException.

Returns:
Message file URL - If null the internal default messages will be used.

setMsgFileUrl

public final void setMsgFileUrl(String msgFileUrl)
Sets the file containing the localized installation messages.

Parameters:
msgFileUrl - Message file URL - A null value will result in usage of the internal default messages.

check

public final void check()
                 throws InvalidConfigException
Checks if the configuration is valid.

Throws:
InvalidConfigException - The configuration is not valid.

getMessages

public final MessagesWrapper getMessages()
Returns the message properties needed for the installer.

Returns:
Localized messages.

isLazyLoading

public final boolean isLazyLoading()
Returns if lazy loading is active.

Returns:
If lazy loading is enabled true else false.

setLazyLoading

public final void setLazyLoading(boolean lazyLoading)
Sets the information if lazy loading is active.

Parameters:
lazyLoading - To enable lazy loading true else false (disable lazy loading)).

getCmdLineOptions

public final Map getCmdLineOptions()
Returns the options form the command line.

Returns:
Key/value String pairs.

getJavaArgs

public final String getJavaArgs()
Returns the command line arguments.

Returns:
Arguments for the Java executable.

setJavaArgs

public final void setJavaArgs(String javaArgs)
Sets the command line arguments.

Parameters:
javaArgs - Arguments for the Java executable.

getJavaExe

public final String getJavaExe()
Returns the Java executable.

Returns:
Java executable.

setJavaExe

public final void setJavaExe(String javaExe)
Sets the Java executable.

Parameters:
javaExe - Java executable.

getDescription

public final String getDescription()
Returns a short description of the application.

Returns:
Description.

setDescription

public final void setDescription(String description)
Sets the short description of the application.

Parameters:
description - Description.

getTitle

public final String getTitle()
Returns the title of the application.

Returns:
Title.

setTitle

public final void setTitle(String title)
Sets the title of the application.

Parameters:
title - Title.

getVendor

public final String getVendor()
Returns the vendor information.

Returns:
Vendor.

setVendor

public final void setVendor(String vendor)
Sets the vendor information.

Parameters:
vendor - Vendor.

getSrcFiles

public final List getSrcFiles()
Returns the list of known source files.

Returns:
List of SrcFile objects.

getMkDirs

public final List getMkDirs()
Returns the list of directories to create.

Returns:
List of MkDir objects.

getSrcDirs

public final List getSrcDirs()
Returns the list of known source directories.

Returns:
List of SrcDir objects.

getConfigFileUrl

public final String getConfigFileUrl()
Returns the URL of the configuration file (only used when lazyLoading=true).

Returns:
URL or null.

getConfigFileURL

public final URL getConfigFileURL()
Returns the URL of the configuration file (only used when lazyLoading=true).

Returns:
URL or null.

setConfigFileUrl

public final void setConfigFileUrl(String configFileUrl)
Sets the URL of the configuration file (only used when lazyLoading=true).

Parameters:
configFileUrl - URL or null.

getVersion

public final String getVersion()
Returns the target application version.

Returns:
Version or null if not set.

setVersion

public final void setVersion(String version)
Sets the target application version.

Parameters:
version - Version or null.

getXmlEncoding

public final String getXmlEncoding()
Returns the encoding to use for XML out.

Returns:
Encoding like "ISO-8859-1" (default) or "UTF-8".

setXmlEncoding

public final void setXmlEncoding(String encoding)
Sets the encoding to use for XML out.

Parameters:
encoding - Encoding like "ISO-8859-1" (default) or "UTF-8".

isShowStartFrame

public final boolean isShowStartFrame()
Show a "starting application" frame?

Returns:
If a frame will be displayed true (default) else false.

setShowStartFrame

public final void setShowStartFrame(boolean b)
Show a "starting application" frame?

Parameters:
b - If a frame should be displayed true else false.

getStartFrameDelaySeconds

public final int getStartFrameDelaySeconds()
Show the start frame for N seconds after application has started.

Returns:
Seconds (Default = 2)

setStartFrameDelaySeconds

public final void setStartFrameDelaySeconds(int seconds)
Show the start frame for N seconds after application has started.

Parameters:
seconds - Number of seconds.

getLogFilename

public final String getLogFilename()
Returns the name and path of the log file.

Returns:
Name and path of log file - ALways non-null.

setLogFilename

public final void setLogFilename(String logFilename)
Sets the name and path of the log file.

Parameters:
logFilename - Log filename - A null value will set the name to "kickstart4j.log".

findSrcFile

public final SrcFile findSrcFile(String path,
                                 String filename)
                          throws SrcFileNotFoundException
Find a source file by it's path and filename.

Parameters:
path - Path - Cannot be null but empty.
filename - Filename to find - Cannot be null.
Returns:
Source file - Always non-null.
Throws:
SrcFileNotFoundException - The file was not found.

findSrcDir

public final SrcDir findSrcDir(String path)
                        throws SrcDirNotFoundException
Find a source directory by it's path.

Parameters:
path - Path - Cannot be null but empty.
Returns:
Source directory - Always non-null.
Throws:
SrcDirNotFoundException - The directory was not found.

replace

public final void replace(SrcFile oldSrcFile,
                          SrcFile newSrcFile)
Replaces a source file with another one.

Parameters:
oldSrcFile - Source file to replace.
newSrcFile - File to insert.

toStaticXML

public final String toStaticXML()
Returns the configuration as XML with all variables replaced with their values.

Returns:
XML configuration.

toVarXML

public final String toVarXML()
Returns the configuration as XML with no variables replaced.

Returns:
XML configuration.

toString

public final String toString()

Overrides:
toString in class Object

toDebugString

public final String toDebugString()

Specified by:
toDebugString in interface org.fuin.utils4j.ToDebugStringCapable

writeToVarXML

public final void writeToVarXML(File configFile,
                                boolean backup)
                         throws IOException
Writes this configuration to an XML file with no variables replaced.

Parameters:
configFile - Target file.
backup - Create a backup if this file already exists (same filename but with ".bak" extension).
Throws:
IOException - Error writing the file.

writeToStaticXML

public final void writeToStaticXML(File configFile,
                                   boolean backup)
                            throws IOException
Writes this configuration to an XML file with all variables replaced with their values.

Parameters:
configFile - Target file.
backup - Create a backup if this file already exists (same filename but with ".bak" extension).
Throws:
IOException - Error writing the file.

simpleAttributesEquals

public final boolean simpleAttributesEquals(Object obj)
Determines if all simple attributes ( boolean, byte, short, int, long, float, double, char Boolean, Byte, Short, Integer, Long, Float, Double, Character and String ) of the object are equal to the fields of the other object (using the Object.equals(Object) method). No complex types like lists, maps or sub-objects will be compared.

Specified by:
simpleAttributesEquals in interface SimpleAttributesEqualsCapable
Parameters:
obj - Object to compare with. If null or not an instance of this class then false will be returned.
Returns:
If all simple attributes are equal true else false.


Copyright © 2011 Future Invent Informationsmanagement GmbH. All Rights Reserved.