de.fhg.igd.logging
Class SourceLocation

java.lang.Object
  extended byde.fhg.igd.logging.SourceLocation

public class SourceLocation
extends Object

This class represents a source code location. It provides access to class name, method name and the current line number (if possible, i.e. the source has been compiled using the Java compiler's -debug option). Instead of a constructor, detect() is meant to be called for requesting the current source location.

Notice: This class is actually obsolete since Java 1.4 provides the java.lang.StackTraceElement class, but anyway needed here to ensure compatibility to older Java versions.

Version:
"$Id: SourceLocation.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Matthias Pressfreund

Field Summary
protected  String clazz_
          The class name
protected  String line_
          The line number
protected  String method_
          The method name
static String UNKNOWN
          The identifier for an unknown parameter
 
Constructor Summary
protected SourceLocation()
          Create a completely unknown SourceLocation object.
protected SourceLocation(String clazz, String method, String line)
          Create a SourceLocation object.
 
Method Summary
static SourceLocation detect()
          Detect the current source code location.
 String getClassName()
           
 String getLineNumber()
           
 String getMethodName()
           
static String[] spallStackTrace(Throwable thrown)
          Cut a stacktrace into single lines of text.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final String UNKNOWN
The identifier for an unknown parameter

See Also:
Constant Field Values

clazz_

protected String clazz_
The class name


method_

protected String method_
The method name


line_

protected String line_
The line number

Constructor Detail

SourceLocation

protected SourceLocation()
Create a completely unknown SourceLocation object.


SourceLocation

protected SourceLocation(String clazz,
                         String method,
                         String line)
Create a SourceLocation object.

Method Detail

detect

public static SourceLocation detect()
Detect the current source code location. It should always be possible to detect class and method name, whereas in order to detect the line number it is mandatory that the source code has been compiled using the Java compiler's debug option.

Returns:
The location of the currently executed source code

getClassName

public String getClassName()

getMethodName

public String getMethodName()

getLineNumber

public String getLineNumber()

spallStackTrace

public static String[] spallStackTrace(Throwable thrown)
Cut a stacktrace into single lines of text.

Parameters:
thrown - The stacktrace origin
Returns:
The stacktrace as an array of lines of text

toString

public String toString()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.