|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectrabbit.util.Config
public class Config
a class to handle configs for different things. reads file on the format
[sectionName1] key=value key2=value2 [sectionName2] key=value key2=value2 key_with_equals\=still_key=value3everything after the first '#' is considered a comment. blank lines are ignored. If you want keys with '=' in them escape it to '\=' and you should be fine.
| Constructor Summary | |
|---|---|
Config()
create an empty Config (has only section "" with no data in it) |
|
Config(java.io.File file)
Create a Config for the specified file |
|
Config(java.io.InputStream is)
Create a Config by reading it from a stream. |
|
Config(java.io.Reader reader)
Create a Config by reading it from a reader. |
|
Config(java.lang.String filename)
Create a Config for the specified file |
|
| Method Summary | |
|---|---|
SProperties |
getProperties(java.lang.String sectionName)
get the properties for a given section |
java.lang.String |
getProperty(java.lang.String section,
java.lang.String key)
get a property for given key in specified section |
java.lang.String |
getProperty(java.lang.String section,
java.lang.String key,
java.lang.String defaultstring)
get a property for given key in specified section |
java.util.Collection<java.lang.String> |
getSections()
get the available sections |
void |
merge(Config other)
Merge this config with another one. |
void |
save(java.io.OutputStream os)
save the config to a OutputStream |
void |
setProperties(java.lang.String sectionName,
SProperties prop)
set the properties for a given section |
void |
setProperty(java.lang.String section,
java.lang.String key,
java.lang.String value)
set a property for given section. |
java.lang.String |
toString()
Get a string describing this Config |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Config()
public Config(java.lang.String filename)
throws java.io.IOException
filename - the File we read the config from
java.io.IOException - if the given file can not be read
public Config(java.io.File file)
throws java.io.IOException
file - the File we read the config from
java.io.IOException - if the given file can not be read
public Config(java.io.InputStream is)
throws java.io.IOException
is - the stream to read the config from.
java.io.IOException - if the given input stream can not be read
public Config(java.io.Reader reader)
throws java.io.IOException
reader - the Reader to read the config from.
java.io.IOException - if the given Reader can not be read| Method Detail |
|---|
public java.util.Collection<java.lang.String> getSections()
public SProperties getProperties(java.lang.String sectionName)
sectionName - the section we want properties for.
public void setProperties(java.lang.String sectionName,
SProperties prop)
sectionName - the section we want to set the properties for.prop - the SProperties for the sections
public java.lang.String getProperty(java.lang.String section,
java.lang.String key)
section - the section we should look in.key - the key we want a value for.
public java.lang.String getProperty(java.lang.String section,
java.lang.String key,
java.lang.String defaultstring)
section - the section we should look in.key - the key we want a value for.defaultstring - the string to use if no value is found.
public void setProperty(java.lang.String section,
java.lang.String key,
java.lang.String value)
section - the section we should look in.key - the key.value - the value.public void save(java.io.OutputStream os)
os - the OutputStream to write topublic java.lang.String toString()
toString in class java.lang.Objectpublic void merge(Config other)
other - the Config to merge with.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||