[med-svn] [liboptions-java] 01/05: Imported Upstream version 0.0.20120113

Andreas Tille tille at debian.org
Sun Nov 29 08:31:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository liboptions-java.

commit 9e85000f5ed393082d75e59766b004a706d60dac
Author: Andreas Tille <tille at debian.org>
Date:   Tue Jan 17 11:25:58 2012 +0100

    Imported Upstream version 0.0.20120113
---
 LICENSE-2.0.txt                         |  202 +++++
 build.xml                               |   74 ++
 catalog.xml                             |    0
 nbproject/build-impl.xml                | 1042 +++++++++++++++++++++++
 nbproject/genfiles.properties           |    8 +
 nbproject/private/config.properties     |    0
 nbproject/private/private.properties    |    8 +
 nbproject/private/private.xml           |    4 +
 nbproject/project.properties            |   79 ++
 nbproject/project.xml                   |   16 +
 src/config/options.xsd                  |  206 +++++
 src/ml/options/Constrainable.java       |   38 +
 src/ml/options/Constraint.java          |   41 +
 src/ml/options/DefaultHelpPrinter.java  |  291 +++++++
 src/ml/options/ExclusiveConstraint.java |  263 ++++++
 src/ml/options/HelpPrinter.java         |   45 +
 src/ml/options/OptionData.java          |  685 +++++++++++++++
 src/ml/options/OptionSet.java           |  645 +++++++++++++++
 src/ml/options/Options.java             | 1379 +++++++++++++++++++++++++++++++
 src/ml/options/SchemaValidator.java     |  149 ++++
 src/ml/options/ValueConstraint.java     |  452 ++++++++++
 src/ml/options/XMLConstraint.java       |   46 ++
 src/ml/options/XMLParsingException.java |   78 ++
 23 files changed, 5751 insertions(+)

