KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > wsdl > codegen > CodeGenConfiguration


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis2.wsdl.codegen;
18
19 import org.apache.axis2.wsdl.databinding.TypeMapper;
20 import org.apache.wsdl.WSDLDescription;
21
22 import java.io.File JavaDoc;
23 import java.util.Map JavaDoc;
24
25 /**
26  * @author chathura@opensource.lk
27  *
28  */

29 public class CodeGenConfiguration implements CommandLineOptionConstants {
30
31     private WSDLDescription wom;
32     private CommandLineOptionParser parser;
33     private File JavaDoc outputLocation;
34     private int outputLanguage = XSLTConstants.LanguageTypes.JAVA;
35     private int databindingType = XSLTConstants.DataBindingTypes.XML_BEANS; //default is XML beans
36
private boolean advancedCodeGenEnabled=false;
37
38
39     private boolean asyncOn=true;
40     private boolean syncOn=true;
41     private boolean serverSide=false;
42     private boolean generateDeployementDescriptor=true;
43     private boolean writeTestCase=false;
44     private boolean writeMessageReceiver = true;
45     private String JavaDoc packageName=XSLTConstants.DEFAULT_PACKAGE_NAME;
46
47
48     private TypeMapper typeMapper;
49
50     public TypeMapper getTypeMapper() {
51         return typeMapper;
52     }
53
54     public void setTypeMapper(TypeMapper typeMapper) {
55         this.typeMapper = typeMapper;
56     }
57
58     public int getDatabindingType() {
59         return databindingType;
60     }
61
62     public void setDatabindingType(int databindingType) {
63         this.databindingType = databindingType;
64     }
65
66     /**
67      * @param wom
68      * @param parser
69      */

70     public CodeGenConfiguration(WSDLDescription wom,
71             CommandLineOptionParser parser) {
72         this(wom,parser.getAllOptions());
73         this.parser = parser;
74     }
75
76     public CodeGenConfiguration(WSDLDescription wom,Map JavaDoc optionMap) {
77        this.wom = wom;
78
79        String JavaDoc outputLocation = ((CommandLineOption)optionMap.get(OUTPUT_LOCATION_OPTION)).getOptionValue();
80         this.outputLocation = new File JavaDoc(outputLocation);
81
82         serverSide = (optionMap.get(SERVER_SIDE_CODE_OPTION)!=null);
83         generateDeployementDescriptor = (optionMap.get(GENERATE_SERVICE_DESCRIPTION_OPTION)!=null);
84         writeTestCase = (optionMap.get(GENERATE_TEST_CASE_OPTION)!=null);
85
86         boolean asyncFlagPresent = (optionMap.get(CODEGEN_ASYNC_ONLY_OPTION)!=null);
87         boolean syncFlagPresent = (optionMap.get(CODEGEN_SYNC_ONLY_OPTION)!=null);
88         if (asyncFlagPresent) {this.asyncOn=true;this.syncOn=false;}
89         if (syncFlagPresent) {this.asyncOn=false;this.syncOn=true;}
90
91         CommandLineOption packageOption = (CommandLineOption)optionMap.get(PACKAGE_OPTION);
92         if(packageOption!=null) {this.packageName = packageOption.getOptionValue();}
93
94         CommandLineOption langOption = (CommandLineOption)optionMap.get(STUB_LANGUAGE_OPTION);
95         if (langOption!=null){
96             loadLanguge(langOption.getOptionValue());
97         }
98
99
100
101      }
102
103
104
105
106     private void loadLanguge(String JavaDoc langName) {
107         if (LanguageNames.JAVA.equalsIgnoreCase(langName)){
108             this.outputLanguage = XSLTConstants.LanguageTypes.JAVA;
109         }else if (LanguageNames.C_SHARP.equalsIgnoreCase(langName)){
110             this.outputLanguage = XSLTConstants.LanguageTypes.C_SHARP;
111         }else if (LanguageNames.C_PLUS_PLUS.equalsIgnoreCase(langName)){
112             this.outputLanguage = XSLTConstants.LanguageTypes.C_PLUS_PLUS;
113         }else if (LanguageNames.VB_DOT_NET.equalsIgnoreCase(langName)){
114             this.outputLanguage = XSLTConstants.LanguageTypes.VB_DOT_NET;
115         }
116     }
117
118     /**
119      * @return Returns the parser.
120      */

121     public CommandLineOptionParser getParser() {
122         return parser;
123     }
124
125     /**
126      * @return Returns the wom.
127      */

128     public WSDLDescription getWom() {
129         return wom;
130     }
131     
132     
133     /**
134      * @return Returns the outputLocation.
135      */

136     public File JavaDoc getOutputLocation() {
137         return outputLocation;
138     }
139
140     public int getOutputLanguage() {
141         return outputLanguage;
142     }
143
144     public boolean isAdvancedCodeGenEnabled() {
145         return advancedCodeGenEnabled;
146     }
147
148     
149     
150     /**
151      * @return Returns the packageName.
152      */

153     public String JavaDoc getPackageName() {
154         return packageName;
155     }
156     /**
157      * @param packageName The packageName to set.
158      */

159     public void setPackageName(String JavaDoc packageName) {
160         this.packageName = packageName;
161     }
162
163
164     public boolean isAsyncOn() {
165         return asyncOn;
166     }
167
168
169     public boolean isSyncOn() {
170         return syncOn;
171     }
172
173     public boolean isServerSide() {
174         return serverSide;
175     }
176
177     public boolean isGenerateDeployementDescriptor() {
178         return generateDeployementDescriptor;
179     }
180
181     public boolean isWriteTestCase() {
182         return writeTestCase;
183     }
184     
185     
186     public boolean isWriteMessageReceiver() {
187         return writeMessageReceiver;
188     }
189     public void setWriteMessageReceiver(boolean writeMessageReceiver) {
190         this.writeMessageReceiver = writeMessageReceiver;
191     }
192 }
Popular Tags