From d4c8b802bd0bf15d1bd267420ee187be01593398 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Fri, 27 Apr 2012 11:33:28 +0000 Subject: [PATCH] refs #8 Code cleanup and removal of unused classes. --- src/eva2/server/go/GOStandaloneVersion.java | 2 - src/eva2/tools/TokenHolder.java | 147 -------------------- src/eva2/tools/ToolBox.java | 133 ++++++++++-------- 3 files changed, 76 insertions(+), 206 deletions(-) delete mode 100644 src/eva2/tools/TokenHolder.java diff --git a/src/eva2/server/go/GOStandaloneVersion.java b/src/eva2/server/go/GOStandaloneVersion.java index 5a9ee999..4a0a6792 100644 --- a/src/eva2/server/go/GOStandaloneVersion.java +++ b/src/eva2/server/go/GOStandaloneVersion.java @@ -18,7 +18,6 @@ import eva2.server.go.strategies.EvolutionStrategies; import eva2.server.go.strategies.GeneticAlgorithm; import eva2.server.go.strategies.InterfaceOptimizer; import eva2.server.modules.GOParameters; -import eva2.tools.TokenHolder; import eva2.tools.jproxy.ThreadProxy; import eva2.tools.math.RNG; import java.awt.BorderLayout; @@ -524,7 +523,6 @@ public class GOStandaloneVersion implements InterfaceGOStandalone, InterfacePopu public static void main(String[] args) { if (false) { InterfaceGOStandalone app = (InterfaceGOStandalone)ThreadProxy.newInstance(new GOStandaloneVersion()); - new TokenHolder("streiche", ""); app.startExperiment(); app.setShow(false); } else { diff --git a/src/eva2/tools/TokenHolder.java b/src/eva2/tools/TokenHolder.java deleted file mode 100644 index 9f5b76c5..00000000 --- a/src/eva2/tools/TokenHolder.java +++ /dev/null @@ -1,147 +0,0 @@ -package eva2.tools; - -/** - * Title: EvA2 - * Description: - * Copyright: Copyright (c) 2003 - * Company: University of Tuebingen, Computer Architecture - * @author Holger Ulmer, Felix Streichert, Hannes Planatscher - * @version: $Revision: 10 $ - * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ - * $Author: streiche $ - */ - -/*==========================================================================* - * IMPORTS - *==========================================================================*/ -import java.io.BufferedReader; -import java.io.InputStreamReader; - - -/** - * - */ -public class TokenHolder extends Thread -{ - //~ Instance fields //////////////////////////////////////////////////////// - - private String m_account; - private String m_passwd = ""; - private boolean m_wait = true; - - //~ Constructors /////////////////////////////////////////////////////////// - - /** - * - */ - public TokenHolder(String acc, String passw) - { - m_account = acc; - - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - - //System.out.println("passwd:"); - m_passwd = passw; - - // try { - // m_passwd = in.readLine(); - // } catch (Exception e) { - // System.out.println(""+e.getMessage()); - // } - start(); - } - - //~ Methods //////////////////////////////////////////////////////////////// - - /** - * - */ - public String getExecOutput(String command) - { - String Out = new String(); - - try - { - BufferedReader in = null; - Process pro = null; - //System.out.println("Calling the command:" + command); - pro = Runtime.getRuntime().exec(command); - in = new BufferedReader(new InputStreamReader(pro.getInputStream())); - - String line = null; - - while ((line = in.readLine()) != null) - { - System.out.println(line); - Out = Out + line; - } - } - catch (Exception e) - { - //System.out.println("Error in calling the command:" + e.getMessage()); - } - - return Out; - } - - /** - * - */ - public static void main(String[] x) - { - TokenHolder holder = new TokenHolder("ulmerh", "bal"); - } - - /** - * - */ - public void run() - { - String s = getExecOutput("tokens"); - //System.out.println("-->tokens " + s); - s = getExecOutput("klog -principal " + m_account + " -password " + - m_passwd); - - //System.out.println("-->klog "+s); - s = getExecOutput("tokens"); - - //System.out.println("-->tokens "+s); - m_wait = true; - - while (m_wait == true) - { - //System.out.println(System.currentTimeMillis()); - - try - { - double min = 360; - sleep(((long) (1000 * 60 * min))); - } - catch (Exception e) - { - //System.out.println("" + e.getMessage()); - e.printStackTrace(); - } - - s = getExecOutput("klog -principal " + m_account + " -password " + - m_passwd); - - //System.out.println("-->klog "+s); - s = getExecOutput("tokens"); - //System.out.println("-->tokens " + s); - } - - //System.out.println("Tokenholder finished !!"); - } - - /** - * - */ - public void stoprun() - { - m_wait = false; - } -} -/////////////////////////////////////////////////////////////////////////////// -// END OF FILE. -/////////////////////////////////////////////////////////////////////////////// diff --git a/src/eva2/tools/ToolBox.java b/src/eva2/tools/ToolBox.java index e068e7d4..bda1b9fe 100644 --- a/src/eva2/tools/ToolBox.java +++ b/src/eva2/tools/ToolBox.java @@ -1,17 +1,20 @@ package eva2.tools; +import eva2.gui.BeanInspector; import java.util.ArrayList; import java.util.List; -import eva2.gui.BeanInspector; - /** * Collection of miscellaneous static helper methods. * * @author mkron * */ -public class ToolBox { +public final class ToolBox { + /** + * Private constructor to prevent instances of module class. + */ + private ToolBox() { } /** * Convert all items of an enum to a String array and append the given String array at the end. @@ -22,10 +25,15 @@ public class ToolBox { public static String[] appendEnumAndArray(Enum e, String[] additionals) { Enum[] fields = e.getClass().getEnumConstants(); int enumLen = fields.length; //values().length; - int len = enumLen+additionals.length; + int len = enumLen + additionals.length; String[] ret = new String[len]; - for (int i=0; idata[0].length) System.err.println("Error, mismatching column count in Mathematics.getCols!"); - double[][] ret = new double[data.length][cols.length]; - for (int i=0; i data[0].length) { + System.err.println("Error, mismatching column count in Mathematics.getCols!"); + } + double[][] ret = new double[data.length][cols.length]; + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < cols.length; j++) { + ret[i][j] = data[i][cols[j]]; + } + } + return ret; + } }