[Schmitzm-commits] r1140 - trunk/src/skrueger/versionnumber

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Oct 16 14:02:19 CEST 2010


Author: alfonx
Date: 2010-10-16 14:02:19 +0200 (Sat, 16 Oct 2010)
New Revision: 1140

Modified:
   trunk/src/skrueger/versionnumber/ReleaseUtil.java
Log:
Unified the getLicense method in ReleaseUtil

Modified: trunk/src/skrueger/versionnumber/ReleaseUtil.java
===================================================================
--- trunk/src/skrueger/versionnumber/ReleaseUtil.java	2010-10-15 21:53:30 UTC (rev 1139)
+++ trunk/src/skrueger/versionnumber/ReleaseUtil.java	2010-10-16 12:02:19 UTC (rev 1140)
@@ -117,8 +117,9 @@
 
 			return str;
 		} catch (final Exception e) {
-			log.error("/release.properties could not be read from "
-					+ clazz.getSimpleName(), e);
+			log.error(
+					"/release.properties could not be read from "
+							+ clazz.getSimpleName(), e);
 			return "0";
 		}
 
@@ -154,8 +155,9 @@
 				return defaultVer;
 			return versionProperty;
 		} catch (final Exception e) {
-			log.error("/release.properties could not be read from "
-					+ clazz.getSimpleName(), e);
+			log.error(
+					"/release.properties could not be read from "
+							+ clazz.getSimpleName(), e);
 			return defaultVer;
 		}
 
@@ -208,45 +210,50 @@
 	}
 
 	/**
-	 * @param clazz
-	 *            Pass a class that resides in the same "project" or jar, where
-	 *            the /release.properties resides as well.
-	 * 
-	 *            Print the GPL disclaimer to the given {@link Logger} on INFO
-	 *            level.
+	 * Different types of licenses supported.
 	 */
-	public static void logGPLCopyright(final Logger logger) {
-		logger
-				.info("\nThis program is free software: you can redistribute it and/or modify\n"
-						+ "it under the terms of the GNU General Public License as published by\n"
-						+ "the Free Software Foundation, either version 3 of the License, or\n"
-						+ "(at your option) any later version.\n"
-						+ "\n"
-						+ "This program is distributed in the hope that it will be useful,\n"
-						+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-						+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
-						+ "GNU General Public License for more details.\n");
-	}
+	public enum License {
+		LGPL3, GPL3
+	};
 
 	/**
-	 * @param clazz
-	 *            Pass a class that resides in the same "project" or jar, where
-	 *            the /release.properties resides as well.
+	 * Print the GPL disclaimer to the given {@link Logger} on INFO level.
 	 * 
-	 *            Print the LGPL disclaimer to the given {@link Logger} on INFO
-	 *            level.
+	 * @param progname
+	 *            Name of the program as printed in the license. Will
+	 *            automatically be starting with an upper-case letter.
+	 *            <code>null</code> will fall-back to <code>This program</code>
 	 */
-	public static void logLGPLCopyright(final Logger logger) {
-		logger
-				.info("\nThis program is free software: you can redistribute it and/or modify\n"
-						+ "it under the terms of the GNU Lesser General Public License as published by\n"
-						+ "the Free Software Foundation, either version 3 of the License, or\n"
-						+ "(at your option) any later version.\n"
-						+ "\n"
-						+ "This program is distributed in the hope that it will be useful,\n"
-						+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-						+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
-						+ "GNU Lesser General Public License for more details.\n");
+	public static String getLicense(License l, String progname) {
+		if (progname == null || progname.isEmpty())
+			progname = "This program";
+		switch (l) {
+		case GPL3:
+			return ("\n"
+					+ progname
+					+ " is free software: you can redistribute it and/or modify\n"
+					+ "it under the terms of the GNU General Public License as published by\n"
+					+ "the Free Software Foundation, either version 3 of the License, or\n"
+					+ "(at your option) any later version.\n"
+					+ "\n"
+					+ progname
+					+ " is distributed in the hope that it will be useful,\n"
+					+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+					+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n" + "GNU General Public License for more details.\n");
+		case LGPL3:
+			return ("\n"
+					+ progname
+					+ " is free software: you can redistribute it and/or modify\n"
+					+ "it under the terms of the GNU Lesser General Public License as published by\n"
+					+ "the Free Software Foundation, either version 3 of the License, or\n"
+					+ "(at your option) any later version.\n"
+					+ "\n"
+					+ progname
+					+ " is distributed in the hope that it will be useful,\n"
+					+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+					+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n" + "GNU Lesser General Public License for more details.\n");
+		}
+		throw new IllegalArgumentException();
 	}
 
 	public static boolean isSnapshow(Class<?> clazz) {



More information about the Schmitzm-commits mailing list