<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Svjatoslav Commons - Java library of commonly used functions</title>
-<!-- 2015-03-01 Sun 19:03 -->
+<!-- 2015-03-21 Sat 00:00 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="generator" content="Org-mode" />
<meta name="author" content="Svjatoslav Agejenko" />
Library contains:
</p>
<ul class="org-ul">
-<li>Wildcards matcher. (?, *)
+<li>Commandline Interface helper
</li>
<li>Commandline arguments parser and validator.
</li>
+<li>Bit input and output streams.
+</li>
+
+<li>Slightly enhanced data input and output streams.
+</li>
+
+<li>Byte array to HEX string converter.
+</li>
+
+<li>Utility that tries to quess user desktop directory.
+</li>
+
<li>File path parser.
</li>
+<li>File IO helper.
+</li>
+
<li>Graphical error dialog.
<ul class="org-ul">
<li>Reusable graphical dialog to capture and show program exceptions
</ul>
</li>
-<li>Primitive URL parameters encoder / decoder.
+<li>Primitive and simple component to add navigation menus to the web
+sites.
+</li>
+
+<li>String tokenizer.
+</li>
+
+<li>Improved String, optimized for dealing with prefixes and suffixes.
+</li>
+
+<li>Wildcards matcher. (?, *)
</li>
</ul>
</div>
</div>
-
<div id="outline-container-sec-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Usage</h2>
<div class="outline-text-2" id="text-2">
</div>
<div id="postamble" class="status">
<p class="author">Author: Svjatoslav Agejenko</p>
-<p class="date">Created: 2015-03-01 Sun 19:03</p>
+<p class="date">Created: 2015-03-21 Sat 00:00</p>
<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.4.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10)</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
* General
Library contains:
-- Wildcards matcher. (?, *)
+- Commandline Interface helper
- Commandline arguments parser and validator.
+- Bit input and output streams.
+
+- Slightly enhanced data input and output streams.
+
+- Byte array to HEX string converter.
+
+- Utility that tries to quess user desktop directory.
+
- File path parser.
+- File IO helper.
+
- Graphical error dialog.
- Reusable graphical dialog to capture and show program exceptions
and associated program call stack traceback.
-- Primitive URL parameters encoder / decoder.
+- Primitive and simple component to add navigation menus to the web
+ sites.
+
+- String tokenizer.
+- Improved String, optimized for dealing with prefixes and suffixes.
+
+- Wildcards matcher. (?, *)
* Usage
Instructions to embed svjatoslav-commons in your project as a library:
/*
* Svjatoslav Commons - shared library of common functionality.
* Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
* or later as published by the Free Software Foundation.
public enum ArgumentCount {
- NONE, SINGLE, MULTI
+ NONE, // parameter has no arguments
+ SINGLE, // parameter has one argument
+ MULTI // parameter can have multiple arguments
}
// check if arguments are allowed for this parameter
if (argumentCount.equals(ArgumentCount.NONE)) {
System.out
- .println("Error! No arguments are allowed for parameters: "
- + getAliases());
+ .println("Error! No arguments are allowed for parameters: "
+ + getAliases());
return false;
}
if ((arguments.size() > 0)
&& (argumentCount.equals(ArgumentCount.SINGLE))) {
System.out
- .println("Error! Only single argument is allowed for parameters: "
- + getAliases());
+ .println("Error! Only single argument is allowed for parameters: "
+ + getAliases());
return false;
}
return parameter;
}
+ /**
+ * @return <code>true</code> if no errors were found. <code>false</code>
+ * otherwise.
+ */
+ private boolean checkMandatoryArgumentsPresent() {
+
+ for (final Parameter parameter : parameters)
+ if (parameter.isMandatory() && (!parameter.isParameterSpecified())) {
+ System.out.println("Error! Mandatory parameter ("
+ + parameter.getAliases() + ") is not specified.");
+ return false;
+ }
+
+ return true;
+ }
+
/**
* Return parameter by given alias or <code>null</code> if no parameter
* exists for given alias.
}
- // check if any mandatory parameters are missing
-
- for (final Parameter parameter : parameters)
- if (parameter.isMandatory() && (!parameter.isParameterSpecified())) {
- System.out.println("Error! Mandatory parameter ("
- + parameter.getAliases() + ") is not specified.");
- return false;
- }
-
- return true;
+ return checkMandatoryArgumentsPresent();
}
public void showHelp() {