diff --git a/LICENSE-2.0.txt b/LICENSE-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE-2.0.txt
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..8bfdd4f
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="options" default="default" basedir=".">
+    <description>Builds, tests, and runs the project options.</description>
+    <import file="nbproject/build-impl.xml"/>
+    <!--
+
+    There exist several targets which are by default empty and which can be 
+    used for execution of your tasks. These targets are usually executed 
+    before and after some main targets. They are: 
+
+      -pre-init:                 called before initialization of project properties
+      -post-init:                called after initialization of project properties
+      -pre-compile:              called before javac compilation
+      -post-compile:             called after javac compilation
+      -pre-compile-single:       called before javac compilation of single file
+      -post-compile-single:      called after javac compilation of single file
+      -pre-compile-test:         called before javac compilation of JUnit tests
+      -post-compile-test:        called after javac compilation of JUnit tests
+      -pre-compile-test-single:  called before javac compilation of single JUnit test
+      -post-compile-test-single: called after javac compilation of single JUunit test
+      -pre-jar:                  called before JAR building
+      -post-jar:                 called after JAR building
+      -post-clean:               called after cleaning build products
+
+    (Targets beginning with '-' are not intended to be called on their own.)
+
+    Example of inserting an obfuscator after compilation could look like this:
+
+        <target name="-post-compile">
+            <obfuscate>
+                <fileset dir="${build.classes.dir}"/>
+            </obfuscate>
+        </target>
+
+    For list of available properties check the imported 
+    nbproject/build-impl.xml file. 
+
+
+    Another way to customize the build is by overriding existing main targets.
+    The targets of interest are: 
+
+      -init-macrodef-javac:     defines macro for javac compilation
+      -init-macrodef-junit:     defines macro for junit execution
+      -init-macrodef-debug:     defines macro for class debugging
+      -init-macrodef-java:      defines macro for class execution
+      -do-jar-with-manifest:    JAR building (if you are using a manifest)
+      -do-jar-without-manifest: JAR building (if you are not using a manifest)
+      run:                      execution of project 
+      -javadoc-build:           Javadoc generation
+      test-report:              JUnit report generation
+
+    An example of overriding the target for project execution could look like this:
+
+        <target name="run" depends="options-impl.jar">
+            <exec dir="bin" executable="launcher.exe">
+                <arg file="${dist.jar}"/>
+            </exec>
+        </target>
+
+    Notice that the overridden target depends on the jar target and not only on 
+    the compile target as the regular run target does. Again, for a list of available 
+    properties which you can use, check the target you are overriding in the
+    nbproject/build-impl.xml file. 
+
+    -->
+</project>
diff --git a/catalog.xml b/catalog.xml
new file mode 100644
index 0000000..e69de29
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
new file mode 100644
index 0000000..9ec84de
--- /dev/null
+++ b/nbproject/build-impl.xml
@@ -0,0 +1,1042 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT  ***
+***         EDIT ../build.xml INSTEAD         ***
+
+For the purpose of easier reading the script
+is divided into following sections:
+
+  - initialization
+  - compilation
+  - jar
+  - execution
+  - debugging
+  - javadoc
+  - junit compilation
+  - junit execution
+  - junit debugging
+  - applet
+  - cleanup
+
+        -->
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="options-impl">
+    <fail message="Please build using Ant 1.7.1 or higher.">
+        <condition>
+            <not>
+                <antversion atleast="1.7.1"/>
+            </not>
+        </condition>
+    </fail>
+    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
+    <!-- 
+                ======================
+                INITIALIZATION SECTION 
+                ======================
+            -->
+    <target name="-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init" name="-init-private">
+        <property file="nbproject/private/config.properties"/>
+        <property file="nbproject/private/configs/${config}.properties"/>
+        <property file="nbproject/private/private.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private" name="-init-user">
+        <property file="${user.properties.file}"/>
+        <!-- The two properties below are usually overridden -->
+        <!-- by the active platform. Just a fallback. -->
+        <property name="default.javac.source" value="1.4"/>
+        <property name="default.javac.target" value="1.4"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
+        <property file="nbproject/configs/${config}.properties"/>
+        <property file="nbproject/project.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+        <available file="${manifest.file}" property="manifest.available"/>
+        <condition property="splashscreen.available">
+            <and>
+                <not>
+                    <equals arg1="${application.splash}" arg2="" trim="true"/>
+                </not>
+                <available file="${application.splash}"/>
+            </and>
+        </condition>
+        <condition property="main.class.available">
+            <and>
+                <isset property="main.class"/>
+                <not>
+                    <equals arg1="${main.class}" arg2="" trim="true"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="manifest.available+main.class">
+            <and>
+                <isset property="manifest.available"/>
+                <isset property="main.class.available"/>
+            </and>
+        </condition>
+        <condition property="do.archive">
+            <not>
+                <istrue value="${jar.archive.disabled}"/>
+            </not>
+        </condition>
+        <condition property="do.mkdist">
+            <and>
+                <isset property="do.archive"/>
+                <isset property="libs.CopyLibs.classpath"/>
+                <not>
+                    <istrue value="${mkdist.disabled}"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="manifest.available+main.class+mkdist.available">
+            <and>
+                <istrue value="${manifest.available+main.class}"/>
+                <isset property="do.mkdist"/>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available">
+            <and>
+                <isset property="manifest.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+main.class.available">
+            <and>
+                <isset property="main.class.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+splashscreen.available">
+            <and>
+                <isset property="splashscreen.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available+main.class">
+            <and>
+                <istrue value="${manifest.available+main.class}"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="manifest.available-mkdist.available">
+            <or>
+                <istrue value="${manifest.available}"/>
+                <isset property="do.mkdist"/>
+            </or>
+        </condition>
+        <condition property="manifest.available+main.class-mkdist.available">
+            <or>
+                <istrue value="${manifest.available+main.class}"/>
+                <isset property="do.mkdist"/>
+            </or>
+        </condition>
+        <condition property="have.tests">
+            <or>
+                <available file="${test.src.dir}"/>
+            </or>
+        </condition>
+        <condition property="have.sources">
+            <or>
+                <available file="${src.dir}"/>
+            </or>
+        </condition>
+        <condition property="netbeans.home+have.tests">
+            <and>
+                <isset property="netbeans.home"/>
+                <isset property="have.tests"/>
+            </and>
+        </condition>
+        <condition property="no.javadoc.preview">
+            <and>
+                <isset property="javadoc.preview"/>
+                <isfalse value="${javadoc.preview}"/>
+            </and>
+        </condition>
+        <property name="run.jvmargs" value=""/>
+        <property name="javac.compilerargs" value=""/>
+        <property name="work.dir" value="${basedir}"/>
+        <condition property="no.deps">
+            <and>
+                <istrue value="${no.dependencies}"/>
+            </and>
+        </condition>
+        <property name="javac.debug" value="true"/>
+        <property name="javadoc.preview" value="true"/>
+        <property name="application.args" value=""/>
+        <property name="source.encoding" value="${file.encoding}"/>
+        <property name="runtime.encoding" value="${source.encoding}"/>
+        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
+            <and>
+                <isset property="javadoc.encoding"/>
+                <not>
+                    <equals arg1="${javadoc.encoding}" arg2=""/>
+                </not>
+            </and>
+        </condition>
+        <property name="javadoc.encoding.used" value="${source.encoding}"/>
+        <property name="includes" value="**"/>
+        <property name="excludes" value=""/>
+        <property name="do.depend" value="false"/>
+        <condition property="do.depend.true">
+            <istrue value="${do.depend}"/>
+        </condition>
+        <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
+        <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
+            <length length="0" string="${endorsed.classpath}" when="greater"/>
+        </condition>
+        <condition else="false" property="jdkBug6558476">
+            <and>
+                <matches pattern="1\.[56]" string="${java.specification.version}"/>
+                <not>
+                    <os family="unix"/>
+                </not>
+            </and>
+        </condition>
+        <property name="javac.fork" value="${jdkBug6558476}"/>
+        <property name="jar.index" value="false"/>
+        <property name="jar.index.metainf" value="${jar.index}"/>
+        <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
+    </target>
+    <target name="-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
+        <fail unless="src.dir">Must set src.dir</fail>
+        <fail unless="test.src.dir">Must set test.src.dir</fail>
+        <fail unless="build.dir">Must set build.dir</fail>
+        <fail unless="dist.dir">Must set dist.dir</fail>
+        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
+        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
+        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
+        <fail unless="dist.jar">Must set dist.jar</fail>
+    </target>
+    <target name="-init-macrodef-property">
+        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute name="name"/>
+            <attribute name="value"/>
+            <sequential>
+                <property name="@{name}" value="${@{value}}"/>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="sourcepath"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <mkdir dir="@{apgeneratedsrcdir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <compilerarg value="-processorpath"/>
+                    <compilerarg path="@{processorpath}:${empty.dir}"/>
+                    <compilerarg line="${ap.processors.internal}"/>
+                    <compilerarg line="${annotation.processing.processor.options}"/>
+                    <compilerarg value="-s"/>
+                    <compilerarg path="@{apgeneratedsrcdir}"/>
+                    <compilerarg line="${ap.proc.none.internal}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="sourcepath"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
+        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <sequential>
+                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </depend>
+            </sequential>
+        </macrodef>
+        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <sequential>
+                <fail unless="javac.includes">Must set javac.includes</fail>
+                <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
+                    <path>
+                        <filelist dir="@{destdir}" files="${javac.includes}"/>
+                    </path>
+                    <globmapper from="*.java" to="*.class"/>
+                </pathconvert>
+                <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
+                <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
+                <delete>
+                    <files includesfile="${javac.includesfile.binary}"/>
+                </delete>
+                <delete>
+                    <fileset file="${javac.includesfile.binary}"/>
+                </delete>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-junit">
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <batchtest todir="${build.test.results.dir}">
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
+                    </batchtest>
+                    <classpath>
+                        <path path="${run.test.classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/>
+    <target name="-profile-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target name="-profile-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target name="-profile-init-macrodef-profile">
+        <macrodef name="resolve">
+            <attribute name="name"/>
+            <attribute name="value"/>
+            <sequential>
+                <property name="@{name}" value="${env.@{value}}"/>
+            </sequential>
+        </macrodef>
+        <macrodef name="profile">
+            <attribute default="${main.class}" name="classname"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property environment="env"/>
+                <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
+                <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
+                    <jvmarg value="${profiler.info.jvmargs.agent}"/>
+                    <jvmarg line="${profiler.info.jvmargs}"/>
+                    <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+                    <arg line="${application.args}"/>
+                    <classpath>
+                        <path path="${run.classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check">
+        <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
+        <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
+    </target>
+    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
+        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${main.class}" name="name"/>
+            <attribute default="${debug.classpath}" name="classpath"/>
+            <attribute default="" name="stopclassname"/>
+            <sequential>
+                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </nbjpdastart>
+            </sequential>
+        </macrodef>
+        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${build.classes.dir}" name="dir"/>
+            <sequential>
+                <nbjpdareload>
+                    <fileset dir="@{dir}" includes="${fix.classes}">
+                        <include name="${fix.includes}*.class"/>
+                    </fileset>
+                </nbjpdareload>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-debug-args">
+        <property name="version-output" value="java version "${ant.java.version}"/>
+        <condition property="have-jdk-older-than-1.4">
+            <or>
+                <contains string="${version-output}" substring="java version "1.0"/>
+                <contains string="${version-output}" substring="java version "1.1"/>
+                <contains string="${version-output}" substring="java version "1.2"/>
+                <contains string="${version-output}" substring="java version "1.3"/>
+            </or>
+        </condition>
+        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
+            <istrue value="${have-jdk-older-than-1.4}"/>
+        </condition>
+        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+            <os family="windows"/>
+        </condition>
+        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+            <isset property="debug.transport"/>
+        </condition>
+    </target>
+    <target depends="-init-debug-args" name="-init-macrodef-debug">
+        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${debug.classpath}" name="classpath"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-java">
+        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${run.classpath}" name="classpath"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-copylibs">
+        <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${manifest.file}" name="manifest"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+                <pathconvert property="run.classpath.without.build.classes.dir">
+                    <path path="${run.classpath}"/>
+                    <map from="${build.classes.dir.resolved}" to=""/>
+                </pathconvert>
+                <pathconvert pathsep=" " property="jar.classpath">
+                    <path path="${run.classpath.without.build.classes.dir}"/>
+                    <chainedmapper>
+                        <flattenmapper/>
+                        <globmapper from="*" to="lib/*"/>
+                    </chainedmapper>
+                </pathconvert>
+                <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+                <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+                    <fileset dir="${build.classes.dir}"/>
+                    <manifest>
+                        <attribute name="Class-Path" value="${jar.classpath}"/>
+                        <customize/>
+                    </manifest>
+                </copylibs>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-presetdef-jar">
+        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
+                <j2seproject1:fileset dir="${build.classes.dir}"/>
+            </jar>
+        </presetdef>
+    </target>
+    <target name="-init-ap-cmdline-properties">
+        <property name="annotation.processing.enabled" value="true"/>
+        <property name="annotation.processing.processors.list" value=""/>
+        <property name="annotation.processing.processor.options" value=""/>
+        <property name="annotation.processing.run.all.processors" value="true"/>
+        <property name="javac.processorpath" value="${javac.classpath}"/>
+        <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
+        <condition property="ap.supported.internal" value="true">
+            <not>
+                <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
+        <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
+            <isfalse value="${annotation.processing.run.all.processors}"/>
+        </condition>
+        <condition else="" property="ap.proc.none.internal" value="-proc:none">
+            <isfalse value="${annotation.processing.enabled}"/>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
+        <property name="ap.cmd.line.internal" value=""/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
+    <!--
+                ===================
+                COMPILATION SECTION
+                ===================
+            -->
+    <target name="-deps-jar-init" unless="built-jar.properties">
+        <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
+        <delete file="${built-jar.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
+        <echo level="warn" message="Cycle detected: options was already built"/>
+    </target>
+    <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-jar.properties}" verbose="false"/>
+        <property file="${built-jar.properties}" prefix="already.built.jar."/>
+        <antcall target="-warn-already-built-jar"/>
+        <propertyfile file="${built-jar.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
+    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
+    <target depends="init" name="-check-automatic-build">
+        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
+    </target>
+    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
+        <antcall target="clean"/>
+    </target>
+    <target depends="init,deps-jar" name="-pre-pre-compile">
+        <mkdir dir="${build.classes.dir}"/>
+    </target>
+    <target name="-pre-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="do.depend.true" name="-compile-depend">
+        <pathconvert property="build.generated.subdirs">
+            <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="*"/>
+            </dirset>
+        </pathconvert>
+        <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
+        <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
+        <copy todir="${build.classes.dir}">
+            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target if="has.persistence.xml" name="-copy-persistence-xml">
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy todir="${build.classes.dir}/META-INF">
+            <fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
+        </copy>
+    </target>
+    <target name="-post-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
+    <target name="-pre-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <j2seproject3:force-recompile/>
+        <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
+    </target>
+    <target name="-post-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
+    <!--
+                ====================
+                JAR BUILDING SECTION
+                ====================
+            -->
+    <target depends="init" name="-pre-pre-jar">
+        <dirname file="${dist.jar}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+    </target>
+    <target name="-pre-jar">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
+        <j2seproject1:jar/>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
+        <j2seproject1:jar manifest="${manifest.file}"/>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
+        <j2seproject1:jar manifest="${manifest.file}">
+            <j2seproject1:manifest>
+                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
+            </j2seproject1:manifest>
+        </j2seproject1:jar>
+        <echo level="info">To run this application from the command line without Ant, try:</echo>
+        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
+        <pathconvert property="run.classpath.with.dist.jar">
+            <path path="${run.classpath}"/>
+            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
+        </pathconvert>
+        <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
+    </target>
+    <target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <touch file="${tmp.manifest.file}" verbose="false"/>
+    </target>
+    <target depends="init" if="do.archive+manifest.available" name="-do-jar-with-libraries-copy-manifest">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
+    </target>
+    <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+main.class.available" name="-do-jar-with-libraries-set-main">
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="Main-Class" value="${main.class}"/>
+        </manifest>
+    </target>
+    <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-with-libraries-set-splashscreen">
+        <basename file="${application.splash}" property="splashscreen.basename"/>
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
+        </manifest>
+    </target>
+    <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen" if="do.mkdist" name="-do-jar-with-libraries-pack">
+        <j2seproject3:copylibs manifest="${tmp.manifest.file}"/>
+        <echo level="info">To run this application from the command line without Ant, try:</echo>
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
+        <echo level="info">java -jar "${dist.jar.resolved}"</echo>
+    </target>
+    <target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest">
+        <delete>
+            <fileset file="${tmp.manifest.file}"/>
+        </delete>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen,-do-jar-with-libraries-pack,-do-jar-with-libraries-delete-manifest" name="-do-jar-with-libraries"/>
+    <target name="-post-jar">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
+    <!--
+                =================
+                EXECUTION SECTION
+                =================
+            -->
+    <target depends="init,compile" description="Run a main class." name="run">
+        <j2seproject1:java>
+            <customize>
+                <arg line="${application.args}"/>
+            </customize>
+        </j2seproject1:java>
+    </target>
+    <target name="-do-not-recompile">
+        <property name="javac.includes.binary" value=""/>
+    </target>
+    <target depends="init,compile-single" name="run-single">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <j2seproject1:java classname="${run.class}"/>
+    </target>
+    <target depends="init,compile-test-single" name="run-test-with-main">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
+    </target>
+    <!--
+                =================
+                DEBUGGING SECTION
+                =================
+            -->
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
+        <j2seproject1:nbjpdastart name="${debug.class}"/>
+    </target>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
+        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
+    </target>
+    <target depends="init,compile" name="-debug-start-debuggee">
+        <j2seproject3:debug>
+            <customize>
+                <arg line="${application.args}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
+        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
+    </target>
+    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <j2seproject3:debug classname="${debug.class}"/>
+    </target>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
+    <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
+    </target>
+    <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
+    <target depends="init" name="-pre-debug-fix">
+        <fail unless="fix.includes">Must set fix.includes</fail>
+        <property name="javac.includes" value="${fix.includes}.java"/>
+    </target>
+    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
+        <j2seproject1:nbjpdareload/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
+    <!--
+                =================
+                PROFILING SECTION
+                =================
+            -->
+    <target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile">
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile/>
+    </target>
+    <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single">
+        <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile classname="${profile.class}"/>
+    </target>
+    <!--
+                =========================
+                APPLET PROFILING  SECTION
+                =========================
+            -->
+    <target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet">
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </profile>
+    </target>
+    <!--
+                =========================
+                TESTS PROFILING  SECTION
+                =========================
+            -->
+    <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single">
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true">
+            <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+            <jvmarg value="${profiler.info.jvmargs.agent}"/>
+            <jvmarg line="${profiler.info.jvmargs}"/>
+            <test name="${profile.class}"/>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+            </classpath>
+            <syspropertyset>
+                <propertyref prefix="test-sys-prop."/>
+                <mapper from="test-sys-prop.*" to="*" type="glob"/>
+            </syspropertyset>
+            <formatter type="brief" usefile="false"/>
+            <formatter type="xml"/>
+        </junit>
+    </target>
+    <!--
+                ===============
+                JAVADOC SECTION
+                ===============
+            -->
+    <target depends="init" if="have.sources" name="-javadoc-build">
+        <mkdir dir="${dist.javadoc.dir}"/>
+        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
+            <classpath>
+                <path path="${javac.classpath}"/>
+            </classpath>
+            <fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
+                <filename name="**/*.java"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/*.java"/>
+                <exclude name="*.java"/>
+            </fileset>
+        </javadoc>
+        <copy todir="${dist.javadoc.dir}">
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+                <filename name="**/doc-files/**"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/doc-files/**"/>
+            </fileset>
+        </copy>
+    </target>
+    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
+        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+    </target>
+    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
+    <!--
+                =========================
+                JUNIT COMPILATION SECTION
+                =========================
+            -->
+    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
+        <mkdir dir="${build.test.classes.dir}"/>
+    </target>
+    <target name="-pre-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="do.depend.true" name="-compile-test-depend">
+        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+    </target>
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
+    <target name="-pre-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
+    <!--
+                =======================
+                JUNIT EXECUTION SECTION
+                =======================
+            -->
+    <target depends="init" if="have.tests" name="-pre-test-run">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
+        <j2seproject3:junit testincludes="**/*Test.java"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init" if="have.tests" name="test-report"/>
+    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
+    <target depends="init" if="have.tests" name="-pre-test-run-single">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
+        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+        <j2seproject3:junit excludes="" includes="${test.includes}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+    <!--
+                =======================
+                JUNIT DEBUGGING SECTION
+                =======================
+            -->
+    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
+        <delete file="${test.report.file}"/>
+        <mkdir dir="${build.test.results.dir}"/>
+        <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
+            <customize>
+                <syspropertyset>
+                    <propertyref prefix="test-sys-prop."/>
+                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                </syspropertyset>
+                <arg value="${test.class}"/>
+                <arg value="showoutput=true"/>
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
+        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
+    </target>
+    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
+        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
+    <!--
+                =========================
+                APPLET EXECUTION SECTION
+                =========================
+            -->
+    <target depends="init,compile-single" name="run-applet">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <j2seproject1:java classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </j2seproject1:java>
+    </target>
+    <!--
+                =========================
+                APPLET DEBUGGING  SECTION
+                =========================
+            -->
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <j2seproject3:debug classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
+    <!--
+                ===============
+                CLEANUP SECTION
+                ===============
+            -->
+    <target name="-deps-clean-init" unless="built-clean.properties">
+        <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
+        <delete file="${built-clean.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
+        <echo level="warn" message="Cycle detected: options was already built"/>
+    </target>
+    <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-clean.properties}" verbose="false"/>
+        <property file="${built-clean.properties}" prefix="already.built.clean."/>
+        <antcall target="-warn-already-built-clean"/>
+        <propertyfile file="${built-clean.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
+    <target depends="init" name="-do-clean">
+        <delete dir="${build.dir}"/>
+        <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
+    </target>
+    <target name="-post-clean">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
+    <target name="-check-call-dep">
+        <property file="${call.built.properties}" prefix="already.built."/>
+        <condition property="should.call.dep">
+            <not>
+                <isset property="already.built.${call.subproject}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
+        <ant antfile="${call.script}" inheritall="false" target="${call.target}">
+            <propertyset>
+                <propertyref prefix="transfer."/>
+                <mapper from="transfer.*" to="*" type="glob"/>
+            </propertyset>
+        </ant>
+    </target>
+</project>
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
new file mode 100644
index 0000000..804c577
--- /dev/null
+++ b/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=32f23a77
+build.xml.script.CRC32=e348ee9b
+build.xml.stylesheet.CRC32=28e38971 at 1.44.1.45
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=32f23a77
+nbproject/build-impl.xml.script.CRC32=35271214
+nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408 at 1.44.1.45
diff --git a/nbproject/private/config.properties b/nbproject/private/config.properties
new file mode 100644
index 0000000..e69de29
diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties
new file mode 100644
index 0000000..9c4ecd8
--- /dev/null
+++ b/nbproject/private/private.properties
@@ -0,0 +1,8 @@
+application.args=
+compile.on.save=false
+do.depend=false
+do.jar=true
+javac.debug=true
+javadoc.preview=true
+jaxbwiz.endorsed.dirs=C:\\Program Files\\NetBeans 6.8\\ide12\\modules\\ext\\jaxb\\api
+user.properties.file=C:\\Documents and Settings\\i000698\\.netbeans\\7.0\\build.properties
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
new file mode 100644
index 0000000..cc2c0e5
--- /dev/null
+++ b/nbproject/private/private.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+</project-private>
diff --git a/nbproject/project.properties b/nbproject/project.properties
new file mode 100644
index 0000000..9971c3b
--- /dev/null
+++ b/nbproject/project.properties
@@ -0,0 +1,79 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.run.all.processors=true
+application.args=
+application.title=options
+application.vendor=
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+debug.classpath=\
+    ${run.classpath}
+debug.test.classpath=\
+    ${run.test.classpath}
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/options.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+file.reference.jdom-1.1.1.jar=C:\\Work\\Development\\Java\\lib\\jdom-1.1.1.jar
+includes=**
+jar.archive.disabled=${jnlp.enabled}
+jar.compress=false
+jar.index=${jnlp.enabled}
+javac.classpath=\
+    ${file.reference.jdom-1.1.1.jar}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+    ${javac.classpath}
+javac.source=1.6
+javac.target=1.6
+javac.test.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
+jnlp.codebase.type=no.codebase
+jnlp.descriptor=application
+jnlp.enabled=false
+jnlp.mixed.code=default
+jnlp.offline-allowed=false
+jnlp.signed=false
+jnlp.signing=
+jnlp.signing.alias=
+jnlp.signing.keystore=
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
+# or test-sys-prop.name=value to set system properties for unit tests):
+run.jvmargs=
+run.test.classpath=\
+    ${javac.test.classpath}:\
+    ${build.test.classes.dir}
+src.dir=src
+test.src.dir=test
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644
index 0000000..2641c1b
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.java.j2seproject</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
+            <name>options</name>
+            <minimum-ant-version>1.6.5</minimum-ant-version>
+            <source-roots>
+                <root id="src.dir"/>
+            </source-roots>
+            <test-roots>
+                <root id="test.src.dir"/>
+            </test-roots>
+        </data>
+    </configuration>
+</project>
diff --git a/src/config/options.xsd b/src/config/options.xsd
new file mode 100644
index 0000000..31f65a5
--- /dev/null
+++ b/src/config/options.xsd
@@ -0,0 +1,206 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+    
+    <xsd:element name="options" type="OptionsType"/>
+    
+    <!-- ========================================================================== -->
+    <!-- The entire options definition -->
+    <!-- ========================================================================== -->
+
+    <xsd:complexType name="OptionsType">
+        
+        <!-- Set definition. The options defined here are used in the addOptionAllSets() methods -->
+
+        <xsd:sequence>
+            <xsd:element name="option"     type="OptionType"           minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="defaultSet" type="DefaultOptionSetType" minOccurs="0" maxOccurs="1"/>
+            <xsd:element name="set"        type="OptionSetType"        minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+        
+        <!-- These are all the defaults that can be overridden using the setDefault() methods -->
+
+        <xsd:attribute name="defData"   type="DefData"   use="optional"/>
+        <xsd:attribute name="defMult"   type="Mult"      use="optional"/>
+        <xsd:attribute name="defSep"    type="DefSep"    use="optional"/>
+        <xsd:attribute name="defPrefix" type="DefPrefix" use="optional"/>
+        
+    </xsd:complexType>
+    
+    <!-- Some helper types for setting the defaults -->
+    
+    <!-- For the number of data items, three possibilities are provided:
+
+     - One integer: minData == maxData
+     - Two integers separated by colon: minData and maxData
+     - One integer and INF separated by colon: minData and maxData == INF      -->
+
+    <xsd:simpleType name="DefData">
+        <xsd:restriction base="xsd:string">
+            <xsd:pattern value="\d+"/>
+            <xsd:pattern value="\d+:\d+"/>
+            <xsd:pattern value="\d+:INF"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+    
+    <!-- Separators: either just one (which becomes the valueSeparator) or two separated
+     by colon (where the second one becomes the detailSeparator)  -->
+
+    <xsd:simpleType name="DefSep">
+        <xsd:restriction base="xsd:string">
+            <xsd:pattern value="(COLON|EQUALS|BLANK)"/>
+            <xsd:pattern value="(COLON|EQUALS|BLANK):(COLON|EQUALS|BLANK)"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+    
+    <!-- Prefixes: either just one (which becomes the prefix for keys) or two separated
+     by colon (where the second one becomes the prefx for alternate keys)  -->
+
+    <xsd:simpleType name="DefPrefix">
+        <xsd:restriction base="xsd:string">
+            <xsd:pattern value="(DASH|DOUBLEDASH|SLASH)"/>
+            <xsd:pattern value="(DASH|DOUBLEDASH|SLASH):(DASH|DOUBLEDASH|SLASH)"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+    
+    <!-- ========================================================================== -->
+    <!-- An option set -->
+    <!-- ========================================================================== -->
+
+    <xsd:complexType name="DefaultOptionSetType">
+        <xsd:sequence>
+            <xsd:element name="option"      type="OptionType"  minOccurs="1" maxOccurs="unbounded"/>
+            <xsd:element name="text"        type="DataText"    minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="constraints" type="Constraints" minOccurs="0" maxOccurs="1"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="OptionSetType">
+        <xsd:sequence>
+            <xsd:element name="option"      type="OptionType"  minOccurs="1" maxOccurs="unbounded"/>
+            <xsd:element name="text"        type="DataText"    minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="constraints" type="Constraints" minOccurs="0" maxOccurs="1"/>
+        </xsd:sequence>
+        <xsd:attribute name="name" type="xsd:string" use="required"/>
+        <xsd:attribute name="data" type="DefData"    use="optional"/>
+    </xsd:complexType>
+    
+    <!-- Text for an data item -->
+
+    <xsd:complexType name="DataText">
+        <xsd:sequence>
+            <xsd:element name="data" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+            <xsd:element name="help" type="xsd:string" minOccurs="0" maxOccurs="1"/>
+        </xsd:sequence>
+        <xsd:attribute name="index" type="xsd:nonNegativeInteger" use="required"/>
+    </xsd:complexType>
+    
+    <!-- ========================================================================== -->
+    <!-- An option -->
+    <!-- ========================================================================== -->
+
+    <xsd:complexType name="OptionType">
+        
+        <xsd:sequence>
+            <xsd:element name="text"        type="OptionText"  minOccurs="0" maxOccurs="1"/>
+            <xsd:element name="constraints" type="Constraints" minOccurs="0" maxOccurs="1"/>
+        </xsd:sequence>
+        
+        <xsd:attribute name="type"   type="Type"       use="required"/>
+        <xsd:attribute name="key"    type="xsd:string" use="required"/>
+        <xsd:attribute name="altKey" type="xsd:string" use="optional"/>
+        <xsd:attribute name="mult"   type="Mult"       use="optional"/>
+        
+    </xsd:complexType>
+    
+    <!-- A helper type to make sure only valid option types can be specified -->
+
+    <xsd:simpleType name="Type">
+        <xsd:restriction base="xsd:string">
+            <xsd:enumeration value="SIMPLE"/>
+            <xsd:enumeration value="VALUE"/>
+            <xsd:enumeration value="DETAIL"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+    
+    <!-- Text for an option -->
+
+    <xsd:complexType name="OptionText">
+        <xsd:sequence>
+            <xsd:element name="help"   type="xsd:string" minOccurs="1" maxOccurs="1"/>
+            <xsd:element name="value"  type="xsd:string" minOccurs="0" maxOccurs="1"/>
+            <xsd:element name="detail" type="xsd:string" minOccurs="0" maxOccurs="1"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <!-- ========================================================================== -->
+    <!-- Constraints -->
+    <!-- ========================================================================== -->
+    
+    <!-- Base element for option constraints -->
+
+    <xsd:complexType name="Constraints">
+        <xsd:sequence>
+            <xsd:element name="constraint" type="Constraint" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <!-- Constraint -->
+
+    <xsd:complexType name="Constraint">
+        <xsd:sequence>
+            <xsd:element name="params" type="Params" minOccurs="1" maxOccurs="1"/>
+        </xsd:sequence>
+        <xsd:attribute name="class" type="xsd:string" use="required"/>
+    </xsd:complexType>
+    
+    <!-- Params -->
+
+    <xsd:complexType name="Params">
+        <xsd:sequence>
+            <xsd:element name="param" type="Param" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <!-- Param -->
+
+    <xsd:complexType name="Param">
+        <xsd:attribute name="name"  type="xsd:string" use="required"/>
+        <xsd:attribute name="value" type="xsd:string" use="required"/>
+    </xsd:complexType>
+    
+    <!-- ========================================================================== -->
+    <!-- Helper types -->
+    <!-- ========================================================================== -->
+    
+    <!-- Multiplicities -->
+
+    <xsd:simpleType name="Mult">
+        <xsd:restriction base="xsd:string">
+            <xsd:enumeration value="ONCE"/>
+            <xsd:enumeration value="ONCE_OR_MORE"/>
+            <xsd:enumeration value="ZERO_OR_ONCE"/>
+            <xsd:enumeration value="ZERO_OR_MORE"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+    
+    <!-- Separators -->
+
+    <xsd:simpleType name="Sep">
+        <xsd:restriction base="xsd:string">
+            <xsd:enumeration value="COLON"/>
+            <xsd:enumeration value="EQUALS"/>
+            <xsd:enumeration value="BLANK"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+    
+    <!-- Prefixes -->
+
+    <xsd:simpleType name="Prefix">
+        <xsd:restriction base="xsd:string">
+            <xsd:enumeration value="DASH"/>
+            <xsd:enumeration value="DOUBLEDASH"/>
+            <xsd:enumeration value="SLASH"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+    
+</xsd:schema>
+
diff --git a/src/ml/options/Constrainable.java b/src/ml/options/Constrainable.java
new file mode 100644
index 0000000..1a36f75
--- /dev/null
+++ b/src/ml/options/Constrainable.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * The interface for objects which can be constrained, i. e. {@link Constraint}s can 
+ * be attached to such objects. 
+ */
+public interface Constrainable {
+
+    /**
+     * Add a constraint to this instance. 
+     * <p>
+     * @param constraint The {@link Constraint} to add to the list of constraints for this instance
+     */
+    public void addConstraint(Constraint constraint);
+
+    /**
+     * Access all known constraints
+     * <p>
+     * @return A list of {@link Constraint}s for this instance
+     */
+    public java.util.List<Constraint> getConstraints();
+}
+
diff --git a/src/ml/options/Constraint.java b/src/ml/options/Constraint.java
new file mode 100644
index 0000000..957f59c
--- /dev/null
+++ b/src/ml/options/Constraint.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * The interface for all constraints. Custom constraints need to implement this interface.
+ */
+public interface Constraint {
+
+    /**
+     * Check whether a constraint is satisfied. This method can be invoked after a set of 
+     * command line arguments has been analyzed such that the results are known for each 
+     * option and option set.
+     * <p>
+     * @return A boolean to indicate whether a constraint is satisfied or not
+     */
+    public boolean isSatisfied();
+
+    /**
+     * Indicates whether a constraint supports a given type of {@link Constrainable}
+     * <p>
+     * @param constrainable 
+     * @return A boolean to indicate whether this {@link Constrainable} is supported
+     */
+    public boolean supports(Constrainable constrainable);
+}
+
+
diff --git a/src/ml/options/DefaultHelpPrinter.java b/src/ml/options/DefaultHelpPrinter.java
new file mode 100644
index 0000000..1f299de
--- /dev/null
+++ b/src/ml/options/DefaultHelpPrinter.java
@@ -0,0 +1,291 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * A simple implementation of the {@link HelpPrinter} interface. This can serve as a
+ * basis for more complex formatting requirements. 
+ * <p>
+ * The following approach is used here for the command line syntax:
+ * <p>
+ * <table border=1 cellpadding=6>
+ * <tr><td colspan=3 align=center bgcolor=blue><font color=white><b>Option Output Format</b></font>
+ * <tr bgcolor=#ffcc33><td><b> Component </b><td width=350><b> Example</b> <td> <b> Remark </b>
+ * <tr><td> <code>OptionData.Type.SIMPLE</code> option 
+ *     <td> <code>-a </code> 
+ *     <td>  
+ * <tr><td> <code>OptionData.Type.VALUE</code> option 
+ *     <td> <code>-log <logfile> </code> 
+ *     <td> The text <code>logfile</code> can be changed using <code>OptionData.setValueText()</code>
+ * <tr><td> <code>OptionData.Type.DETAIL</code> option 
+ *     <td> <code>-D<detail>=<value> </code> 
+ *     <td> The text <code>value</code> can be changed using <code>OptionData.setValueText()</code>,
+ *          the text <code>detail</code> can be changed using <code>OptionData.setDetailText()</code>
+ * <tr><td> Option names with alternate keys 
+ *     <td> <code> (-a|--Access)</code> 
+ *     <td>  
+ * <tr><td> <code>Options.Multiplicity.ZERO_OR_ONCE</code> 
+ *     <td> <code> [-a] </code> 
+ *     <td>  
+ * <tr><td> <code>Options.Multiplicity.ONCE_OR_MORE</code> 
+ *     <td> <code> -v=<value1> [ -v=<value2> [...]] </code> 
+ *     <td> The text <code>value</code> can be changed using <code>OptionData.setValueText()</code>
+ * <tr><td> <code>Options.Multiplicity.ZERO_OR_MORE</code> 
+ *     <td> <code> [-v=<value1> [ -v=<value2> [...]]] </code> 
+ *     <td> The text <code>value</code> can be changed using <code>OptionData.setValueText()</code>
+ * <tr><td> Exclusive constraints
+ *     <td> <code> { <option1> | <option2> | <option3> } </code>
+ *     <td> <code><optionN></code> is a placeholder for the general option syntax described above 
+ *          which is grouped here using the curly brackets and the pipe symbol
+ * </table>
+ * <p>
+ */
+public class DefaultHelpPrinter implements HelpPrinter {
+
+    private final static String CLASS = "DefaultHelpPrinter";
+
+    /**
+     * Return the help text describing the different options and data arguments
+     * <p>
+     * @param set The {@link OptionSet} to format the output for
+     * <p>
+     * @return A string with the help text for this option set
+     */
+    @Override
+    public String getHelpText(OptionSet set) {
+
+        if (set == null) {
+            throw new IllegalArgumentException(CLASS + ": set may not be null");
+        }
+
+//.... Collect option and data item names
+
+        String st = null;
+        StringBuilder sb = null;
+        java.util.List<String> out = new java.util.ArrayList<String>();
+        int maxLen = 0;
+
+        for (OptionData option : set.getOptionData()) {
+            st = option.getSyntax();
+            if (st.length() > maxLen) {
+                maxLen = st.length();
+            }
+            out.add(st);
+        }
+
+        int limit = set.getMaxData();
+        if (set.hasUnlimitedData()) {
+            limit = set.getMinData() + 1;
+        }
+
+        for (int i = 0; i < limit; i++) {
+            st = dataSyntax(i, set.getDataText(i), set.getMinData(), set.getMaxData());
+            if (st.length() > maxLen) {
+                maxLen = st.length();
+            }
+            out.add(st.toString());
+        }
+
+//.... Assemble final output
+
+        StringBuilder s = new StringBuilder(100);
+        for (int i = 0; i < maxLen + 3; i++) {
+            s.append(' ');
+        }
+        String blank = s.toString();
+
+        sb = new StringBuilder(300);
+
+//.... Help texts for options
+
+        int i = 0;
+        String k = null;
+        String[] texts = null;
+        boolean first = true;
+
+        for (OptionData option : set.getOptionData()) {
+
+            k = out.get(i++) + blank;
+            texts = option.getHelpText().split("\n");
+            first = true;
+
+            for (String text : texts) {
+                if (first) {
+                    sb.append(k.substring(0, maxLen));
+                    sb.append(" : ");
+                    first = false;
+                } else {
+                    sb.append(blank);
+                }
+                sb.append(text);
+                sb.append('\n');
+            }
+
+        }
+
+//.... Help texts for data items
+
+        for (int j = 0; j < limit; j++) {
+
+            k = out.get(i++) + blank;
+            texts = set.getHelpText(j).split("\n");
+            first = true;
+
+            for (String text : texts) {
+                if (first) {
+                    sb.append(k.substring(0, maxLen));
+                    sb.append(" : ");
+                    first = false;
+                } else {
+                    sb.append(blank);
+                }
+                sb.append(text);
+                sb.append('\n');
+            }
+
+        }
+
+        if (sb.length() > 0) {
+            sb.deleteCharAt(sb.length() - 1);
+        }   // Delete last \n
+
+        return sb.toString();
+
+    }
+
+    /**
+     * Return a string with the command line syntax for the given option set
+     * <p>
+     * @param set         The {@link OptionSet} to format the output for
+     * @param leadingText The text to precede the command line
+     * @param lineBreak   A boolean indicating whether the command line for the option set should
+     *                    be printed with line breaks after each option or not
+     * <p>
+     * @return A string with the command line syntax for this option set
+     */
+    @Override
+    public String getCommandLine(OptionSet set, String leadingText, boolean lineBreak) {
+
+        if (set == null) {
+            throw new IllegalArgumentException(CLASS + ": set may not be null");
+        }
+
+        int limit = set.getMaxData();
+        if (set.hasUnlimitedData()) {
+            limit = set.getMinData() + 1;
+        }
+
+        StringBuilder sb = new StringBuilder(200);
+        StringBuilder s = new StringBuilder();
+        String[] d = null;
+
+        if (leadingText != null) {
+            sb.append(leadingText.trim());
+            sb.append(' ');
+            d = leadingText.trim().split("\\n");                    // We may have \n in the leading text string
+            for (int i = 0; i <= d[d.length - 1].length(); i++) {
+                s.append(' ');
+            }
+        }
+
+//.... Options (not part of an ExclusiveConstraint)
+
+        boolean first = true;
+        for (OptionData option : set.getOptionData()) {
+            if (!option.isExclusive()) {
+                if (lineBreak && !first) {
+                    sb.append(s);
+                } else {
+                    first = false;
+                }
+                sb.append(option.getSyntax());
+                if (lineBreak) {
+                    sb.append('\n');
+                } else {
+                    sb.append(' ');
+                }
+            }
+        }
+
+//.... ExclusiveConstraint options
+
+        if (set.getConstraints() != null) {
+
+            ExclusiveConstraint ec = null;
+
+            for (Constraint constraint : set.getConstraints()) {
+
+                if (constraint instanceof ExclusiveConstraint) {
+
+                    ec = (ExclusiveConstraint) constraint;
+
+                    if (lineBreak && !first) {
+                        sb.append(s);
+                    } else {
+                        first = false;
+                    }
+
+                    sb.append('{');                                 // This identifies this type of constraint
+                    for (OptionData option : ec.getOptionData()) {
+                        sb.append(option.getSyntax());
+                        sb.append('|');                               // Separator in between options
+                    }
+                    sb.deleteCharAt(sb.length() - 1);               // Remove last | character
+                    sb.append('}');                                 // End of constraint output
+
+                    if (lineBreak) {
+                        sb.append('\n');
+                    } else {
+                        sb.append(' ');
+                    }
+
+                }
+
+            }
+        }
+
+//.... Data
+
+        if (set.acceptsData()) {
+            if (lineBreak && set.getOptionData().size() > 0) {
+                sb.append(s);
+            }
+            for (int i = 0; i < limit; i++) {
+                sb.append(dataSyntax(i, set.getDataText(i), set.getMinData(), set.getMaxData()));
+                sb.append(' ');
+            }
+        }
+
+        sb.deleteCharAt(sb.length() - 1);
+
+        return sb.toString();
+
+    }
+
+    /**
+     * Helper
+     */
+    private String dataSyntax(int index, String text, int minData, int maxData) {
+        if (index < minData) {
+            return "<" + text + ">";
+        }
+        if (maxData == OptionSet.INF) {
+            return "[<" + text + "> [...]]";
+        }
+        return "[<" + text + ">]";
+    }
+}
+
diff --git a/src/ml/options/ExclusiveConstraint.java b/src/ml/options/ExclusiveConstraint.java
new file mode 100644
index 0000000..4457149
--- /dev/null
+++ b/src/ml/options/ExclusiveConstraint.java
@@ -0,0 +1,263 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * A constraint combining one or more options such that just one of them 
+ * can occur. This type of constraint can only be added to an option set as 
+ * it combines one or more options.
+ * <p>
+ * Constraints of this kind are also accounted for in the {@link DefaultHelpPrinter} 
+ * to format the output provided.
+ */
+public class ExclusiveConstraint implements XMLConstraint {
+
+    private static final String CLASS = "ExclusiveConstraint";
+    private java.util.List<OptionData> optionData = new java.util.ArrayList<OptionData>();
+    private Options.Multiplicity multiplicity = null;
+
+    /**
+     * The public no-org constructor. This is a prereq for all constraints since it is used
+     * for initialization based on XML data.
+     */
+    public ExclusiveConstraint() {
+    
+    }
+
+    /**
+     * This method is used to initialize this constraint based on data read from an XML configuration
+     * file. The method is invoked internally during setup with the instance of
+     * {@link Constrainable} to which the constraint applies and a list of JDOM elements,
+     * which contain the details about the constraint itself.
+     * <p>
+     * This method initializes the constraint and attaches it to the list of constraints
+     * of the {@link Constrainable} instance.
+     * <p>
+     * The parameters expected in the XML <code><param></code> tags for this constraint
+     * are
+     * <p>
+     * <table border=1 cellpadding=6>
+     * <tr bgcolor=#dddddd> <td> <b >Name</b> <td> <b>Value</b> <td> <b>Status</b>
+     * <tr> <td> keys <td> Same as the <code>keys</code> 
+     *                     parameter in {@link #add(OptionSet, Options.Multiplicity, String[])} <td> Required
+     * <tr> <td> mult <td> Same as the <code>multiplicity</code> 
+     *                     parameter in {@link #add(OptionSet, Options.Multiplicity, String[])} <td> Optional
+     * </table>
+     * <p>
+     * @param constrainable The {@link Constrainable} instance to which this constraint applies
+     * @param list          A list of JDOM elements to be used to initialize the constraint. Specifically,
+     *                      these are tags of the form
+     *                      <p>
+     *                      <code><param name="..." value="..." /></code>
+     *                      <p>
+     *                      containing key/value pairs with information.
+     */
+    @Override
+    public void init(Constrainable constrainable, java.util.List<org.jdom.Element> list) {
+
+        if (list == null) {
+            throw new IllegalArgumentException(CLASS + ": list may not be null");
+        }
+        if (constrainable == null) {
+            throw new IllegalArgumentException(CLASS + ": constrainable may not be null");
+        }
+        if (!supports(constrainable)) {
+            throw new IllegalArgumentException(CLASS + ": Constrainable must be instance of OptionSet");
+        }
+
+//.... Extract all parameters
+
+        java.util.Map<String, String> params = new java.util.HashMap<String, String>();
+        for (org.jdom.Element param : list) {
+            params.put(param.getAttributeValue("name").trim(), param.getAttributeValue("value").trim());
+        }
+
+//.... Checks
+
+        if (!params.containsKey("keys")) {
+            throw new IllegalArgumentException(CLASS + ": missing <param> element with attribute named 'keys'");
+        }
+
+        Options.Multiplicity mult = Options.Multiplicity.valueOf(params.get("mult"));
+
+//.... Add the constraint
+
+        if (params.containsKey("mult")) {
+            add((OptionSet) constrainable, mult, params.get("keys").split("\\|"));
+        } else {
+            add((OptionSet) constrainable, params.get("keys").split("\\|"));
+        }
+
+    }
+
+    /**
+     * Add a constraint to the given option set
+     * <p>
+     * @param optionSet    The {@link OptionSet} to add this constraint to
+     * @param multiplicity The {@link Options.Multiplicity} to use for all options tied together by these constraints. 
+     *                     A <code>Multiplicity</code> defined previously for any option contained in this constraint 
+     *                     is overridden.
+     * @param keys         The keys of the options to tie together by this constraint. At least two keys
+     *                     must be given here, and the corresponding options must already be defined in the set.
+     */
+    public static void add(OptionSet optionSet, Options.Multiplicity multiplicity, String... keys) {
+        if (optionSet == null) {
+            throw new IllegalArgumentException(CLASS + ": optionSet may not be null");
+        }
+        if (multiplicity == null) {
+            throw new IllegalArgumentException(CLASS + ": multiplicity may not be null");
+        }
+        if (keys.length < 2) {
+            throw new IllegalArgumentException(CLASS + ": at least two keys must be provided");
+        }
+        optionSet.addConstraint(new ExclusiveConstraint(optionSet, multiplicity, keys));
+    }
+
+    /**
+     * Add a constraint to the given option set using the default multiplicity defined for this set
+     * <p>
+     * @param optionSet    The {@link OptionSet} to add this constraint to
+     * @param keys         The keys of the options to tie together by this constraint. At least two keys
+     *                     must be given here, and the corresponding options must already be defined in the set.
+     */
+    public static void add(OptionSet optionSet, String... keys) {
+        if (optionSet == null) {
+            throw new IllegalArgumentException(CLASS + ": optionSet may not be null");
+        }
+        if (keys.length < 2) {
+            throw new IllegalArgumentException(CLASS + ": at least two keys must be provided");
+        }
+        optionSet.addConstraint(new ExclusiveConstraint(optionSet, optionSet.getDefaultMultiplicity(), keys));
+    }
+
+    /**
+     * Constructor
+     */
+    ExclusiveConstraint(OptionSet optionSet, Options.Multiplicity multiplicity, String[] keys) {
+        OptionData od = null;
+        for (String key : keys) {
+            od = optionSet.getOption(key);
+            if (od.isExclusive()) {
+                throw new IllegalArgumentException(CLASS + ": option '" + key + "' is already part of an " + CLASS);
+            }
+            optionData.add(od);
+            od.setExclusive(true);
+            od.setMultiplicity(multiplicity);
+            this.multiplicity = multiplicity;
+        }
+    }
+
+    /**
+     *
+     */
+    Options.Multiplicity getMultiplicity() {
+        return multiplicity;
+    }
+
+    /**
+     *
+     */
+    java.util.List<OptionData> getOptionData() {
+        return optionData;
+    }
+
+    /**
+     * Indicates whether a constraint supports a given type of {@link Constrainable}
+     * <p>
+     * @param constrainable 
+     * @return A boolean to indicate whether this {@link Constrainable} is supported. This constraint only
+     *         supports {@link OptionSet} constrainables
+     */
+    @Override
+    public boolean supports(Constrainable constrainable) {
+        if (constrainable == null) {
+            throw new IllegalArgumentException(CLASS + ": constrainable may not be null");
+        }
+        if (constrainable instanceof OptionSet) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * The actual check routine
+     * <p>
+     * @return A boolean indicating whether the constraint is satisfied or not
+     */
+    @Override
+    public boolean isSatisfied() {
+
+//.... Check whether only one of the grouped options appears
+
+        boolean found = false;
+        OptionData odata = null;
+        for (OptionData od : optionData) {
+            if (od.getResultCount() > 0) {
+                if (found) {
+                    return false;
+                }               // We found the second one - failure
+                found = true;                          // We found the first one
+                odata = od;
+            }
+        }
+
+        if (!found) {
+            return false;
+        }       // No occurence found - constraint not satisfied
+
+//.... Check multiplicity for the one option found
+
+        switch (multiplicity) {
+            case ONCE:
+                if (odata.getResultCount() != 1) {
+                    return false;
+                }
+                break;
+            case ONCE_OR_MORE:
+                if (odata.getResultCount() == 0) {
+                    return false;
+                }
+                break;
+            case ZERO_OR_ONCE:
+                if (odata.getResultCount() > 1) {
+                    return false;
+                }
+                break;
+        }
+
+        return true;
+
+    }
+
+    /**
+     * This is the overloaded {@link Object#toString()} method
+     * <p>
+     * @return A string representing the instance
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        for (OptionData od : optionData) {
+            sb.append(od.getKey());
+            sb.append("|");
+        }
+        sb.deleteCharAt(sb.length() - 1);
+        return sb.toString();
+    }
+}
+
+
diff --git a/src/ml/options/HelpPrinter.java b/src/ml/options/HelpPrinter.java
new file mode 100644
index 0000000..6edc460
--- /dev/null
+++ b/src/ml/options/HelpPrinter.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * This interface is supposed to be implemented by all classes providing help printing 
+ * capabilities.
+ */
+public interface HelpPrinter {
+
+    /**
+     * Return a string with the command line syntax for this option set
+     * <p>
+     * @param set         The {@link OptionSet} to format the output for 
+     * @param leadingText The text to precede the command line
+     * @param lineBreak   A boolean indicating whether the command line for the option set should
+     *                    be printed with line breaks after each option or not
+     * <p>
+     * @return A string with the command line syntax for this option set
+     */
+    public String getCommandLine(OptionSet set, String leadingText, boolean lineBreak);
+
+    /**
+     * Return the help text describing the different options and data arguments
+     * <p>
+     * @param set The {@link OptionSet} to format the output for 
+     * <p>
+     * @return A string with the help text for this option set
+     */
+    public String getHelpText(OptionSet set);
+}
+
diff --git a/src/ml/options/OptionData.java b/src/ml/options/OptionData.java
new file mode 100644
index 0000000..be39fae
--- /dev/null
+++ b/src/ml/options/OptionData.java
@@ -0,0 +1,685 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class holds all the data for an option. This includes the prefix, the key, the separators
+ * (for value and detail options), the multiplicity, and all the other settings describing the option. The class
+ * is designed to be only a data container from a user perspective, i. e. the user has access to
+ * any data determined by the {@link Options#check()} methods, but not access to any of the other methods
+ * which are used internally for the operation of the actual check.
+ */
+public class OptionData implements Constrainable {
+
+    private final static String CLASS = "OptionData";
+    private Options.Prefix prefix = null;
+    private Options.Prefix altPrefix = null;
+    private String key = null;
+    private String altKey = null;
+    private String helpText = "";
+    private String valueText = "value";
+    private String detailText = "detail";
+    private boolean detail = false;
+    private Options.Separator separator = null;
+    private boolean value = false;
+    private boolean exclusive = false;
+    private Options.Multiplicity multiplicity = null;
+    private java.util.regex.Pattern pattern = null;
+    private int counter = 0;
+    private java.util.List<String> values = null;
+    private java.util.List<String> details = null;
+    private java.util.List<Constraint> constraints = null;
+    private Type type = null;
+
+    /**
+     * An enum describing the different available types of options
+     */
+    public enum Type {
+
+        /**
+         * An option which acts as a switch (i. e. no value or detail argument is taken)
+         */
+        SIMPLE(false, false),
+        /**
+         * An option which expects a value to be specified along with it
+         */
+        VALUE(true, false),
+        /**
+         * An option which expects both a value and details further describing the value to be specified along with it
+         */
+        DETAIL(true, true);
+        boolean value = false;
+        boolean detail = false;
+
+        Type(boolean value, boolean detail) {
+            this.value = value;
+            this.detail = detail;
+        }
+
+        boolean value() {
+            return value;
+        }
+
+        boolean detail() {
+            return detail;
+        }
+    }
+
+    /**
+     * A copying constructor. This is for setup purposes only, i. e. result data is NOT copied.
+     */
+    OptionData(OptionData od) {
+        this(od.getType(), od.getPrefix(), od.getAltPrefix(), od.getKey(), od.getAltKey(),
+             od.getSeparator(), od.getMultiplicity());
+        this.helpText = od.getHelpText();
+        this.valueText = od.getValueText();
+        this.detailText = od.getDetailText();
+    }
+
+    /**
+     * The constructor
+     */
+    OptionData(Type type,
+               Options.Prefix prefix,
+               Options.Prefix altPrefix,
+               String key,
+               String altKey,
+               Options.Separator separator,
+               Options.Multiplicity multiplicity) {
+
+        if (type == null) {
+            throw new IllegalArgumentException(CLASS + ": type may not be null");
+        }
+        if (prefix == null) {
+            throw new IllegalArgumentException(CLASS + ": prefix may not be null");
+        }
+        if (altPrefix == null) {
+            throw new IllegalArgumentException(CLASS + ": altPrefix may not be null");
+        }
+        if (key == null) {
+            throw new IllegalArgumentException(CLASS + ": key may not be null");
+        }
+        if (multiplicity == null) {
+            throw new IllegalArgumentException(CLASS + ": multiplicity may not be null");
+        }
+
+//.... The data describing the option
+
+        this.type = type;
+        this.prefix = prefix;
+        this.altPrefix = altPrefix;
+        this.key = key;
+        this.altKey = altKey;
+        this.separator = separator;
+        this.multiplicity = multiplicity;
+
+        value = type.value();
+        detail = type.detail();
+
+//.... Create the pattern to match this option
+
+        String keyPattern = null;
+        if (altKey == null) {
+            keyPattern = prefix.getName() + key;
+        } else {
+            keyPattern = "(" + prefix.getName() + key + "|" + altPrefix.getName() + altKey + ")";
+        }
+
+        if (value) {
+            if (separator.equals(Options.Separator.BLANK)) {
+                if (detail) {
+                    pattern = java.util.regex.Pattern.compile(keyPattern + "((\\w|\\.)+)$");
+                } else {
+                    pattern = java.util.regex.Pattern.compile(keyPattern + "$");
+                }
+            } else {
+                if (detail) {
+                    pattern = java.util.regex.Pattern.compile(keyPattern + "((\\w|\\.)+)" + separator.getName() + "(.+)$");
+                } else {
+                    pattern = java.util.regex.Pattern.compile(keyPattern + separator.getName() + "(.+)$");
+                }
+            }
+        } else {
+            pattern = java.util.regex.Pattern.compile(keyPattern + "$");
+        }
+
+//.... Structures to hold result data
+
+        if (value) {
+            values = new java.util.ArrayList<String>();
+            if (detail) {
+                details = new java.util.ArrayList<String>();
+            }
+        }
+
+    }
+
+// ==========================================================================================
+// Inquiry methods
+// ==========================================================================================
+    /**
+     * Check whether this option has a defined alternate key value
+     * <p>
+     * @return A boolean indicating whether this option has a defined alternate key value
+     */
+    boolean hasAlternateKey() {
+        return altKey == null ? false : true;
+    }
+
+    /**
+     * Getter method for <code>prefix</code> property
+     * <p>
+     * @return The value for the <code>prefix</code> property
+     */
+    Options.Prefix getPrefix() {
+        return prefix;
+    }
+
+    /**
+     * Getter method for <code>altPrefix</code> property
+     * <p>
+     * @return The value for the <code>altPprefix</code> property
+     */
+    Options.Prefix getAltPrefix() {
+        return altPrefix;
+    }
+
+    /**
+     * Getter method for <code>type</code> property
+     * <p>
+     * @return The value for the <code>type</code> property
+     */
+    Type getType() {
+        return type;
+    }
+
+    /**
+     * Getter method for <code>key</code> property
+     * <p>
+     * @return The value for the <code>key</code> property
+     */
+    String getKey() {
+        return key;
+    }
+
+    /**
+     * Getter method for <code>altKey</code> property
+     * <p>
+     * @return The value for the <code>altKey</code> property
+     */
+    String getAltKey() {
+        return altKey;
+    }
+
+    /**
+     * Getter method for <code>detail</code> property
+     * <p>
+     * @return The value for the <code>detail</code> property
+     */
+    boolean useDetail() {
+        return detail;
+    }
+
+    /**
+     * Getter method for <code>separator</code> property
+     * <p>
+     * @return The value for the <code>separator</code> property
+     */
+    Options.Separator getSeparator() {
+        return separator;
+    }
+
+    /**
+     * Getter method for <code>value</code> property
+     * <p>
+     * @return The value for the <code>value</code> property
+     */
+    boolean useValue() {
+        return value;
+    }
+
+    /**
+     * Getter method for <code>multiplicity</code> property
+     * <p>
+     * @return The value for the <code>multiplicity</code> property
+     */
+    Options.Multiplicity getMultiplicity() {
+        return multiplicity;
+    }
+
+    /**
+     * Setter method for <code>multiplicity</code> property
+     * <p>
+     * @param multiplicity The value for the <code>multiplicity</code> property
+     */
+    void setMultiplicity(Options.Multiplicity multiplicity) {
+        if (multiplicity == null) {
+            throw new IllegalArgumentException(CLASS + ": multiplicity may not be null");
+        }
+        this.multiplicity = multiplicity;
+    }
+
+    /**
+     * Getter method for <code>pattern</code> property
+     * <p>
+     * @return The value for the <code>pattern</code> property
+     */
+    java.util.regex.Pattern getPattern() {
+        return pattern;
+    }
+
+// ==========================================================================================
+// Result management
+// ==========================================================================================
+    /**
+     * Check whether this option has been found on the command line
+     * <p>
+     * @return A boolean indicating whether this option has been found on the command line
+     */
+    public boolean isSet() {
+        return getResultCount() > 0 ? true : false;
+    }
+
+    /**
+     * Get the number of results found for this option, which is number of times the key matched
+     * <p>
+     * @return The number of results
+     */
+    public int getResultCount() {
+        if (value) {
+            return values.size();
+        } else {
+            return counter;
+        }
+    }
+
+    /**
+     * Get the value with the given index. The index can range between 0 and {@link #getResultCount()}<code> - 1</code>.
+     * However, only for value options, a non-<code>null</code> value will be returned. Non-value options always
+     * return <code>null</code>.
+     * <p>
+     * @param index The index for the desired value
+     * <p>
+     * @return The option value with the given index
+     */
+    public String getResultValue(int index) {
+        if (!value) {
+            return null;
+        }
+        if (index < 0 || index >= getResultCount()) {
+            throw new IllegalArgumentException(CLASS + ": illegal value for index");
+        }
+        return values.get(index);
+    }
+
+    /**
+     * Return a list of all result values
+     * <p>
+     * @return A list with all result values
+     */
+    public List<String> getResultValues() {
+        List<String> list = new ArrayList<String>();
+        for (int index = 0; index < getResultCount(); index++) {
+            list.add(getResultValue(index));
+        }
+        return list;
+    }
+
+    /**
+     * Get the detail with the given index. The index can range between 0 and {@link #getResultCount()}<code> - 1</code>.
+     * However, only for value options which take details, a non-<code>null</code> detail will be returned. Non-value options
+     * and value options which do not take details always return <code>null</code>.
+     * <p>
+     * @param index The index for the desired value
+     * <p>
+     * @return The option detail with the given index
+     */
+    public String getResultDetail(int index) {
+        if (!detail) {
+            return null;
+        }
+        if (index < 0 || index >= getResultCount()) {
+            throw new IllegalArgumentException(CLASS + ": illegal value for index");
+        }
+        return details.get(index);
+    }
+
+    /**
+     * Return a list of all option details
+     * <p>
+     * @return A list with all option details
+     */
+    public List<String> getResultDetails() {
+        List<String> list = new ArrayList<String>();
+        for (int index = 0; index < getResultCount(); index++) {
+            list.add(getResultDetail(index));
+        }
+        return list;
+    }
+
+    /**
+     * Store the data for a match found
+     */
+    void addResult(String valueData, String detailData) {
+        if (value) {
+            if (valueData == null) {
+                throw new IllegalArgumentException(CLASS + ": valueData may not be null");
+            }
+            values.add(valueData);
+            if (detail) {
+                if (detailData == null) {
+                    throw new IllegalArgumentException(CLASS + ": detailData may not be null");
+                }
+                details.add(detailData);
+            }
+        }
+        counter++;
+    }
+
+// ==========================================================================================
+// Description management
+// ==========================================================================================
+    /**
+     * Set the text to be used for the <value> argument of a value option.
+     * This is used in the {@link HelpPrinter} output.
+     * <p>
+     * @param text The text used for the <value> argument of a value option
+     * <p>
+     * @return The option instance itself to allow incovation chaining
+     */
+    public OptionData setValueText(String text) {
+        if (text == null) {
+            throw new IllegalArgumentException(CLASS + ": text may not be null");
+        }
+        this.valueText = text.trim();
+        return this;
+    }
+
+    /**
+     * Set the text to be used for the <detail> argument of a value option.
+     * This is used in the {@link HelpPrinter} output.
+     * <p>
+     * @param text The text used for the <detail> argument of a value option
+     * <p>
+     * @return The option instance itself to allow incovation chaining
+     */
+    public OptionData setDetailText(String text) {
+        if (text == null) {
+            throw new IllegalArgumentException(CLASS + ": text may not be null");
+        }
+        this.detailText = text.trim();
+        return this;
+    }
+
+    /**
+     * Set the text describing the purpose of the option. This is used in the {@link HelpPrinter} output.
+     * <p>
+     * @param text The text describing the purpose of the option
+     * <p>
+     * @return The option instance itself to allow incovation chaining
+     */
+    public OptionData setHelpText(String text) {
+        if (text == null) {
+            throw new IllegalArgumentException(CLASS + ": text may not be null");
+        }
+        this.helpText = text.trim();
+        return this;
+    }
+
+    /**
+     * Return the text describing the purpose of the option
+     * <p>
+     * @return The text describing the purpose of the option (or an empty string, if that text has not been set)
+     */
+    public String getHelpText() {
+        return helpText;
+    }
+
+    /**
+     * Return the text to be used for the <value> argument of a value option
+     * <p>
+     * @return The text to be used for the <value> argument of a value option (or a default value if this
+     *         text has not been set, or if this is not a value option at all)
+     */
+    public String getValueText() {
+        return valueText;
+    }
+
+    /**
+     * Return the text to be used for the <detail> argument of a detail option
+     * <p>
+     * @return The text to be used for the <detail> argument of a detail option (or a default value if this
+     *         text has not been set, or if this is not a detail option at all)
+     */
+    public String getDetailText() {
+        return detailText;
+    }
+
+    /**
+     * Add a constraint for this option
+     * <p>
+     * @param constraint The {@link Constraint} to add
+     */
+    @Override
+    public void addConstraint(Constraint constraint) {
+        if (constraint == null) {
+            throw new IllegalArgumentException(CLASS + ": constraint may not be null");
+        }
+
+        if (!constraint.supports(this)) {
+            throw new IllegalArgumentException(CLASS + ": the given constraint can not be applied to options");
+        }
+
+        if (constraints == null) {
+            constraints = new java.util.ArrayList<Constraint>();
+        }
+
+        constraints.add(constraint);
+    }
+
+    /**
+     *
+     */
+    boolean isExclusive() {
+        return exclusive;
+    }
+
+    /**
+     *
+     */
+    void setExclusive(boolean exclusive) {
+        this.exclusive = exclusive;
+    }
+
+    /**
+     * Get the constraints defined for this option
+     * <p>
+     * @return The defined constraints for this option (or <code>null</code> if no constraints have been defined)
+     */
+    @Override
+    public java.util.List<Constraint> getConstraints() {
+        return constraints;
+    }
+
+    /**
+     * Get the command line syntax for this option. This method accounts for all characteristics
+     * of the option such as separators, multiplicity, alternate keys and the like.
+     * <p>
+     * @return A string with the command line syntax
+     */
+    public String getSyntax() {
+
+        StringBuilder sb = new StringBuilder(20);
+
+        boolean mult = (multiplicity == Options.Multiplicity.ZERO_OR_MORE) ||
+                (multiplicity == Options.Multiplicity.ONCE_OR_MORE) ? true : false;
+        boolean opt = (multiplicity == Options.Multiplicity.ONCE_OR_MORE) ||
+                (multiplicity == Options.Multiplicity.ONCE) ? false : true;
+
+        if (opt) {
+            sb.append('[');
+        }     // Option can also be omitted
+        printFullOption(sb, mult);
+        if (opt) {
+            sb.append(']');
+        }     // Option can also be omitted
+
+        return sb.toString();
+
+    }
+
+    /**
+     * Helper method: print the full text for an option, accounting for multiplicity
+     */
+    void printFullOption(StringBuilder sb, boolean mult) {
+        printOption(sb);
+        if (mult) {                  // Option can occur more than once
+            printTexts(sb, 1);
+            sb.append(" [");
+            printOption(sb);
+            printTexts(sb, 2);
+            sb.append(" [...]]");
+        } else {
+            printTexts(sb, 0);
+        }
+    }
+
+    /**
+     * Helper method: add the descriptive texts for value and detail options
+     */
+    void printTexts(StringBuilder sb, int i) {
+        if (detail) {
+            sb.append('<');
+            sb.append(detailText);
+            if (i > 0) {
+                sb.append(i);
+            }
+            sb.append('>');
+        }
+        if (value) {
+            sb.append(separator.getName());
+            sb.append('<');
+            sb.append(valueText);
+            if (i > 0) {
+                sb.append(i);
+            }
+            sb.append('>');
+        }
+    }
+
+    /**
+     * Helper method: prints the key and - if present - the alternate key for an option, adds () if necessary
+     */
+    void printOption(StringBuilder sb) {
+        if (altKey != null) {
+            sb.append('(');
+        }
+        sb.append(prefix.getName());
+        sb.append(key);
+        if (altKey != null) {
+            sb.append('|');
+            sb.append(altPrefix.getName());
+            sb.append(altKey);
+            sb.append(')');
+        }
+    }
+
+    /**
+     * This is the overloaded {@link Object#toString()} method.
+     * <p>
+     * @return A string representing the instance
+     */
+    @Override
+    public String toString() {
+
+        StringBuilder sb = new StringBuilder();
+
+        sb.append("Prefix      : ");
+        sb.append(prefix);
+        sb.append('\n');
+        sb.append("AltPrefix   : ");
+        sb.append(altPrefix);
+        sb.append('\n');
+        sb.append("Key         : ");
+        sb.append(key);
+        sb.append('\n');
+        if (hasAlternateKey()) {
+            sb.append("AltKey      : ");
+            sb.append(altKey);
+            sb.append('\n');
+        }
+        sb.append("Detail      : ");
+        sb.append(detail);
+        sb.append('\n');
+        sb.append("Separator   : ");
+        sb.append(separator);
+        sb.append('\n');
+        sb.append("Value       : ");
+        sb.append(value);
+        sb.append('\n');
+        sb.append("Multiplicity: ");
+        sb.append(multiplicity);
+        sb.append('\n');
+        sb.append("Pattern     : ");
+        sb.append(pattern);
+        sb.append('\n');
+        sb.append("HelpText    : ");
+        sb.append(helpText);
+        sb.append('\n');
+        sb.append("ValueText   : ");
+        sb.append(valueText);
+        sb.append('\n');
+        sb.append("DetailText  : ");
+        sb.append(detailText);
+        sb.append('\n');
+
+        if (constraints != null) {
+            for (Constraint constraint : constraints) {
+                sb.append("Constraint  : ");
+                sb.append(constraint.toString());
+                sb.append('\n');
+            }
+        }
+
+        sb.append("Results #   : ");
+        sb.append(counter);
+        sb.append('\n');
+
+        if (value) {
+            if (detail) {
+                for (int i = 0; i < values.size(); i++) {
+                    sb.append(details.get(i));
+                    sb.append(" / ");
+                    sb.append(values.get(i));
+                    sb.append('\n');
+                }
+            } else {
+                for (int i = 0; i < values.size(); i++) {
+                    sb.append(values.get(i));
+                    sb.append('\n');
+                }
+            }
+        }
+
+        return sb.toString();
+
+    }
+}
+
+
diff --git a/src/ml/options/OptionSet.java b/src/ml/options/OptionSet.java
new file mode 100644
index 0000000..0f4b5f4
--- /dev/null
+++ b/src/ml/options/OptionSet.java
@@ -0,0 +1,645 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * This class holds the information for a <i>set</i> of options. A set can hold any number of 
+ * <code>OptionData</code> instances which are checked together to determine success or failure. 
+ * <p>
+ * The approach to use this class looks like this:
+ * <p>
+ * <ol>
+ * <li> The user uses any of the <code>Options.addSet()</code> methods 
+ *      (e. g. {@link Options#addSet(String)}) to create 
+ *      any number of sets required (or just relies on the default set, if only one set is required)
+ * <li> The user adds all required option definitions to each set
+ * <li> Using any of the <code>Options.check()</code> methods, each set can be checked whether the options
+ *      that were specified on the command line satisfy its requirements
+ * <li> If the check was successful for a given set, several data items are available from this class:
+ *      <ul>
+ *      <li> All options defined for the set (through which e. g. values, details, and multiplicity are available)
+ *      <li> All data items found (these are the items on the command line which do not start with the prefix, 
+ *           i. e. non-option arguments)
+ *      <li> All unmatched arguments on the command line (these are the items on the command line which start 
+ *           with the prefix, but do not match to one of the options).
+ *           Programs can elect to ignore these, or react with an error
+ *      </ul>
+ * </ol>
+ */
+public class OptionSet implements Constrainable {
+
+    private final static String CLASS = "OptionSet";
+    private static java.util.regex.Pattern keyPattern = java.util.regex.Pattern.compile("\\w+");
+    private java.util.ArrayList<OptionData> options = new java.util.ArrayList<OptionData>();
+    private java.util.HashMap<String, OptionData> keys = new java.util.HashMap<String, OptionData>();
+    private java.util.HashSet<String> altKeys = new java.util.HashSet<String>();
+    private java.util.ArrayList<String> unmatched = new java.util.ArrayList<String>();
+    private java.util.ArrayList<String> data = new java.util.ArrayList<String>();
+    private String name = null;
+    private String[] dataText = null;
+    private String[] helpText = null;
+    private int minData = 0;
+    private int maxData = 0;
+    private Options.Prefix prefix = null;
+    private Options.Prefix altPrefix = null;
+    private Options.Multiplicity defaultMultiplicity = null;
+    private Options.Separator valueSeparator = null;
+    private Options.Separator detailSeparator = null;
+    private boolean isDefault = false;
+    private boolean unlimitedData = false;
+    private int limit = 0;
+    private java.util.List<Constraint> constraints = null;
+    /**
+     * A constant indicating an unlimited number of supported data items
+     */
+    public static final int INF = -1;
+
+    /**
+     * A copying constructor. This is for setup purposes only and does not copy any result data.
+     */
+    OptionSet(String name, OptionSet os) {
+
+        this(name, os.getPrefix(), os.getAltPrefix(), os.getValueSeparator(), os.getDetailSeparator(),
+                os.getDefaultMultiplicity(), os.getMinData(), os.getMaxData(), false);
+
+        this.limit = os.getLimit();
+
+        for (int i = 0; i < limit; i++) {
+            helpText[i] = os.getHelpText(i);
+            dataText[i] = os.getDataText(i);
+        }
+
+        for (String s : os.getAltKeys()) {
+            altKeys.add(s);
+        }
+
+        OptionData nod = null;
+        for (OptionData od : os.getOptionData()) {
+            nod = new OptionData(od);
+            options.add(nod);
+            keys.put(od.getKey(), nod);
+        }
+
+    }
+
+    Options.Multiplicity getDefaultMultiplicity() {
+        return defaultMultiplicity;
+    }
+
+    java.util.HashMap<String, OptionData> getKeys() {
+        return keys;
+    }
+
+    java.util.HashSet<String> getAltKeys() {
+        return altKeys;
+    }
+
+    /**
+     * Constructor
+     */
+    OptionSet(String name,
+            Options.Prefix prefix,
+            Options.Prefix altPrefix,
+            Options.Separator valueSeparator,
+            Options.Separator detailSeparator,
+            Options.Multiplicity defaultMultiplicity,
+            int minData,
+            int maxData,
+            boolean isDefault) {
+
+        if (name == null) {
+            throw new IllegalArgumentException(CLASS + ": name may not be null");
+        }
+        if (minData < 0) {
+            throw new IllegalArgumentException(CLASS + ": minData must be >= 0");
+        }
+        if (maxData < minData) {
+            throw new IllegalArgumentException(CLASS + ": maxData must be >= minData");
+        }
+
+        this.prefix = prefix;
+        this.altPrefix = altPrefix;
+        this.defaultMultiplicity = defaultMultiplicity;
+        this.valueSeparator = valueSeparator;
+        this.detailSeparator = detailSeparator;
+        this.name = name;
+        this.minData = minData;
+        this.maxData = maxData;
+
+//.... Unless we support an unlimited number of data items, we can define texts for up to maxData
+//     data items. Otherwise, we only can use up to (minData + 1) definitions: minData for the 
+//     first required ones, and 1 more which goes into the [] brackets
+
+        limit = maxData;
+        if (maxData == Integer.MAX_VALUE) {
+            unlimitedData = true;
+            limit = minData + 1;
+        }
+
+        dataText = new String[limit];
+        for (int i = 0; i < limit; i++) // Set the default for the data text
+        {
+            dataText[i] = "data";
+        }
+        helpText = new String[limit];
+        for (int i = 0; i < limit; i++) // Set the default for the help text
+        {
+            helpText[i] = "";
+        }
+
+        this.isDefault = isDefault;                         // Whether this is the default set
+
+    }
+
+    /**
+     * Indicate whether this set has no upper limit for the number of allowed data items
+     * <p>
+     * @return A boolean indicating whether this set has no upper limit for the number of allowed data items
+     */
+    public boolean hasUnlimitedData() {
+        return unlimitedData;
+    }
+
+    /**
+     * Indicate whether this set is the default set or not
+     * <p>
+     * @return A boolean indicating whether this set is the default set or not
+     */
+    public boolean isDefault() {
+        return isDefault;
+    }
+
+    /**
+     * Add a constraint for this option set
+     * <p>
+     * @param constraint The {@link Constraint} to add
+     */
+    @Override
+    public void addConstraint(Constraint constraint) {
+        if (constraint == null) {
+            throw new IllegalArgumentException(CLASS + ": constraint may not be null");
+        }
+
+        if (!constraint.supports(this)) {
+            throw new IllegalArgumentException(CLASS + ": the given constraint can not be applied to option sets");
+        }
+
+        if (constraints == null) {
+            constraints = new java.util.ArrayList<Constraint>();
+        }
+
+        constraints.add(constraint);
+    }
+
+    /**
+     * Get the constraints defined for this option set
+     * <p>
+     * @return The defined constraints for this option (or <code>null</code> if no constraints have been defined)
+     */
+    @Override
+    public java.util.List<Constraint> getConstraints() {
+        return constraints;
+    }
+
+    /**
+     * Set the data text for a data item on the command line. This is exploited e. g. in {@link HelpPrinter} instances.
+     * <p>
+     * @param index The index for this data item on the command line. Must be within the allowed range of 
+     *              <code>0 ... maxData - 1</code> for this set. If this set supports an unlimited 
+     *              number of data items, the allowed range is <code>0 ... minData</code>.
+     * @param text  The text to use for this data item in the command line syntax
+     * <p>
+     * @return This set to allow for invocation chaining
+     */
+    public OptionSet setDataText(int index, String text) {
+        if (text == null) {
+            throw new IllegalArgumentException(CLASS + ": text may not be null");
+        }
+        if (index < 0 || index >= limit) {
+            throw new IllegalArgumentException(CLASS + ": invalid value for index");
+        }
+        this.dataText[index] = text.trim();
+        return this;
+    }
+
+    /**
+     * Set the help text for a data item on the command line. This is exploited e. g. in {@link HelpPrinter} instances.
+     * <p>
+     * @param index The index for this data item on the command line. Must be within the allowed range of 
+     *              <code>0 ... maxData - 1</code> for this set. If this set supports an unlimited 
+     *              number of data items, the allowed range is <code>0 ... minData</code>.
+     * @param text  The help text to use to describe the purpose of the data item
+     * <p>
+     * @return This set to allow for invocation chaining
+     */
+    public OptionSet setHelpText(int index, String text) {
+        if (text == null) {
+            throw new IllegalArgumentException(CLASS + ": text may not be null");
+        }
+        if (index < 0 || index >= limit) {
+            throw new IllegalArgumentException(CLASS + ": invalid value for index");
+        }
+        this.helpText[index] = text.trim();
+        return this;
+    }
+
+    /**
+     * Get the data text for a data item on the command line. This is only useful if such a data text is used.
+     * <p>
+     * @param index The index for this data item on the command line. Must be within the allowed range of 
+     *              <code>0 ... maxData - 1</code> for this set. If this set supports an unlimited 
+     *              number of data items, the allowed range is <code>0 ... minData</code>.
+     * <p>
+     * @return The text used for this data item in the command line syntax
+     */
+    public String getDataText(int index) {
+        if (index < 0 || index >= limit) {
+            throw new IllegalArgumentException(CLASS + ": invalid value for index");
+        }
+        return dataText[index];
+    }
+
+    /**
+     * Get the help text for a data item on the command line. This is only useful if such a help text is used.
+     * <p>
+     * @param index The index for this data item on the command line. Must be within the allowed range of 
+     *              <code>0 ... maxData - 1</code> for this set. If this set supports an unlimited 
+     *              number of data items, the allowed range is <code>0 ... minData</code>.
+     * <p>
+     * @return The help text used to describe the purpose of the data item
+     */
+    public String getHelpText(int index) {
+        if (index < 0 || index >= limit) {
+            throw new IllegalArgumentException(CLASS + ": invalid value for index");
+        }
+        return helpText[index];
+    }
+
+    /**
+     * Get the primary {@link Options.Prefix} for this set. This is primarily intended for use by
+     * {@link HelpPrinter} instances to format their output.
+     * <p>
+     * @return The {@link Options.Prefix} instance used as primary prefix for this set
+     */
+    Options.Prefix getPrefix() {
+        return prefix;
+    }
+
+    /**
+     * Get the alternate {@link Options.Prefix} for this set. This is primarily intended for use by
+     * {@link HelpPrinter} instances to format their output.
+     * <p>
+     * @return The {@link Options.Prefix} instance used as alternate prefix for this set
+     */
+    Options.Prefix getAltPrefix() {
+        return altPrefix;
+    }
+
+    /**
+     * Get a list of all the options defined for this set
+     * <p>
+     * @return A list of {@link OptionData} instances defined for this set
+     */
+    public java.util.List<OptionData> getOptionData() {
+        return options;
+    }
+
+    /**
+     * Get the data for a specific option, identified by its key name (which is unique)
+     * <p>
+     * @param key The key for the option
+     * <p>
+     * @return The {@link OptionData} instance
+     */
+    public OptionData getOption(String key) {
+        if (key == null) {
+            throw new IllegalArgumentException(CLASS + ": key may not be null");
+        }
+        if (!keys.containsKey(key)) {
+            throw new IllegalArgumentException(CLASS + ": unknown key: " + key);
+        }
+        return keys.get(key);
+    }
+
+    /**
+     * Check whether a specific option is set, i. e. whether it was specified at least once on the command line. 
+     * <p>
+     * @param key The key for the option
+     * <p>
+     * @return <code>true</code> or <code>false</code>, depending on the outcome of the check
+     */
+    public boolean isSet(String key) {
+        if (key == null) {
+            throw new IllegalArgumentException(CLASS + ": key may not be null");
+        }
+        if (!keys.containsKey(key)) {
+            throw new IllegalArgumentException(CLASS + ": unknown key: " + key);
+        }
+        return keys.get(key).isSet();
+    }
+
+    /**
+     * Return the name of the set
+     * <p>
+     * @return The name of the set
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Getter method for <code>minData</code> property
+     * <p>
+     * @return The value for the <code>minData</code> property
+     */
+    public int getMinData() {
+        return minData;
+    }
+
+    /**
+     * Getter method for <code>maxData</code> property
+     * <p>
+     * @return The value for the <code>maxData</code> property
+     */
+    public int getMaxData() {
+        if (hasUnlimitedData()) {
+            return INF;
+        } else {
+            return maxData;
+        }
+    }
+
+    /**
+     * Getter method for <code>valueSeparator</code> property
+     * <p>
+     * @return The value for the <code>valueSeparator</code> property
+     */
+    Options.Separator getValueSeparator() {
+        return valueSeparator;
+    }
+
+    /**
+     * Getter method for <code>detailSeparator</code> property
+     * <p>
+     * @return The value for the <code>detailSeparator</code> property
+     */
+    Options.Separator getDetailSeparator() {
+        return detailSeparator;
+    }
+
+    /**
+     * Helper method required for option set cloning
+     */
+    int getLimit() {
+        return limit;
+    }
+
+    /**
+     * Indicate whether this set accepts data (which means that <code>maxData</code> is 1 or larger).
+     * <p>
+     * @return A boolean indicating whether this set accepts data
+     */
+    public boolean acceptsData() {
+        return (minData + maxData) == 0 ? false : true;
+    }
+
+    /**
+     * Return the data items found (these are the items on the command line 
+     * which do not start with the prefix, i. e. non-option arguments)
+     * <p>
+     * @return A list of strings with all data items found
+     */
+    public java.util.List<String> getData() {
+        return data;
+    }
+
+    /**
+     * Return the number of data items found (these are the items on the command line 
+     * which do not start with the prefix, i. e. non-option arguments)
+     * <p>
+     * @return The number of all data items found
+     */
+    public int getDataCount() {
+        return data.size();
+    }
+
+    /**
+     * Return a specific data item.
+     * <p>
+     * @param index 
+     * @return The requested data item
+     */
+    public String getData(int index) {
+        if (index < 0 || index >= getDataCount()) {
+            if (getDataCount() == 0) {
+                throw new IllegalArgumentException(CLASS + ": No data items are available");
+            } else {
+                int n = getDataCount() - 1;
+                throw new IllegalArgumentException(CLASS + ": Invalid index value - must be between 0 and " + n);
+            }
+        }
+        return data.get(index);
+    }
+
+    /**
+     * Return all unmatched items found (these are the items on the 
+     * command line which start with the prefix, but do not
+     * match to one of the options)
+     * <p>
+     * @return A list of strings with all unmatched items found
+     */
+    public java.util.List<String> getUnmatched() {
+        return unmatched;
+    }
+
+    /**
+     * Return the number of unmatched items found (these are the items on the 
+     * command line which start with the prefix, but do not
+     * match to one of the options)
+     * <p>
+     * @return The number of all unmatched items found
+     */
+    public int getUnmatchedCount() {
+        return unmatched.size();
+    }
+
+    /**
+     * Return a specific unmatched item.
+     * <p>
+     * @param index 
+     * @return The requested unmatched item
+     */
+    public String getUnmatched(int index) {
+        if (index < 0 || index >= getUnmatchedCount()) {
+            if (getUnmatchedCount() == 0) {
+                throw new IllegalArgumentException(CLASS + ": No unmatched items are available");
+            } else {
+                int n = getUnmatchedCount() - 1;
+                throw new IllegalArgumentException(CLASS + ": Invalid index value - must be between 0 and " + n);
+            }
+        }
+        return unmatched.get(index);
+    }
+
+// ==========================================================================================
+// Add a non-value option
+// ==========================================================================================
+    /**
+     * Add the given option to the set.
+     * <p>
+     * @param type The type of the option
+     * @param key  The name of the option
+     * <p>
+     * @return The newly created option (to support invocation chaining)
+     */
+    public OptionData addOption(OptionData.Type type, String key) {
+        return addOption(type,
+                key,
+                null,
+                type.detail() ? detailSeparator : valueSeparator,
+                defaultMultiplicity);
+    }
+
+    /**
+     * Add the given option to the set.
+     * <p>
+     * @param type         The type of the option
+     * @param key          The name of the option
+     * @param multiplicity The multiplicity of the option
+     * <p>
+     * @return The newly created option (to support invocation chaining)
+     */
+    public OptionData addOption(OptionData.Type type, String key, Options.Multiplicity multiplicity) {
+        return addOption(type,
+                key,
+                null,
+                type.detail() ? detailSeparator : valueSeparator,
+                multiplicity);
+    }
+
+    /**
+     * Add the given option to the set.
+     * <p>
+     * @param type   The type of the option
+     * @param key    The name of the option
+     * @param altKey The alternate name of the option
+     * <p>
+     * @return The newly created option (to support invocation chaining)
+     */
+    public OptionData addOption(OptionData.Type type, String key, String altKey) {
+        return addOption(type,
+                key,
+                altKey,
+                type.detail() ? detailSeparator : valueSeparator,
+                defaultMultiplicity);
+    }
+
+    /**
+     * Add the given option to the set.
+     * <p>
+     * @param type         The type of the option
+     * @param key          The name of the option
+     * @param altKey       The alternate name of the option
+     * @param multiplicity The multiplicity of the option
+     * <p>
+     * @return The newly created option (to support invocation chaining)
+     */
+    public OptionData addOption(OptionData.Type type, String key, String altKey, Options.Multiplicity multiplicity) {
+        return addOption(type,
+                key,
+                altKey,
+                type.detail() ? detailSeparator : valueSeparator,
+                multiplicity);
+    }
+
+    /**
+     * The master method to add an option. Since there are combinations which are not 
+     * acceptable (like a NONE separator and a true value), this method is not public.
+     * Internally, we only supply acceptable combinations.
+     */
+    OptionData addOption(OptionData.Type type,
+            String key,
+            String altKey,
+            Options.Separator separator,
+            Options.Multiplicity multiplicity) {
+
+        if (type == null) {
+            throw new IllegalArgumentException(CLASS + ": type may not be null");
+        }
+        if (key == null) {
+            throw new IllegalArgumentException(CLASS + ": key may not be null");
+        }
+        if (multiplicity == null) {
+            throw new IllegalArgumentException(CLASS + ": multiplicity may not be null");
+        }
+        if (keys.containsKey(key)) {
+            throw new IllegalArgumentException(CLASS + ": the key " + key + " has already been defined for this OptionSet");
+        }
+        if (altKey != null && altKeys.contains(altKey)) {
+            throw new IllegalArgumentException(CLASS + ": the alternate key " + altKey + " has already been defined for this OptionSet");
+        }
+
+//.... Check keys for valid names (especially no whitespace)
+
+        java.util.regex.Matcher m = keyPattern.matcher(key);
+        if (!m.matches()) {
+            throw new IllegalArgumentException(CLASS + ": invalid key: may only contain [a-zA-Z_0-9]");
+        }
+        if (altKey != null) {
+            m = keyPattern.matcher(altKey);
+            if (!m.matches()) {
+                throw new IllegalArgumentException(CLASS + ": invalid alternate key: may only contain [a-zA-Z_0-9]");
+            }
+        }
+
+        OptionData od = new OptionData(type, prefix, altPrefix, key, altKey, separator, multiplicity);
+        options.add(od);
+        keys.put(key, od);
+        if (altKey != null) {
+            altKeys.add(altKey);
+        }
+
+        return od;
+
+    }
+
+    /**
+     * A convenience method that prints all the results obtained for this option set to 
+     * <code>System.out</code>. This is quite handy to quickly check whether a set definition
+     * yields the expected results for a given set of command line arguments.
+     */
+    public void printResults() {
+        for (OptionData od : getOptionData()) {
+            System.out.println("Option: " + od.getSyntax() + " (found " + od.getResultCount() + " time(s))");
+            for (int i = 0; i < od.getResultCount(); i++) {
+                if (od.useDetail()) {
+                    System.out.println("- Detail " + i + ": " + od.getResultDetail(i));
+                }
+                if (od.useValue()) {
+                    System.out.println("- Value  " + i + ": " + od.getResultValue(i));
+                }
+            }
+        }
+        for (String s : getData()) {
+            System.out.println("Data : " + s);
+        }
+        for (String s : getUnmatched()) {
+            System.out.println("Unmatched : " + s);
+        }
+    }
+}
+
+
diff --git a/src/ml/options/Options.java b/src/ml/options/Options.java
new file mode 100644
index 0000000..9fc032e
--- /dev/null
+++ b/src/ml/options/Options.java
@@ -0,0 +1,1379 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * The central class for option processing. Sets are identified by their name, but there is also 
+ * an anonymous default set, which is very convenient if an application requieres only one set. 
+ * <p>
+ * The default values used in this class are:
+ * <p>
+ * <table border=1 cellpadding=6>
+ * <tr><td colspan=4 align=center bgcolor=blue><font color=white><b>Default Values</b></font>
+ * <tr bgcolor=#ffcc33><td> <b>ID</b> <td> <b>Parameter</b> <td><b>Default</b> <td><b>Individual Setting</b>
+ * <tr><td> 1 <td> Prefix                       
+ *     <td> <code>Prefix.SLASH</code> (Windows) <br> <code>Prefix.DASH</code> (all others)
+ *     <td> No
+ * <tr><td> 2 <td> Alternate Prefix             
+ *     <td> <code>Prefix.DOUBLEDASH</code>
+ *     <td> No
+ * <tr><td> 3 <td> Separator for value options  
+ *     <td> <code>Separator.BLANK</code>
+ *     <td> No
+ * <tr><td> 4 <td> Separator for detail options 
+ *     <td> <code>Separator.EQUALS</code>
+ *     <td> No
+ * <tr><td> 5 <td> Min. Data                    
+ *     <td> <code>0</code>
+ *     <td> Option set level
+ * <tr><td> 6 <td> Max. Data                    
+ *     <td> <code>0</code>
+ *     <td> Option set level
+ * <tr><td> 7 <td> Multiplicity                 
+ *     <td> <code>Multiplicity.ZERO_OR_ONCE</code>
+ *     <td> Option level
+ * </table>
+ * <p>
+ * All of these values can be changed using one of the <code>setDefault()</code> methods. However, for
+ * 1 - 4 this can only be done <i>before</i> any actual set or option has been created (otherwise an 
+ * <code>UnsupportedOperationException</code> is thrown). 5 - 7 can be called
+ * anytime, but they affect only sets and options which are created <i>afterwards</i>.
+ */
+public class Options {
+
+    private final static String CLASS = "Options";
+    /**
+     * The name used internally for the default set
+     */
+    private final static String DEFAULT_SET = "DEFAULT_OPTION_SET";
+
+// ==========================================================================================
+// Helper enums
+// ==========================================================================================
+    /** 
+     * An enum encapsulating the possible separators between value options and their actual values. 
+     */
+    public enum Separator {
+
+        /**
+         * Separate option and value by ":"
+         */
+        COLON(':'),
+        /**
+         * Separate option and value by "="
+         */
+        EQUALS('='),
+        /**
+         * Separate option and value by blank space
+         */
+        BLANK(' ');      // Or, more precisely, whitespace (as allowed by the CLI)
+        private char c;
+
+        private Separator(char c) {
+            this.c = c;
+        }
+
+        /**
+         * Return the actual separator character 
+         * <p>
+         * @return The actual separator character
+         */
+        char getName() {
+            return c;
+        }
+    }
+
+// ==========================================================================================
+    /**
+     * An enum encapsulating the possible prefixes identifying options (and separating them from command line data items)
+     */
+    public enum Prefix {
+
+        /**
+         * Options start with a "-" (typically on Unix platforms)
+         */
+        DASH("-"),
+        /**
+         * Options start with a "--" (like GNU-style options on Unix platforms)
+         */
+        DOUBLEDASH("--"),
+        /**
+         * Options start with a "/" (typically on Windows platforms)
+         */
+        SLASH("/");
+        private String c;
+
+        private Prefix(String c) {
+            this.c = c;
+        }
+
+        /**
+         * Return the actual prefix character 
+         * <p>
+         * @return The actual prefix character
+         */
+        String getName() {
+            return c;
+        }
+    }
+
+// ==========================================================================================
+    /**
+     * An enum encapsulating the possible multiplicities for options
+     */
+    public enum Multiplicity {
+
+        /**
+         * Option needs to occur exactly once
+         */
+        ONCE(true),
+        /**
+         * Option needs to occur at least once
+         */
+        ONCE_OR_MORE(true),
+        /**
+         * Option needs to occur either once or not at all
+         */
+        ZERO_OR_ONCE(false),
+        /**
+         * Option can occur any number of times
+         */
+        ZERO_OR_MORE(false);
+        private boolean required = false;
+
+        private Multiplicity(boolean required) {
+            this.required = required;
+        }
+
+        boolean isRequired() {
+            return required;
+        }
+    }
+
+// ==========================================================================================
+// Instance members
+// ==========================================================================================
+    private java.util.TreeMap<String, OptionSet> optionSets = new java.util.TreeMap<String, OptionSet>();
+    private String[] arguments = null;
+    private boolean ignoreUnmatched = false;
+    private StringBuilder checkErrors = new StringBuilder();
+//.... Defaults
+    private Prefix defaultPrefix = getDefaultPrefix();
+    private Prefix defaultAltPrefix = Prefix.DOUBLEDASH;
+    private Separator defaultValueSeparator = Separator.BLANK;
+    private Separator defaultDetailSeparator = Separator.EQUALS;
+    private Multiplicity defaultMultiplicity = Multiplicity.ZERO_OR_ONCE;
+    private int defaultMinData = 0;
+    private int defaultMaxData = 0;
+
+    /**
+     * Constructor
+     * <p>
+     * @param args The command line arguments to check
+     */
+    public Options(String args[]) {
+        if (args == null) {
+            throw new IllegalArgumentException(CLASS + ": args may not be null");
+        }
+        arguments = new String[args.length];
+        int i = 0;
+        for (String s : args) {
+            arguments[i++] = s;
+        }
+    }
+
+    /**
+     * This constructor uses the XML file provided by the reader to set up option sets and options.
+     * <p>
+     * @param args   The command line arguments to check
+     * @param reader The reader instance providing the XML file
+     * @throws org.jdom.JDOMException 
+     */
+    @SuppressWarnings("unchecked")
+    public Options(String args[], java.io.Reader reader) throws org.jdom.JDOMException {
+        this(args);
+        if (reader == null) {
+            throw new IllegalArgumentException(CLASS + ": reader may not be null");
+        }
+
+//.... Copy the XML content into a string. This is done since we need to read the data 
+//     twice (once for validation, once for evaluation), and not all readers support the 
+//     reset() method.
+
+        StringBuilder sb = new StringBuilder(1000);
+        String line = null;
+        java.io.BufferedReader r = new java.io.BufferedReader(reader);
+
+        try {
+            while ((line = r.readLine()) != null) {
+                sb.append(line);
+                sb.append('\n');
+            }
+        } catch (java.io.IOException ex) {
+            throw new XMLParsingException(CLASS + ": Error while reading XML file!\n" + ex.getMessage());
+        }
+        line = sb.toString();
+
+//.... Try to validate the XML document against the schema
+
+        SchemaValidator validator = new SchemaValidator();
+
+        try {
+            if (!validator.validate(new java.io.BufferedReader(new java.io.StringReader(line)))) {
+                throw new XMLParsingException(CLASS + ": Error in XML file validation against schema!\n" + validator.getError());
+            }
+        } catch (java.io.IOException ex) {
+            throw new XMLParsingException(CLASS + ": Error in XML file validation against schema!\n" + ex.getMessage());
+        } catch (org.xml.sax.SAXException ex) {
+            throw new XMLParsingException(CLASS + ": Error in XML file validation against schema!\n" + ex.getMessage());
+        }
+
+        validator = null;
+
+//.... Retrieve the data and create the option sets and options
+
+        try {
+
+            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder();
+            org.jdom.Document doc = builder.build(new java.io.BufferedReader(new java.io.StringReader(line)));
+
+//... Process the <options> tag
+
+            org.jdom.Element root = doc.getRootElement();
+            String value = null;
+            String values[] = null;
+
+            if (root.getAttribute("defData") != null) {
+                value = root.getAttributeValue("defData");
+                if (value.indexOf(':') < 0) {
+                    setDefault(Integer.parseInt(value));
+                } else {
+                    values = value.split(":");
+                    if (values[1].equals("INF")) {
+                        setDefault(Integer.parseInt(values[0]), Integer.MAX_VALUE);
+                    } else {
+                        setDefault(Integer.parseInt(values[0]), Integer.parseInt(values[1]));
+                    }
+                }
+            }
+
+            if (root.getAttribute("defMult") != null) {
+                setDefault(Multiplicity.valueOf(root.getAttributeValue("defMult")));
+            }
+
+            if (root.getAttribute("defSep") != null) {
+                value = root.getAttributeValue("defSep");
+                if (value.indexOf(':') < 0) {
+                    setDefault(Separator.valueOf(value));
+                } else {
+                    values = value.split(":");
+                    setDefault(Separator.valueOf(values[0]), Separator.valueOf(values[1]));
+                }
+            }
+
+            if (root.getAttribute("defPrefix") != null) {
+                value = root.getAttributeValue("defPrefix");
+                if (value.indexOf(':') < 0) {
+                    setDefault(Prefix.valueOf(value));
+                } else {
+                    values = value.split(":");
+                    setDefault(Prefix.valueOf(values[0]), Prefix.valueOf(values[1]));
+                }
+            }
+
+//... Process the <set> tag(s)
+
+            OptionSet set = null;
+            boolean found = false;
+
+            for (org.jdom.Element element : (java.util.List<org.jdom.Element>) root.getChildren("set")) {
+
+                if (element.getAttribute("data") != null) {          // Create the set
+                    value = element.getAttributeValue("data");
+                    if (value.indexOf(':') < 0) {
+                        set = addSet(element.getAttributeValue("name"),
+                                     Integer.parseInt(value));
+                    } else {
+                        values = value.split(":");
+                        if (values[1].equals("INF")) {                        // Allow unlimited number of data items
+                            set = addSet(element.getAttributeValue("name"),
+                                         Integer.parseInt(values[0]), Integer.MAX_VALUE);
+                        } else {
+                            set = addSet(element.getAttributeValue("name"),
+                                         Integer.parseInt(values[0]), Integer.parseInt(values[1]));
+                        }
+                    }
+                } else {
+                    set = addSet(element.getAttributeValue("name"));
+                }
+
+                processSet(set, element);
+                found = true;
+
+            }
+
+//... Process the <defaultSet> tag (if present)
+
+            if (root.getChild("defaultSet") != null) {
+                processSet(getSet(), root.getChild("defaultSet"));
+                found = true;
+            }
+
+            if (!found) {
+                throw new XMLParsingException(CLASS + ": At least one option set needs to be defined");
+            }
+
+//.... Process the <option> tags (for addOptionAllSets())
+
+            for (org.jdom.Element element : (java.util.List<org.jdom.Element>) root.getChildren("option")) {
+                for (String name : optionSets.keySet()) {
+                    addOptions(optionSets.get(name), element);
+                }
+            }
+
+        } catch (java.io.IOException ex) {
+            throw new XMLParsingException(CLASS + ": Error during XML file content validation!\n" + ex.getMessage());
+        }
+
+    }
+
+//.... Helper method to add the options to a set
+    @SuppressWarnings("unchecked")
+    private void addOptions(OptionSet set, org.jdom.Element element) {
+
+        boolean details = false;
+        String type = element.getAttributeValue("type");
+        String key = element.getAttributeValue("key");
+        String altKey = element.getAttributeValue("altKey");
+        String mult = element.getAttributeValue("mult");
+        String value = null;
+        String detail = null;
+        String help = null;
+        OptionData.Type otype = null;
+
+//.... Create the option
+
+        if (type.equals(OptionData.Type.SIMPLE.name())) {
+            otype = OptionData.Type.SIMPLE;
+            if (altKey == null) {
+                if (mult == null) {
+                    set.addOption(otype, key);
+                } else {
+                    set.addOption(otype, key, Multiplicity.valueOf(mult));
+                }
+            } else {
+                if (mult == null) {
+                    set.addOption(otype, key, altKey);
+                } else {
+                    set.addOption(otype, key, altKey, Multiplicity.valueOf(mult));
+                }
+            }
+        } else {
+            if (type.equals(OptionData.Type.VALUE.name())) {
+                otype = OptionData.Type.VALUE;
+            } else {
+                otype = OptionData.Type.DETAIL;
+            }
+            if (altKey == null) {
+                if (mult == null) {
+                    set.addOption(otype, key);
+                } else {
+                    set.addOption(otype, key, Multiplicity.valueOf(mult));
+                }
+            } else {
+                if (mult == null) {
+                    set.addOption(otype, key, altKey);
+                } else {
+                    set.addOption(otype, key, altKey, Multiplicity.valueOf(mult));
+                }
+            }
+        }
+
+//.... Add texts, if necessary
+
+        if (element.getChild("text") != null) {   // Texts for this set
+
+            org.jdom.Element textElement = element.getChild("text");
+
+            value = textElement.getChildText("value");
+            detail = textElement.getChildText("detail");
+            help = textElement.getChildText("help");
+
+            if (value != null) {
+                if (detail != null) {
+                    set.getOption(key).setValueText(value).setDetailText(detail).setHelpText(help);
+                } else {
+                    set.getOption(key).setValueText(value).setHelpText(help);
+                }
+            } else {
+                set.getOption(key).setHelpText(help);
+            }
+
+        }
+
+//.... Add constraints, if necessary. Only instances of XMLConstraint are possible here, of course
+
+        if (element.getChild("constraints") != null) {   // Constraints for this option
+
+            try {
+
+                org.jdom.Element constraints = element.getChild("constraints");
+                XMLConstraint constr = null;
+                for (org.jdom.Element constraint : (java.util.List<org.jdom.Element>) constraints.getChildren("constraint")) {
+                    constr = (XMLConstraint) Class.forName(constraint.getAttributeValue("class").trim()).newInstance();
+                    constr.init(set.getOption(key),
+                                (java.util.List<org.jdom.Element>) constraint.getChild("params").getChildren("param"));
+                }
+
+            } catch (InstantiationException ex) {
+                throw new XMLParsingException(CLASS + ": Could not create constraint instance", ex);
+            } catch (ClassNotFoundException ex) {
+                throw new XMLParsingException(CLASS + ": Could not create constraint instance", ex);
+            } catch (IllegalAccessException ex) {
+                throw new XMLParsingException(CLASS + ": Could not create constraint instance", ex);
+            }
+
+        }
+
+    }
+
+//.... Helper method to add the texts to a set
+    private void addTexts(OptionSet set, org.jdom.Element element) {
+        int index = Integer.parseInt(element.getAttributeValue("index"));
+        String data = element.getChildText("data");
+        String help = element.getChildText("help");
+
+        if (help != null) {
+            set.setDataText(index, data).setHelpText(index, help);
+        } else {
+            set.setDataText(index, data);
+        }
+    }
+
+    /**
+     * Helper method used when adding a set
+     */
+    @SuppressWarnings("unchecked")
+    private void processSet(OptionSet set, org.jdom.Element element) {
+
+        for (org.jdom.Element subElement : (java.util.List<org.jdom.Element>) element.getChildren("option")) {
+            addOptions(set, subElement);
+        }
+
+        if (element.getChildren("text") != null) {
+            for (org.jdom.Element subElement : (java.util.List<org.jdom.Element>) element.getChildren("text")) {
+                addTexts(set, subElement);
+            }
+        }
+
+        if (element.getChild("constraints") != null) {   // Constraints for this set
+
+            try {
+
+                org.jdom.Element constraints = element.getChild("constraints");
+                XMLConstraint constr = null;
+                for (org.jdom.Element constraint : (java.util.List<org.jdom.Element>) constraints.getChildren("constraint")) {
+                    constr = (XMLConstraint) Class.forName(constraint.getAttributeValue("class").trim()).newInstance();
+                    constr.init(set, (java.util.List<org.jdom.Element>) constraint.getChild("params").getChildren("param"));
+                }
+
+            } catch (InstantiationException ex) {
+                throw new XMLParsingException(CLASS + ": Could not create constraint instance", ex);
+            } catch (ClassNotFoundException ex) {
+                throw new XMLParsingException(CLASS + ": Could not create constraint instance", ex);
+            } catch (IllegalAccessException ex) {
+                throw new XMLParsingException(CLASS + ": Could not create constraint instance", ex);
+            }
+
+        }
+    }
+
+// ==========================================================================================
+// Defaults handling
+// ==========================================================================================
+    /**
+     * Define the default to use for the separator for value options. Note that this method can 
+     * only be invoked <i>before</i> any option set has been created.
+     * <p>
+     * @param defaultValueSeparator The default separator to use for all value options
+     * <p>
+     * @return This instance to allow for invocation chaining
+     */
+    public Options setDefault(Separator defaultValueSeparator) {
+        if (defaultValueSeparator == null) {
+            throw new IllegalArgumentException(CLASS + ": defaultValueSeparator may not be null");
+        }
+        if (optionSets.size() > 0) {
+            throw new UnsupportedOperationException(CLASS + ": method can not be invoked, OptionSets have already been defined");
+        }
+        this.defaultValueSeparator = defaultValueSeparator;
+        return this;
+    }
+
+    /**
+     * Define the defaults to use for the separators for value and detail options. Note that this method can 
+     * only be invoked <i>before</i> any option set has been created.
+     * <p>
+     * @param defaultValueSeparator  The default separator to use for all value options
+     * @param defaultDetailSeparator The default separator to use for all detail options 
+     * <p>
+     * @return This instance to allow for invocation chaining
+     */
+    public Options setDefault(Separator defaultValueSeparator, Separator defaultDetailSeparator) {
+
+        if (defaultValueSeparator == null) {
+            throw new IllegalArgumentException(CLASS + ": defaultValueSeparator may not be null");
+        }
+        if (defaultDetailSeparator == null) {
+            throw new IllegalArgumentException(CLASS + ": defaultDetailSeparator may not be null");
+        }
+        if (optionSets.size() > 0) {
+            throw new UnsupportedOperationException(CLASS + ": method can not be invoked, OptionSets have already been defined");
+        }
+
+        this.defaultValueSeparator = defaultValueSeparator;
+        this.defaultDetailSeparator = defaultDetailSeparator;
+
+        return this;
+
+    }
+
+    /**
+     * Define the default to use for the option prefix. Note that this method can 
+     * only be invoked <i>before</i> any option set has been created.
+     * <p>
+     * @param defaultPrefix The prefix to use for all options
+     * <p>
+     * @return This instance to allow for invocation chaining
+     */
+    public Options setDefault(Prefix defaultPrefix) {
+        if (defaultPrefix == null) {
+            throw new IllegalArgumentException(CLASS + ": defaultPrefix may not be null");
+        }
+        if (optionSets.size() > 0) {
+            throw new UnsupportedOperationException(CLASS + ": method can not be invoked, OptionSets have already been defined");
+        }
+        this.defaultPrefix = defaultPrefix;
+        return this;
+    }
+
+    /**
+     * Define the defaults to use for the option prefixes. Note that this method can 
+     * only be invoked <i>before</i> any option set has been created.
+     * <p>
+     * @param defaultPrefix    The prefix to use for all options
+     * @param defaultAltPrefix The prefix to use for all alternate keys for options
+     * <p>
+     * @return This instance to allow for invocation chaining
+     */
+    public Options setDefault(Prefix defaultPrefix, Prefix defaultAltPrefix) {
+
+        if (defaultPrefix == null) {
+            throw new IllegalArgumentException(CLASS + ": defaultPrefix may not be null");
+        }
+        if (defaultAltPrefix == null) {
+            throw new IllegalArgumentException(CLASS + ": defaultAltPrefix may not be null");
+        }
+        if (defaultPrefix.equals(defaultAltPrefix)) {
+            throw new IllegalArgumentException(CLASS + ": The prefixes must be different");
+        }
+        if (optionSets.size() > 0) {
+            throw new UnsupportedOperationException(CLASS + ": method can not be invoked, OptionSets have already been defined");
+        }
+
+        this.defaultPrefix = defaultPrefix;
+        this.defaultAltPrefix = defaultAltPrefix;
+
+        return this;
+
+    }
+
+    /**
+     * Define the default to use for the multiplicity for options. This applies only to 
+     * option sets and options within these sets which are created <i>after</i> this call.
+     * <p>
+     * @param defaultMultiplicity The default multiplicity to use for all options
+     * <p>
+     * @return This instance to allow for invocation chaining
+     */
+    public Options setDefault(Multiplicity defaultMultiplicity) {
+        if (defaultMultiplicity == null) {
+            throw new IllegalArgumentException(CLASS + ": defaultMultiplicity may not be null");
+        }
+        this.defaultMultiplicity = defaultMultiplicity;
+        return this;
+    }
+
+    /**
+     * Define the defaults to use for the number of data items for a set. This applies only to 
+     * option sets which are created <i>after</i> this call.
+     * <p>
+     * @param defaultData The default minimum and maximum number of data items
+     * <p>
+     * @return This instance to allow for invocation chaining
+     */
+    public Options setDefault(int defaultData) {
+        if (defaultData < 0) {
+            throw new IllegalArgumentException(CLASS + ": defaultData must be >= 0");
+        }
+        this.defaultMinData = defaultData;
+        this.defaultMaxData = defaultData;
+        return this;
+    }
+
+    /**
+     * Define the defaults to use for the number of data items for a set. This applies only to 
+     * option sets which are created <i>after</i> this call.
+     * <p>
+     * @param defaultMinData The default minimum number of data items
+     * @param defaultMaxData The default maximum number of data items
+     * <p>
+     * @return This instance to allow for invocation chaining
+     */
+    public Options setDefault(int defaultMinData, int defaultMaxData) {
+
+        if (defaultMinData < 0) {
+            throw new IllegalArgumentException(CLASS + ": defaultMinData must be >= 0");
+        }
+
+        int limit = defaultMaxData;
+        if (defaultMaxData == OptionSet.INF) {
+            limit = Integer.MAX_VALUE;
+        }
+
+        if (limit < defaultMinData) {
+            throw new IllegalArgumentException(CLASS + ": defaultMaxData must be >= defaultMinData");
+        }
+        this.defaultMinData = defaultMinData;
+        this.defaultMaxData = limit;
+        return this;
+
+    }
+
+// ==========================================================================================
+// The actual API
+// ==========================================================================================
+    /**
+     * Return the (first) matching set. This invocation does not ignore unmatched options and requires that 
+     * data items are the last ones on the command line. It is equivalent to calling 
+     * <code>getMatchingSet(false, true)</code>. 
+     * <p>
+     * @return The first set which matches (i. e. the <code>check()</code> method returns <code>true</code>) - or 
+     *         <code>null</code>, if no set matches.
+     */
+    public OptionSet getMatchingSet() {
+        return getMatchingSet(false, true);
+    }
+
+    /**
+     * Return the (first) matching set. 
+     * <p>
+     * @param ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
+     * @param requireDataLast A boolean to indicate whether the data items 
+     *                        have to be the last ones on the command line or not
+     * <p>
+     * @return The first set which matches (i. e. the <code>check()</code> method returns <code>true</code>) - or 
+     *         <code>null</code>, if no set matches.
+     */
+    public OptionSet getMatchingSet(boolean ignoreUnmatched, boolean requireDataLast) {
+
+        // If we have no set at this stage, we need to create the default set since
+        // chances are the user just wants to check for data (no options), and thus
+        // getSet() has not been invoked by the user at this stage.
+
+        if (optionSets.isEmpty()) {
+            getSet();
+        }
+
+        // Run the checks for all known sets
+
+        for (String name : optionSets.keySet()) {
+            if (check(name, ignoreUnmatched, requireDataLast)) {
+                return optionSets.get(name);
+            }
+        }
+
+        return null;
+
+    }
+
+    /**
+     * Add an option set.
+     * <p>
+     * @param name    The name for the set. This must be a unique identifier
+     * @param minData The minimum number of data items for this set
+     * @param maxData The maximum number of data items for this set (if set to <code>OptionSet.INF</code>, this 
+     *                effectively corresponds to an unlimited number)
+     * <p>
+     * @return The new <code>OptionSet</code> instance created. This is useful to allow 
+     *          chaining of <code>addOption()</code> calls right after this method
+     */
+    public OptionSet addSet(String name, int minData, int maxData) {
+        if (name == null) {
+            throw new IllegalArgumentException(CLASS + ": name may not be null");
+        }
+        if (optionSets.containsKey(name)) {
+            throw new IllegalArgumentException(CLASS + ": a set with the name " + name + " has already been defined");
+        }
+
+        int limit = maxData;
+        if (maxData == OptionSet.INF) {
+            limit = Integer.MAX_VALUE;
+        }
+
+        OptionSet os = new OptionSet(name,
+                                     defaultPrefix,
+                                     defaultAltPrefix,
+                                     defaultValueSeparator,
+                                     defaultDetailSeparator,
+                                     defaultMultiplicity,
+                                     minData,
+                                     limit,
+                                     name.equals(DEFAULT_SET));
+        optionSets.put(name, os);
+
+        return os;
+
+    }
+
+    /**
+     * Add an option set.
+     * <p>
+     * @param name The name for the set. This must be a unique identifier
+     * @param data The minimum and maximum number of data items for this set
+     * <p>
+     * @return The new <code>OptionSet</code> instance created. This is useful to allow chaining 
+     *         of <code>addOption()</code> calls right after this method
+     */
+    public OptionSet addSet(String name, int data) {
+        return addSet(name, data, data);
+    }
+
+    /**
+     * Add an option set. The defaults for the number of data items are used. 
+     * <p>
+     * @param name The name for the set. This must be a unique identifier
+     * <p>
+     * @return The new <code>OptionSet</code> instance created. This is useful to allow 
+     *         chaining of <code>addOption()</code> calls right after this method
+     */
+    public OptionSet addSet(String name) {
+        return addSet(name, defaultMinData, defaultMaxData);
+    }
+
+    /**
+     * Add an option set by cloning an existing set. Note that is designed for setup purposes only, i. e. no 
+     * check result data is copied either for the set or any options. This method can be very handy if an application
+     * requires two (or more) sets which have a lot of options in common and differ only in a few of them. In this
+     * case, one would first create a set with the common options, then clone any number of additionally required 
+     * sets, and add the non-common options to each of these sets.
+     * <p>
+     * Note that it is not possible to change the number of data items required for the new set.
+     * <p>
+     * @param name The name for the new set. This must be a unique identifier
+     * @param set  The set to clone the new set from
+     * <p>
+     * @return The new <code>OptionSet</code> instance created. This is useful to allow chaining 
+     *         of <code>addOption()</code> calls right after this method
+     */
+    public OptionSet addSet(String name, OptionSet set) {
+        if (name == null) {
+            throw new IllegalArgumentException(CLASS + ": name may not be null");
+        }
+        if (set == null) {
+            throw new IllegalArgumentException(CLASS + ": set may not be null");
+        }
+        if (optionSets.containsKey(name)) {
+            throw new IllegalArgumentException(CLASS + ": a set with the name " + name + " has already been defined");
+        }
+
+        OptionSet os = new OptionSet(name, set);
+        optionSets.put(name, os);
+        return os;
+    }
+
+    /**
+     * Return an option set - or <code>null</code>, if no set with the given name exists
+     * <p>
+     * @param name The name for the set to retrieve
+     * <p>
+     * @return The set to retrieve (or <code>null</code>, if no set with the given name exists)
+     */
+    public OptionSet getSet(String name) {
+        return optionSets.get(name);
+    }
+
+    /**
+     * Print a help description for this instance using a {@link DefaultHelpPrinter}. This method 
+     * provides a basic service in the sense that it loops over all known option sets
+     * and prints the command line for each set. If <code>printTexts</code> is <code>true</code>, also 
+     * descriptive texts are printed for all options and the data arguments.
+     * <p>
+     * Note that default values are used for all the components of the helper text, which can be 
+     * overridden by various methods available in the {@link OptionSet} and {@link OptionData} classes.
+     * <p>
+     * @param leadingText The text to precede the command line for each 
+     *                    option set (see {@link HelpPrinter#getCommandLine(OptionSet, String, boolean)})
+     * @param lineBreak   A boolean indicating whether the command lines for the option sets should 
+     *                    be printed with line breaks or not 
+     *                    (see {@link HelpPrinter#getCommandLine(OptionSet, String, boolean)})
+     * @param printTexts  A boolean indicating whether the full help information should be printer (command lines
+     *                    and description texts) or just the command lines
+     */
+    public void printHelp(String leadingText, boolean lineBreak, boolean printTexts) {
+        printHelp(new DefaultHelpPrinter(), leadingText, lineBreak, printTexts);
+    }
+
+    /**
+     * Print a help description for this instance using the provided {@link HelpPrinter}. This method 
+     * provides a basic service in the sense that it loops over all known option sets
+     * and prints the command line for each set. If <code>printTexts</code> is <code>true</code>, also 
+     * descriptive texts are printed for all options and the data arguments.
+     * <p>
+     * Note that default values are used for all the components of the helper text, which can be 
+     * overridden by various methods available in the {@link OptionSet} and {@link OptionData} classes.
+     * <p>
+     * @param helpPrinter The {@link HelpPrinter} to use to format the output
+     * @param leadingText The text to precede the command line for each 
+     *                    option set (see {@link HelpPrinter#getCommandLine(OptionSet, String, boolean)})
+     * @param lineBreak   A boolean indicating whether the command lines for the option sets should 
+     *                    be printed with line breaks or not 
+     *                    (see {@link HelpPrinter#getCommandLine(OptionSet, String, boolean)})
+     * @param printTexts  A boolean indicating whether the full help information should be printer (command lines
+     *                    and description texts) or just the command lines
+     */
+    public void printHelp(HelpPrinter helpPrinter, String leadingText, boolean lineBreak, boolean printTexts) {
+
+        if (helpPrinter == null) {
+            throw new IllegalArgumentException(CLASS + ": helpPrinter may not be null");
+        }
+        if (leadingText == null) {
+            throw new IllegalArgumentException(CLASS + ": leadingText may not be null");
+        }
+
+        OptionSet set = null;
+
+//.... No sets are defined, we only work with the default set
+
+        if (getSetNames().size() == 0) {
+            set = getSet();
+            System.out.println(helpPrinter.getCommandLine(set, leadingText, lineBreak));
+            if (printTexts) {
+                System.out.print('\n');
+                System.out.println(helpPrinter.getHelpText(set));
+            }
+
+//.... Loop over all defined sets
+
+        } else {
+            java.util.Set<String> sets = getSetNames();
+            for (String name : sets) {
+                set = getSet(name);
+                System.out.println(helpPrinter.getCommandLine(set, leadingText, lineBreak));
+                if (printTexts) {
+                    System.out.print('\n');
+                    System.out.println(helpPrinter.getHelpText(set));
+                    if (sets.size() > 1) {
+                        System.out.print('\n');
+                    }
+                }
+            }
+        }
+
+    }
+
+    /**
+     * Get a set view on the known option set names. This is not public since it includes the default
+     * set name as well, which we don't want to expose.
+     * <p>
+     * @return A set containing the names of the option sets, or <code>null</code> if no such sets are defined
+     * <p>
+     */
+    java.util.Set<String> getSetNames() {
+        return optionSets.keySet();
+    }
+
+    /**
+     * This returns the (anonymous) default set
+     * <p>
+     * @return The default set
+     */
+    public OptionSet getSet() {
+        if (getSet(DEFAULT_SET) == null) {
+            addSet(DEFAULT_SET, defaultMinData, defaultMaxData);
+        }
+        return getSet(DEFAULT_SET);
+    }
+
+    /**
+     * Determine a default prefix depending on the OS platform. This uses the <code>os.name</code> Java system property.
+     * For Windows, <code>Prefix.SLASH</code> is used, else <code>Prefix.DASH</code>. This will likely need to be
+     * adapted over time for other platforms and VMs, depending on the string they return for that Java system property.
+     * <p>
+     * @return The default prefix for the current platform
+     */
+    private static Prefix getDefaultPrefix() {
+        String os = System.getProperty("os.name");
+        if (os.startsWith("Windows")) {
+            return Prefix.SLASH;
+        } else {
+            return Prefix.DASH;
+        }
+    }
+
+    /**
+     * This is the overloaded {@link Object#toString()} method.
+     * <p>
+     * @return A string representing the instance
+     */
+    @Override
+    public String toString() {
+
+        StringBuilder sb = new StringBuilder();
+
+        sb.append("defaultPrefix          = ");
+        sb.append(defaultPrefix);
+        sb.append('\n');
+        sb.append("defaultAltPrefix       = ");
+        sb.append(defaultAltPrefix);
+        sb.append('\n');
+        sb.append("defaultValueSeparator  = ");
+        sb.append(defaultValueSeparator);
+        sb.append('\n');
+        sb.append("defaultDetailSeparator = ");
+        sb.append(defaultDetailSeparator);
+        sb.append('\n');
+        sb.append("defaultMultiplicity    = ");
+        sb.append(defaultMultiplicity);
+        sb.append('\n');
+        sb.append("defaultMinData         = ");
+        sb.append(defaultMinData);
+        sb.append('\n');
+        sb.append("defaultMaxData         = ");
+        sb.append(defaultMaxData);
+        sb.append('\n');
+
+        for (OptionSet set : optionSets.values()) {
+            sb.append("Set: ");
+            sb.append(set.getName());
+            sb.append('\n');
+            for (OptionData data : set.getOptionData()) {
+                sb.append(data.toString());
+                sb.append('\n');
+            }
+        }
+
+        return sb.toString();
+
+    }
+
+// ==========================================================================================
+// The checks 
+// ==========================================================================================
+    /**
+     * The error messages collected during the last option check 
+     * (invocation of any of the <code>check()</code> methods). This
+     * is useful to determine what was wrong with the command 
+     * line arguments provided
+     * <p>
+     * @return A string with all collected error messages
+     */
+    public String getCheckErrors() {
+        return checkErrors.toString();
+    }
+
+    /**
+     * Run the checks for the default set with default parameters. This is equivalent
+     * to calling <code>check(false, true)</code>. If the default set has not yet been 
+     * used at all, it is created here with the default settings.
+     * <p>
+     * @return A boolean indicating whether all checks were successful or not
+     */
+    public boolean check() {
+        if (getSet(DEFAULT_SET) == null) {
+            addSet(DEFAULT_SET, defaultMinData, defaultMaxData);
+        }
+        return check(DEFAULT_SET, false, true);
+    }
+
+    /**
+     * Run the checks for the default set. If the default set has not yet been 
+     * used at all, it is created here with the default settings.
+     * <p>
+     * @param ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
+     * @param requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
+     * <p>
+     * @return A boolean indicating whether all checks were successful or not
+     */
+    public boolean check(boolean ignoreUnmatched, boolean requireDataLast) {
+        if (getSet(DEFAULT_SET) == null) {
+            addSet(DEFAULT_SET, defaultMinData, defaultMaxData);
+        }
+        return check(DEFAULT_SET, ignoreUnmatched, requireDataLast);
+    }
+
+    /**
+     * Run the checks for the given set with default parameters. This is equivalent
+     * to calling <code>check(name, false, true)</code>.
+     * <p>
+     * @param name The name for the set to check
+     * <p>
+     * @return A boolean indicating whether all checks were successful or not
+     */
+    public boolean check(String name) {
+        return check(name, false, true);
+    }
+
+    /**
+     * Run the checks for the given set.
+     * <p>
+     * @param name            The name for the set to check
+     * @param ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
+     * @param requireDataLast A boolean to indicate whether the data items have to be the last 
+     *                        ones on the command line or not
+     * <p>
+     * @return A boolean indicating whether all checks were successful or not
+     */
+    public boolean check(String name, boolean ignoreUnmatched, boolean requireDataLast) {
+
+        if (name == null) {
+            throw new IllegalArgumentException(CLASS + ": name may not be null");
+        }
+        if (optionSets.get(name) == null) {
+            throw new IllegalArgumentException(CLASS + ": Unknown OptionSet: " + name);
+        }
+
+        checkErrors.append("Checking set ");
+        checkErrors.append(name);
+        checkErrors.append('\n');
+
+//.... Access the data for the set to use
+
+        OptionSet set = optionSets.get(name);
+        java.util.List<OptionData> options = set.getOptionData();
+        java.util.List<String> data = set.getData();
+        java.util.List<String> unmatched = set.getUnmatched();
+
+//.... Catch some trivial cases
+
+        if (options.size() == 0) {                             // No options have been defined at all
+            if (arguments.length == 0) {
+                if (set.acceptsData()) {
+                    checkErrors.append("The set expects data, but no arguments have been given\n");
+                    return false;
+                } else {         // No options and no data expected, no arguments given - technically true, but useless
+                    return true;
+                }
+            }
+        } else if (arguments.length == 0) {     // Options have been defined, but no arguments given
+            checkErrors.append("Options have been defined, but no arguments have been given; nothing to check\n");
+            return false;
+        }
+
+//.... Parse all the arguments given
+
+        int ipos = 0;
+        int offset = 0;
+        int start = 0;
+        java.util.regex.Matcher m = null;
+        String value = null;
+        String detail = null;
+        String next = null;
+        String key = null;
+        String pre = defaultPrefix.getName();
+        String altPre = defaultAltPrefix.getName();
+        boolean add = true;
+        boolean[] matched = new boolean[arguments.length];
+
+        for (int i = 0; i < matched.length; i++) // Initially, we assume there was no match at all
+        {
+            matched[i] = false;
+        }
+
+        while (true) {
+
+            value = null;
+            detail = null;
+            offset = 0;
+            start = 1;
+            add = true;
+            key = arguments[ipos];
+
+            for (OptionData optionData : options) {          // For each argument, we need to check all defined options
+
+                m = optionData.getPattern().matcher(key);
+
+                if (m.lookingAt()) {
+
+                    if (optionData.useValue()) {                          // The code section for value options
+
+                        if (optionData.hasAlternateKey()) {
+                            start = 2;
+                        }
+
+                        if (optionData.useDetail()) {
+                            detail = m.group(start);
+                            offset = 2;                                       // required for correct Matcher.group access below
+                        }
+
+                        if (optionData.getSeparator() == Separator.BLANK) { // In this case, the next argument must be the value
+                            if (ipos + 1 == arguments.length) {               // The last argument, thus no value follows it: Error
+                                checkErrors.append("At end of arguments - no value found following argument ");
+                                checkErrors.append(key);
+                                checkErrors.append('\n');
+                                add = false;
+                            } else {
+                                next = arguments[ipos + 1];
+                                if (next.startsWith(pre) || next.startsWith(altPre)) {   // The next item is not a value: Error
+                                    checkErrors.append("No value found following argument ");
+                                    checkErrors.append(key);
+                                    checkErrors.append('\n');
+                                    add = false;
+                                } else {
+                                    value = next;
+                                    matched[ipos++] = true;                       // Mark the key and the value
+                                    matched[ipos] = true;
+                                }
+                            }
+                        } else {                                            // The value follows the separator in this case
+                            value = m.group(start + offset);
+                            matched[ipos] = true;
+                        }
+
+                    } else {                                              // Simple, non-value options
+                        matched[ipos] = true;
+                    }
+
+                    if (add) {
+                        optionData.addResult(value, detail);         // Store the result
+                    }
+                    break;                                                // No need to check more options, we have a match
+                }
+            }
+
+            ipos++;                                                   // Advance to the next argument to check
+            if (ipos >= arguments.length) {
+                break;
+            }                      // Terminating condition for the check loop
+
+        }
+
+//.... Identify unmatched arguments and actual (non-option) data
+
+        int first = -1;                                             // Required later for requireDataLast
+        for (int i = 0; i < matched.length; i++) {                  // Assemble the list of unmatched options
+            if (!matched[i]) {
+                if (arguments[i].startsWith(pre) || arguments[i].startsWith(altPre)) {   // An unmatched option
+                    unmatched.add(arguments[i]);
+                    checkErrors.append("No matching option found for argument ");
+                    checkErrors.append(arguments[i]);
+                    checkErrors.append('\n');
+                } else {                                                // This is actual data
+                    if (first < 0) {
+                        first = i;
+                    }
+                    data.add(arguments[i]);
+                }
+            }
+        }
+
+//.... Checks to determine overall success, start with the multiplicity of options
+
+        boolean err = true;
+
+        for (OptionData optionData : options) {
+
+            if (!optionData.isExclusive()) {              // Only check options which are not part of an ExclusiveConstraint
+
+                key = optionData.getKey();
+                err = false;                                // Local check result for one option
+
+                switch (optionData.getMultiplicity()) {
+                    case ONCE:
+                        if (optionData.getResultCount() != 1) {
+                            err = true;
+                        }
+                        break;
+                    case ONCE_OR_MORE:
+                        if (optionData.getResultCount() == 0) {
+                            err = true;
+                        }
+                        break;
+                    case ZERO_OR_ONCE:
+                        if (optionData.getResultCount() > 1) {
+                            err = true;
+                        }
+                        break;
+                }
+
+                if (err) {
+                    checkErrors.append("Wrong number of occurences found for argument ");
+                    checkErrors.append(pre);
+                    checkErrors.append(key);
+                    checkErrors.append('\n');
+                    return false;
+                }
+
+            }
+
+        }
+
+//.... Check defined constraints for all options
+
+        for (OptionData optionData : options) {
+
+            if (optionData.isSet() && (optionData.getConstraints() != null)) {
+                for (Constraint constraint : optionData.getConstraints()) {
+                    if (!constraint.isSatisfied()) {
+                        checkErrors.append("Constraint ");
+                        checkErrors.append(constraint.toString());
+                        checkErrors.append(" violated for option '");
+                        checkErrors.append(optionData.getKey());
+                        checkErrors.append("'\n");
+                        return false;
+                    }
+                }
+            }
+
+        }
+
+//.... Check defined constraints for the current set
+
+        if (set.getConstraints() != null) {
+            for (Constraint constraint : set.getConstraints()) {
+                if (!constraint.isSatisfied()) {
+                    checkErrors.append("Constraint ");
+                    checkErrors.append(constraint.toString());
+                    checkErrors.append(" violated for option set '");
+                    checkErrors.append(set.getName());
+                    checkErrors.append("'\n");
+                    return false;
+                }
+            }
+        }
+
+//.... Check range for data
+
+        int limit = set.getMaxData();
+        if (set.hasUnlimitedData()) {
+            limit = Integer.MAX_VALUE;
+        }
+
+        if (data.size() < set.getMinData() || data.size() > limit) {
+            checkErrors.append("Invalid number of data arguments: ");
+            checkErrors.append(data.size());
+            checkErrors.append(" (allowed range: ");
+            checkErrors.append(set.getMinData());
+            checkErrors.append(" ... ");
+            checkErrors.append(set.getMaxData());
+            checkErrors.append(")\n");
+            return false;
+        }
+
+//.... Check for location of the data in the list of command line arguments
+
+        if (requireDataLast && data.size() > 0) {
+            if (first + data.size() != arguments.length) {
+                checkErrors.append("Invalid data specification: data arguments are not the last ones on the command line\n");
+                return false;
+            }
+        }
+
+//.... Check for unmatched arguments
+
+        if (!ignoreUnmatched && unmatched.size() > 0) {
+            return false;
+        }     // Don't accept unmatched arguments
+
+//.... If we made it to here, all checks were successful
+
+        return true;
+
+    }
+
+// ==========================================================================================
+// Add a value option for all sets
+// ==========================================================================================
+    /**
+     * Add the given option to <i>all</i> known sets.
+     * <p>
+     * @param type The type of the option
+     * @param key  The name of the option
+     */
+    public void addOptionAllSets(OptionData.Type type, String key) {
+        for (String name : optionSets.keySet()) {
+            optionSets.get(name).addOption(type,
+                                           key,
+                                           null,
+                                           type.detail() ? defaultDetailSeparator : defaultValueSeparator,
+                                           defaultMultiplicity);
+        }
+    }
+
+    /**
+     * Add the given option to <i>all</i> known sets.
+     * <p>
+     * @param type The type of the option
+     * @param key  The name of the option
+     * @param multiplicity The multiplicity of the option
+     */
+    public void addOptionAllSets(OptionData.Type type, String key, Multiplicity multiplicity) {
+        for (String name : optionSets.keySet()) {
+            optionSets.get(name).addOption(type,
+                                           key,
+                                           null,
+                                           type.detail() ? defaultDetailSeparator : defaultValueSeparator,
+                                           multiplicity);
+        }
+    }
+
+    /**
+     * Add the given option to <i>all</i> known sets.
+     * <p>
+     * @param type The type of the option
+     * @param key  The name of the option
+     * @param altKey       The alternate name of the option
+     */
+    public void addOptionAllSets(OptionData.Type type, String key, String altKey) {
+        for (String name : optionSets.keySet()) {
+            optionSets.get(name).addOption(type,
+                                           key,
+                                           altKey,
+                                           type.detail() ? defaultDetailSeparator : defaultValueSeparator,
+                                           defaultMultiplicity);
+        }
+    }
+
+    /**
+     * Add the given option to <i>all</i> known sets.
+     * <p>
+     * @param type The type of the option
+     * @param key  The name of the option
+     * @param altKey       The alternate name of the option
+     * @param multiplicity The multiplicity of the option
+     */
+    public void addOptionAllSets(OptionData.Type type, String key, String altKey, Multiplicity multiplicity) {
+        for (String name : optionSets.keySet()) {
+            optionSets.get(name).addOption(type,
+                                           key,
+                                           altKey,
+                                           type.detail() ? defaultDetailSeparator : defaultValueSeparator,
+                                           multiplicity);
+        }
+    }
+}
+
+
diff --git a/src/ml/options/SchemaValidator.java b/src/ml/options/SchemaValidator.java
new file mode 100644
index 0000000..e2014a0
--- /dev/null
+++ b/src/ml/options/SchemaValidator.java
@@ -0,0 +1,149 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+import javax.xml.validation.*;
+
+/**
+ * Validator for XML documents using XML schema. This is based on JDK 5.0 and requires 
+ * no outside library.
+ */
+public class SchemaValidator extends org.xml.sax.helpers.DefaultHandler {
+
+    private final String CLASS = "SchemaValidator";
+    private final String xsdFile = "config/options.xsd";
+    private String error = null;
+
+    /**
+     * The actual validation method. If validation is not successful, the errors found can be retrieved
+     * using the {@link #getError()} method.
+     * <p>
+     * @param xmlReader The reader for the XML file to validate
+     * <p>
+     * @return <code>true</code> if the XML file could be validated against the XML schema, else <code>false</code>
+     * @throws java.io.IOException
+     * @throws org.xml.sax.SAXException 
+     */
+    public boolean validate(java.io.Reader xmlReader) throws java.io.IOException,
+                                                              org.xml.sax.SAXException {
+
+        if (xmlReader == null) {
+            throw new IllegalArgumentException(CLASS + ": xmlReader may not be null");
+        }
+
+//.... Get the XML schema from the JAR and create a validator
+
+        SchemaFactory factory = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        ClassLoader loader = this.getClass().getClassLoader();
+        java.net.URL url = loader.getResource(xsdFile);
+        Schema schema = factory.newSchema(url);
+        Validator validator = schema.newValidator();
+
+        validator.setErrorHandler(this);
+
+//.... Try to validate the XML file given
+
+        org.xml.sax.InputSource source = new org.xml.sax.InputSource(new java.io.BufferedReader(xmlReader));
+        validator.validate(new javax.xml.transform.sax.SAXSource(source));
+
+        return getError() == null ? true : false;
+
+    }
+
+//-----------------------------------------------------------------------------------------
+// Below are helper methods that are required to improve the error handling (specifically,
+// to make sure all thrown exceptions are reported, and row and column numbers are added
+// to the output for better debugging
+//-----------------------------------------------------------------------------------------
+    /**
+     * Retrieve the error message set by the <code>org.xml.sax.ErrorHandler</code> methods.
+     * If no error has been found, <code>null</code> is returned.
+     * <p>
+     * @return A string describing the error encountered
+     */
+    public String getError() {
+        return error;
+    }
+
+    /**
+     * A method required by the <code>org.xml.sax.ErrorHandler</code> interface
+     * <p>
+     * @param ex A parsing exception
+     */
+    @Override
+    public void warning(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException {
+        getError("Warning", ex);
+    }
+
+    /**
+     * A method required by the <code>org.xml.sax.ErrorHandler</code> interface
+     * <p>
+     * @param ex A parsing exception
+     */
+    @Override
+    public void error(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException {
+        getError("Error", ex);
+    }
+
+    /**
+     * A method required by the <code>org.xml.sax.ErrorHandler</code> interface
+     * <p>
+     * @param ex A parsing exception
+     */
+    @Override
+    public void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException {
+        getError("Fatal Error", ex);
+    }
+
+    /**
+     * A helper method for the formatting
+     */
+    private void getError(String type, org.xml.sax.SAXParseException ex) {
+
+        StringBuilder out = new StringBuilder(200);
+
+        out.append(type);
+
+        if (ex == null) {
+            out.append("!!!");
+        }
+
+        String systemId = ex.getSystemId();
+        if (systemId != null) {
+            int index = systemId.lastIndexOf('/');
+            if (index != -1) {
+                systemId = systemId.substring(index + 1);
+            }
+            out.append(systemId);
+        }
+        out.append(": Row ");
+        out.append(ex.getLineNumber());
+        out.append(" /`Col ");
+        out.append(ex.getColumnNumber());
+        out.append(": ");
+        out.append(ex.getMessage());
+
+//.... There may be multiple exceptions thrown, we don't want to miss any information
+
+        if (error == null) {
+            error = out.toString();
+        } else {
+            error += "\n" + out.toString();
+        }
+
+    }
+}
+
diff --git a/src/ml/options/ValueConstraint.java b/src/ml/options/ValueConstraint.java
new file mode 100644
index 0000000..f24e2ce
--- /dev/null
+++ b/src/ml/options/ValueConstraint.java
@@ -0,0 +1,452 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * A constraint for options taking a value. It allows to constrain the values 
+ * acceptable for such an option to e. g. a list of strings. 
+ */
+public class ValueConstraint implements XMLConstraint {
+
+    private static final String CLASS = "ValueConstraint";
+
+    /**
+     * An enum with the supported subtypes for this constraint type
+     */
+    public enum Type {
+
+        /**
+         * A type defining a set of acceptable string values
+         */
+        STRING_ARRAY,
+        /**
+         * A type defining a set of acceptable int values
+         */
+        INT_ARRAY,
+        /**
+         * A type defining a range of acceptable int values
+         */
+        INT_RANGE;
+    }
+    private String[] s_values = null;
+    private int[] i_values = null;
+    private int imin = 0;
+    private int imax = 0;
+    private boolean caseSensitive = true;
+    private Type type = null;
+    private OptionData optionData = null;
+
+    /**
+     * The public no-org constructor. This is a prereq for all constraints since it is used 
+     * for initialization based on XML data. 
+     */
+    public ValueConstraint() {
+
+    }
+
+    /**
+     * This method is used to initialize this constraint based on data read from an XML configuration
+     * file. The method is invoked internally during setup with the instance of
+     * {@link Constrainable} to which the constraint applies and a list of JDOM elements,
+     * which contain the details about the constraint itself.
+     * <p>
+     * This method initializes the constraint and attaches it to the list of constraints
+     * of the {@link Constrainable} instance.
+     * <p>
+     * The parameters expected in the XML <code><param></code> tags for this constraint 
+     * are 
+     * <p>
+     * <table border=1 cellpadding=6>
+     * <tr bgcolor=#dddddd> <td> <b >Name</b> <td> <b>Value</b> <td> <b>Status</b>
+     * <tr> <td> type <td> Same as the <code>type</code> parameter in {@link #add(OptionData, Type, String)} <td> Required
+     * <tr> <td> spec <td> Same as the <code>spec</code> parameter in {@link #add(OptionData, Type, String)} <td> Required
+     * </table>
+     * <p>
+     * @param constrainable The {@link Constrainable} instance to which this constraint applies
+     * @param list          A list of JDOM elements to be used to initialize the constraint. Specifically,
+     *                      these are tags of the form
+     *                      <p>
+     *                      <code><param name="..." value="..." /></code>
+     *                      <p>
+     *                      containing key/value pairs with information.
+     */
+    @Override
+    public void init(Constrainable constrainable, java.util.List<org.jdom.Element> list) {
+
+        if (list == null) {
+            throw new IllegalArgumentException(CLASS + ": list may not be null");
+        }
+        if (constrainable == null) {
+            throw new IllegalArgumentException(CLASS + ": constrainable may not be null");
+        }
+        if (!supports(constrainable)) {
+            throw new IllegalArgumentException(CLASS + ": Constrainable must be instance of OptionData");
+        }
+
+//.... Extract all parameters
+
+        java.util.Map<String, String> params = new java.util.HashMap<String, String>();
+        for (org.jdom.Element param : list) {
+            params.put(param.getAttributeValue("name").trim(), param.getAttributeValue("value").trim());
+        }
+
+//.... Checks
+
+        if (!params.containsKey("type")) {
+            throw new IllegalArgumentException(CLASS + ": missing <param> element with attribute named 'type'");
+        }
+        if (!params.containsKey("spec")) {
+            throw new IllegalArgumentException(CLASS + ": missing <param> element with attribute named 'spec'");
+        }
+
+//.... Add the constraint
+
+        add((OptionData) constrainable, Type.valueOf(params.get("type")), params.get("spec"));
+
+    }
+
+    /**
+     * Add a constraint of {@link Type} <code>STRING_ARRAY</code> for the given option
+     * <p>
+     * @param optionData 
+     * @param values        A string array with the acceptable values for the option
+     * @param caseSensitive Whether the string comparisons are to be made case sensitive or not
+     */
+    public static void add(OptionData optionData, String[] values, boolean caseSensitive) {
+        if (optionData == null) {
+            throw new IllegalArgumentException(CLASS + ": optionData may not be null");
+        }
+        optionData.addConstraint(new ValueConstraint(optionData, values, caseSensitive));
+    }
+
+    /**
+     * Add a constraint of {@link Type} <code>INT_ARRAY</code> for the given option
+     * <p>
+     * @param optionData 
+     * @param values An integer array with the acceptable values for the option
+     */
+    public static void add(OptionData optionData, int[] values) {
+        if (optionData == null) {
+            throw new IllegalArgumentException(CLASS + ": optionData may not be null");
+        }
+        optionData.addConstraint(new ValueConstraint(optionData, values));
+    }
+
+    /**
+     * Add a constraint of {@link Type} <code>INT_RANGE</code> for the given option
+     * <p>
+     * @param optionData 
+     * @param imin The minimum acceptable integer value
+     * @param imax The maximum acceptable integer value (must be greater than or equal to <code>imin</code>)
+     */
+    public static void add(OptionData optionData, int imin, int imax) {
+        if (optionData == null) {
+            throw new IllegalArgumentException(CLASS + ": optionData may not be null");
+        }
+        optionData.addConstraint(new ValueConstraint(optionData, imin, imax));
+    }
+
+    /**
+     * Add a constraint of the given {@link Type} with the specified details
+     * <p>
+     * @param optionData 
+     * @param type The type for this constraint
+     * @param spec A string specifying the details for this constraint:
+     *             <p>
+     *             <table border=1 cellpadding=6>
+     *             <tr bgcolor=#dddddd> <td> <b >Type</b> <td> <b>Format for specification</b>
+     *             <tr> <td> STRING_ARRAY <td> All values separated by vertical bar (e. g. Foo|Bah|Yeah). If the first
+     *                                         string is preceded by '+', the checks are run case insensitive (default 
+     *                                         is to run them case sensitive)
+     *             <tr> <td> INT_ARRAY    <td> All values separated by vertical bar (e. g. 1|2|7)
+     *             <tr> <td> INT_RANGE    <td> MIN:MAX (e. g. 7:12)
+     *             </table>
+     */
+    public static void add(OptionData optionData, Type type, String spec) {
+        if (optionData == null) {
+            throw new IllegalArgumentException(CLASS + ": optionData may not be null");
+        }
+        optionData.addConstraint(new ValueConstraint(optionData, type, spec));
+    }
+
+    /**
+     * Constructor for {@link Type} <code>STRING_ARRAY</code>
+     * <p>
+     * @param values        A string array with the acceptable values for the option
+     * @param caseSensitive Whether the string comparisons are to be made case sensitive or not
+     */
+    ValueConstraint(OptionData optionData, String[] values, boolean caseSensitive) {
+        if (values == null) {
+            throw new IllegalArgumentException(CLASS + ": values may not be null");
+        }
+        if (values.length == 0) {
+            throw new IllegalArgumentException(CLASS + ": values must contain at least one element");
+        }
+        s_values = values;
+        type = Type.STRING_ARRAY;
+        this.caseSensitive = caseSensitive;
+        this.optionData = optionData;
+    }
+
+    /**
+     * Constructor for {@link Type} <code>INT_ARRAY</code>
+     * <p>
+     * @param values An integer array with the acceptable values for the option
+     */
+    ValueConstraint(OptionData optionData, int[] values) {
+        if (values == null) {
+            throw new IllegalArgumentException(CLASS + ": values may not be null");
+        }
+        if (values.length == 0) {
+            throw new IllegalArgumentException(CLASS + ": values must contain at least one element");
+        }
+        i_values = values;
+        type = Type.INT_ARRAY;
+        this.optionData = optionData;
+    }
+
+    /**
+     * Constructor for {@link Type} <code>INT_RANGE</code>
+     * <p>
+     * @param imin The minimum acceptable integer value
+     * @param imax The maximum acceptable integer value (must be greater than or equal to <code>imin</code>)
+     */
+    ValueConstraint(OptionData optionData, int imin, int imax) {
+        if (imax < imin) {
+            throw new IllegalArgumentException(CLASS + ": imax must greater than or equal to imin");
+        }
+        this.imin = imin;
+        this.imax = imax;
+        type = Type.INT_RANGE;
+        this.optionData = optionData;
+    }
+
+    /**
+     * Constructor for any {@link Type} 
+     * <p>
+     * @param type The type for this constraint
+     * @param spec A string specifying the details for this constraint:
+     *             <p>
+     *             <table border=1 cellpadding=6>
+     *             <tr bgcolor=#dddddd> <td> <b >Type</b> <td> <b>Format for specification</b>
+     *             <tr> <td> STRING_ARRAY <td> All values separated by vertical bar (e. g. Foo|Bah|Yeah). If the first
+     *                                         string is preceded by '+', the checks are run case insensitive (default 
+     *                                         is to run them case sensitive)
+     *             <tr> <td> INT_ARRAY    <td> All values separated by vertical bar (e. g. 1|2|7)
+     *             <tr> <td> INT_RANGE    <td> MIN:MAX (e. g. 7:12)
+     *             </table>
+     */
+    ValueConstraint(OptionData optionData, Type type, String spec) {
+
+        if (type == null) {
+            throw new IllegalArgumentException(CLASS + ": type may not be null");
+        }
+        if (spec == null) {
+            throw new IllegalArgumentException(CLASS + ": spec may not be null");
+        }
+
+        this.type = type;
+        this.optionData = optionData;
+
+        switch (type) {
+
+            case STRING_ARRAY:
+
+                s_values = spec.split("\\|");
+                if (s_values[0].startsWith("+")) {
+                    caseSensitive = false;
+                    s_values[0] = s_values[0].substring(1);
+                }
+                break;
+
+            case INT_ARRAY:
+
+                s_values = spec.split("\\|");
+                i_values = new int[s_values.length];
+                try {
+                    int i = 0;
+                    for (String s : s_values) {
+                        i_values[i++] = Integer.parseInt(s);
+                    }
+                } catch (NumberFormatException ex) {
+                    throw new IllegalArgumentException(CLASS + ": Invalid specification for type " + type + ": " + spec);
+                }
+                break;
+
+            case INT_RANGE:
+
+                s_values = spec.split(":");
+                if (s_values.length != 2) {
+                    throw new IllegalArgumentException(CLASS + ": Invalid specification for type " + type + ": " + spec);
+                }
+
+                try {
+                    imin = Integer.parseInt(s_values[0]);
+                    imax = Integer.parseInt(s_values[1]);
+                } catch (NumberFormatException ex) {
+                    throw new IllegalArgumentException(CLASS + ": Invalid specification for type " + type + ": " + spec);
+                }
+                break;
+
+        }
+
+    }
+
+    /**
+     * The actual check routine
+     * <p>
+     * @return A boolean indicating whether the constraint is satisfied or not
+     */
+    @Override
+    public boolean isSatisfied() {
+
+        String test = null;
+
+        for (int i = 0; i < optionData.getResultCount(); i++) {
+
+            test = optionData.getResultValue(i);
+
+            switch (type) {
+
+                case STRING_ARRAY:
+
+                    if (caseSensitive) {
+                        for (String s : s_values) {
+                            if (s.equals(test)) {
+                                return true;
+                            }
+                        }
+                    } else {
+                        for (String s : s_values) {
+                            if (s.equalsIgnoreCase(test)) {
+                                return true;
+                            }
+                        }
+                    }
+
+                    break;
+
+                case INT_ARRAY:
+
+                    int t = 0;
+                    try {
+                        t = Integer.parseInt(test);
+                    } catch (NumberFormatException ex) {
+                        return false;
+                    }
+
+                    for (int ii : i_values) {
+                        if (ii == t) {
+                            return true;
+                        }
+                    }
+
+                    break;
+
+                case INT_RANGE:
+
+                    t = 0;
+                    try {
+                        t = Integer.parseInt(test);
+                    } catch (NumberFormatException ex) {
+                        return false;
+                    }
+
+                    if ((t >= imin) && (t <= imax)) {
+                        return true;
+                    }
+
+                    break;
+
+            }
+
+        }
+
+        return false;
+
+    }
+
+    /**
+     * Indicates whether a constraint supports a given type of {@link Constrainable}
+     * <p>
+     * @param constrainable 
+     * @return A boolean to indicate whether this {@link Constrainable} is supported. This constraint only
+     *         supports {@link OptionData} constrainables
+     */
+    @Override
+    public boolean supports(Constrainable constrainable) {
+        if (constrainable == null) {
+            throw new IllegalArgumentException(CLASS + ": constrainable may not be null");
+        }
+        if (constrainable instanceof OptionData) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Return the type for this constraint
+     * <p>
+     * @return The type for this constraint
+     */
+    Type getType() {
+        return type;
+    }
+
+    /**
+     * This is the overloaded {@link Object#toString()} method
+     * <p>
+     * @return A string representing the instance
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append(type.name());
+        sb.append(": ");
+
+        switch (type) {
+            case STRING_ARRAY:
+                if (!caseSensitive) {
+                    sb.append('+');
+                }
+                for (String s : s_values) {
+                    sb.append(s);
+                    sb.append('|');
+                }
+                sb.deleteCharAt(sb.length() - 1);
+                break;
+            case INT_ARRAY:
+                for (int i : i_values) {
+                    sb.append(i);
+                    sb.append('|');
+                }
+                sb.deleteCharAt(sb.length() - 1);
+                break;
+            case INT_RANGE:
+                sb.append(imin);
+                sb.append(':');
+                sb.append(imax);
+                break;
+        }
+
+        return sb.toString();
+
+    }
+}
+
+
diff --git a/src/ml/options/XMLConstraint.java b/src/ml/options/XMLConstraint.java
new file mode 100644
index 0000000..d1c1ff9
--- /dev/null
+++ b/src/ml/options/XMLConstraint.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * Constraints implementing this interface have - beyond the {@link Constraint} interface - the capability
+ * to be created through XML configuration files. In this case, a public no-arg constructor
+ * is also required.
+ */
+public interface XMLConstraint extends Constraint {
+
+    /**
+     * This method is used to initialize a constraint based on data read from an XML configuration 
+     * file. The method is invoked internally during setup with the instance of 
+     * {@link Constrainable} to which the constraint applies and a list of JDOM elements,
+     * which contain the details about the constraint itself. 
+     * <p>
+     * This method initializes the constraint and attaches it to the list of constraints
+     * of the {@link Constrainable} instance. 
+     * <p>
+     * @param constrainable The {@link Constrainable} instance to which this constraint applies
+     * @param list          A list of JDOM elements to be used to initialize the constraint. Specifically, 
+     *                      these are tags of the form 
+     *                      <p>
+     *                      <code><param name="..." value="..." /></code>
+     *                      <p>
+     *                      containing key/value pairs with information. The expected pairs are specific 
+     *                      to each implementation.
+     */
+    public void init(Constrainable constrainable, java.util.List<org.jdom.Element> list);
+}
+
+
diff --git a/src/ml/options/XMLParsingException.java b/src/ml/options/XMLParsingException.java
new file mode 100644
index 0000000..6e1c1da
--- /dev/null
+++ b/src/ml/options/XMLParsingException.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2007 Dr. Matthias Laux
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ml.options;
+
+/**
+ * <code>XMLParsingException</code> is thrown if an XML file provided to define
+ * option sets and options contains errors
+ */
+public class XMLParsingException extends RuntimeException {
+
+    private static final long serialVersionUID = 1L;
+
+    /** Constructs a new <code>XMLParsingException</code> exception with <code>null</code> as its
+     * detail message.  The cause is not initialized, and may subsequently be
+     * initialized by a call to {@link #initCause}.
+     */
+    public XMLParsingException() {
+        super();
+    }
+
+    /** Constructs a new <code>XMLParsingException</code> exception with the specified detail message.
+     * The cause is not initialized, and may subsequently be initialized by a
+     * call to {@link #initCause}.
+     *
+     * @param   message   the detail message. The detail message is saved for 
+     *          later retrieval by the {@link #getMessage()} method.
+     */
+    public XMLParsingException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a new <code>XMLParsingException</code> exception with the specified detail message and
+     * cause.  <p>Note that the detail message associated with
+     * <code>cause</code> is <i>not</i> automatically incorporated in
+     * this <code>XMLParsingException</code> exception's detail message.
+     *
+     * @param  message the detail message (which is saved for later retrieval
+     *         by the {@link #getMessage()} method).
+     * @param  cause the cause (which is saved for later retrieval by the
+     *         {@link #getCause()} method).  (A <tt>null</tt> value is
+     *         permitted, and indicates that the cause is nonexistent or
+     *         unknown.)
+     */
+    public XMLParsingException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /** Constructs a new <code>XMLParsingException</code> exception with the specified cause and a
+     * detail message of <tt>(cause==null ? null : cause.toString())</tt>
+     * (which typically contains the class and detail message of
+     * <tt>cause</tt>).  This constructor is useful for <code>XMLParsingException</code> exceptions
+     * that are little more than wrappers for other throwables.
+     *
+     * @param  cause the cause (which is saved for later retrieval by the
+     *         {@link #getCause()} method).  (A <tt>null</tt> value is
+     *         permitted, and indicates that the cause is nonexistent or
+     *         unknown.)
+     */
+    public XMLParsingException(Throwable cause) {
+        super(cause);
+    }
+}
+
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/liboptions-java.git



More information about the debian-med-commit mailing list