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: package org.apache.axis2.wsdl.codegen.extension;
20:
21: import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
22: import org.apache.axis2.wsdl.codegen.CodeGenerationException;
23:
24: import java.io.File;
25: import java.util.List;
26: import java.util.Iterator;
27:
28: public abstract class AbstractPrettyPrinterExtension extends
29: AbstractCodeGenerationExtension {
30: /** If the extension for property file changes it might effect this as well !!! */
31: protected String fileExtension = "";
32:
33: public void engage(CodeGenConfiguration configuration)
34: throws CodeGenerationException {
35:
36: //recurse through the output files and prettify them
37: File outputFolder = configuration.getOutputLocation();
38: prettify(outputFolder, configuration);
39:
40: }
41:
42: /**
43: * Recursive procedure to prettify the files
44: *
45: * @param file
46: */
47: protected void prettify(File file,
48: CodeGenConfiguration configuration) {
49:
50: List xmlFileList = configuration.getOutputXmlFileNamesList();
51: String fileName = null;
52: for (Iterator iter = xmlFileList.iterator(); iter.hasNext();) {
53: fileName = (String) iter.next();
54: prettifyFile(new File(fileName));
55: }
56:
57: }
58:
59: /**
60: * Implement this to call the proper pretty printers
61: *
62: * @param file
63: */
64: protected abstract void prettifyFile(File file);
65:
66: }
|