org.openmdx.kernel.log.impl
Class AbstractStackTrace

java.lang.Object
  extended by org.openmdx.kernel.log.impl.AbstractStackTrace
All Implemented Interfaces:
LogLocation

public abstract class AbstractStackTrace
extends Object
implements LogLocation

This the base class for all stack tracers and provides the generic functionality


Constructor Summary
protected AbstractStackTrace()
           
 
Method Summary
protected  void clear()
          Resets the members
protected abstract  String currentStackLine(Throwable throwable, int level)
          This returns the a specific line in the given throwable (stack trace) that corresponds to level.
 String getClassname()
          Returns the full class name including the class' package.
 String getFilename()
          Returns the file name.
 int getLineNumber()
          Returns the line number.
 String getLineNumberString()
          Returns the line number as string.
 String getMethod()
          Returns the method name.
 String getShortClassname()
          Returns the short class name without the class' package.
static String getTraceInfo(Throwable ex)
          Returns the trace information for a given exception if available.
protected abstract  void parse(String raw)
          Breaks the given line into a class name, line number, function, etc.
 void setClassname(String classname)
          Sets the classname
 void setFilename(String filename)
          Sets the file name.
protected abstract  void setLevel(int numLevelsUp)
          Sets the desired depth of in a stack trace that properly indicates the callers level in the stack trace.
 void setLineNumber(int lineNr)
          Sets the line number.
 void setMethod(String method)
          Sets the method name.
 String toString()
          Returns a StackTrace as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractStackTrace

protected AbstractStackTrace()
Method Detail

currentStackLine

protected abstract String currentStackLine(Throwable throwable,
                                           int level)
This returns the a specific line in the given throwable (stack trace) that corresponds to level. This raw line can then be parsed to find the position of a caller in the running program.

Parameters:
throwable - a Throwable
level - a stack trace level we're interested in

setLevel

protected abstract void setLevel(int numLevelsUp)
Sets the desired depth of in a stack trace that properly indicates the callers level in the stack trace. This level will be parsed and the parsed information will be available through the class' getters.

Parameters:
numLevelsUp - the stack trace level we're interested in

parse

protected abstract void parse(String raw)
Breaks the given line into a class name, line number, function, etc. Presumably, the line corresponds to a line from a stack trace.

Parameters:
raw - a line from the stack trace

getTraceInfo

public static String getTraceInfo(Throwable ex)
Returns the trace information for a given exception if available.

Parameters:
ex - a java standard exception. No ServiceException allowed.
Returns:
a String

clear

protected void clear()
Resets the members


getClassname

public String getClassname()
Returns the full class name including the class' package.

Specified by:
getClassname in interface LogLocation
Returns:
a String

getShortClassname

public String getShortClassname()
Returns the short class name without the class' package.

Returns:
a String

getMethod

public String getMethod()
Returns the method name.

Specified by:
getMethod in interface LogLocation
Returns:
a String

getFilename

public String getFilename()
Returns the file name.

Returns:
a String

getLineNumber

public int getLineNumber()
Returns the line number.

Specified by:
getLineNumber in interface LogLocation
Returns:
a String

getLineNumberString

public String getLineNumberString()
Returns the line number as string.

Returns:
a String

setClassname

public void setClassname(String classname)
Sets the classname


setMethod

public void setMethod(String method)
Sets the method name.


setFilename

public void setFilename(String filename)
Sets the file name.


setLineNumber

public void setLineNumber(int lineNr)
Sets the line number.

Parameters:
lineNr - a line number

toString

public String toString()
Returns a StackTrace as a String.

Overrides:
toString in class Object
Returns:
a String


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.