|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
ObjectProperties
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(String file)
Creates new Properties object from file content. |
|
| Method Summary | |
|---|---|
void |
addSection(String sectionname)
Adds a new empty section. |
String |
getProperty(String key)
Returns a property from the section that has been previously specified via setSectionPointer(java.lang.String). |
String |
getProperty(String section,
String key)
Returns a property from the specified section. |
BigInteger |
getPropertyAsBigInt(String key)
Returns a property from the section that has been previously specified via setSectionPointer(java.lang.String). |
BigInteger |
getPropertyAsBigInt(String section,
String key)
Returns a property from the specified section. |
int |
getPropertyAsInt(String key)
Returns a property from the section that has been previously specified via setSectionPointer(java.lang.String). |
int |
getPropertyAsInt(String section,
String key)
Returns a property from the specified section. |
ArrayList |
getSections()
Gets array of section names. |
boolean |
hasSection(String sectionname)
Determines if a section of supplied name already exists. |
void |
setProperty(String key,
String value)
Sets a property in the currently selected section. |
void |
setProperty(String section,
String key,
String value)
Sets a property in the specified section. |
void |
setSectionPointer(String section)
Sets current section pointer. |
String |
toString()
|
| Methods inherited from class Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Properties()
public Properties(String file)
throws IOException
A new Properties object is created and its initial content read from indicated file.
IOException| Method Detail |
|---|
public void setSectionPointer(String section)
IllegalArgumentException - if section does not existpublic void addSection(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(String sectionname)
sectionname - section name
true if section of that name exists,
false otherwise.public ArrayList getSections()
public void setProperty(String section,
String key,
String value)
section - section namekey - property namevalue - property value
IllegalArgumentException - if any parameter is null or
section does not exist
public void setProperty(String key,
String value)
key - property namevalue - value to setpublic String getProperty(String key)
setSectionPointer(java.lang.String).
key - property name
public int getPropertyAsInt(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 BigInteger getPropertyAsBigInt(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 String getProperty(String section,
String key)
section - section namekey - property name
IllegalArgumentException - if section does not exist
public int getPropertyAsInt(String section,
String key)
section - section namekey - property name
IllegalArgumentException - if section does not exist
public BigInteger getPropertyAsBigInt(String section,
String key)
section - section namekey - property name
IllegalArgumentException - if section does not existpublic String toString()
toString in class Object
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||