|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.configuration.AbstractConfiguration
org.apache.commons.configuration.BaseConfiguration
org.apache.commons.configuration.BasePathConfiguration
org.apache.commons.configuration.BasePropertiesConfiguration
loads the configuration from a properties file.
The properties file syntax is explained here:
key = value
Here is an example of a valid extended properties file:
# lines starting with # are comments # This is the simplest property key = value # A long property may be separated on multiple lines longvalue = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa # This is a property with many tokens tokens_on_a_line = first token, second token # This sequence generates exactly the same result tokens_on_multiple_lines = first token tokens_on_multiple_lines = second token # commas may be escaped in tokens commas.excaped = Hi\, what'up? # properties can reference other properties base.prop = /base first.prop = ${base.prop}/first second.prop = ${first.prop}/second
Field Summary | |
protected static String |
include
This is the name of the property that can point to other properties file for including other properties files. |
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration |
DELIMITER, END_TOKEN, START_TOKEN |
Constructor Summary | |
BasePropertiesConfiguration()
|
Method Summary | |
String |
getInclude()
Gets the property value for including other properties files. |
boolean |
getIncludesAllowed()
Reports the status of file inclusion. |
protected abstract InputStream |
getPropertyStream(String resourceName)
Implementations of this class must implement this method. |
void |
load(InputStream input)
Load the properties from the given input stream. |
void |
load(InputStream input,
String encoding)
Load the properties from the given input stream and using the specified encoding. |
void |
save(OutputStream out)
Save the configuration to the specified stream. |
void |
save(OutputStream out,
String encoding)
Save the configuration to the specified stream. |
void |
save(String filename)
Save the configuration to a file. |
void |
save(Writer writer)
Save the configuration to the specified stream. |
void |
setInclude(String inc)
Sets the property value for including other properties files. |
protected void |
setIncludesAllowed(boolean includesAllowed)
Controls whether additional files can be loaded by the include = |
protected static String |
unescapeJava(String str)
Unescapes any Java literals found in the String to a
Writer . |
Methods inherited from class org.apache.commons.configuration.BasePathConfiguration |
getBasePath, setBasePath |
Methods inherited from class org.apache.commons.configuration.BaseConfiguration |
addPropertyDirect, clearProperty, containsKey, getKeys, getPropertyDirect, isEmpty |
Methods inherited from class org.apache.commons.configuration.AbstractConfiguration |
addProperty, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, interpolate, interpolateHelper, setProperty, split, subset |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static String include
Constructor Detail |
public BasePropertiesConfiguration()
Method Detail |
protected abstract InputStream getPropertyStream(String resourceName) throws IOException
resourceName
- The Resource to load
IOException
- Error while loading the properties filepublic void load(InputStream input) throws ConfigurationException
input
- An InputStream.
ConfigurationException
public void load(InputStream input, String encoding) throws ConfigurationException
input
- An InputStream.encoding
- An encoding.
ConfigurationException
public void save(String filename) throws ConfigurationException
filename
- the name of the properties file
ConfigurationException
public void save(OutputStream out) throws IOException
out
- the output stream used to save the configuration
IOException
public void save(OutputStream out, String encoding) throws IOException
out
- the output stream used to save the configurationencoding
- the charset used to write the configuration
IOException
public void save(Writer writer) throws IOException
writer
- the output stream used to save the configuration
IOException
public String getInclude()
public void setInclude(String inc)
inc
- A String.protected void setIncludesAllowed(boolean includesAllowed)
includesAllowed
- includesAllowed True if Includes are allowed.public boolean getIncludesAllowed()
protected static String unescapeJava(String str)
Unescapes any Java literals found in the String
to a
Writer
.
str
- the String
to unescape, may be null
IllegalArgumentException
- if the Writer is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |