Home » geronimo-eclipse-plugin-2.2-source-release » org.apache.geronimo.st.v21.ui.internal » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *    http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.geronimo.st.v21.ui.internal;
   18   
   19   import org.apache.geronimo.st.v21.ui.Activator;
   20   import org.eclipse.core.runtime.IStatus;
   21   
   22   /**
   23    * Helper class to route trace output.
   24    *
   25    * @version $Rev: 471551 $ $Date: 2006-11-05 17:47:11 -0500 (Sun, 05 Nov 2006) $
   26    */
   27   public class Trace {
   28   
   29       /**
   30        * Finest trace event.
   31        */
   32       public static byte INFO = 0;
   33   
   34       /**
   35        * Warning trace event.
   36        */
   37       public static byte WARNING = 1;
   38   
   39       /**
   40        * Severe trace event.
   41        */
   42       public static byte SEVERE = 2;
   43   
   44       /**
   45        * Trace constructor comment.
   46        */
   47       private Trace() {
   48           super();
   49       }
   50   
   51       /**
   52        * Trace the given text.
   53        * 
   54        * @param level
   55        *            the trace level
   56        * @param s
   57        *            a message
   58        */
   59       public static void trace(byte level, String s) {
   60           trace(level, s, null);
   61       }
   62   
   63       /**
   64        * Trace the given message and exception.
   65        * 
   66        * @param level
   67        *            the trace level
   68        * @param s
   69        *            a message
   70        * @param t
   71        *            a throwable
   72        */
   73       public static void trace(byte level, String s, Throwable t) {
   74           if (!Activator.getDefault().isDebugging())
   75               return;
   76   
   77           System.out.println(Activator.PLUGIN_ID + ":  " + s);
   78           if (t != null)
   79               t.printStackTrace();
   80       }
   81   
   82       /**
   83        * Trace the given message 
   84        * 
   85        * @param tracePoint
   86        *            The trace point (e.g., "Exit", "Entry", "Constructor", etc....
   87        *            
   88        * @param classDotMethod
   89        *            The class name + method name (e.g., "Class.method()")
   90        *            
   91        * @param parm1,2,3,4,5
   92        *            Method parameters if the trace point is an "Entry"
   93        *            or
   94        *            Return value if the trace point is an "Exit"
   95        */
   96       public static void trace(String tracePoint, String classDotMethod) {
   97           trace(Trace.INFO, tracePoint + ": " + classDotMethod + "()" );
   98       }   
   99       public static void trace(String tracePoint, String classDotMethod, Object parm1) {
  100           trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "] )" );
  101       }
  102   
  103       public static void trace(String tracePoint, String classDotMethod, Object parm1, Object parm2) {
  104           trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "], " +
  105                                                                    "parm2=[" + (parm2 == null ? null : parm2.toString()) + "] )" );
  106       }
  107       public static void trace(String tracePoint, String classDotMethod, Object parm1, Object parm2, Object parm3) {
  108           trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "], " +
  109                                                                    "parm2=[" + (parm2 == null ? null : parm2.toString()) + "], " +
  110                                                                    "parm3=[" + (parm3 == null ? null : parm3.toString()) + "] )" );
  111       }
  112       public static void trace(String tracePoint, String classDotMethod, Object parm1, Object parm2, Object parm3, Object parm4) {
  113           trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "], " +
  114                                                                    "parm2=[" + (parm2 == null ? null : parm2.toString()) + "], " +
  115                                                                    "parm3=[" + (parm3 == null ? null : parm3.toString()) + "], " +
  116                                                                    "parm4=[" + (parm4 == null ? null : parm4.toString()) + "] )" );
  117       }
  118       public static void trace(String tracePoint, String classDotMethod, Object parm1, Object parm2, Object parm3, Object parm4, Object parm5) {
  119           trace(Trace.INFO, tracePoint + ": " + classDotMethod + "( parm1=[" + (parm1 == null ? null : parm1.toString()) + "], " +
  120                                                                    "parm2=[" + (parm2 == null ? null : parm2.toString()) + "], " +
  121                                                                    "parm3=[" + (parm3 == null ? null : parm3.toString()) + "], " +
  122                                                                    "parm4=[" + (parm4 == null ? null : parm4.toString()) + "], " +
  123                                                                    "parm5=[" + (parm5 == null ? null : parm5.toString()) + "] )" );
  124       }
  125   }

Home » geronimo-eclipse-plugin-2.2-source-release » org.apache.geronimo.st.v21.ui.internal » [javadoc | source]