patterntesting.runtime.util
Class JoinPointHelper

Package class diagram package JoinPointHelper
java.lang.Object
  extended by patterntesting.runtime.util.JoinPointHelper

public final class JoinPointHelper
extends Object

The Class JoinPointHelper.

Since:
23.10.2008
Version:
$Revision: 1.19 $
Author:
oliver

Method Summary
static String getArgAsShortString(Object obj)
          Gets the arg as short string.
static String getArgAsString(Object obj)
          Gets the arg as string.
static String getArgsAsShortString(Object[] args)
          Gets the args as short string.
static String getArgsAsString(Object[] args)
          Gets the args as string.
static String getAsLongString(JoinPoint joinpoint)
          Gets the as long string.
static String getAsShortString(JoinPoint joinpoint)
          Gets the as short string.
static String getAsString(JoinPoint joinpoint)
          Gets the given joinpoint as string.
static Class<?> getCallerClass()
          Gets the caller class by examing the stacktrace.
static Class<?> getCallerClass(Class<?>... excluded)
          Gets the caller class by examing the stacktrace.
static Class<?> getCallerClass(Pattern... excluded)
          Deprecated. Use StackTraceScanner.getCallerClass(Pattern...) instead
static StackTraceElement getCallerOf(JoinPoint jp)
          Gets the caller of the given joinpoint.
static StackTraceElement getCallerOf(JoinPoint jp, Pattern... excluded)
          Gets the caller of the given joinpoint.
static Annotation getClassAnnotation(JoinPoint jp, Class<? extends Annotation> annotationClass)
          Returns the annotation for the given JoinPoint.
static Annotation[][] getParameterAnnotations(JoinPoint joinpoint)
          Gets the parameter annotations.
static boolean isInnerClass(JoinPoint jp)
          The Java compiler generates something like OuterClass$InnerClass as name for the inner class.
static boolean isInnerClass(Signature sig)
          The Java compiler generates something like OuterClass$InnerClass as name for the inner class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAsString

public static String getAsString(JoinPoint joinpoint)
Gets the given joinpoint as string.

Parameters:
joinpoint - the joinpoint
Returns:
the as string

getAsShortString

public static String getAsShortString(JoinPoint joinpoint)
Gets the as short string.

Parameters:
joinpoint - the joinpoint
Returns:
the as short string

getAsLongString

public static String getAsLongString(JoinPoint joinpoint)
Gets the as long string.

Parameters:
joinpoint - the joinpoint
Returns:
the as short string

getParameterAnnotations

@MayReturnNull
public static Annotation[][] getParameterAnnotations(JoinPoint joinpoint)
Gets the parameter annotations.

Parameters:
joinpoint - should be a Method- or Constructor-Signature
Returns:
the annotations of a method or constructor, otherwise null

getClassAnnotation

@MayReturnNull
public static Annotation getClassAnnotation(JoinPoint jp,
                                                          Class<? extends Annotation> annotationClass)
Returns the annotation for the given JoinPoint.

Parameters:
jp - the JoinPoint
annotationClass - the wanted annotation
Returns:
the annotation (if found) or null
Since:
1.0

getArgsAsString

@NullArgsAllowed
public static String getArgsAsString(Object[] args)
Gets the args as string.

Parameters:
args - the args
Returns:
the args as string

getArgsAsShortString

@NullArgsAllowed
public static String getArgsAsShortString(Object[] args)
Gets the args as short string. If the resulting argument string will be too long it will be abbreviated.

Parameters:
args - the args
Returns:
the args as short string
Since:
1.4.1

getArgAsString

@NullArgsAllowed
public static String getArgAsString(Object obj)
Gets the arg as string.

Parameters:
obj - the obj
Returns:
the arg as string

getArgAsShortString

@NullArgsAllowed
public static String getArgAsShortString(Object obj)
Gets the arg as short string.

Parameters:
obj - the obj
Returns:
the arg as short string
Since:
1.4.1

isInnerClass

public static boolean isInnerClass(JoinPoint jp)
The Java compiler generates something like OuterClass$InnerClass as name for the inner class. So if a name contains a '$' it is probably an inner class.

Parameters:
jp - the jp
Returns:
true if joinpoint belongs to an inner class

isInnerClass

public static boolean isInnerClass(Signature sig)
The Java compiler generates something like OuterClass$InnerClass as name for the inner class. So if a name contains a '$' it is probably an inner class.

Parameters:
sig - the sig
Returns:
true if signature belongs to an inner class

getCallerClass

public static Class<?> getCallerClass()
Gets the caller class by examing the stacktrace.

Sometime the caller of the method is an aspect. Because normally you do not want the aspect it is filtered out. If you really want it call getCallerOf(JoinPoint, Pattern...) direct with an empty pattern argument.

Returns:
the caller of a joinpoint
See Also:
getCallerOf(JoinPoint, Pattern...)

getCallerClass

public static Class<?> getCallerClass(Class<?>... excluded)
Gets the caller class by examing the stacktrace.

Sometime the caller of the method is an aspect. With this method you have the chance to list the aspects which should be ignored.

Parameters:
excluded - the excluded
Returns:
the caller of a joinpoint

getCallerClass

@Deprecated
public static Class<?> getCallerClass(Pattern... excluded)
Deprecated. Use StackTraceScanner.getCallerClass(Pattern...) instead

Gets the caller class by examing the stacktrace.

Parameters:
excluded - a list of filters which should be not considered as caller
Returns:
the caller of

getCallerOf

public static StackTraceElement getCallerOf(JoinPoint jp)
Gets the caller of the given joinpoint. For a call joinpoint you have "this" as attribute which gives you the caller. But for an execution joinpoint "this" is not the caller but the object of execution. If you want the caller of the excution joinpoint call this method here.

Sometime the caller of the method is an aspect. Because normally you do not want the aspect it is filtered out. If you really want it call getCallerOf(JoinPoint, Pattern...) direct with an empty pattern argument.

Parameters:
jp - the (execution) joinpoint
Returns:
the caller of the given joinpoint
See Also:
getCallerOf(JoinPoint, Pattern...)

getCallerOf

public static StackTraceElement getCallerOf(JoinPoint jp,
                                            Pattern... excluded)
Gets the caller of the given joinpoint. For a call joinpoint you have "this" as attribute which gives you the caller. But for an execution joinpoint "this" is not the caller but the object of execution. If you want the caller of the excution joinpoint call this method here.

Parameters:
jp - the (execution) joinpoint
excluded - a list of filters which should be not considered as caller
Returns:
the caller of


Copyright © 2002–2014 PatternTesting Team. All rights reserved.