|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectPropertiesFile
public final class PropertiesFile extends java.lang.Object
Used for accessing and creating .[properties] files, reads them as utf-8, saves as utf-8. Internationalization is key importance especially for character codes.
Constructor and Description |
---|
PropertiesFile(java.lang.String fileName)
Creates or opens a properties file using specified filename |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(java.lang.String var)
Checks to see if the .[properties] file contains the given key . |
boolean |
getBoolean(java.lang.String key)
Returns the value of the key given in a Boolean,
however we do not set a string if no key is found. |
boolean |
getBoolean(java.lang.String key,
boolean value)
Returns the boolean value of a key |
double |
getDouble(java.lang.String key)
Returns the value of the key given in a Double,
however we do not set a string if no key is found. |
double |
getDouble(java.lang.String key,
double value)
Returns the double value of a key |
int |
getInt(java.lang.String key)
Returns the value of the key given in a Integer,
however we do not set a string if no key is found. |
int |
getInt(java.lang.String key,
int value)
Returns the int value of a key |
long |
getLong(java.lang.String key)
Returns the value of the key given in a Long,
however we do not set a string if no key is found. |
long |
getLong(java.lang.String key,
long value)
Returns the long value of a key |
java.lang.String |
getProperty(java.lang.String var)
Checks to see if this key exists in the .[properties] file. |
java.lang.String |
getString(java.lang.String key)
Returns the value of the key given as a String ,
however we do not set a string if no key is found. |
java.lang.String |
getString(java.lang.String key,
java.lang.String value)
Returns the value of the key given as a String . |
boolean |
keyExists(java.lang.String key)
Checks the existance of a key . |
void |
load()
The loader for property files, it reads the file as UTF8 or converts the string into UTF8. |
void |
removeKey(java.lang.String var)
Remove a key from the file if it exists. |
java.util.Map<java.lang.String,java.lang.String> |
returnMap()
Returns a Map of all key=value properties in the file as <key (java.lang.String), value (java.lang.String)>
Example: |
void |
save()
Writes out the key=value properties that were changed into
a .[properties] file in UTF8. |
void |
setBoolean(java.lang.String key,
boolean value)
Save the value given as a boolean on the specified key. |
void |
setDouble(java.lang.String key,
double value)
Save the value given as a double on the specified key. |
void |
setInt(java.lang.String key,
int value)
Save the value given as a int on the specified key. |
void |
setLong(java.lang.String key,
long value)
Save the value given as a long on the specified key. |
void |
setString(java.lang.String key,
java.lang.String value)
Save the value given as a String on the specified key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PropertiesFile(java.lang.String fileName)
fileName
- Method Detail |
---|
public void load() throws java.io.IOException
java.io.IOException
public void save()
key=value
properties that were changed into
a .[properties] file in UTF8.
public java.util.Map<java.lang.String,java.lang.String> returnMap() throws java.lang.Exception
key=value
properties in the file as <key (java.lang.String), value (java.lang.String)>
PropertiesFile settings = new PropertiesFile("settings.properties"); MapmappedSettings; try { mappedSettings = settings.returnMap(); } catch (Exception ex) { log.info("Failed mapping settings.properties"); }
map
- Simple Map HashMap of the entire key=value
as <key (java.lang.String), value (java.lang.String)>
java.lang.Exception
- If the properties file doesn't exist.public boolean containsKey(java.lang.String var)
key
.
var
- The key we are going to be checking the existance of.Boolean
- True if the key
exists, false if it cannot be found.public java.lang.String getProperty(java.lang.String var)
key
exists in the .[properties] file.
var
- The key we are grabbing the value of.java.lang.String
- True if the key
exists, false if it cannot be found.public void removeKey(java.lang.String var)
var
- The key
that will be removed from the filesave()
public boolean keyExists(java.lang.String key)
key
.
key
- The key
in question of existance.Boolean
- True for existance, false for key
found.containsKey(java.lang.String)
public java.lang.String getString(java.lang.String key)
key
given as a String
,
however we do not set a string if no key
is found.
key
- The key
we will retrieve the property from, if no key
is found default to "" or empty.getProperty(java.lang.String)
public java.lang.String getString(java.lang.String key, java.lang.String value)
key
given as a String
.
If it is not found, it will invoke saving the default value
to the properties file.
key
- The key that we will be grabbing the value from, if no value is found set and return value
value
- The default value that we will be setting if no prior key
is found.setString(java.lang.String, java.lang.String)
,
getProperty(java.lang.String)
public void setString(java.lang.String key, java.lang.String value)
String
on the specified key.
key
- The key
that we will be addressing the value
to.value
- The value
we will be setting inside the .[properties]
file.save()
public int getInt(java.lang.String key)
key
given in a Integer,
however we do not set a string if no key
is found.
key
- The key
we will retrieve the property from, if no key
is found default to 0getProperty(String var)
public int getInt(java.lang.String key, int value)
key
- The key that we will be grabbing the value from, if no value is found set and return value
value
- The default value that we will be setting if no prior key
is found.Integer
- Either we will return the default value or a prior existing value depending on existance.setInt(String key, int value)
public void setInt(java.lang.String key, int value)
int
on the specified key.
key
- The key
that we will be addressing the value
to.value
- The value
we will be setting inside the .[properties]
file.save()
public double getDouble(java.lang.String key)
key
given in a Double,
however we do not set a string if no key
is found.
key
- The key
we will retrieve the property from, if no key
is found default to 0.0getProperty(String var)
public double getDouble(java.lang.String key, double value)
key
- The key that we will be grabbing the value from, if no value is found set and return value
value
- The default value that we will be setting if no prior key
is found.Double
- Either we will return the default value or a prior existing value depending on existance.setDouble(String key, double value)
public void setDouble(java.lang.String key, double value)
double
on the specified key.
key
- The key
that we will be addressing the value
to.value
- The value
we will be setting inside the .[properties]
file.save()
public long getLong(java.lang.String key)
key
given in a Long,
however we do not set a string if no key
is found.
key
- The key
we will retrieve the property from, if no key
is found default to 0LgetProperty(String var)
public long getLong(java.lang.String key, long value)
key
- The key that we will be grabbing the value from, if no value is found set and return value
value
- The default value that we will be setting if no prior key
is found.Long
- Either we will return the default value or a prior existing value depending on existance.setLong(String key, long value)
public void setLong(java.lang.String key, long value)
long
on the specified key.
key
- The key
that we will be addressing the value
to.value
- The value
we will be setting inside the .[properties]
file.save()
public boolean getBoolean(java.lang.String key)
key
given in a Boolean,
however we do not set a string if no key
is found.
key
- The key
we will retrieve the property from, if no key
is found default to falsegetProperty(String var)
public boolean getBoolean(java.lang.String key, boolean value)
key
- The key that we will be grabbing the value from, if no value is found set and return value
value
- The default value that we will be setting if no prior key
is found.Boolean
- Either we will return the default value or a prior existing value depending on existance.setBoolean(String key, boolean value)
public void setBoolean(java.lang.String key, boolean value)
boolean
on the specified key.
key
- The key
that we will be addressing the value
to.value
- The value
we will be setting inside the .[properties]
file.save()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |