public abstract class AbstractPropertyIO extends Object implements PropertyIO
Constructor and Description |
---|
AbstractPropertyIO(boolean readonly,
boolean cached)
Returns an instance of the class with readonly and cache property.
|
Modifier and Type | Method and Description |
---|---|
String |
backup()
Returns a string containing all the properties [name=value] in the PropertyIO seperated by a line feed [
|
long |
getCacheTime()
How often the typed value cache for a PropertyIO should be automatically flushed every X milliseconds.
|
Date |
getLastLoaded()
The date for when a property was last loaded not using cache.
|
Date |
getLastSaved()
The date for when a property was last saved.
|
org.apache.commons.logging.Log |
getLogger()
Gets a logger
|
Properties |
getTypedProperties()
Gets
Properties with the content name and object . |
Object |
getTypedValue(String propertyName)
Gets type converted object value from the cache by the property name.
|
String |
getValue(String propertyName)
Gets the string value of the name.
|
boolean |
isCached()
A boolean that determines if the PropertyIO shall cache the name,value pairs and the type converted properties.
|
boolean |
isReadonly()
Determines if the IO is readonly or not.
|
protected void |
logPerformanceGetProperties(long startTime)
Convenience method - Call this method as the last in "getProperties" (in the finally section), this will than handle a standardized performance logging and message.
|
protected void |
logPerformanceSetValue(String propertyName,
long startTime)
Convenience method - Call this method as the last in "setValue" (in the finally section), this will than handle a standardized performance logging and message.
|
void |
reload()
Reloads the name,value pairs for the PropertyIO, or forces the values to reload when read next time.
|
void |
setCacheTime(long cacheTime)
How often the typed value cache for a PropertyIO should be automatically flushed every X milliseconds.
This will override the global framework paramenter for default property io flushing. |
void |
storeTypedValue(String propertyName,
Object value)
Stores a type converted value in the IO cache, if cache option is implemented.
|
protected void |
updateLastLoaded()
Sets the date on when the properties was last loaded to current date.
|
protected void |
updateLastSaved()
Sets the date on when the properties was last saved to current date.
|
protected void |
validateWritable(String propertyName)
Convenience method that verifies that the PropertyIO is writeable otherwise a PropertyIOException is thrown with a standardized message.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, getProperties, getSource, setValue, validate
public AbstractPropertyIO(boolean readonly, boolean cached)
readonly
- shall the AbstractPropertyIO
be read only.cached
- shall the values be cached in the PropertyIO
's.public final Object getTypedValue(String propertyName)
PropertyIO
getTypedValue
in interface PropertyIO
propertyName
- the name of Propertynull
.public final void storeTypedValue(String propertyName, Object value)
PropertyIO
storeTypedValue
in interface PropertyIO
propertyName
- the name of the property.value
- the object value to store in cache.public long getCacheTime()
getCacheTime
in interface PropertyIO
PropertyIO.reload()
public final void setCacheTime(long cacheTime)
setCacheTime
in interface PropertyIO
cacheTime
- the amount of milliseconds between the typed value cache is flushed. if less than or equal to zero no automatic cache flush is performed and must be done manually with reload.reload()
public final Properties getTypedProperties()
Properties
with the content name
and object
.public final boolean isCached()
PropertyIO
isCached
in interface PropertyIO
true
if it shall use cache, otherwise false
.public final boolean isReadonly()
PropertyIO
isReadonly
in interface PropertyIO
true
if the PropertyIO is readonly, otherwise false
.public void reload()
PropertyIO
reload
in interface PropertyIO
public String getValue(String propertyName)
PropertyIO
${name}
in the value, will be passed by the StringUtils.replaceInlinedProperties(String)
method, to replace ${name} where name can either be
a System.getProperty(String) or System.getenv(String).getValue
in interface PropertyIO
propertyName
- the name of the property.null
is returned.StringUtils.replaceInlinedProperties(String)
,
PropertyFrameworkGlobals
public String backup()
PropertyIO
\n].
backup
in interface PropertyIO
public final Date getLastLoaded()
PropertyIO
getLastLoaded
in interface PropertyIO
getProperties
method, if not loaded new Date(0)
shall be returned.public final Date getLastSaved()
PropertyIO
getLastSaved
in interface PropertyIO
protected final void updateLastLoaded()
protected final void updateLastSaved()
public org.apache.commons.logging.Log getLogger()
PropertyIO
getLogger
in interface PropertyIO
protected final void logPerformanceGetProperties(long startTime)
startTime
- the System.currentTimeMillis() when the method started.System.currentTimeMillis()
,
PropertyIO.getProperties()
protected final void logPerformanceSetValue(String propertyName, long startTime)
propertyName
- the name of the property you are trying to set.startTime
- the System.currentTimeMillis() when the method started.protected final void validateWritable(String propertyName) throws PropertyIOException
propertyName
- the name of the property use are trying to set.PropertyIOException
- the exception thrown if the PropertyIO is not writeable,isReadonly()
,
PropertyIO.setValue(String, String)