Java Utililty Methods Aspectj Usage

List of utility methods to do Aspectj Usage

Description

The list of methods to do Aspectj Usage are organized into topic(s).

Method

StringgenSignature(IProgramElement node)
gen Signature
StringBuffer sb = new StringBuffer();
String accessibility = node.getAccessibility().toString();
if (!accessibility.equals("package")) {
    sb.append(accessibility);
    sb.append(' ');
String modifiers = "";
for (Iterator modIt = node.getModifiers().iterator(); modIt.hasNext();) {
...
MapgetArgsMap(JoinPoint pjp)
get Args Map
MethodSignature signature = (MethodSignature) pjp.getSignature();
Map<String, Object> args = new LinkedHashMap<>();
String names[] = signature.getParameterNames();
for (int i = 0, len = names.length; i < len; i++) {
    args.put(names[i], pjp.getArgs()[i]);
return args;
StringgetFieldName(JoinPoint jp)
get Field Name
Signature sig = jp.getSignature();
if (sig instanceof MethodSignature) {
    MethodSignature mSig = (MethodSignature) sig;
    return getFieldNameFromMethodName(mSig.getName());
} else if (sig instanceof FieldSignature) {
    FieldSignature fSig = (FieldSignature) sig;
    return fSig.getField().getName();
return "";
ListgetFilesInPackage(IProgramElement packageNode)
get Files In Package
List packageContents;
if (packageNode == null) {
    return null;
} else {
    packageContents = packageNode.getChildren();
List files = new ArrayList();
for (Iterator it = packageContents.iterator(); it.hasNext();) {
...
OptionalgetMethodArgByIndex(final JoinPoint joinPoint, final int index)
get Method Arg By Index
return Optional.ofNullable(joinPoint.getArgs()).filter(args -> index >= 0 && index < args.length)
        .map(args -> args[index]);
StringgetMethodName(ProceedingJoinPoint pjp)
get Method Name
StringBuilder methodName = new StringBuilder(pjp.getSignature().getName()).append("(");
MethodSignature signature = (MethodSignature) pjp.getSignature();
String[] names = signature.getParameterNames();
Class[] args = signature.getParameterTypes();
for (int i = 0, len = args.length; i < len; i++) {
    if (i != 0)
        methodName.append(",");
    methodName.append(args[i].getSimpleName()).append(" ").append(names[i]);
...
ListgetPackagesHelper(IProgramElement node, IProgramElement.Kind kind, String prename, List matches)
get Packages Helper
if (kind == null || node.getKind().equals(kind)) {
    if (prename == null) {
        prename = new String(node.toString());
    } else {
        prename = new String(prename + "." + node);
    Object[] o = new Object[2];
    o[0] = node;
...
ListgetPackagesInModel(AsmManager modl)
get Packages In Model
List packages = new ArrayList();
IHierarchy model = modl.getHierarchy();
if (model.getRoot().equals(IHierarchy.NO_STRUCTURE)) {
    return null;
} else {
    return getPackagesHelper(model.getRoot(), IProgramElement.Kind.PACKAGE, null, packages);
StringgetSignature(Signature signature, String nameFromAnnotation, boolean absolute)
get Signature
String className = null;
if (!absolute) {
    className = signature.getDeclaringTypeName();
    className = className.substring(className.lastIndexOf('.') + 1, className.length());
return getSignature(className, signature.getName(), nameFromAnnotation, absolute);
intgetSourceLine(InstructionHandle ih)
returns -1 if no source line attribute
public static int getSourceLine(InstructionHandle ih) {
    int lookahead = 0;
    while (lookahead++ < 100) {
        if (ih == null) {
            return -1;
        Iterator<InstructionTargeter> tIter = ih.getTargeters().iterator();
        while (tIter.hasNext()) {
    ...