Caller

public class Caller

A Caller represents the class calling the method which generates this Caller. It retrieves information from the stack trace and is a relatively expensive operation. As a result, it should be used only when there is an absolute need.

Author:Hugo Y. K. Lam

Constructors

Caller

public Caller()

Creates a new instance of Caller.

Caller

public Caller(int backSteps)

Creates a new instance of Caller.

Parameters:
  • backSteps – number of steps backward from the point of the immediate caller in the trace.

Methods

getClassName

public String getClassName()

Gets the name of the calling class.

Returns:the name of the calling class.

getFileName

public String getFileName()

Gets the file name of the calling class.

Returns:the file name of the calling class.

getLineNumber

public int getLineNumber()

Gets the line number in the source file of the caller class at which the call is made.

Returns:the line number in the source file.

getMethodName

public String getMethodName()

Gets the method name of the method, which makes the call, in the caller class.

Returns:the method name.

getName

public static String getName()

Gets the name of the calling class.

Returns:the name of the calling class.

isUnknown

public boolean isUnknown()

Checks if the calling class is undetermined.

Returns:true if the calling class is undetermined.

toString

public String toString()

Returns a string representation of this Caller.

Returns:a string representation of this Caller.

See also: java.lang.Object.toString()