1 28 29 package org.objectweb.openccm.corba.idl2java; 30 31 import java.io.IOException ; 33 import java.util.Iterator ; 34 import java.util.Map ; 35 import java.util.Set ; 36 37 44 public class IdlToJava 45 extends IdlToJavaApplication 46 { 47 53 54 private String arg_delimiter_; 55 56 62 63 public IdlToJava() 64 { 65 if ( System.getProperty("file.separator").compareTo("\\") == 0 ) 66 arg_delimiter_ = "\""; 67 else 68 arg_delimiter_ = ""; 69 } 70 71 77 82 private String 83 getCommand() 84 { 85 return System.getProperty("ORB_HOMEDIR") + "/bin/idl2java "; 86 } 87 88 93 private String 94 getArguments() 95 { 96 String args = null, 97 key = null, 98 value = null; 99 String [] includes = null; 100 Map mappings = null; 101 Set mapping_keys = null; 102 103 args = "-strict "; 105 106 args += "-root_dir " + arg_delimiter_ + getDestinationDirectory() + arg_delimiter_ + " "; 108 109 includes = getIncludeDirectories(); 111 for (int i=0; i<includes.length; i++) 112 { 113 args += arg_delimiter_ + "-I" + includes[i] + arg_delimiter_ + " "; 114 } 115 116 mappings = getPackageMappings(); 118 mapping_keys = getPackageMappings().keySet(); 119 for (Iterator it=mapping_keys.iterator(); it.hasNext(); ) 120 { 121 key = (String ) it.next(); 122 value = (String ) mappings.get(key); 123 args += "-idl2package ::" + key + " " + value + " "; 124 } 125 126 args += arg_delimiter_ + getInputFile() + arg_delimiter_; 128 129 return args; 130 } 131 132 138 145 public int 146 start(String [] args) 147 { 148 Process process = null; 149 Redirector redirector = null; 150 151 parse_cmdline(args); 152 153 try 154 { 155 process = Runtime.getRuntime().exec( getCommand() + getArguments() ); 156 157 redirector = new Redirector(process); 158 redirector.redirectOutput(); 159 } catch (IOException e) { 160 e.printStackTrace(); 161 } 162 163 try 164 { 165 process.waitFor(); 166 } catch (InterruptedException e) { 167 e.printStackTrace(); 168 } 169 170 return process.exitValue(); 171 } 172 173 179 public static void 180 main(String [] args) 181 { 182 IdlToJava app = new IdlToJava(); 183 app.runMain(args); 184 } 185 } 186 | Popular Tags |