buildframework/helium/sf/java/antlint/src/com/nokia/helium/antlint/ant/types/CheckScriptDef.java
changeset 628 7c4a911dc066
parent 588 c7c26511138f
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
    16  */
    16  */
    17 package com.nokia.helium.antlint.ant.types;
    17 package com.nokia.helium.antlint.ant.types;
    18 
    18 
    19 import java.io.File;
    19 import java.io.File;
    20 import java.io.FileOutputStream;
    20 import java.io.FileOutputStream;
       
    21 import java.io.IOException;
    21 import java.io.PrintWriter;
    22 import java.io.PrintWriter;
    22 import java.util.ArrayList;
    23 import java.util.ArrayList;
    23 import java.util.List;
    24 import java.util.List;
    24 import java.util.regex.Matcher;
    25 import java.util.regex.Matcher;
    25 import java.util.regex.Pattern;
    26 import java.util.regex.Pattern;
    26 import java.io.IOException;
       
    27 
    27 
    28 import org.apache.tools.ant.BuildException;
    28 import org.apache.tools.ant.BuildException;
    29 import org.dom4j.Document;
    29 import org.dom4j.Document;
    30 import org.dom4j.DocumentException;
    30 import org.dom4j.DocumentException;
    31 import org.dom4j.Element;
    31 import org.dom4j.Element;
   125             File file = new File(heliumpath + File.separator + "beanshell"
   125             File file = new File(heliumpath + File.separator + "beanshell"
   126                     + File.separator + scriptdefname + ".java");
   126                     + File.separator + scriptdefname + ".java");
   127             PrintWriter output = new PrintWriter(new FileOutputStream(file));
   127             PrintWriter output = new PrintWriter(new FileOutputStream(file));
   128 
   128 
   129             for (String line : text.split("\n")) {
   129             for (String line : text.split("\n")) {
   130                 if (line.trim().startsWith("import"))
   130                 if (line.trim().startsWith("import")) {
   131                     output.write(line + "\n");
   131                     output.write(line + "\n");
       
   132                 }
   132             }
   133             }
   133 
   134 
   134             output.write("/**\n * x\n */\npublic final class " + scriptdefname
   135             output.write("/**\n * x\n */\npublic final class " + scriptdefname
   135                     + " {\n");
   136                     + " {\n");
   136             output.write("private " + scriptdefname + "() { }\n");
   137             output.write("    private " + scriptdefname + "() { }\n");
   137             output.write("public static void main(String[] args) {\n");
   138             output.write("    public static void main(String[] args) {\n");
   138             for (String line : text.split("\n")) {
   139             for (String line : text.split("\n")) {
   139                 if (!line.trim().startsWith("import"))
   140                 if (!line.trim().startsWith("import")) {
   140                     output.write(line + "\n");
   141                     output.write("        " + line + "\n");
   141             }
   142                 }
   142             output.write("} }");
   143             }
       
   144             output.write("    }\n");
       
   145             output.write("}\n");
   143             output.close();
   146             output.close();
   144         } catch (IOException e) {
   147         } catch (IOException e) {
   145             throw new BuildException("Not able to write Beanshell File "
   148             throw new BuildException("Not able to write Beanshell File "
   146                     + scriptdefname + ".java");
   149                     + scriptdefname + ".java");
   147         }
   150         }