com.townleyenterprises.trace
Class MethodTrace

java.lang.Object
  extended bycom.townleyenterprises.trace.TraceCore
      extended bycom.townleyenterprises.trace.MethodTrace
Direct Known Subclasses:
BasicTrace, ErrorTrace

public class MethodTrace
extends TraceCore

This class augments the trace core with a way to track the name of the currently traced method. This class is now thread safe.


Field Summary
static java.lang.String TRACE_ARG_GEN_FMT
          This is the message format for method other method arguments
static java.lang.String TRACE_ARG_STR_FMT
          This is the message format for method arguments that are strings
static java.lang.String TRACE_RETURN_FMT
          This is the message format used for methods that return no values
static java.lang.String TRACE_RETURN_GEN_FMT
          This is the message format used for methods returning object values
static java.lang.String TRACE_RETURN_STR_FMT
          This is the message format used for methods returning string values
static java.lang.String TRACE_START_FMT
          This is the message format used for method start
static java.lang.String TRACE_THROW_FMT
          This is the message format for throwing exceptions
 
Constructor Summary
protected MethodTrace(java.lang.String name, int maturity)
          The constructor initializes the trace core instance as well as setting the default value for method information to 1.
protected MethodTrace(java.lang.String name, int maturity, int methodTraceLevel)
          The constructor initializes the trace core instance as well as specifies the default value at which the method information should be printed.
 
Method Summary
 void methodArg(java.lang.String name, boolean arg)
           
 void methodArg(java.lang.String name, double arg)
           
 void methodArg(java.lang.String name, int arg)
           
 void methodArg(java.lang.String name, java.lang.Object arg)
           
 void methodArg(java.lang.String name, java.lang.String arg)
          This method should be called to specify a method argument parameter.
 void methodArg(java.lang.String name, Traceable arg)
           
 void methodArgs(java.lang.String[] pnames, java.lang.Object[] params)
           
 void methodReturn()
          This method should be called to specify that the method is about to return, with no value.
 boolean methodReturn(boolean arg)
           
 double methodReturn(double arg)
           
 float methodReturn(float arg)
           
 int methodReturn(int arg)
           
 long methodReturn(long arg)
           
 java.lang.Object methodReturn(java.lang.Object arg)
           
 java.lang.String methodReturn(java.lang.String arg)
          This method should be called to specify that the method is about to return, with the indicated value.
 Traceable methodReturn(Traceable arg)
           
 void methodStart(java.lang.String name)
          This method should be called at the beginning of each method to be traced with the method name.
 void methodStart(java.lang.String name, java.lang.Object[] params)
          This version of methodStart prints all of the arguments without the parameter names.
 void methodStart(java.lang.String name, java.lang.String[] pnames, java.lang.Object[] params)
          This version of methodStart prints all of the arguments together with the parameter names.
 void methodThrow(java.lang.Throwable ex)
          This method is used to specify that the method is about to throw an exception.
 java.lang.Throwable methodThrow(java.lang.Throwable ex, boolean print)
          This method is used to specify that the method is about to throw an exception.
protected  java.lang.String popCurrentMethod()
          This method is used to pop the method name off the stack
 
Methods inherited from class com.townleyenterprises.trace.TraceCore
getInstanceTraceLevel, getShowThreadNameAlways, getShowTimestamp, getTimestampFormat, getTraceFile, getTraceLevel, getTraceLevel, getTraceStream, loadInstanceSettings, loadSettings, printStackTrace, setInstanceTraceLevel, setShowThreadNameAlways, setShowTimestamp, setTimestampFormat, setTraceFile, setTraceLevel, setTraceLevel, tprintln, tprintln, willTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_START_FMT

public static final java.lang.String TRACE_START_FMT
This is the message format used for method start

See Also:
Constant Field Values

TRACE_RETURN_FMT

public static final java.lang.String TRACE_RETURN_FMT
This is the message format used for methods that return no values

See Also:
Constant Field Values

TRACE_RETURN_GEN_FMT

