From 2cef2c13e720e889304333e70f893a23d1a98f42 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 5 Oct 2016 16:31:57 +0100 Subject: [PATCH] JAL-2189 formatting and GPL --- utils/HelpLinksChecker.java | 64 +++++++++++--------- utils/JettyExamplesDir.java | 10 ++- utils/MessageBundleChecker.java | 20 ++++++ utils/getJavaVersion.java | 50 +++++++-------- utils/help2Website.java | 128 +++++++++++++++++++-------------------- 5 files changed, 147 insertions(+), 125 deletions(-) diff --git a/utils/HelpLinksChecker.java b/utils/HelpLinksChecker.java index 8085446..7c57cc7 100644 --- a/utils/HelpLinksChecker.java +++ b/utils/HelpLinksChecker.java @@ -1,5 +1,23 @@ - - +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -159,9 +177,8 @@ public class HelpLinksChecker unusedTargets.remove(image); if (!tocTargets.containsKey(image)) { - log(String.format( - "Invalid image '%s' at line %d of %s", image, lineNo, - HELP_HS)); + log(String.format("Invalid image '%s' at line %d of %s", image, + lineNo, HELP_HS)); invalidImageCount++; } } @@ -184,23 +201,18 @@ public class HelpLinksChecker log(unusedTargets.size() + " unused targets"); for (String target : unusedTargets.keySet()) { - log(String.format(" %s: %s", target, - unusedTargets.get(target))); + log(String.format(" %s: %s", target, unusedTargets.get(target))); } log(invalidMapUrlCount + " invalid map urls"); log(invalidImageCount + " invalid image attributes"); - log(String.format( - "%d internal href links (%d with anchors)", internalHrefCount, - anchorRefCount)); - log(invalidInternalHrefCount - + " invalid internal href links"); - log(invalidAnchorRefCount - + " invalid internal anchor links"); + log(String.format("%d internal href links (%d with anchors)", + internalHrefCount, anchorRefCount)); + log(invalidInternalHrefCount + " invalid internal href links"); + log(invalidAnchorRefCount + " invalid internal anchor links"); log(externalHrefCount + " external href links"); if (internetAvailable) { - log(invalidExternalHrefCount - + " invalid external href links"); + log(invalidExternalHrefCount + " invalid external href links"); } else { @@ -284,9 +296,8 @@ public class HelpLinksChecker { if (!checkAnchorExists(hrefFile, anchor)) { - log(String.format( - "Invalid anchor: %s at line %d of %s", anchor, - lineNo, getPath(htmlFile))); + log(String.format("Invalid anchor: %s at line %d of %s", + anchor, lineNo, getPath(htmlFile))); invalidAnchorRefCount++; } } @@ -294,9 +305,8 @@ public class HelpLinksChecker } if (badLink) { - log(String.format( - "Invalid href %s at line %d of %s", href, lineNo, - getPath(htmlFile))); + log(String.format("Invalid href %s at line %d of %s", href, + lineNo, getPath(htmlFile))); } } data = br.readLine(); @@ -455,9 +465,8 @@ public class HelpLinksChecker } if (!new File(helpFolder, url).exists()) { - log(String.format( - "Invalid url path '%s' at line %d of %s", url, lineNo, - HELP_JHM)); + log(String.format("Invalid url path '%s' at line %d of %s", url, + lineNo, HELP_JHM)); invalidMapUrlCount++; } } @@ -498,9 +507,8 @@ public class HelpLinksChecker unusedTargets.remove(target); if (!tocTargets.containsKey(target)) { - log(String.format( - "Invalid target '%s' at line %d of %s", target, lineNo, - HELP_TOC_XML)); + log(String.format("Invalid target '%s' at line %d of %s", target, + lineNo, HELP_TOC_XML)); invalidTargetCount++; } } diff --git a/utils/JettyExamplesDir.java b/utils/JettyExamplesDir.java index 76375d6..5518e13 100644 --- a/utils/JettyExamplesDir.java +++ b/utils/JettyExamplesDir.java @@ -36,7 +36,6 @@ //======================================================================== // - import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; @@ -70,16 +69,15 @@ public class JettyExamplesDir // In this example it is the current directory but it can be configured to // anything that the jvm has access to. resource_handler.setDirectoriesListed(true); - resource_handler.setWelcomeFiles(new String[] - { "applets.html" }); + resource_handler.setWelcomeFiles(new String[] { "applets.html" }); resource_handler.setResourceBase("."); // Add the ResourceHandler to the server. // GzipHandler gzip = new GzipHandler(); // server.setHandler(gzip); HandlerList handlers = new HandlerList(); - handlers.setHandlers(new Handler[] - { resource_handler, new DefaultHandler() }); + handlers.setHandlers(new Handler[] { resource_handler, + new DefaultHandler() }); server.setHandler(handlers); // Start things up! By using the server.join() the server thread will join @@ -89,5 +87,5 @@ public class JettyExamplesDir // for more details. server.start(); server.join(); -} + } } diff --git a/utils/MessageBundleChecker.java b/utils/MessageBundleChecker.java index 9d322df..15e16cf 100644 --- a/utils/MessageBundleChecker.java +++ b/utils/MessageBundleChecker.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; diff --git a/utils/getJavaVersion.java b/utils/getJavaVersion.java index 98747f7..8496f8b 100644 --- a/utils/getJavaVersion.java +++ b/utils/getJavaVersion.java @@ -28,28 +28,32 @@ import java.util.jar.JarInputStream; public class getJavaVersion { -/** - * Takes a set of Jars and/or class files as arguments. Reports the java version for the classes - */ + /** + * Takes a set of Jars and/or class files as arguments. Reports the java + * version for the classes + */ public static void main(String[] args) throws IOException { - Hashtable observed=new Hashtable(); + Hashtable observed = new Hashtable(); for (int i = 0; i < args.length; i++) - { - checkClassVersion(args[i], observed); - } + { + checkClassVersion(args[i], observed); + } printVersions(observed, System.out); } - public static void printVersions(Hashtable observed, java.io.PrintStream outs) + + public static void printVersions(Hashtable observed, + java.io.PrintStream outs) { - if (observed.size()>0) + if (observed.size() > 0) { - int space=0; - String key=null; - for (Enumeration keys = observed.keys(); keys.hasMoreElements(); ) { + int space = 0; + String key = null; + for (Enumeration keys = observed.keys(); keys.hasMoreElements();) + { key = (String) keys.nextElement(); - if (space++>0) + if (space++ > 0) { outs.print(" "); } @@ -65,13 +69,13 @@ public class getJavaVersion String version = checkClassVersion(filename); if (version == null) { -// System.err.println("Reading "+filename+" as jar:"); + // System.err.println("Reading "+filename+" as jar:"); try { JarInputStream jis = new JarInputStream(new FileInputStream( filename)); JarEntry entry; - Hashtable perjar=new Hashtable(); + Hashtable perjar = new Hashtable(); while ((entry = jis.getNextJarEntry()) != null) { if (entry != null) @@ -93,8 +97,8 @@ public class getJavaVersion } } } - System.err.println("Jar : "+filename); - printVersions(perjar,System.err); + System.err.println("Jar : " + filename); + printVersions(perjar, System.err); } catch (Exception e) { @@ -110,12 +114,11 @@ public class getJavaVersion { if (version != null) { -// System.err.println("Version is '"+version+"'"); + // System.err.println("Version is '"+version+"'"); int[] vrs = (int[]) observed.get(version); if (vrs == null) { - vrs = new int[] - { 0 }; + vrs = new int[] { 0 }; } vrs[0]++; observed.put(version, vrs); @@ -147,14 +150,13 @@ public class getJavaVersion versions.put("52.0", "1.8"); } - String version = (String) versions.get(major + "." - + minor); + String version = (String) versions.get(major + "." + minor); if (version == null) { // get nearest known version version = (String) versions.get(major + ".0"); } -// System.err.println("Version "+version); + // System.err.println("Version "+version); if (version == null) { versions.put(major + "." + minor, "Class v" + major + ".0"); @@ -171,7 +173,7 @@ public class getJavaVersion } int minor = in.readUnsignedShort(); int major = in.readUnsignedShort(); -// System.err.println("Version "+major+"."+minor); + // System.err.println("Version "+major+"."+minor); return parseVersions(minor, major); } diff --git a/utils/help2Website.java b/utils/help2Website.java index e9e9ce7..83e4b5f 100755 --- a/utils/help2Website.java +++ b/utils/help2Website.java @@ -24,93 +24,87 @@ import java.util.*; public class help2Website { - public static void main(String [] args) - { - String line = ""; - try{ - Hashtable targets = new Hashtable(); + public static void main(String[] args) + { + String line = ""; + try + { + Hashtable targets = new Hashtable(); - File toc = new File("helpTOC.xml"); - File jhm = new File("help.jhm"); + File toc = new File("helpTOC.xml"); + File jhm = new File("help.jhm"); - BufferedReader in = new BufferedReader(new FileReader(jhm)); + BufferedReader in = new BufferedReader(new FileReader(jhm)); - PrintWriter out = new PrintWriter(new FileWriter("helpTOC.html")); - out.println("Jalview - Help \n" - +"\n" - +"

