Code cleanup and removal of unused classes.
This commit is contained in:
2012-04-27 11:33:28 +00:00
parent 7778c46fd1
commit d4c8b802bd
3 changed files with 76 additions and 206 deletions

View File

@@ -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 {

View File

@@ -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.
///////////////////////////////////////////////////////////////////////////////

View File

@@ -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.
@@ -24,8 +27,13 @@ public class ToolBox {
int enumLen = fields.length; //values().length;
int len = enumLen + additionals.length;
String[] ret = new String[len];
for (int i=0; i<enumLen; i++) ret[i]=fields[i].toString();
for (int i=enumLen; i<ret.length; i++) ret[i] = additionals[i-enumLen];
for (int i = 0; i < enumLen; i++) {
ret[i] = fields[i].toString();
}
for (int i = enumLen; i < ret.length; i++) {
ret[i] = additionals[i - enumLen];
}
return ret;
}
@@ -36,34 +44,34 @@ public class ToolBox {
* @param strArr2
* @return
*/
public static String[] appendArrays(String[] strArr1,
String[] strArr2) {
if (strArr1==null) return strArr2;
if (strArr2==null) return strArr1;
public static String[] appendArrays(String[] strArr1, String[] strArr2) {
if (strArr1 == null) {
return strArr2;
}
if (strArr2 == null) {
return strArr1;
}
String[] ret = new String[strArr1.length + strArr2.length];
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
System.arraycopy(strArr2, 0, ret, strArr1.length, strArr2.length);
return ret;
}
public static String[] appendArrays(String[] strArr1,
String str) {
public static String[] appendArrays(String[] strArr1, String str) {
String[] ret = new String[strArr1.length + 1];
System.arraycopy(strArr1, 0, ret, 0, strArr1.length);
ret[ret.length - 1] = str;
return ret;
}
public static Object[] appendArrays(Object[] objArr1,
Object o) {
public static Object[] appendArrays(Object[] objArr1, Object o) {
Object[] ret = new Object[objArr1.length + 1];
System.arraycopy(objArr1, 0, ret, 0, objArr1.length);
ret[ret.length - 1] = o;
return ret;
}
public static Object[] appendArrays(Object[] objArr1,
Object[] objArr2) {
public static Object[] appendArrays(Object[] objArr1, Object[] objArr2) {
Object[] ret = new Object[objArr1.length + objArr2.length];
System.arraycopy(objArr1, 0, ret, 0, objArr1.length);
System.arraycopy(objArr2, 0, ret, objArr1.length, objArr2.length);
@@ -96,11 +104,16 @@ public class ToolBox {
* @return
*/
public static Double toDouble(Object o) {
if (o instanceof Number) return ((Number)o).doubleValue();
else try {
if (o instanceof Number) {
return ((Number) o).doubleValue();
} else {
try {
Double d = Double.parseDouble(BeanInspector.toString(o));
return d;
} catch(Exception e) { }
} catch (Exception e) {
// Here be dragons!
}
}
return null;
}
@@ -152,12 +165,18 @@ public class ToolBox {
* @return a 2D double array containing the indexed columns from data
*/
public static double[][] getCols(double[][] data, int... cols) {
if (data==null || (data[0]==null)) return null;
if (data == null || (data[0] == null)) {
return null;
}
int nCols = cols.length;
if (nCols>data[0].length) System.err.println("Error, mismatching column count in Mathematics.getCols!");
if (nCols > 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]];
for (int j = 0; j < cols.length; j++) {
ret[i][j] = data[i][cols[j]];
}
}
return ret;
}