Sourceforge.net project page | Download | Javadoc | Contact |
Summary | Features | To Do | Tutorial | License |
The jsettings
package is meant to provide a Java library for dealing
with program settings. (I use "settings" as just another synonym for preferences,
properties, etc but I chose the word settings because of the already existing
Preferences
and
Properties
frameworks in Java). It wants to be a powerful tool for the developers of Java programs
that want to manipulate structures of settings.
The code (as well as this page) is at an early development and testing stage. On top of that, I am only doing it as a means to teach myself Java (I'm an economist by training and by profession) , so even at later stages you can expect the quality of the code to be quite low. If you feel like any part of the design, code, Javadoc, examples etc is silly please don't hesitate to let me know about it. Also, I would also be happy to include requested features as long as I can understand the need for them and I also know how to do it. So please write to me if you have anything to say about this project!
Related projects that I found on the Net are IniEditor and ini4j.
INI
and FSTAB
type of files and settings.
There is no XML support yet, but I plan to do it if it seems to be requested. -
INI
settings are specified by a
setting = value
pair.
-
FSTAB
settings are defined by an array of settings, each in a predefined field. I call them like this because the structure is similar to thefstab
file in UNIX environments. Logical structure is quite similar to that of XML files.
There are two degrees of hierarchy available, called hierarchical and non-hierarchical. For example, in a hierarchical organization, the settings in a file called settings.ini, containing the following lines:
[section1]
setting1=value1
[[section1-2]] //Notice the double brackets
setting1-2=value1-2
would be refered to as
settings:section1:setting1
and
settings:section1:section1-2:setting1-2
In a non-hierarchical structure they would be
settings:section1:setting1
and
settings:section1-2:setting1-2
(section1-2 is not a child of section1 anymore).
The advantage is that the actual ini and fstab files will only contain the 'deviations' from the defaults.
A program would first load the defaults, then the system-wide settings and then the user-specific ones. Also when modifying the settings, there is a choice between doing it at user and at system level.
Each ini-type setting and each fstab-type field have a validation rule in the form of a regular expression. When loading the value for that setting/field, it is being checked against the rule and only accepted if it confirms to the rule. Of course, if the user wants it she can have '.*' as the rule for each setting.
Currently working on: changes undo.
This library is provided under the MIT License - you can find the complete text of the license here .