Contents

\n"); + PrintWriter out = new PrintWriter(new FileWriter("helpTOC.html")); + out.println("Jalview - Help \n" + + "\n" + + "

Contents

\n"); + StringTokenizer st; + StringBuffer indent = new StringBuffer(); + String target, url, text; + while ((line = in.readLine()) != null) + { + if (line.indexOf("target") == -1) + continue; - StringTokenizer st; - StringBuffer indent = new StringBuffer(); - String target, url, text; - while( (line = in.readLine()) != null) - { - if(line.indexOf("target")==-1) - continue; + st = new StringTokenizer(line, "\""); + st.nextToken(); // ") != -1) + indent.setLength(indent.length() - 18); - url = st.nextToken(); - targets.put(target, url); - } + if (line.indexOf("")!=-1) - indent.setLength(indent.length()-18); + st = new StringTokenizer(line, "\""); + st.nextToken(); - if(line.indexOf("" + indent + "" + text + ""); + } + else + out.println("
" + indent + text); - target = st.nextToken(); + if (line.indexOf("/>") == -1) + indent.append("   "); - if(targets.get(target)!=null) - { - out.println("
"+indent+"" - +text - +""); - } - else - out.println("
"+indent+text); + } + // Add Googletracker. + out.close(); - if(line.indexOf("/>")==-1) - indent.append("   "); + } - } - // Add Googletracker. + catch (Exception ex) + { + ex.printStackTrace(); - out.close(); - - } - - catch(Exception ex) - { - - ex.printStackTrace(); - - System.out.println("\n"+line+"\n"); - - System.out.println("Usage: move to Help directory. help2Website will read" - +"\nhelpTOC.xml and help.jhm producing output helpTOC.html"); - } - } + System.out.println("\n" + line + "\n"); + System.out + .println("Usage: move to Help directory. help2Website will read" + + "\nhelpTOC.xml and help.jhm producing output helpTOC.html"); + } + } } -- 1.7.10.2