当前位置: 首页>>代码示例>>Java>>正文


Java AttEnclosingMethod类代码示例

本文整理汇总了Java中com.android.dx.cf.attrib.AttEnclosingMethod的典型用法代码示例。如果您正苦于以下问题:Java AttEnclosingMethod类的具体用法?Java AttEnclosingMethod怎么用?Java AttEnclosingMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AttEnclosingMethod类属于com.android.dx.cf.attrib包,在下文中一共展示了AttEnclosingMethod类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: translateEnclosingMethod

import com.android.dx.cf.attrib.AttEnclosingMethod; //导入依赖的package包/类
/**
 * Gets the {@code EnclosingMethod} attribute out of a given
 * {@link AttributeList}, if any, translating it to an annotation.
 * If the class really has an enclosing method, this returns an
 * {@code EnclosingMethod} annotation; if not, this returns
 * an {@code EnclosingClass} annotation.
 *
 * @param attribs {@code non-null;} the attributes list to search in
 * @return {@code null-ok;} the converted {@code EnclosingMethod} or
 * {@code EnclosingClass} annotation, if there was an
 * attribute to translate
 */
private static Annotation translateEnclosingMethod(AttributeList attribs) {
    AttEnclosingMethod enclosingMethod = (AttEnclosingMethod)
        attribs.findFirst(AttEnclosingMethod.ATTRIBUTE_NAME);

    if (enclosingMethod == null) {
        return null;
    }

    CstType enclosingClass = enclosingMethod.getEnclosingClass();
    CstNat nat = enclosingMethod.getMethod();

    if (nat == null) {
        /*
         * Dalvik doesn't use EnclosingMethod annotations unless
         * there really is an enclosing method. Anonymous classes
         * are unambiguously identified by having an InnerClass
         * annotation with an empty name along with an appropriate
         * EnclosingClass.
         */
        return AnnotationUtils.makeEnclosingClass(enclosingClass);
    }

    return AnnotationUtils.makeEnclosingMethod(
            new CstMethodRef(enclosingClass, nat));
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:38,代码来源:AttributeTranslator.java

示例2: enclosingMethod

import com.android.dx.cf.attrib.AttEnclosingMethod; //导入依赖的package包/类
/**
 * Parses an {@code EnclosingMethod} attribute.
 */
private Attribute enclosingMethod(DirectClassFile cf, int offset,
        int length, ParseObserver observer) {
    if (length != 4) {
        throwBadLength(4);
    }

    ByteArray bytes = cf.getBytes();
    ConstantPool pool = cf.getConstantPool();

    int idx = bytes.getUnsignedShort(offset);
    CstType type = (CstType) pool.get(idx);

    idx = bytes.getUnsignedShort(offset + 2);
    CstNat method = (CstNat) pool.get0Ok(idx);

    Attribute result = new AttEnclosingMethod(type, method);

    if (observer != null) {
        observer.parsed(bytes, offset, 2, "class: " + type);
        observer.parsed(bytes, offset + 2, 2, "method: " +
                        DirectClassFile.stringOrNone(method));
    }

    return result;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:29,代码来源:StdAttributeFactory.java

示例3: processClass

import com.android.dx.cf.attrib.AttEnclosingMethod; //导入依赖的package包/类
/**
 * Creates an XMLVM element for the given type and appends it to the given
 * root element.
 * 
 * @param cf
 *            the {@link DirectClassFile} instance of this class
 * @param root
 *            the root element to append the generated element to
 * @param referencedTypes
 *            will be filled with the types references in this class file
 * @return the generated element
 */
private Element processClass(DirectClassFile cf, Element root,
        Map<String, ReferenceKind> referencedTypes) {
    Element classElement = new Element("class", NS_XMLVM);
    CstType type = cf.getThisClass();
    PackagePlusClassName parsedClassName = parseClassName(type.getClassType().getClassName());
    addReference(referencedTypes, parsedClassName.toString(), ReferenceKind.SELF);
    classElement.setAttribute("name", parsedClassName.className);
    classElement.setAttribute("package", parsedClassName.packageName);
    String superClassName = "";

    // if we are an innerclass add the enclosingMethod
    AttEnclosingMethod enclosingMethodAnnotation = (AttEnclosingMethod) cf.getAttributes().findFirst(
            AttEnclosingMethod.ATTRIBUTE_NAME);

    if (enclosingMethodAnnotation != null) {
        CstType enclosingClass=enclosingMethodAnnotation.getEnclosingClass();
        CstNat enclosingMethod = enclosingMethodAnnotation.getMethod();
        if(enclosingClass!=null){
            addReference(referencedTypes, enclosingClass.toHuman(), ReferenceKind.USAGE);
            classElement.setAttribute("enclosingClass", enclosingClass.toHuman());
        }
        if(enclosingMethod!=null){
            classElement.setAttribute("enclosingMethod", enclosingMethod.toHuman());
        }
    }
    
    //get signature annotation if availabke
    AttSignature signatureAnnotation=(AttSignature) cf.getAttributes().findFirst(
            AttSignature.ATTRIBUTE_NAME);
    
    if(signatureAnnotation!=null){
        classElement.setAttribute("signature", signatureAnnotation.getSignature().toHuman());
    }
    
    // This can happen for java.lang.Object.
    if (cf.getSuperclass() != null) {
        superClassName = parseClassName(cf.getSuperclass().getClassType().getClassName())
                .toString();
        addReference(referencedTypes, superClassName, ReferenceKind.SUPER_CLASS);
    }

    classElement.setAttribute("extends", superClassName);

    processAccessFlags(cf.getAccessFlags(), classElement);

    TypeList interfaces = cf.getInterfaces();
    if (interfaces.size() > 0) {
        String interfaceList = "";
        for (int i = 0; i < interfaces.size(); ++i) {
            if (i > 0) {
                interfaceList += ",";
            }
            String interfaceName = parseClassName(interfaces.getType(i).getClassName())
                    .toString();
            interfaceList += interfaceName;
            addReference(referencedTypes, interfaceName, ReferenceKind.INTERFACE);
        }
        classElement.setAttribute("interfaces", interfaceList);
    }

    root.addContent(classElement);
    return classElement;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:76,代码来源:DEXmlvmOutputProcess.java


注:本文中的com.android.dx.cf.attrib.AttEnclosingMethod类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。