KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > wsdl > codegen > writer > ClassWriter


1 package org.apache.axis2.wsdl.codegen.writer;
2
3 import org.apache.axis2.wsdl.codegen.XSLTConstants;
4 import org.apache.axis2.wsdl.util.FileWriter;
5 import org.apache.axis2.wsdl.util.XSLTTemplateProcessor;
6
7 import java.io.File JavaDoc;
8 import java.io.FileOutputStream JavaDoc;
9 import java.io.InputStream JavaDoc;
10
11 /*
12 * Copyright 2004,2005 The Apache Software Foundation.
13 *
14 * Licensed under the Apache License, Version 2.0 (the "License");
15 * you may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
17 *
18 * http://www.apache.org/licenses/LICENSE-2.0
19 *
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
25 *
26 *
27 * Abstract writer to be extended by writers. To use a class writer one needs to call the
28 * methods in order
29 * ususally it is setLanguage() ->loadTemplate() ->createOutFile() ->WriteOutFile()
30 */

31 public abstract class ClassWriter {
32
33     protected File JavaDoc outputFileLocation = null;
34     protected FileOutputStream JavaDoc stream = null;
35     protected InputStream JavaDoc xsltStream = null;
36     protected int language = XSLTConstants.LanguageTypes.JAVA; //default is again java
37

38     /**
39      * Sets the language
40      * @param language
41      */

42     public void setLanguage(int language) {
43         this.language = language;
44     }
45
46     /**
47      * Load the template
48      */

49     public abstract void loadTemplate();
50
51     /**
52      * Creates the output file
53      * @param packageName
54      * @param fileName
55      * @throws Exception
56      */

57     public void createOutFile(String JavaDoc packageName,String JavaDoc fileName) throws Exception JavaDoc{
58         File JavaDoc outputFile = FileWriter.createClassFile(outputFileLocation,packageName,fileName,language);
59         this.stream = new FileOutputStream JavaDoc(outputFile);
60     }
61
62     /**
63      * Writes the output file
64      * @param documentStream
65      * @throws Exception
66      */

67     public void writeOutFile(InputStream JavaDoc documentStream) throws Exception JavaDoc{
68         XSLTTemplateProcessor.parse(this.stream,documentStream,this.xsltStream);
69         this.stream.flush();
70         this.stream.close();
71
72
73     }
74
75
76 }
77
Popular Tags