KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > Connector > EEG > EEM > Actions > Cat


1 package SOFA.Connector.EEG.EEM.Actions;
2
3 import SOFA.Connector.EEG.EEM.ActionException;
4 import SOFA.Connector.EEG.EEM.ActionInterface;
5
6 /** Cat action. Append line with types and classfiles to the specified file. It is used as the last action for each
7   * generated class file of connector.
8   *
9   * @author Petr Hnetynka
10   */

11 public class Cat implements ActionInterface {
12   public Cat(java.util.HashMap JavaDoc props) {
13   }
14
15   public String JavaDoc getName() {
16     return "cat";
17   }
18
19   public void perform(SOFA.Connector.Property[] params, String JavaDoc sourceDir, String JavaDoc sourcePackage, String JavaDoc destDir, String JavaDoc destPackage) throws ActionException {
20     String JavaDoc outFile = null, types = null, classFile = null;
21     if ((outFile = SOFA.Connector.Property.findFirst(params,"resolverFile")) == null) {
22       throw new ActionException("\"resolverFile\" param not specified");
23     }
24     if ((types = SOFA.Connector.Property.findFirst(params,"types")) == null) {
25       throw new ActionException("\"types\" param not specified");
26     }
27     if ((classFile = SOFA.Connector.Property.findFirst(params,"classFile")) == null) {
28       throw new ActionException("\"classFile\" param not specified");
29     }
30     try {
31       java.io.FileWriter JavaDoc fw = new java.io.FileWriter JavaDoc(outFile, true); // open for append
32
String JavaDoc rrr = java.io.File.separator;
33       if (java.io.File.separator.equals("\\")) {
34         rrr = java.io.File.separator + java.io.File.separator;
35       }
36       fw.write(destDir+java.io.File.separator+classFile+" "+destPackage.replaceAll("\\.",rrr)+java.io.File.separator+classFile+" "+types+"\n");
37       fw.close();
38     } catch (java.io.IOException JavaDoc e) {
39       throw new ActionException("Cannot write type info of \""+classFile+"\".", e);
40     }
41   }
42 }
43
Popular Tags