|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object raccoon.core.types.AbsComponent raccoon.core.types.AbsLoadable raccoon.core.types.AbsConfigurableLoadable raccoon.core.config.StrConfig
public class StrConfig
Improvement to the java.util.PropertyResourceBundle
.
CoreHelper.getConfig()
methods. The ConfigBase
properties can be refreshed (i.e. reread from the provided string) by calling the
refresh()
method.
log4j.appender.Raccoon = org.apache.log4j.RollingFileAppender
log4j.appender.Raccoon.File = Raccoon.log
log4j.appender.Raccoon.Append = false
log4j.appender.Raccoon.MaxFileSize = 5MB
log4j.appender.Raccoon.MaxBackupIndex = 10
log4j.appender.Raccoon.layout = org.apache.log4j.PatternLayout
log4j.appender.Raccoon.layout.ConversionPattern = %r [%t] %-5p %c{2} %x - %m %n
log4j.rootCategory=debug, Raccoon
And is assigned by invoking the method setStringElements(java.lang.String)
.
RaccoonException
if this component isn't active.
Field Summary |
---|
Fields inherited from class raccoon.core.types.AbsConfigurableLoadable |
---|
mConfigurableManager |
Fields inherited from class raccoon.core.types.AbsLoadable |
---|
mIsLoaded |
Fields inherited from class raccoon.core.types.AbsComponent |
---|
mIsInError |
Fields inherited from interface raccoon.api.config.IConfig |
---|
PTY_CONFIG |
Constructor Summary | |
---|---|
StrConfig()
|
Method Summary | |
---|---|
void |
configureParameters()
Configures the various parameters for this component. |
boolean |
getBoolean(java.lang.String pProperty)
Reads the value of the propery and converts it to a boolean. |
boolean |
getBoolean(java.lang.String pProperty,
boolean pDefaultValue)
Reads the value of the propery and converts it to a boolean. |
double |
getDouble(java.lang.String pProperty)
Reads the value of the propery and converts it to a double. |
double |
getDouble(java.lang.String pProperty,
double pDefaultValue)
Reads the value of the propery and converts it to a double. |
int |
getInt(java.lang.String pProperty)
Reads the value of the propery and converts it to a integer. |
int |
getInt(java.lang.String pProperty,
int pDefaultValue)
Reads the value of the propery and converts it to a integer. |
long |
getLong(java.lang.String pProperty)
Reads the value of the propery and converts it to a long. |
long |
getLong(java.lang.String pProperty,
long pDefaultValue)
Reads the value of the propery and converts it to a long. |
(package private) java.lang.String |
getMissingPropertyMsg(java.lang.String pDesiredProperty)
Creates an error message to inform the developper that a property is missing from his file. |
java.util.Properties |
getProperties()
Extracts all the available properties to a convenient format. |
java.lang.String |
getString(java.lang.String pProperty)
Reads the value of the propery and converts it to a String. |
java.lang.String |
getString(java.lang.String pProperty,
java.lang.Object[] pParams)
Retrieves a Message String from the configuration file and
converts it into a String . |
java.lang.String |
getString(java.lang.String pProperty,
java.lang.Object[] pParams,
java.lang.String pDefaultValue)
Retrieves a Message String from the configuration file and
converts it into a String . |
java.lang.String |
getString(java.lang.String pProperty,
java.lang.String pDefaultValue)
Reads the value of the propery and converts it to a String. |
java.util.StringTokenizer |
getStrings(java.lang.String pProperty)
Reads the value of the property and returns a StringTokenizer object. |
boolean |
isAvailable(java.lang.String pProperty)
Convenience method to check if a specific property is defined. |
void |
load()
Loads or initializes the component. |
void |
refresh()
Reload the properties from the properties file. |
void |
setStringElements(java.lang.String pStringElements)
Defines the string to be used as properties contents. |
Methods inherited from class raccoon.core.types.AbsConfigurableLoadable |
---|
isStable, setConfigurableManager, setLogger |
Methods inherited from class raccoon.core.types.AbsLoadable |
---|
getLog, isInError, isInitialised, isRunning, unload |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StrConfig()
Method Detail |
---|
public void configureParameters()
IConfigurableManager
provided during the
invocation of AbsConfigurableLoadable.setConfigurableManager(raccoon.api.types.IConfigurableManager)
.
configureParameters
in interface IConfigurable
configureParameters
in class AbsConfigurableLoadable
public void setStringElements(java.lang.String pStringElements) throws ResourceNotFoundException
pStringElements
- the properties.
ResourceNotFoundException
public boolean isAvailable(java.lang.String pProperty) throws RaccoonException
isAvailable
in interface IConfig
pProperty
- the property to search for.
RaccoonException
- if this component is active.public void load() throws java.lang.IllegalStateException, LoadableException
load
in interface ILoadable
load
in class AbsConfigurableLoadable
LoadableException
- if the component couldn't load itself.
java.lang.IllegalStateException
- if the component isn't in a state to load itself. for example it is already loaded.public boolean getBoolean(java.lang.String pProperty) throws RaccoonException, java.lang.NumberFormatException
true
if the value of the property
is a String(true)
or is 1.
This method will return false
if the value of the property
is a String(false)
or is 0.
- Specified by:
getBoolean
in interface IConfig
- Parameters:
pProperty
- the property to look for
- Returns:
- the boolean value for the requested property
- Throws:
RaccoonException
- if the property couldn't be found
java.lang.NumberFormatException
- if the specified property isn't a boolean.
public boolean getBoolean(java.lang.String pProperty, boolean pDefaultValue)
true
if the value of the property
is a String(true)
or is 1.
This method will return false
if the value of the property
is a String(false)
or is 0.
This method will return pDefaultvalue
if any error occurs.
- Specified by:
getBoolean
in interface IConfig
- Parameters:
pProperty
- the property to look forpDefaultValue
- the default value returned if the property is not
found in the config file
- Returns:
- the boolean value for the requested property
public int getInt(java.lang.String pProperty) throws RaccoonException, java.lang.NumberFormatException
getInt
in interface IConfig
pProperty
- the property to look for
RaccoonException
- if the property couldn't be found
java.lang.NumberFormatException
- if the specified property isn't a int.public int getInt(java.lang.String pProperty, int pDefaultValue)
pDefaultvalue
if any error occurs.
getInt
in interface IConfig
pProperty
- the property to look forpDefaultValue
- the default value returned if the property is not
found in the config file
public long getLong(java.lang.String pProperty) throws RaccoonException, java.lang.NumberFormatException
getLong
in interface IConfig
pProperty
- the property to look for
RaccoonException
- if the property couldn't be found
java.lang.NumberFormatException
- if the specified property isn't a long.public long getLong(java.lang.String pProperty, long pDefaultValue)
pDefaultvalue
if any error occurs.
getLong
in interface IConfig
pProperty
- the property to look forpDefaultValue
- the default value returned if the property is not
found in the config file
public double getDouble(java.lang.String pProperty) throws RaccoonException
getDouble
in interface IConfig
pProperty
- the property to look for
RaccoonException
- if the value can't be found or is invalid.public double getDouble(java.lang.String pProperty, double pDefaultValue)
pDefaultvalue
if any error occurs.
getDouble
in interface IConfig
pProperty
- the property to look forpDefaultValue
- the default value returned if the property is not
found in the config file
public java.util.StringTokenizer getStrings(java.lang.String pProperty) throws RaccoonException
getStrings
in interface IConfig
pProperty
- the property for which the data is required.
RaccoonException
- if the property couldn't be found.public java.lang.String getString(java.lang.String pProperty) throws RaccoonException
getString
in interface IConfig
pProperty
- the property to look for
RaccoonException
- if the value is an invalid Stringpublic java.lang.String getString(java.lang.String pProperty, java.lang.String pDefaultValue)
pDefaultvalue
if any error occurs.
getString
in interface IConfig
pProperty
- the property to look forpDefaultValue
- the default value returned if the property is not
found in the config file
public java.lang.String getString(java.lang.String pProperty, java.lang.Object[] pParams) throws RaccoonException
Message String
from the configuration file and
converts it into a String
.
A Message String
is a specific String
, because
each occurrence of {i} in that String will be replaced by
Object[i].toString()
For example:
property = "Hello {0}, you have {1}, new Object[] {"Kathleen", "mail"}
String
being returned:
"Hello Kathleen, you have mail"
No matter what the implementation behind the scenes is.
getString
in interface IConfig
pProperty
- the property that is to be retrieved.pParams
- a list of objects implementing the toString() method that
will be inserted into the resulting String
RaccoonException
- if this method failspublic java.lang.String getString(java.lang.String pProperty, java.lang.Object[] pParams, java.lang.String pDefaultValue)
Message String
from the configuration file and
converts it into a String
.
A Message String
is a specific String
, because
each occurrence of {i} in that String will be replaced by
Object[i].toString()
For example:
property = "Hello {0}, you have {1}, new Object[] {"Kathleen", "mail"}
String
being returned:
"Hello Kathleen, you have mail"
No matter what the implementation behind the scenes is.
This method will return pDefaultvalue
if any error occurs.
getString
in interface IConfig
pProperty
- the property that is to be retrieved.pParams
- a list of objects implementing the toString() method that
will be inserted into the resulting String
pDefaultValue
- the default value returned if the property is not
found in the config file
public void refresh() throws RaccoonException
refresh
in interface IConfig
RaccoonException
- if this component hasn't been initialised.public java.util.Properties getProperties() throws RaccoonException
getProperties
in interface IConfig
Properties
object
RaccoonException
- if the component isn't activejava.lang.String getMissingPropertyMsg(java.lang.String pDesiredProperty)
pDesiredProperty
- the missing property
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |