/* * Helper.java * * Created on 23. November 2005, 14:27 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.semports.handshakes; import java.io.*; import java.util.HashSet; import java.util.Iterator; /** * This class provides some helper functions for convinient output. * * @author Lutz Maicher */ public class Helper { // Writes into the file [result]+[expname]+".dat" private PrintWriter myPrintWriterDat; Simulation myMain; /** Creates a new instance of Helper */ public Helper(PrintWriter myPrintWriterDat) { this.myPrintWriterDat = myPrintWriterDat; } /* This functions outputs all values parallel to the console and to the File */ public void out(String output) { this.out(output, false); } /* This functions outputs all values parallel to the console * and to the File. If gnuplot is true, this value should be visible * to gnuplot (no comment). */ public void out(String output , boolean gnuplot) { System.out.println(output); try { if (!gnuplot) output = "# " + output; out(output, this.myPrintWriterDat); } catch (Exception E) {} } public void out(String output , PrintWriter myPrintWriter) { myPrintWriter.println(output); } /** This function outputs the state of the Proxys */ public void output(HashSet Proxys) { Iterator it_Proxys = Proxys.iterator(); while (it_Proxys.hasNext()) { this.out(((Proxy)it_Proxys.next()).getRepositoryContent()); } } /** This function returns the current value * of a distribution in a String. * * @return The serialisation of a given distribution.**/ public String outputDistribution(double dis[] ) { String result = ""; for (int i=0; i