/* * Created on Apr 6, 2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package fr.lifl.stc.stan.tools.tester; import java.io.FileNotFoundException; import java.io.BufferedReader; //import java.io.FileReader; import java.io.InputStreamReader; import java.io.FileInputStream; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.StringTokenizer; //import fr.lifl.rd2p.jits.tools.ea.analyser.GlobalAnalyser; import fr.lifl.stc.stan.link.Link; import fr.lifl.stc.stan.link.defaultLink.DefaultLink; /** * @author dorina * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class ClassSign { private HashMap methods; String name; /** * */ public ClassSign(String name) throws IOException, FileNotFoundException { this.name = name; //String fileName = "/tmp/T6.txt"; String fileName = "/tmp/signatures/"+name+".txt"; System.out.println("file name = "+fileName); methods = new HashMap(); //"ISO-8859-1" BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(fileName))); String methodName; String methodSignature; String line; while((methodName = bf.readLine())!=null){ methodSignature = bf.readLine(); line = bf.readLine(); int dim = Integer.parseInt(line); //System.out.println("dim = "+dim); Link[][]deps = new Link[dim][dim]; for(int i = 0 ; i < deps.length; i++) { line = bf.readLine(); StringTokenizer tokenizer = new StringTokenizer (line, " "); int j = 0; while (tokenizer.hasMoreTokens() && j < deps[i].length) { String token = tokenizer.nextToken(); try { deps[i][j] = new DefaultLink((byte)Integer.parseInt (token)); //GlobalAnalyser.linkFactory.createLink((byte)Integer.parseInt (token)); // j++; } catch (Exception exception) { System.out.println(exception); } } } MethodSign ms = new MethodSign(methodName, methodSignature, deps); this.addMethod(methodName, ms); //ms.print(); } bf.close(); } public boolean addMethod(String key, MethodSign m){ if(methods.containsKey(key)) return false; methods.put(key, m); return true; } public String getClassName(){ return this.name; } public String toString(){ String s = "ClassName: "+this.name +"\n"; Iterator it = methods.keySet().iterator(); while(it.hasNext()){ s = s + methods.get(it.next());// + "\n"; } return s; } public MethodSign[] getMethodSign() { MethodSign[] m = new MethodSign[methods.size()]; Iterator it = methods.keySet().iterator(); int i = 0; while(it.hasNext()){ m[i++] = methods.get(it.next()); } return m; } }