public class ConfigManager extends Object
| Modifier and Type | Field and Description |
|---|---|
private String |
configFileName |
private String |
configSchema |
private static ConfigManager |
currentConfigManager |
static File |
DEFAULT_IQM_CONF_DIR |
static File |
DEFAULT_IQM_ROOT_DIR |
static File |
DEFAULT_IQM_SCRIPT_DIR |
static File |
DEFAULT_IQM_TEMP_DIR |
private InputStream |
defaultConfigFileIS |
private ArrayList<String> |
errorMsgs |
private IQMConfig |
iqmConfiguration |
private JAXBContext |
jaxbContext |
private static org.apache.log4j.Logger |
logger |
private Marshaller |
marshaller |
private Unmarshaller |
unmarshaller |
static String |
USER_HOME |
private File |
xmlConfigFile |
private File |
xmlSchemaFile |
private InputStream |
xmlSchemaFileIS |
| Modifier | Constructor and Description |
|---|---|
private |
ConfigManager()
Create a new instance of the configuration manager.
|
| Modifier and Type | Method and Description |
|---|---|
private String |
extractSingleVariable(String s,
ArrayList<String> envVarList)
Extract all keys from referenced environment variables from a given
String
s. |
File |
getConfPath()
Get the currently configured configuration file path as file object.
|
static ConfigManager |
getCurrentInstance() |
private IQMConfig |
getDefaultIQMConfig()
Constructs a default configuration with the standard values for starting
up the application.
|
File |
getDefaultIqmConfPath() |
File |
getDefaultIqmRootPath() |
File |
getDefaultIqmScriptPath() |
File |
getDefaultIqmTempPath() |
String |
getDefaultUserHome() |
File |
getImagePath()
Get the currently configured image path as file object.
|
IQMConfig |
getIQMConfig()
Gets the applications configuration, it constructs a default one, if it
is null.
|
boolean |
getKeepExistingROIs()
Get a flag, whether or not the existing ROIs should be kept while drawing
new ones.
|
File |
getRootPath()
Get the currently configured root file path as file object.
|
File |
getScriptPath()
Get the currently configured path to the script directory.
|
File |
getTempPath()
Get the currently configured temporary file path.
|
File |
getXmlSchemaFile() |
private void |
loadDefaultConfiguration() |
private void |
loadXMLConfiguration(File xmlFile)
Loads a configuration from an existing XML file.
|
private void |
loadXMLConfiguration(InputStream is)
Loads a configuration from an existing XML file.
|
private String |
parseEnvVars(String original)
This method gets the names of the environment variables from a specified
String
s. |
private String |
resolve(String original,
ArrayList<String> envVars)
Resolves the path from a list of environment variables.
|
void |
setConfPath(File path)
Updates the current configuration file with the specified
path for the IQM configuration. |
void |
setConfPath(String path)
Updates the current configuration file with the specified
path for the IQM configuration. |
void |
setImagePath(File path)
Updates the current configuration file with the specified
path for the images. |
void |
setImagePath(String path)
Updates the current configuration file with the specified
path for the images. |
void |
setKeepExistingROIs(boolean value)
Set the flag, whether or not the existing ROIs should be kept while
drawing new ones.
|
private void |
setLastUpdate()
Each time the configuration is updated, write the time stamp too.
|
void |
setRootPath(File path)
Updates the current configuration file with the specified
path for the IQM root. |
void |
setRootPath(String path)
Updates the current configuration file with the specified
path for the IQM root. |
void |
setScriptPath(File path)
Updates the current configuration file with the specified
path for the IQM configuration. |
void |
setScriptPath(String path)
Updates the current configuration file with the specified
path for the IQM configuration. |
void |
setTempPath(File path)
Updates the current configuration file with the specified
path for temporary files. |
void |
setTempPath(String path)
Updates the current configuration file with the specified
path for temporary files. |
void |
setXmlSchemaFile(File xmlSchemaFile) |
private void |
validate()
Validates the configuration file against the defined schema.
|
void |
validateAndSetConfiguration()
Collects configuration violations and stores it in a
List<String> of error messages. |
void |
write()
Store the current configuration to the config file.
|
private void |
writeDefaultXMLConfiguration()
Writes a new default XML configuration file to the specified path in the
file system.
|
private void |
writeXMLConfiguration()
Writes an XML configuration file to the specified path in the file
system.
|
private static final org.apache.log4j.Logger logger
private static ConfigManager currentConfigManager
public static final String USER_HOME
public static final File DEFAULT_IQM_ROOT_DIR
public static final File DEFAULT_IQM_TEMP_DIR
public static final File DEFAULT_IQM_CONF_DIR
public static final File DEFAULT_IQM_SCRIPT_DIR
private final String configFileName
private final String configSchema
private InputStream defaultConfigFileIS
private File xmlConfigFile
private File xmlSchemaFile
private InputStream xmlSchemaFileIS
private JAXBContext jaxbContext
private Marshaller marshaller
private Unmarshaller unmarshaller
private IQMConfig iqmConfiguration
private ConfigManager()
throws JAXBException
JAXBExceptionprivate void loadDefaultConfiguration()
throws JAXBException
JAXBExceptionpublic void validateAndSetConfiguration()
throws Exception
List<String> of error messages. If there are some
errors, throw new Exception and print error messages to log
file.Exception - - if the configuration is invalidprivate void loadXMLConfiguration(File xmlFile) throws JAXBException, Exception
JAXBException - - if the XML file does not comply with the schemaExceptionprivate void loadXMLConfiguration(InputStream is) throws JAXBException
JAXBException - - if the XML file does not comply with the schemaprivate void validate()
private void writeDefaultXMLConfiguration()
public void write()
private void writeXMLConfiguration()
public File getXmlSchemaFile()
public void setXmlSchemaFile(File xmlSchemaFile)
xmlSchemaFile - the xmlSchemaFile to setpublic IQMConfig getIQMConfig()
private IQMConfig getDefaultIQMConfig()
private String parseEnvVars(String original) throws EnvVariableNotFoundException
s.original - - the string from the configuration fileEnvVariableNotFoundException - if a specified environment variable cannot be foundprivate String extractSingleVariable(String s, ArrayList<String> envVarList)
s. This method works recursivelys - - the String toenvVarList - private String resolve(String original, ArrayList<String> envVars) throws EnvVariableNotFoundException
original - - the original stringenvVars - - the list of variable keysEnvVariableNotFoundException - - if one of the keys is not availablepublic File getScriptPath()
public File getTempPath()
public File getImagePath()
public File getRootPath()
public File getConfPath()
public void setTempPath(String path)
path for temporary files.path - - temporary file storepublic void setTempPath(File path)
path for temporary files.path - - temporary file storepublic void setImagePath(String path)
path for the images.path - - last used image pathpublic void setImagePath(File path)
path for the images.path - - last used image pathpublic void setRootPath(String path)
path for the IQM root.path - - path to the root where the application has writing
permissionspublic void setRootPath(File path)
path for the IQM root.path - - path to the root where the application has writing
permissionspublic void setConfPath(String path)
path for the IQM configuration.path - - path to the configuration files where the application has
writing permissionspublic void setConfPath(File path)
path for the IQM configuration.path - - path to the configuration files where the application has
writing permissionspublic void setScriptPath(String path)
path for the IQM configuration.path - - path to the Groovy script files where the application has
writing permissionspublic void setScriptPath(File path)
path for the IQM configuration.path - - path to the Groovy script files where the application has
writing permissionspublic boolean getKeepExistingROIs()
If the config file does not contain any annotation tags, the default values will be written to the file.
true or falsepublic void setKeepExistingROIs(boolean value)
value - private void setLastUpdate()
public static ConfigManager getCurrentInstance()
public File getDefaultIqmConfPath()
public File getDefaultIqmScriptPath()
public File getDefaultIqmRootPath()
public File getDefaultIqmTempPath()
public String getDefaultUserHome()
Copyright © 2009–2017 Helmut Ahammer, Philipp Kainz. All rights reserved.