Java Aspectj Usage getPackagesInModel(AsmManager modl)

Here you can find the source of getPackagesInModel(AsmManager modl)

Description

get Packages In Model

License

Open Source License

Declaration

public static List getPackagesInModel(AsmManager modl) 

Method Source Code


//package com.java2s;
/* *******************************************************************
 * Copyright (c) 1999-2001 Xerox Corporation, 
 *               2002 Palo Alto Research Center, Incorporated (PARC).
 * All rights reserved. // www.  j  a  va2  s.c  om
 * 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: 
 *     Xerox/PARC     initial implementation 
 * ******************************************************************/

import java.util.ArrayList;

import java.util.Iterator;
import java.util.List;

import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IHierarchy;
import org.aspectj.asm.IProgramElement;

public class Main {
    public static List getPackagesInModel(AsmManager modl) {
        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);
        }
    }

    private static List getPackagesHelper(IProgramElement node, IProgramElement.Kind kind, String prename,
            List matches) {

        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;
            o[1] = prename;

            matches.add(o);
        }

        for (Iterator it = node.getChildren().iterator(); it.hasNext();) {
            IProgramElement nextNode = (IProgramElement) it.next();
            getPackagesHelper(nextNode, kind, prename, matches);
        }

        return matches;
    }
}

Related

  1. getFieldName(JoinPoint jp)
  2. getFilesInPackage(IProgramElement packageNode)
  3. getMethodArgByIndex(final JoinPoint joinPoint, final int index)
  4. getMethodName(ProceedingJoinPoint pjp)
  5. getPackagesHelper(IProgramElement node, IProgramElement.Kind kind, String prename, List matches)
  6. getSignature(Signature signature, String nameFromAnnotation, boolean absolute)
  7. getSourceLine(InstructionHandle ih)
  8. getTargetClass(JoinPoint jp)
  9. getTargets(IProgramElement node, IRelationship.Kind kind)