From: Svjatoslav Agejenko Date: Sat, 30 May 2015 20:45:58 +0000 (+0300) Subject: improved javadoc X-Git-Tag: svjatoslavcommons-1.8~76 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=846af2def5b489670668b978e4ea703c8dfb22b6;p=svjatoslav_commons.git improved javadoc --- 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 --- 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 - * + * * 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. + * + * @param prompt + * to show to the user + * @return true is user answered affirmative. */ public static boolean askBoolean(final String prompt) { @@ -49,6 +53,10 @@ public class CLIHelper { /** * 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) { @@ -76,6 +84,10 @@ public class CLIHelper { /** * 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) { 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 --- 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 { this.argumentCount = argumentCount; } + @SuppressWarnings("unchecked") public T addAliases(final String... aliasArray) { // save aliases @@ -61,6 +62,8 @@ public abstract class Parameter { } /** + * @param argumentString + * argument to add * @return true if no errors were found. false * otherwise. */ @@ -147,6 +150,8 @@ public abstract class Parameter { } /** + * @param alias + * alias to check against * @return true if given alias is registered for this * parameter. */ @@ -177,6 +182,7 @@ public abstract class Parameter { return true; } + @SuppressWarnings("unchecked") public T setMandatory() { mandatory = true; return (T) this; @@ -191,6 +197,8 @@ public abstract class Parameter { } /** + * @param value + * value to validate * @return true if value is correct, false * 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 --- 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 { - private final ArrayList parameters = new ArrayList(); + private final ArrayList> parameters = new ArrayList>(); - public E add(final E parameter) { + public > E add(final E parameter) { parameters.add(parameter); return parameter; } @@ -31,7 +31,7 @@ public class Parser { */ 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."); @@ -44,10 +44,14 @@ public class Parser { /** * Return parameter by given alias or null if no parameter * exists for given alias. + * + * @param alias + * parameter alias + * @return found parameter or null 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; @@ -55,16 +59,18 @@ public class Parser { } /** + * @param args + * commandline arguments * @return true if no errors were found. false * otherwise. */ public boolean parse(final String[] args) { - Parameter currentParameter = null; + Parameter currentParameter = null; 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: " @@ -90,7 +96,7 @@ public class Parser { } public void showHelp() { - for (final Parameter parameter : parameters) + for (final Parameter parameter : parameters) 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 --- 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 - * + * * 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. + * + * @return file that points to user desktop directory. + * @throws RuntimeException + * if user desktop directory is not found. */ 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 --- 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!!! + * + * @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()) { @@ -64,7 +70,16 @@ public class IOHelper { * 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 true 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 { 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 --- 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 - * + * * 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 + * + * @param args + * commandline arguments */ 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 --- 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 { try { final String requestPath = new URL(requestUrl).getPath(); + @SuppressWarnings("unchecked") final NI match = (NI) rootNavigationItem .getMatchingNavigationItem(requestPath); @@ -67,6 +68,7 @@ public class Navigation { return getDefaultNavigationItem(); } + @SuppressWarnings("unchecked") 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 --- 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 - * + * * 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) { 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 --- 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 - * + * * 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. * + * + * @param inputString + * input string + * @param wildcardExpression + * wildcard expression + * @return true if input string matches input pattern */ - public static boolean match(final String inputString, final String wildcardExpression) {