public static final java.lang.String TRACE_RETURN_GEN_FMT
This is the message format used for methods returning object values

See Also:
Constant Field Values

TRACE_RETURN_STR_FMT

public static final java.lang.String TRACE_RETURN_STR_FMT
This is the message format used for methods returning string values

See Also:
Constant Field Values

TRACE_ARG_STR_FMT

public static final java.lang.String TRACE_ARG_STR_FMT
This is the message format for method arguments that are strings

See Also:
Constant Field Values

TRACE_ARG_GEN_FMT

public static final java.lang.String TRACE_ARG_GEN_FMT
This is the message format for method other method arguments

See Also:
Constant Field Values

TRACE_THROW_FMT

public static final java.lang.String TRACE_THROW_FMT
This is the message format for throwing exceptions

See Also:
Constant Field Values
Constructor Detail

MethodTrace

protected MethodTrace(java.lang.String name,
                      int maturity,
                      int methodTraceLevel)
The constructor initializes the trace core instance as well as specifies the default value at which the method information should be printed.

Parameters:
methodTraceLevel - set the level when the method information is printed (default is 1)

MethodTrace

protected MethodTrace(java.lang.String name,
                      int maturity)
The constructor initializes the trace core instance as well as setting the default value for method information to 1.

Method Detail

methodStart

public void methodStart(java.lang.String name)
This method should be called at the beginning of each method to be traced with the method name.

Parameters:
name - the name of the method, without the '()'

methodStart

public void methodStart(java.lang.String name,
                        java.lang.String[] pnames,
                        java.lang.Object[] params)
This version of methodStart prints all of the arguments together with the parameter names.

Parameters:
name - the method name
pnames - the parameter names
params - the parameters

methodStart

public void methodStart(java.lang.String name,
                        java.lang.Object[] params)
This version of methodStart prints all of the arguments without the parameter names.

Parameters:
name - the method name
params - the parameters

methodArg

public void methodArg(java.lang.String name,
                      java.lang.String arg)
This method should be called to specify a method argument parameter.

Parameters:
name - the parameter name
arg - the parameter value

methodArg

public void methodArg(java.lang.String name,
                      int arg)

methodArg

public void methodArg(java.lang.String name,
                      boolean arg)

methodArg

public void methodArg(java.lang.String name,
                      double arg)

methodArg

public void methodArg(java.lang.String name,
                      Traceable arg)

methodArg

public void methodArg(java.lang.String name,
                      java.lang.Object arg)

methodArgs

public void methodArgs(java.lang.String[] pnames,
                       java.lang.Object[] params)

methodReturn

public void methodReturn()
This method should be called to specify that the method is about to return, with no value.


methodReturn

public java.lang.String methodReturn(java.lang.String arg)
This method should be called to specify that the method is about to return, with the indicated value.


methodReturn

public boolean methodReturn(boolean arg)

methodReturn

public float methodReturn(float arg)

methodReturn

public double methodReturn(double arg)

methodReturn

public int methodReturn(int arg)

methodReturn

public long methodReturn(long arg)

methodReturn

public Traceable methodReturn(Traceable arg)

methodReturn

public java.lang.Object methodReturn(java.lang.Object arg)

methodThrow

public void methodThrow(java.lang.Throwable ex)
This method is used to specify that the method is about to throw an exception.

Parameters:
ex - the exception that is to be thrown

methodThrow

public java.lang.Throwable methodThrow(java.lang.Throwable ex,
                                       boolean print)
This method is used to specify that the method is about to throw an exception.

Parameters:
ex - the exception that is to be thrown
print - if true, print the stack trace of the exception automatically.
Returns:
the throwable instance is returned from this method in order to reduce programming errors.
Since:
2.0

popCurrentMethod

protected java.lang.String popCurrentMethod()
This method is used to pop the method name off the stack



Copyright © 2002-2004, Andrew S. Townley and Townley Enterprises. All Rights Reserved.
This project is hosted on http://te-code.sourceforge.net.