#include <PropertyFile.h>
Public Member Functions | |
PropertyFile (const char *n) | |
The name of the general node. | |
int | close () |
Store the current properties that are in the data arraylist in the filesystem. | |
int | setPropertyValue (const char *prop, const char *value) |
The setPropertyValue of the PropertyFile calls the super implementation and then write in the journal list with a simple append. | |
int | removeProperty (const char *prop) |
To remove the property, also the journal has to be updated. | |
int | removeAllProperties () |
It remove all the properties in memory and in the storage. | |
bool | separateKeyValue (StringBuffer &s, StringBuffer &key, StringBuffer &value) |
It sepatares from the line read from the property file the key and value. | |
Private Member Functions | |
int | read () |
Extract all currently properties in the node looking also at the journal file if exists. | |
Private Attributes | |
StringBuffer | node |
The name of the property file. | |
StringBuffer | nodeJour |
The name of the property file that is used as a journal. |
It provides methods to read and write in the filesystem the arraylist of KeyValuePair
int PropertyFile::close | ( | ) | [virtual] |
Store the current properties that are in the data arraylist in the filesystem.
It deletes the journal too
Implements MemoryKeyValueStore.
int PropertyFile::read | ( | ) | [private] |
Extract all currently properties in the node looking also at the journal file if exists.
It populates the data ArrayList to hold the key/values in the filesystem
Referenced by PropertyFile().
int PropertyFile::removeProperty | ( | const char * | prop | ) | [virtual] |
To remove the property, also the journal has to be updated.
In the case, it is always updated with an append so at the next read it can be fixed
Reimplemented from MemoryKeyValueStore.
bool PropertyFile::separateKeyValue | ( | StringBuffer & | s, | |
StringBuffer & | key, | |||
StringBuffer & | value | |||
) |
It sepatares from the line read from the property file the key and value.
It takes care
int PropertyFile::setPropertyValue | ( | const char * | prop, | |
const char * | value | |||
) | [virtual] |
The setPropertyValue of the PropertyFile calls the super implementation and then write in the journal list with a simple append.
prop | - the name of the prop | |
value | - the value |
Reimplemented from MemoryKeyValueStore.
StringBuffer PropertyFile::nodeJour [private] |
The name of the property file that is used as a journal.
It contains all the entries that are set with setPropertyValue (they are appended into the file). They can be more than twice of the same key (two calls to setPropertyValue(prop1,val1); setPropertyValue(prop1,val111);) The idea is that in memory there is the ArrayList of KeyValuePair with all the properties that are with a unique key and this journal contains all the entries that can have more that one time the same key. (in the case above, the arrayList contains only (prop1,val111)). With the close() method the right property/value is written in the final storage and the journal is deleted. If there is something wrong and the memory is erased before the close() is called, the next read() will find the journal file and populates properly the ArrayList in memory with the right property/value. Note that the ArrayList in memory is filled in the same order the properties are read from the journal file.
Referenced by PropertyFile().