01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.axis2.wsdl.codegen.writer;
21:
22: import org.apache.axis2.util.XSLTTemplateProcessor;
23: import org.w3c.dom.Document;
24:
25: import javax.xml.transform.URIResolver;
26: import java.io.File;
27: import java.io.FileOutputStream;
28:
29: public class CSvcSkeletonWriter extends FileWriter {
30:
31: public CSvcSkeletonWriter(String outputFileLocation) {
32: this .outputFileLocation = new File(outputFileLocation);
33: }
34:
35: public CSvcSkeletonWriter(File outputFileLocation, String language) {
36: this .outputFileLocation = outputFileLocation;
37: this .language = language;
38: }
39:
40: public void createOutFile(String packageName, String fileName)
41: throws Exception {
42: outputFile = org.apache.axis2.util.FileWriter.createClassFile(
43: outputFileLocation, "", fileName,
44: getFileExtensionForLanguage(language));
45: //set the existing flag
46: fileExists = outputFile.exists();
47: if (!fileExists) {
48: this .stream = new FileOutputStream(outputFile);
49: }
50: }
51:
52: /**
53: * Writes the output file.
54: *
55: * @param doc
56: * @throws Exception
57: */
58: public void parse(Document doc, URIResolver resolver)
59: throws Exception {
60: if (!fileExists) {
61: XSLTTemplateProcessor.parse(this .stream, doc,
62: this .xsltStream, resolver);
63: this .stream.write('\n');
64: this .stream.write('\n');
65: this.stream.flush();
66: this.stream.close();
67: }
68: }
69:
70: }
|