Example usage for org.aspectj.apache.bcel.classfile ConstantCP getClass

List of usage examples for org.aspectj.apache.bcel.classfile ConstantCP getClass

Introduction

In this page you can find the example usage for org.aspectj.apache.bcel.classfile ConstantCP getClass.

Prototype

public String getClass(ConstantPool cp) 

Source Link

Usage

From source file:br.jabuti.metrics.klass.MetricCBO.java

License:Open Source License

@Override
public double getResult(Program prog, String className) {
    RClass rc = prog.get(className);//  ww  w.  ja  v  a2s .  co m
    if (!(rc instanceof RClassCode)) {
        return -1.0;
    }
    RClassCode rcc = (RClassCode) rc;
    JavaClass theClazz = rcc.getTheClass();
    ConstantPool cp = theClazz.getConstantPool();
    Constant[] cts = cp.getConstantPool();
    Set<String> hs = new HashSet<String>();
    for (Constant ct : cts) {
        if (ct instanceof ConstantCP) {
            ConstantCP cc = (ConstantCP) ct;
            if (!className.equals(cc.getClass(cp))) {
                hs.add(cc.getClass(cp));
            }
        }
    }
    return hs.size();
}