RPG Next Gen
Wiki RSS Feed Weblog
Business picture

Properties

A Properties "object" contains a persistent set of properties. A property is a key/value pair. Keys and values are of the data type character. Each key can only exist once in a Properties object. There is no guaranteed order of the entries.The properties can be persistent where the default persistence method is saving and loading to/from a stream file.

This project is inspired by the Java Properties class and a similar project from Dieter Bender at www.bender-dv.de.

Property Files

Properties are usually saved to a stream file, normally with the suffix .properties (at least in the Java world). There are some rules how these files are structured.

Comments

Lines starting with # and ! are treated as comments and are thus are ignored.

Key/Value Pair

The key and the value are separated by one character. The default separator character is the equal sign (=). A different character can be passed to the load procedure as there are many files which f. e. use the : as a separator. Spaces before and after the separator are ignored and thus stripped from the key and the value. Trailing spaces will also be stripped.

Line continuation

If a line should be "too long" it may be ended with a backslash and continued on the next line. This next line will be added to the previous line as a value. Any leading spaces in this line also counts as content and will be included in the value.

File Encoding

As the file I/O is handled by the RNG Input Providers service programs all file encodings are supported.

Line Ending

As the file I/O is handled by the RNG Input Providers service programs LF (line feed) and CRLF (carriage return and line feed) are supported as line ending characters. This should cover files created on Unix and Windows platforms.

Features

The following features are available in the Properties service program (in no particular order):

  • Creating an Properties "object"
  • Adding entries
  • Removing entries
  • Clearing
  • Get entry
  • Check if an entry exist
  • Get number of entries
  • Load entries from stream file
  • Dump all entries to screen
  • List all keys

Todos

Currently there is no procedure for saving the properties to a stream file. Only the loading of properties from a stream file is supported, see properties_load().

Code sample

// loading properties from a file properties = properties_load('manifest.mf' : ':'); if (properties_contains(properties : 'Bundle-Version')); dsply 'jap. version exist'; dsp = properties_get(properties : 'Bundle-Version'); dsply dsp; else; dsply 'nope. no version'; endif; // freeing the allocated memory properties_finalize(properties);

Installation Instructions

The service program comes as source files (stream files) packaged in a tar-archive. The package needs to be extraced in the IFS. The installation script is a Makefile. The destination library and the destination folder for the copy book should be adjusted in the Makefile. To create/install the service program just enter QSH and go to the directory where the sources/Makefile are located. Then call "make".

Requirements

This service program depends on the following packages:

  • Includes
  • ArrayList
  • libtree
  • RNG Input Providers

Examples

The examples section contains some examples of how to use the service program procedures.

Download

For source packages take a look at the download area.

Documentation

API documentation of the Properties service program can be found at the open documentation library at ILEDocs on Sourceforge.net.

License

This service program is released under the GNU Lesser General Public License.