IDatapool Interface

The IDatapool Interface is the most important data pool class. You get access via the kernel or, in the case of the optional namespace data pools, via the namespaces:

kernel.getDatapool();
Namespace.getDatapool();

Read Data

The keys for a specific path can be retrieved via:

Collection<String> getKeys(String aPath);

You can fetch all data pool records of a particular path as follows:

Collection<IDatapoolRecord> getRecords(String aPath);

You can get the subdirectories of a path by choosing:

Collection<String> getSubDirectories(String aPath);

All records of the subdirectories can be retrieved via:

Collection<IDatapoolRecord> getSubRecords(String aPath);

You can get a single value by calling:

String getValue(String aPath, String aKey);

or a default value that is returned if the key is not found:

String getValue(String aPath,
                String aKey,
                String aDefaultValue);

Write Data

The writing of a single value is done via:

void setValue(String aPath,
              String aKey,
              String aValue);

You can also write a completely new value using the following method:

void addOrUpdateRecord(IDatapoolRecord aRecord,
                       boolean aForce);

This has the advantage that the other fields of a record can also be set, for example the description.

Clear Data

You can delete a single value using the following method:

void remove(String aPath,
            String aKey);

The following method removes all entries of a path, as well as all subdirectories. Caution!:

void remove(String aPath);

Import

The contents of a configuration file (in XML format) can be imported as follows:

CResult importConfigFile(String aPath);

If a file is already available, you can do it like this:

void importXml(File aFile) throws CException;

Statistics

The number of data records can be obtained via:

int getCount();

For a certain path, you get the number of records via:

int getCount(String aPath);

Listener and Observer

Values in the data pool can be observed. Messages are sent when the data is changed, which notifies the listeners.

The registration process is as follows:

IDatapool dp = getKernel().getDatapool();
dp.addListener("plugin/myapp", "mykey", getAddress());

The listener receives the message |CRecordNotifyDatapoolValueChanged|.

The notifications are deactivated during the startup of the devel. one framework. Notifications are only enabled again when the framework has been started completely. Switching on and off is done by two methods:

boolean isNotificationEnabled();

void disableNotifications();

void enableNotifications(INamespace aNamespace) throws CException;

When switching on the notifications, you have to enter a namespace as the corresponding data pool target is registered there.

Debugging

A list of all entries in the “Path/Key=Value” format is available by the following method:

Collection<String> getDump();

The following method can be used to log the list:

void dumpValues(Logger aLogger);