Java Aspectj Usage genPointcutDetails(Pointcut pcd)

Here you can find the source of genPointcutDetails(Pointcut pcd)

Description

Generates the pointcut details for the given pointcut, for example an anonymous pointcut will return '' and a named pointcut called p() will return 'p()..'

License

Open Source License

Declaration

public static String genPointcutDetails(Pointcut pcd) 

Method Source Code

//package com.java2s;
/********************************************************************
 * Copyright (c) 2006 Contributors. 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://eclipse.org/legal/epl-v10.html 
 *  //from  ww  w .  ja v a  2s.c o  m
 * Contributors: IBM Corporation - initial API and implementation 
 *              Helen Hawkins   - initial version
 *******************************************************************/

import org.aspectj.weaver.patterns.AndPointcut;
import org.aspectj.weaver.patterns.OrPointcut;
import org.aspectj.weaver.patterns.Pointcut;
import org.aspectj.weaver.patterns.ReferencePointcut;

public class Main {
    public static final String POINTCUT_ANONYMOUS = "<anonymous pointcut>";
    public static final String DOUBLE_DOTS = "..";

    /**
     * Generates the pointcut details for the given pointcut, for example an anonymous pointcut will return '<anonymous pointcut>'
     * and a named pointcut called p() will return 'p()..'
     */
    public static String genPointcutDetails(Pointcut pcd) {
        StringBuffer details = new StringBuffer();
        if (pcd instanceof ReferencePointcut) {
            ReferencePointcut rp = (ReferencePointcut) pcd;
            details.append(rp.name).append(DOUBLE_DOTS);
        } else if (pcd instanceof AndPointcut) {
            AndPointcut ap = (AndPointcut) pcd;
            if (ap.getLeft() instanceof ReferencePointcut) {
                details.append(ap.getLeft().toString()).append(DOUBLE_DOTS);
            } else {
                details.append(POINTCUT_ANONYMOUS).append(DOUBLE_DOTS);
            }
        } else if (pcd instanceof OrPointcut) {
            OrPointcut op = (OrPointcut) pcd;
            if (op.getLeft() instanceof ReferencePointcut) {
                details.append(op.getLeft().toString()).append(DOUBLE_DOTS);
            } else {
                details.append(POINTCUT_ANONYMOUS).append(DOUBLE_DOTS);
            }
        } else {
            details.append(POINTCUT_ANONYMOUS);
        }
        return details.toString();
    }
}

Related

  1. combine(String[] one, String[] two)
  2. convertToFile(String path)
  3. copyInstruction(Instruction i)
  4. createConstant(InstructionFactory fact, int value)
  5. createInstanceof(InstructionFactory fact, ReferenceType t)
  6. genSignature(IProgramElement node)
  7. getArgsMap(JoinPoint pjp)
  8. getFieldName(JoinPoint jp)
  9. getFilesInPackage(IProgramElement packageNode)