public class ConfigFile
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
ConfigData |
data
The core of this ConfigFile
|
MySQLDatabase |
db
The MySQLDatabase settings used for storing and loading the configuration from MySQL
|
java.lang.String |
dbArgs
The MySQLDatabase settings used for storing and loading the configuration from MySQL
|
java.lang.String |
dbKey
The MySQLDatabase settings used for storing and loading the configuration from MySQL
|
java.lang.String |
dbTable
The MySQLDatabase settings used for storing and loading the configuration from MySQL
|
java.lang.String |
dbValue
The MySQLDatabase settings used for storing and loading the configuration from MySQL
|
java.io.File |
file
The file used for storing and loading the configuration
|
| Constructor and Description |
|---|
ConfigFile()
Constructs an empty ConfigFile
|
ConfigFile(ConfigData d)
Wrap an already existing ConfigData
|
ConfigFile(java.io.File file)
Constructs an empty ConfigFile and loads it from the given InputStream
|
ConfigFile(java.io.InputStream stream)
Constructs an empty ConfigFile and loads it from the given InputStream
|
ConfigFile(MySQLDatabase mysql)
Constructs an empty ConfigFile and loads it from MySQL
|
ConfigFile(MySQLDatabase mysql,
java.lang.String table,
java.lang.String key,
java.lang.String value)
Constructs an empty ConfigFile and loads it from MySQL
|
ConfigFile(java.lang.String in)
Constructs an empty ConfigFile and loads it from the given String
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
get(java.lang.String adress,
java.lang.Class<T> cl)
Get the given typed Object from the ConfigFiles given address.
|
<T> T |
get(java.lang.String adress,
java.lang.Class<T> cl,
java.lang.reflect.Type... types)
Get the given typed Object from the ConfigFiles given address.
|
boolean |
getBoolean(java.lang.String address)
Get a boolean variable from the configuration
|
boolean |
getBoolean(java.lang.String address,
boolean def)
Get a boolean variable from the configuration
|
byte |
getByte(java.lang.String address)
Get a byte variable from the configuration
|
byte |
getByte(java.lang.String address,
byte def)
Get a byte variable from the configuration
|
ConfigData |
getData(java.lang.String address)
Get data found in the given address
|
ConfigData |
getData(java.lang.String address,
boolean autoCreate)
Get data found in the given address.
|
double |
getDouble(java.lang.String address)
Get a double variable from the configuration
|
double |
getDouble(java.lang.String address,
double def)
Get a double variable from the configuration
|
float |
getFloat(java.lang.String address)
Get a float variable from the configuration
|
float |
getFloat(java.lang.String address,
float def)
Get a float variable from the configuration
|
int |
getInt(java.lang.String address)
Get an int variable from the configuration
|
int |
getInt(java.lang.String address,
int def)
Get an int variable from the configuration
|
long |
getLong(java.lang.String address)
Get a long variable from the configuration
|
long |
getLong(java.lang.String address,
long def)
Get a long variable from the configuration
|
<T> T |
getObject(java.lang.String adress,
java.lang.Class<T> cl,
T def,
java.lang.reflect.Type... types)
Get the given typed Object from the ConfigFile
|
<T> T |
getObject(java.lang.String adress,
java.lang.Class<T> cl,
java.lang.reflect.Type... types)
Get the given typed Object from the ConfigFile
|
short |
getShort(java.lang.String address)
Get a short variable from the configuration
|
short |
getShort(java.lang.String address,
short def)
Get a short variable from the configuration
|
java.lang.String |
getString(java.lang.String address)
Get a String variable from the configuration
|
java.lang.String |
getString(java.lang.String address,
java.lang.String def)
Get a String variable from the configuration
|
java.util.ArrayList<java.lang.String> |
getStringKeyList()
Get all the main sub keys of this configuration
|
java.util.ArrayList<java.lang.String> |
getStringKeyList(java.lang.String key)
Get all the main sub keys of this configuration which are under the root key
|
boolean |
load(java.io.File f)
Load configuration from a File
|
boolean |
load(java.io.InputStream is)
Load configuration from an InputStream
|
boolean |
load(java.lang.String in)
Load configuration from a String
|
void |
mysqlLoad()
Load the configuration from MySQL
|
void |
mysqlLoad(java.lang.String address,
java.lang.String args)
Load the given address of this configuration from MySQL
|
void |
mysqlUpdate(java.util.ArrayList<java.lang.String> l,
java.lang.String args)
Add to the given list the MySQL commands required for updating the storage based on this Configuration
|
boolean |
reload()
Reloads the configuration from the file used in initialization
|
boolean |
removeData(java.lang.String address)
Remove the given address from the configuration
|
boolean |
save()
Saves the configuration asynchronously.
|
boolean |
save(java.io.OutputStream out)
Saves the configuration to the given OutputStream.
|
boolean |
saveNoAsync()
Save the config file without using async thread.
|
void |
serialize()
Serializes the ConfigData for being able to throw all the object references
|
void |
setData(java.lang.String address,
ConfigData cd)
Set the given the given address to the given ConfigData
|
void |
setObject(java.lang.String address,
java.lang.Object obj)
Set the given address to the given Object.
|
void |
setString(java.lang.String address,
java.lang.String value)
Set the given address to the given String.
|
ConfigFile |
subConfig(java.lang.String address)
Get the given sub section of this ConfigFile
|
ConfigFile |
subConfig(java.lang.String address,
java.lang.String dbArgs)
Get the given sub section of this ConfigFile referring to
|
java.lang.String |
toString()
Convert this ConfigFile to a String
|
public ConfigData data
public MySQLDatabase db
public java.lang.String dbTable
public java.lang.String dbKey
public java.lang.String dbValue
public java.lang.String dbArgs
public java.io.File file
public ConfigFile()
public ConfigFile(java.io.InputStream stream)
stream - - The InputStream containing the loadable configurationpublic ConfigFile(java.io.File file)
file - - The File containing the loadable configurationpublic ConfigFile(MySQLDatabase mysql)
mysql - - The MySQLDatabase containing the loadable configurationpublic ConfigFile(MySQLDatabase mysql, java.lang.String table, java.lang.String key, java.lang.String value)
mysql - - The MySQLDatabase containing the loadable configurationtable - - The table which contains the configuration, usually mysql.tablekey - - The columns name which should be used for storing configurations addresses, usually "key"value - - The columns name which should be used for storing configurations values, usually "value"public ConfigFile(java.lang.String in)
in - - The String containing the loadable configurationpublic ConfigFile(ConfigData d)
d - - The wrapable ConfigDatapublic <T> T get(java.lang.String adress,
java.lang.Class<T> cl)
T - - The requested Objects typeadress - - The addresscl - - The requested Objects typepublic <T> T get(java.lang.String adress,
java.lang.Class<T> cl,
java.lang.reflect.Type... types)
T - - The requested Objects typeadress - - The addresscl - - The requested Objects typetypes - - The parameter types of the requested Objectpublic boolean getBoolean(java.lang.String address,
boolean def)
address - - The address used for storing the valuedef - - Default value which should be returned if the address does not existpublic boolean getBoolean(java.lang.String address)
address - - The address used for storing the valuepublic byte getByte(java.lang.String address,
byte def)
address - - The address used for storing the valuedef - - Default value which should be returned if the address does not existpublic byte getByte(java.lang.String address)
address - - The address used for storing the valuepublic ConfigData getData(java.lang.String address)
address - - Requested addresspublic ConfigData getData(java.lang.String address, boolean autoCreate)
address - - Requested addressautoCreate - - Automatically create the road for accessing the given addresspublic double getDouble(java.lang.String address,
double def)
address - - The address used for storing the valuedef - - Default value which should be returned if the address does not existpublic double getDouble(java.lang.String address)
address - - The address used for storing the valuepublic float getFloat(java.lang.String address,
float def)
address - - The address used for storing the valuedef - - Default value which should be returned if the address does not existpublic float getFloat(java.lang.String address)
address - - The address used for storing the valuepublic int getInt(java.lang.String address,
int def)
address - - The address used for storing the valuedef - - Default value which should be returned if the address does not existpublic int getInt(java.lang.String address)
address - - The address used for storing the valuepublic long getLong(java.lang.String address,
long def)
address - - The address used for storing the valuedef - - Default value which should be returned if the address does not existpublic long getLong(java.lang.String address)
address - - The address used for storing the valuepublic <T> T getObject(java.lang.String adress,
java.lang.Class<T> cl,
java.lang.reflect.Type... types)
T - - The type of the Objectadress - - The address of the Objectcl - - The objects typetypes - - Object type parameterspublic <T> T getObject(java.lang.String adress,
java.lang.Class<T> cl,
T def,
java.lang.reflect.Type... types)
T - - The type of the Objectadress - - The address of the Objectcl - - The objects typedef - - Default return Object used, when Object can not be found under the given keytypes - - Object type parameterspublic short getShort(java.lang.String address,
short def)
address - - The address used for storing the valuedef - - Default value which should be returned if the address does not existpublic short getShort(java.lang.String address)
address - - The address used for storing the valuepublic java.lang.String getString(java.lang.String address,
java.lang.String def)
address - - The address used for storing the valuedef - - Default value which should be returned if the address does not existpublic java.lang.String getString(java.lang.String address)
address - - The address used for storing the valuepublic java.util.ArrayList<java.lang.String> getStringKeyList()
public java.util.ArrayList<java.lang.String> getStringKeyList(java.lang.String key)
key - - Root keypublic boolean load(java.io.InputStream is)
is - - The loadable InputStreampublic boolean load(java.lang.String in)
in - - The loadable Stringpublic boolean load(java.io.File f)
f - - The loadable Filepublic void mysqlLoad(java.lang.String address,
java.lang.String args)
address - - The loadable addressargs - - Arguments of the MySQL WHERE clausepublic void mysqlLoad()
public void mysqlUpdate(java.util.ArrayList<java.lang.String> l,
java.lang.String args)
l - - The listargs - - The arguments which should be passed after MySQL WHERE clause.public boolean reload()
public boolean removeData(java.lang.String address)
address - - The removable addresspublic boolean save()
public boolean save(java.io.OutputStream out)
public boolean saveNoAsync()
public void serialize()
public void setData(java.lang.String address,
ConfigData cd)
address - - The changable addresscd - - Target ConfigDatapublic void setObject(java.lang.String address,
java.lang.Object obj)
address - - The setable addressobj - - Target Objectpublic void setString(java.lang.String address,
java.lang.String value)
address - - The setable addressvalue - - Target Stringpublic ConfigFile subConfig(java.lang.String address)
address - - Sub sections addresspublic ConfigFile subConfig(java.lang.String address, java.lang.String dbArgs)
address - - Sub sections addressdbArgs - - The MySQL arguments which should be used for saving this sub sectionpublic java.lang.String toString()
toString in class java.lang.Object