projects
/
svjatoslav_commons.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
2be5dfa
)
improved javadoc
author
Svjatoslav Agejenko
<svjatoslav@svjatoslav.eu>
Sat, 30 May 2015 20:45:58 +0000
(23:45 +0300)
committer
Svjatoslav Agejenko
<svjatoslav@svjatoslav.eu>
Sat, 30 May 2015 20:45:58 +0000
(23:45 +0300)
src/main/java/eu/svjatoslav/commons/commandline/CLIHelper.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parser.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/commons/file/CommonPathResolver.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/commons/file/IOHelper.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/commons/network/navigation/Navigation.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/commons/string/String2.java
patch
|
blob
|
history
src/main/java/eu/svjatoslav/commons/string/WildCardMatcher.java
patch
|
blob
|
history
diff --git
a/src/main/java/eu/svjatoslav/commons/commandline/CLIHelper.java
b/src/main/java/eu/svjatoslav/commons/commandline/CLIHelper.java
index
a3764a1
..
5a774e2
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/commandline/CLIHelper.java
+++ b/
src/main/java/eu/svjatoslav/commons/commandline/CLIHelper.java
@@
-1,7
+1,7
@@
/*
* Svjatoslav Commons - shared library of common functionality.
* Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
/*
* 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.
* 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.
@@
-20,6
+20,10
@@
public class CLIHelper {
/**
* Ask boolean value from user on command-line.
/**
* Ask boolean value from user on command-line.
+ *
+ * @param prompt
+ * to show to the user
+ * @return <code>true</code> is user answered affirmative.
*/
public static boolean askBoolean(final String prompt) {
*/
public static boolean askBoolean(final String prompt) {
@@
-49,6
+53,10
@@
public class CLIHelper {
/**
* Ask numerical long value from user on command-line.
/**
* Ask numerical long value from user on command-line.
+ *
+ * @param prompt
+ * to show to the user
+ * @return value given by user
*/
public static long askLong(final String prompt) {
*/
public static long askLong(final String prompt) {
@@
-76,6
+84,10
@@
public class CLIHelper {
/**
* Ask string value from user on command-line.
/**
* Ask string value from user on command-line.
+ *
+ * @param prompt
+ * to show to the user
+ * @return value given by the user
*/
public static String askString(final String prompt) {
*/
public static String askString(final String prompt) {
diff --git
a/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java
b/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java
index
fd22c89
..
25f406d
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java
+++ b/
src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parameter.java
@@
-51,6
+51,7
@@
public abstract class Parameter<T> {
this.argumentCount = argumentCount;
}
this.argumentCount = argumentCount;
}
+ @SuppressWarnings("unchecked")
public T addAliases(final String... aliasArray) {
// save aliases
public T addAliases(final String... aliasArray) {
// save aliases
@@
-61,6
+62,8
@@
public abstract class Parameter<T> {
}
/**
}
/**
+ * @param argumentString
+ * argument to add
* @return <code>true</code> if no errors were found. <code>false</code>
* otherwise.
*/
* @return <code>true</code> if no errors were found. <code>false</code>
* otherwise.
*/
@@
-147,6
+150,8
@@
public abstract class Parameter<T> {
}
/**
}
/**
+ * @param alias
+ * alias to check against
* @return <code>true</code> if given alias is registered for this
* parameter.
*/
* @return <code>true</code> if given alias is registered for this
* parameter.
*/
@@
-177,6
+182,7
@@
public abstract class Parameter<T> {
return true;
}
return true;
}
+ @SuppressWarnings("unchecked")
public T setMandatory() {
mandatory = true;
return (T) this;
public T setMandatory() {
mandatory = true;
return (T) this;
@@
-191,6
+197,8
@@
public abstract class Parameter<T> {
}
/**
}
/**
+ * @param value
+ * value to validate
* @return <code>true</code> if value is correct, <code>false</code>
* otherwise.
*/
* @return <code>true</code> if value is correct, <code>false</code>
* otherwise.
*/
diff --git
a/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parser.java
b/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parser.java
index
69b26dc
..
7ee27a0
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parser.java
+++ b/
src/main/java/eu/svjatoslav/commons/commandline/parameterparser/Parser.java
@@
-18,9
+18,9
@@
import java.util.ArrayList;
*/
public class Parser {
*/
public class Parser {
- private final ArrayList<Parameter
> parameters = new ArrayList<Parameter
>();
+ private final ArrayList<Parameter
<?>> parameters = new ArrayList<Parameter<?>
>();
- public <E extends Parameter> E add(final E parameter) {
+ public <E extends Parameter
<?>
> E add(final E parameter) {
parameters.add(parameter);
return parameter;
}
parameters.add(parameter);
return parameter;
}
@@
-31,7
+31,7
@@
public class Parser {
*/
private boolean checkMandatoryArgumentsPresent() {
*/
private boolean checkMandatoryArgumentsPresent() {
- for (final Parameter parameter : parameters)
+ for (final Parameter
<?>
parameter : parameters)
if (parameter.isMandatory() && (!parameter.isParameterSpecified())) {
System.out.println("Error! Mandatory parameter ("
+ parameter.getAliases() + ") is not specified.");
if (parameter.isMandatory() && (!parameter.isParameterSpecified())) {
System.out.println("Error! Mandatory parameter ("
+ parameter.getAliases() + ") is not specified.");
@@
-44,10
+44,14
@@
public class Parser {
/**
* Return parameter by given alias or <code>null</code> if no parameter
* exists for given alias.
/**
* Return parameter by given alias or <code>null</code> if no parameter
* exists for given alias.
+ *
+ * @param alias
+ * parameter alias
+ * @return found parameter or <code>null</code> if parameter was not found.
*/
*/
- public Parameter findParameterByAlias(final String alias) {
+ public Parameter
<?>
findParameterByAlias(final String alias) {
- for (final Parameter parameter : parameters)
+ for (final Parameter
<?>
parameter : parameters)
if (parameter.matchesAlias(alias))
return parameter;
if (parameter.matchesAlias(alias))
return parameter;
@@
-55,16
+59,18
@@
public class Parser {
}
/**
}
/**
+ * @param args
+ * commandline arguments
* @return <code>true</code> if no errors were found. <code>false</code>
* otherwise.
*/
public boolean parse(final String[] args) {
* @return <code>true</code> if no errors were found. <code>false</code>
* otherwise.
*/
public boolean parse(final String[] args) {
- Parameter currentParameter = null;
+ Parameter
<?>
currentParameter = null;
for (final String argument : args) {
for (final String argument : args) {
- final Parameter parameterForAlias = findParameterByAlias(argument);
+ final Parameter
<?>
parameterForAlias = findParameterByAlias(argument);
if (parameterForAlias == null) {
if (currentParameter == null) {
System.out.println("Unknown commandline parameter: "
if (parameterForAlias == null) {
if (currentParameter == null) {
System.out.println("Unknown commandline parameter: "
@@
-90,7
+96,7
@@
public class Parser {
}
public void showHelp() {
}
public void showHelp() {
- for (final Parameter parameter : parameters)
+ for (final Parameter
<?>
parameter : parameters)
System.out.println(parameter.getHelp());
}
System.out.println(parameter.getHelp());
}
diff --git
a/src/main/java/eu/svjatoslav/commons/file/CommonPathResolver.java
b/src/main/java/eu/svjatoslav/commons/file/CommonPathResolver.java
index
bef34aa
..
7441290
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/file/CommonPathResolver.java
+++ b/
src/main/java/eu/svjatoslav/commons/file/CommonPathResolver.java
@@
-1,7
+1,7
@@
/*
* Svjatoslav Commons - shared library of common functionality.
* Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
/*
* 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.
* 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.
@@
-30,6
+30,10
@@
public class CommonPathResolver {
/**
* This method tries to guess user desktop directory. Implementation is
* pretty lousy. Need to improve it some day.
/**
* This method tries to guess user desktop directory. Implementation is
* pretty lousy. Need to improve it some day.
+ *
+ * @return file that points to user desktop directory.
+ * @throws RuntimeException
+ * if user desktop directory is not found.
*/
public static File getDesktopDirectory() {
*/
public static File getDesktopDirectory() {
diff --git
a/src/main/java/eu/svjatoslav/commons/file/IOHelper.java
b/src/main/java/eu/svjatoslav/commons/file/IOHelper.java
index
46abaa5
..
e7ee659
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/file/IOHelper.java
+++ b/
src/main/java/eu/svjatoslav/commons/file/IOHelper.java
@@
-20,6
+20,12
@@
public class IOHelper {
/**
* Deletes files and directories recursively. WARNING!!! Follows symlinks!!!
/**
* Deletes files and directories recursively. WARNING!!! Follows symlinks!!!
+ *
+ * @param file
+ * directory to delete with entire contents.
+ *
+ * @throws IOException
+ * if filesystem error happens
*/
public static void deleteRecursively(final File file) throws IOException {
if (file.isDirectory()) {
*/
public static void deleteRecursively(final File file) throws IOException {
if (file.isDirectory()) {
@@
-64,7
+70,16
@@
public class IOHelper {
* then leaves file as-is. If content differs, then overrides file with the
* new content.
*
* then leaves file as-is. If content differs, then overrides file with the
* new content.
*
+ * @param file
+ * file to potentially overwrite
+ * @param newContent
+ * new content
* @return <code>true</code> if file was overwritten.
* @return <code>true</code> if file was overwritten.
+ *
+ * @throws FileNotFoundException
+ * if file is not found.
+ * @throws IOException
+ * if error happens during file IO.
*/
public static boolean overwriteFileIfContentDiffers(final File file,
final byte[] newContent) throws FileNotFoundException, IOException {
*/
public static boolean overwriteFileIfContentDiffers(final File file,
final byte[] newContent) throws FileNotFoundException, IOException {
diff --git
a/src/main/java/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.java
b/src/main/java/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.java
index
f350168
..
24ba80e
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.java
+++ b/
src/main/java/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.java
@@
-1,7
+1,7
@@
/*
* Svjatoslav Commons - shared library of common functionality.
* Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
/*
* 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.
* 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.
@@
-21,6
+21,9
@@
public class ExceptionDialog {
/**
* This method is for testing
/**
* This method is for testing
+ *
+ * @param args
+ * commandline arguments
*/
public static void main(final String[] args) {
*/
public static void main(final String[] args) {
diff --git
a/src/main/java/eu/svjatoslav/commons/network/navigation/Navigation.java
b/src/main/java/eu/svjatoslav/commons/network/navigation/Navigation.java
index
4dffa36
..
ff16177
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/network/navigation/Navigation.java
+++ b/
src/main/java/eu/svjatoslav/commons/network/navigation/Navigation.java
@@
-54,6
+54,7
@@
public class Navigation<NI extends NavigationItem> {
try {
final String requestPath = new URL(requestUrl).getPath();
try {
final String requestPath = new URL(requestUrl).getPath();
+ @SuppressWarnings("unchecked")
final NI match = (NI) rootNavigationItem
.getMatchingNavigationItem(requestPath);
final NI match = (NI) rootNavigationItem
.getMatchingNavigationItem(requestPath);
@@
-67,6
+68,7
@@
public class Navigation<NI extends NavigationItem> {
return getDefaultNavigationItem();
}
return getDefaultNavigationItem();
}
+ @SuppressWarnings("unchecked")
public String getTopMenu(final HttpServletRequest request) {
final String currentLocale = localeConfiguration
public String getTopMenu(final HttpServletRequest request) {
final String currentLocale = localeConfiguration
diff --git
a/src/main/java/eu/svjatoslav/commons/string/String2.java
b/src/main/java/eu/svjatoslav/commons/string/String2.java
index
b19e99a
..
45c6cd0
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/string/String2.java
+++ b/
src/main/java/eu/svjatoslav/commons/string/String2.java
@@
-1,7
+1,7
@@
/*
* Svjatoslav Commons - shared library of common functionality.
* Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
/*
* 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.
* 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.
@@
-36,8
+36,11
@@
public class String2 {
}
/**
}
/**
- * Cut given amount of characters from the left of the string. Return cutted
- * part.
+ * Cut given amount of characters from the left of the string.
+ *
+ * @param cutAmount
+ * of characters to cut
+ * @return cutted part.
*/
public String cutLeft(final int cutAmount) {
*/
public String cutLeft(final int cutAmount) {
diff --git
a/src/main/java/eu/svjatoslav/commons/string/WildCardMatcher.java
b/src/main/java/eu/svjatoslav/commons/string/WildCardMatcher.java
index
c3162cd
..
e7fa56b
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/commons/string/WildCardMatcher.java
+++ b/
src/main/java/eu/svjatoslav/commons/string/WildCardMatcher.java
@@
-1,7
+1,7
@@
/*
* Svjatoslav Commons - shared library of common functionality.
* Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
/*
* 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.
* 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.
@@
-32,8
+32,13
@@
public class WildCardMatcher {
* * -- corresponds to any amount of characters.
* ? -- corresponds to any single character.
* </pre>
* * -- corresponds to any amount of characters.
* ? -- corresponds to any single character.
* </pre>
+ *
+ * @param inputString
+ * input string
+ * @param wildcardExpression
+ * wildcard expression
+ * @return <code>true</code> if input string matches input pattern
*/
*/
-
public static boolean match(final String inputString,
final String wildcardExpression) {
public static boolean match(final String inputString,
final String wildcardExpression) {