List of usage examples for org.aspectj.apache.bcel.generic InstructionList iterator
public Iterator iterator()
From source file:br.jabuti.metrics.klass.MetricAMZNMS.java
License:Open Source License
@Override public double getResult(Program prog, String className) { double theValue = 0.0; RClass rc = prog.get(className);//w ww . j ava2 s . c o m if (!(rc instanceof RClassCode)) { return -1.0; } int cont = 0; RClassCode rcc = (RClassCode) rc; JavaClass theClazz = rcc.getTheClass(); ConstantPoolGen cp = new ConstantPoolGen(theClazz.getConstantPool()); Method[] methods = theClazz.getMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].isAbstract()) { continue; } MethodGen mg = new MethodGen(methods[i], theClazz.getClassName(), cp); InstructionList instructions = mg.getInstructionList(); Iterator<Instruction> instructionsIterator = instructions.iterator(); while (instructionsIterator.hasNext()) { Instruction instruction = instructionsIterator.next(); if (instruction instanceof InvokeInstruction) { theValue++; } } cont++; } if (cont == 0) { return -1.0; } return theValue / cont; }