|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.tc.utils.properties.Properties
public class Properties
Class for handling configuration files in Java properties like formatting.
Example of expected format:
# a comment [Section1] something = anything [Section2] whatever = new thing
Constructor Summary | |
---|---|
Properties()
Creates new empty Properties. |
|
Properties(java.lang.String file)
Creates new Properties object from file content. |
Method Summary | |
---|---|
void |
addSection(java.lang.String sectionname)
Adds a new empty section. |
java.lang.String |
getProperty(java.lang.String key)
Returns a property from the section that has been previously specified via setSectionPointer(java.lang.String) . |
java.lang.String |
getProperty(java.lang.String section,
java.lang.String key)
Returns a property from the specified section. |
java.math.BigInteger |
getPropertyAsBigInt(java.lang.String key)
Returns a property from the section that has been previously specified via setSectionPointer(java.lang.String) . |
java.math.BigInteger |
getPropertyAsBigInt(java.lang.String section,
java.lang.String key)
Returns a property from the specified section. |
int |
getPropertyAsInt(java.lang.String key)
Returns a property from the section that has been previously specified via setSectionPointer(java.lang.String) . |
int |
getPropertyAsInt(java.lang.String section,
java.lang.String key)
Returns a property from the specified section. |
java.util.ArrayList |
getSections()
Gets array of section names. |
boolean |
hasSection(java.lang.String sectionname)
Determines if a section of supplied name already exists. |
void |
setProperty(java.lang.String key,
java.lang.String value)
Sets a property in the currently selected section. |
void |
setProperty(java.lang.String section,
java.lang.String key,
java.lang.String value)
Sets a property in the specified section. |
void |
setSectionPointer(java.lang.String section)
Sets current section pointer. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Properties()
public Properties(java.lang.String file) throws java.io.IOException
A new Properties object is created and its initial content read from indicated file.
java.io.IOException
Method Detail |
---|
public void setSectionPointer(java.lang.String section)
java.lang.IllegalArgumentException
- if section does not existpublic void addSection(java.lang.String sectionname)
After successful creation of the new section the current section pointer is updated to the new section. If a section of the specified name already existed, the current section pointer is only updated to this section.
sectionname
- name of the section to createpublic boolean hasSection(java.lang.String sectionname)
sectionname
- section name
true
if section of that name exists,
false
otherwise.public java.util.ArrayList getSections()
public void setProperty(java.lang.String section, java.lang.String key, java.lang.String value)
section
- section namekey
- property namevalue
- property value
java.lang.IllegalArgumentException
- if any parameter is null or
section does not existpublic void setProperty(java.lang.String key, java.lang.String value)
key
- property namevalue
- value to setpublic java.lang.String getProperty(java.lang.String key)
setSectionPointer(java.lang.String)
.
key
- property name
public int getPropertyAsInt(java.lang.String key)
setSectionPointer(java.lang.String)
.
It is assumed the property String can be converted on the fly to an integer type.
key
- property name
public java.math.BigInteger getPropertyAsBigInt(java.lang.String key)
setSectionPointer(java.lang.String)
.
It is assumed the property String can be converted on the fly to a BigInteger type.
key
- property name
public java.lang.String getProperty(java.lang.String section, java.lang.String key)
section
- section namekey
- property name
java.lang.IllegalArgumentException
- if section does not existpublic int getPropertyAsInt(java.lang.String section, java.lang.String key)
section
- section namekey
- property name
java.lang.IllegalArgumentException
- if section does not existpublic java.math.BigInteger getPropertyAsBigInt(java.lang.String section, java.lang.String key)
section
- section namekey
- property name
java.lang.IllegalArgumentException
- if section does not existpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |