Package de.hsh.graja.util
Class ConfigBase
- java.lang.Object
-
- de.hsh.graja.util.ConfigBase
-
- Direct Known Subclasses:
InstallationSettings
public class ConfigBase extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ConfigBase.KD<T>
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConfigBase()
This constructor creates an incomplete object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDump()
<T> T
getProp(ConfigBase.KD<T> kd)
Map<String,String>
getUnmodifiableMapStringStringView()
protected void
loadAndValidate(File configFile, Class<? extends ConfigBase> configClass, String prefix)
loads a config file from configFilename.protected void
loadAndValidate(InputStream input, Class<? extends ConfigBase> configClass, String prefix)
loads a config file from a stream validates, that the loaded properties are valid compared to the private static final KD fields of configClass (only fields starting with prefix) The input stream remains open.protected void
loadAndValidate(String configFilename, Class<? extends ConfigBase> configClass, String prefix)
loads a config file from configFilename.protected void
save(OutputStream output, String comments)
protected void
setAndValidate(Properties properties, Class<? extends ConfigBase> configClass, String prefix)
initializes the config from a properties object.protected <T> void
setProp(ConfigBase.KD<T> kd, T value)
-
-
-
Method Detail
-
loadAndValidate
protected void loadAndValidate(File configFile, Class<? extends ConfigBase> configClass, String prefix) throws IOException
loads a config file from configFilename. validates, that the loaded properties are valid compared to the private static final KD fields of configClass (only fields starting with prefix)- Parameters:
configFile
-configClass
-- Throws:
IOException
-
loadAndValidate
protected void loadAndValidate(String configFilename, Class<? extends ConfigBase> configClass, String prefix) throws IOException
loads a config file from configFilename. validates, that the loaded properties are valid compared to the private static final KD fields of configClass (only fields starting with prefix) The input stream remains open.- Parameters:
configFilename
-configClass
-- Throws:
IOException
-
loadAndValidate
protected void loadAndValidate(InputStream input, Class<? extends ConfigBase> configClass, String prefix) throws IOException
loads a config file from a stream validates, that the loaded properties are valid compared to the private static final KD fields of configClass (only fields starting with prefix) The input stream remains open.- Parameters:
input
-configClass
-- Throws:
IOException
-
save
protected void save(OutputStream output, String comments) throws IOException
- Throws:
IOException
-
setAndValidate
protected void setAndValidate(Properties properties, Class<? extends ConfigBase> configClass, String prefix) throws InvalidFormatException
initializes the config from a properties object. The properties object will serve as a backend. Changes in properties will reflect in new values returned from getProp calls. validates, that the properties are valid compared to the private static final KD fields of configClass (only fields starting with prefix)- Parameters:
properties
-configClass
-prefix
-- Throws:
IllegalArgumentException
IllegalAccessException
InvalidFormatException
-
getProp
public <T> T getProp(ConfigBase.KD<T> kd)
-
getDump
public String getDump()
-
setProp
protected <T> void setProp(ConfigBase.KD<T> kd, T value)
-
-