Search in sources :

Example 26 with NameValuePair

use of com.android.dx.rop.annotation.NameValuePair in project J2ME-Loader by nikita36078.

the class AnnotationUtils method makeInnerClass.

/**
 * Constructs a standard {@code InnerClass} annotation.
 *
 * @param name {@code null-ok;} the original name of the class, or
 * {@code null} to represent an anonymous class
 * @param accessFlags the original access flags
 * @return {@code non-null;} the annotation
 */
public static Annotation makeInnerClass(CstString name, int accessFlags) {
    Annotation result = new Annotation(INNER_CLASS_TYPE, SYSTEM);
    Constant nameCst = (name != null) ? name : CstKnownNull.THE_ONE;
    result.put(new NameValuePair(NAME_STRING, nameCst));
    result.put(new NameValuePair(ACCESS_FLAGS_STRING, CstInteger.make(accessFlags)));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.android.dx.rop.annotation.NameValuePair) Constant(com.android.dx.rop.cst.Constant) Annotation(com.android.dx.rop.annotation.Annotation) CstAnnotation(com.android.dx.rop.cst.CstAnnotation)

Example 27 with NameValuePair

use of com.android.dx.rop.annotation.NameValuePair in project J2ME-Loader by nikita36078.

the class AnnotationUtils method makeAnnotationDefault.

/**
 * Constructs a standard {@code AnnotationDefault} annotation.
 *
 * @param defaults {@code non-null;} the defaults, itself as an annotation
 * @return {@code non-null;} the constructed annotation
 */
public static Annotation makeAnnotationDefault(Annotation defaults) {
    Annotation result = new Annotation(ANNOTATION_DEFAULT_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, new CstAnnotation(defaults)));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.android.dx.rop.annotation.NameValuePair) CstAnnotation(com.android.dx.rop.cst.CstAnnotation) Annotation(com.android.dx.rop.annotation.Annotation) CstAnnotation(com.android.dx.rop.cst.CstAnnotation)

Example 28 with NameValuePair

use of com.android.dx.rop.annotation.NameValuePair in project J2ME-Loader by nikita36078.

the class AnnotationUtils method makeSourceDebugExtension.

/**
 * Constructs a standard {@code SourceDebugExtension} annotation.
 *
 * @param smapString {@code non-null;} the SMAP string associated with
 * @return {@code non-null;} the annotation
 */
public static Annotation makeSourceDebugExtension(CstString smapString) {
    Annotation result = new Annotation(SOURCE_DEBUG_EXTENSION_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, smapString));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.android.dx.rop.annotation.NameValuePair) Annotation(com.android.dx.rop.annotation.Annotation) CstAnnotation(com.android.dx.rop.cst.CstAnnotation)

Example 29 with NameValuePair

use of com.android.dx.rop.annotation.NameValuePair in project J2ME-Loader by nikita36078.

the class ValueEncoder method addContents.

/**
 * Helper for {@code addContents()} methods, which adds
 * contents for a particular {@link Annotation}, calling itself
 * recursively should it encounter a nested annotation.
 *
 * @param file {@code non-null;} the file to add to
 * @param annotation {@code non-null;} the annotation to add contents for
 */
public static void addContents(DexFile file, Annotation annotation) {
    TypeIdsSection typeIds = file.getTypeIds();
    StringIdsSection stringIds = file.getStringIds();
    typeIds.intern(annotation.getType());
    for (NameValuePair pair : annotation.getNameValuePairs()) {
        stringIds.intern(pair.getName());
        addContents(file, pair.getValue());
    }
}
Also used : NameValuePair(com.android.dx.rop.annotation.NameValuePair)

Aggregations

NameValuePair (com.android.dx.rop.annotation.NameValuePair)29 Annotation (com.android.dx.rop.annotation.Annotation)20 CstAnnotation (com.android.dx.rop.cst.CstAnnotation)17 CstString (com.android.dx.rop.cst.CstString)10 Constant (com.android.dx.rop.cst.Constant)8 CstArray (com.android.dx.rop.cst.CstArray)6 CstType (com.android.dx.rop.cst.CstType)6 AttAnnotationDefault (com.android.dx.cf.attrib.AttAnnotationDefault)2 AttEnclosingMethod (com.android.dx.cf.attrib.AttEnclosingMethod)2 AttributeList (com.android.dx.cf.iface.AttributeList)2 Method (com.android.dx.cf.iface.Method)2 MethodList (com.android.dx.cf.iface.MethodList)2 TypeList (com.android.dx.rop.type.TypeList)2 ArrayList (java.util.ArrayList)2 ClassDefItem (com.android.dx.dex.file.ClassDefItem)1 Annotations (com.android.dx.rop.annotation.Annotations)1