You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/11/19 05:50:39 UTC
svn commit: r345633 -
/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/PrettyPrinter.java
Author: dims
Date: Fri Nov 18 20:50:33 2005
New Revision: 345633
URL: http://svn.apache.org/viewcvs?rev=345633&view=rev
Log:
oops! forgot to check-in this one
Added:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/PrettyPrinter.java
Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/PrettyPrinter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/PrettyPrinter.java?rev=345633&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/PrettyPrinter.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/PrettyPrinter.java Fri Nov 18 20:50:33 2005
@@ -0,0 +1,60 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.wsdl.codegen.writer;
+
+import org.apache.axis2.util.Loader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.lang.reflect.Method;
+
+/**
+ * tidies up the java source code using Jalopy
+ */
+public class PrettyPrinter {
+ private static Log log = LogFactory.getLog(PrettyPrinter.class);
+
+
+ /**
+ * Pretty print contents of the java source file
+ * @param file
+ */
+ public static void prettify(File file) {
+ try {
+ // Create an instance of the Jalopy bean
+ Class clazz = Loader.loadClass("de.hunsicker.jalopy.Jalopy");
+ Object prettifier = clazz.newInstance();
+
+ // Set the input file
+ Method input = clazz.getMethod("setInput", new Class[]{File.class});
+ input.invoke(prettifier, new Object[]{file});
+
+ // Set the output file
+ Method output = clazz.getMethod("setOutput", new Class[]{File.class});
+ output.invoke(prettifier, new Object[]{file});
+
+ // format and overwrite the given input file
+ Method format = clazz.getMethod("format", new Class[]{});
+ format.invoke(prettifier, new Object[]{});
+ } catch (ClassNotFoundException e) {
+ log.info("Jalopy not found - unable to pretty print " + file);
+ } catch (Exception e) {
+ log.info(e);
+ }
+ }
+}