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.util.PrettyPrinter;
22: import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
23:
24: import java.io.File;
25:
26: public class JavaPrettyPrinterExtension extends
27: AbstractPrettyPrinterExtension {
28:
29: public JavaPrettyPrinterExtension() {
30: /*
31: * If the extension for property file changes it might effect this as
32: * well !!!
33: */
34: fileExtension = ".java";
35: }
36:
37: /**
38: * Recursive procedure to prettify the files
39: *
40: * @param file
41: */
42: protected void prettify(File file,
43: CodeGenConfiguration configuration) {
44: if (file.isFile() && file.exists()
45: && file.getName().toLowerCase().endsWith(fileExtension)) {
46: prettifyFile(file);
47: } else if (file.isDirectory()) {
48: File[] childFiles = file.listFiles();
49: for (int i = 0; i < childFiles.length; i++) {
50: prettify(childFiles[i], configuration);
51: }
52: }
53: }
54:
55: /**
56: * Overridden to call the java pretty printer
57: *
58: * @param file
59: */
60: protected void prettifyFile(File file) {
61: // Special case jaxbri generated package-info.java
62: // as jalopy corrupts the package level annotations
63: if (file.getName().equals("package-info.java")) {
64: return;
65: }
66: PrettyPrinter.prettify(file);
67: }
68: }
|