Java Aspectj Usage genSignature(IProgramElement node)

Here you can find the source of genSignature(IProgramElement node)

Description

gen Signature

License

Open Source License

Declaration

public static String genSignature(IProgramElement node) 

Method Source Code

//package com.java2s;
/* *******************************************************************
 * Copyright (c) 2003 Contributors./*from ww  w .  j a va 2  s. c o m*/
 * All rights reserved. 
 * This program and the accompanying materials are made available 
 * under the terms of the Eclipse Public License v1.0 
 * which accompanies this distribution and is available at 
 * http://www.eclipse.org/legal/epl-v10.html 
 *  
 * Contributors: 
 *     Mik Kersten     initial implementation 
 * ******************************************************************/

import java.util.Iterator;

import org.aspectj.asm.IProgramElement;

public class Main {
    public static String genSignature(IProgramElement node) {
        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();) {
            modifiers += modIt.next() + " ";
        }

        if (node.getKind().equals(IProgramElement.Kind.METHOD)
                || node.getKind().equals(IProgramElement.Kind.FIELD)) {
            sb.append(node.getCorrespondingType());
            sb.append(' ');
        }

        if (node.getKind().equals(IProgramElement.Kind.CLASS)) {
            sb.append("class ");
        } else if (node.getKind().equals(IProgramElement.Kind.INTERFACE)) {
            sb.append("interface ");
        }

        sb.append(node.getName());

        if (node.getParameterTypes() != null) {
            sb.append('(');
            for (int i = 0; i < node.getParameterTypes().size(); i++) {
                sb.append(String.valueOf(node.getParameterTypes().get(i)));
                sb.append(' ');
                sb.append((String) node.getParameterNames().get(i));
                if (i < node.getParameterTypes().size() - 1) {
                    sb.append(", ");
                }
            }
            sb.append(')');
        }

        return sb.toString();
    }
}

Related

  1. convertToFile(String path)
  2. copyInstruction(Instruction i)
  3. createConstant(InstructionFactory fact, int value)
  4. createInstanceof(InstructionFactory fact, ReferenceType t)
  5. genPointcutDetails(Pointcut pcd)
  6. getArgsMap(JoinPoint pjp)
  7. getFieldName(JoinPoint jp)
  8. getFilesInPackage(IProgramElement packageNode)
  9. getMethodArgByIndex(final JoinPoint joinPoint, final int index)