1 16 package org.apache.axis.tool.codegen; 17 18 import java.io.File ; 19 import java.io.FileInputStream ; 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 import java.util.HashMap ; 23 import java.util.Map ; 24 25 import javax.wsdl.WSDLException; 26 27 import org.apache.axis.tool.codegen.eclipse.util.UIConstants; 28 import org.apache.axis.wsdl.builder.WOMBuilderFactory; 29 import org.apache.axis.wsdl.codegen.CommandLineOption; 30 import org.apache.axis.wsdl.codegen.CommandLineOptionConstants; 31 import org.apache.wsdl.WSDLDescription; 32 33 34 public class WSDL2JavaGenerator { 35 36 42 private String mapLanguagesWithCombo(String UILangValue) 43 { 44 if (UIConstants.JAVA.equals(UILangValue)) 45 { 46 return CommandLineOptionConstants.LanguageNames.JAVA; 47 } 48 else if (UIConstants.C_SHARP.equals(UILangValue)) 49 { 50 return CommandLineOptionConstants.LanguageNames.C_SHARP; 51 } 52 else if (UIConstants.C_PLUS_PLUS.equals(UILangValue)) 53 { 54 return CommandLineOptionConstants.LanguageNames.C_PLUS_PLUS; 55 } 56 else 57 { 58 return null; 59 } 60 } 61 67 public Map fillOptionMap(boolean isAyncOnly, 68 boolean isSyncOnly, 69 boolean isServerSide, 70 boolean isServerXML, 71 boolean isTestCase, 72 String WSDLFileName, 73 String packageName, 74 String selectedLanguage, 75 String outputLocation 76 ) 77 { 78 Map optionMap = new HashMap (); 79 optionMap.put(CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION, new CommandLineOption( 81 CommandLineOptionConstants.WSDL_LOCATION_URI_OPTION, getStringArray(WSDLFileName))); 82 83 if (isAyncOnly) 85 { 86 optionMap.put(CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION, new CommandLineOption( 87 CommandLineOptionConstants.CODEGEN_ASYNC_ONLY_OPTION, new String [0])); 88 } 89 if (isSyncOnly) 91 { 92 optionMap.put(CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION, new CommandLineOption( 93 CommandLineOptionConstants.CODEGEN_SYNC_ONLY_OPTION, new String [0])); 94 } 95 if (isServerSide) 97 { 98 optionMap.put(CommandLineOptionConstants.SERVER_SIDE_CODE_OPTION, new CommandLineOption( 99 CommandLineOptionConstants.SERVER_SIDE_CODE_OPTION, new String [0])); 100 if (isServerXML) 102 { 103 optionMap.put(CommandLineOptionConstants.GENERATE_SERVICE_DESCRIPTION_OPTION, new CommandLineOption( 104 CommandLineOptionConstants.GENERATE_SERVICE_DESCRIPTION_OPTION, new String [0])); 105 } 106 } 107 if (isTestCase) 109 { 110 optionMap.put(CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION, new CommandLineOption( 111 CommandLineOptionConstants.GENERATE_TEST_CASE_OPTION, new String [0])); 112 } 113 optionMap.put(CommandLineOptionConstants.PACKAGE_OPTION, new CommandLineOption( 115 CommandLineOptionConstants.PACKAGE_OPTION, getStringArray(packageName))); 116 optionMap.put(CommandLineOptionConstants.STUB_LANGUAGE_OPTION, new CommandLineOption( 118 CommandLineOptionConstants.STUB_LANGUAGE_OPTION, getStringArray(mapLanguagesWithCombo(selectedLanguage)))); 119 optionMap.put(CommandLineOptionConstants.OUTPUT_LOCATION_OPTION, new CommandLineOption( 121 CommandLineOptionConstants.OUTPUT_LOCATION_OPTION, getStringArray(outputLocation))); 122 123 return optionMap; 125 } 126 134 public WSDLDescription getWOM(String wsdlLocation) throws WSDLException, IOException 135 { 136 InputStream in = new FileInputStream (new File (wsdlLocation)); 137 return WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in); 138 } 139 140 146 private String [] getStringArray(String value) 147 { 148 String [] values = new String [1]; 149 values[0] = value; 150 return values; 151 } 152 } 153 | Popular Tags |