com.android.dx.rop.cst.CstAnnotation Java Examples

The following examples show how to use com.android.dx.rop.cst.CstAnnotation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationUtils.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source File: ValueEncoder.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@code addContents()} methods, which adds
 * contents for a particular constant, calling itself recursively
 * should it encounter a {@link CstArray} and calling {@link
 * #addContents(DexFile,Annotation)} recursively should it
 * encounter a {@link CstAnnotation}.
 *
 * @param file {@code non-null;} the file to add to
 * @param cst {@code non-null;} the constant to add contents for
 */
public static void addContents(DexFile file, Constant cst) {
    if (cst instanceof CstAnnotation) {
        addContents(file, ((CstAnnotation) cst).getAnnotation());
    } else if (cst instanceof CstArray) {
        CstArray.List list = ((CstArray) cst).getList();
        int size = list.size();
        for (int i = 0; i < size; i++) {
            addContents(file, list.get(i));
        }
    } else {
        file.internIfAppropriate(cst);
    }
}
 
Example #3
Source File: AnnotationUtils.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: ValueEncoder.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@code addContents()} methods, which adds
 * contents for a particular constant, calling itself recursively
 * should it encounter a {@link CstArray} and calling {@link
 * #addContents(DexFile,Annotation)} recursively should it
 * encounter a {@link CstAnnotation}.
 *
 * @param file {@code non-null;} the file to add to
 * @param cst {@code non-null;} the constant to add contents for
 */
public static void addContents(DexFile file, Constant cst) {
    if (cst instanceof CstAnnotation) {
        addContents(file, ((CstAnnotation) cst).getAnnotation());
    } else if (cst instanceof CstArray) {
        CstArray.List list = ((CstArray) cst).getList();
        int size = list.size();
        for (int i = 0; i < size; i++) {
            addContents(file, list.get(i));
        }
    } else {
        file.internIfAppropriate(cst);
    }
}
 
Example #5
Source File: AnnotationUtils.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: ValueEncoder.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@code addContents()} methods, which adds
 * contents for a particular constant, calling itself recursively
 * should it encounter a {@link CstArray} and calling {@link
 * #addContents(DexFile,Annotation)} recursively should it
 * encounter a {@link CstAnnotation}.
 *
 * @param file {@code non-null;} the file to add to
 * @param cst {@code non-null;} the constant to add contents for
 */
public static void addContents(DexFile file, Constant cst) {
    if (cst instanceof CstAnnotation) {
        addContents(file, ((CstAnnotation) cst).getAnnotation());
    } else if (cst instanceof CstArray) {
        CstArray.List list = ((CstArray) cst).getList();
        int size = list.size();
        for (int i = 0; i < size; i++) {
            addContents(file, list.get(i));
        }
    } else {
        file.internIfAppropriate(cst);
    }
}
 
Example #7
Source File: AnnotationUtils.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: ValueEncoder.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Helper for {@code addContents()} methods, which adds
 * contents for a particular constant, calling itself recursively
 * should it encounter a {@link CstArray} and calling {@link
 * #addContents(DexFile,Annotation)} recursively should it
 * encounter a {@link CstAnnotation}.
 *
 * @param file {@code non-null;} the file to add to
 * @param cst {@code non-null;} the constant to add contents for
 */
public static void addContents(DexFile file, Constant cst) {
    if (cst instanceof CstAnnotation) {
        addContents(file, ((CstAnnotation) cst).getAnnotation());
    } else if (cst instanceof CstArray) {
        CstArray.List list = ((CstArray) cst).getList();
        int size = list.size();
        for (int i = 0; i < size; i++) {
            addContents(file, list.get(i));
        }
    } else {
        file.internIfAppropriate(cst);
    }
}
 
Example #9
Source File: ValueEncoder.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the value type for the given constant.
 *
 * @param cst {@code non-null;} the constant
 * @return the value type; one of the {@code VALUE_*} constants
 * defined by this class
 */
private static int constantToValueType(Constant cst) {
    /*
     * TODO: Constant should probable have an associated enum, so this
     * can be a switch().
     */
    if (cst instanceof CstByte) {
        return VALUE_BYTE;
    } else if (cst instanceof CstShort) {
        return VALUE_SHORT;
    } else if (cst instanceof CstChar) {
        return VALUE_CHAR;
    } else if (cst instanceof CstInteger) {
        return VALUE_INT;
    } else if (cst instanceof CstLong) {
        return VALUE_LONG;
    } else if (cst instanceof CstFloat) {
        return VALUE_FLOAT;
    } else if (cst instanceof CstDouble) {
        return VALUE_DOUBLE;
    } else if (cst instanceof CstProtoRef) {
        return VALUE_METHOD_TYPE;
    } else if (cst instanceof CstMethodHandle) {
       return VALUE_METHOD_HANDLE;
    } else if (cst instanceof CstString) {
        return VALUE_STRING;
    } else if (cst instanceof CstType) {
        return VALUE_TYPE;
    } else if (cst instanceof CstFieldRef) {
        return VALUE_FIELD;
    } else if (cst instanceof CstMethodRef) {
        return VALUE_METHOD;
    } else if (cst instanceof CstEnumRef) {
        return VALUE_ENUM;
    } else if (cst instanceof CstArray) {
        return VALUE_ARRAY;
    } else if (cst instanceof CstAnnotation) {
        return VALUE_ANNOTATION;
    } else if (cst instanceof CstKnownNull) {
        return VALUE_NULL;
    } else if (cst instanceof CstBoolean) {
        return VALUE_BOOLEAN;
    } else {
        throw new RuntimeException("Shouldn't happen");
    }
}
 
Example #10
Source File: ValueEncoder.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the value type for the given constant.
 *
 * @param cst {@code non-null;} the constant
 * @return the value type; one of the {@code VALUE_*} constants
 * defined by this class
 */
private static int constantToValueType(Constant cst) {
    /*
     * TODO: Constant should probable have an associated enum, so this
     * can be a switch().
     */
    if (cst instanceof CstByte) {
        return VALUE_BYTE;
    } else if (cst instanceof CstShort) {
        return VALUE_SHORT;
    } else if (cst instanceof CstChar) {
        return VALUE_CHAR;
    } else if (cst instanceof CstInteger) {
        return VALUE_INT;
    } else if (cst instanceof CstLong) {
        return VALUE_LONG;
    } else if (cst instanceof CstFloat) {
        return VALUE_FLOAT;
    } else if (cst instanceof CstDouble) {
        return VALUE_DOUBLE;
    } else if (cst instanceof CstProtoRef) {
        return VALUE_METHOD_TYPE;
    } else if (cst instanceof CstMethodHandle) {
       return VALUE_METHOD_HANDLE;
    } else if (cst instanceof CstString) {
        return VALUE_STRING;
    } else if (cst instanceof CstType) {
        return VALUE_TYPE;
    } else if (cst instanceof CstFieldRef) {
        return VALUE_FIELD;
    } else if (cst instanceof CstMethodRef) {
        return VALUE_METHOD;
    } else if (cst instanceof CstEnumRef) {
        return VALUE_ENUM;
    } else if (cst instanceof CstArray) {
        return VALUE_ARRAY;
    } else if (cst instanceof CstAnnotation) {
        return VALUE_ANNOTATION;
    } else if (cst instanceof CstKnownNull) {
        return VALUE_NULL;
    } else if (cst instanceof CstBoolean) {
        return VALUE_BOOLEAN;
    } else {
        throw new RuntimeException("Shouldn't happen");
    }
}
 
Example #11
Source File: ValueEncoder.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the value type for the given constant.
 *
 * @param cst {@code non-null;} the constant
 * @return the value type; one of the {@code VALUE_*} constants
 * defined by this class
 */
private static int constantToValueType(Constant cst) {
    /*
     * TODO: Constant should probable have an associated enum, so this
     * can be a switch().
     */
    if (cst instanceof CstByte) {
        return VALUE_BYTE;
    } else if (cst instanceof CstShort) {
        return VALUE_SHORT;
    } else if (cst instanceof CstChar) {
        return VALUE_CHAR;
    } else if (cst instanceof CstInteger) {
        return VALUE_INT;
    } else if (cst instanceof CstLong) {
        return VALUE_LONG;
    } else if (cst instanceof CstFloat) {
        return VALUE_FLOAT;
    } else if (cst instanceof CstDouble) {
        return VALUE_DOUBLE;
    } else if (cst instanceof CstString) {
        return VALUE_STRING;
    } else if (cst instanceof CstType) {
        return VALUE_TYPE;
    } else if (cst instanceof CstFieldRef) {
        return VALUE_FIELD;
    } else if (cst instanceof CstMethodRef) {
        return VALUE_METHOD;
    } else if (cst instanceof CstEnumRef) {
        return VALUE_ENUM;
    } else if (cst instanceof CstArray) {
        return VALUE_ARRAY;
    } else if (cst instanceof CstAnnotation) {
        return VALUE_ANNOTATION;
    } else if (cst instanceof CstKnownNull) {
        return VALUE_NULL;
    } else if (cst instanceof CstBoolean) {
        return VALUE_BOOLEAN;
    } else {
        throw new RuntimeException("Shouldn't happen");
    }
}
 
Example #12
Source File: ValueEncoder.java    From buck with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the value type for the given constant.
 *
 * @param cst {@code non-null;} the constant
 * @return the value type; one of the {@code VALUE_*} constants
 * defined by this class
 */
private static int constantToValueType(Constant cst) {
    /*
     * TODO: Constant should probable have an associated enum, so this
     * can be a switch().
     */
    if (cst instanceof CstByte) {
        return VALUE_BYTE;
    } else if (cst instanceof CstShort) {
        return VALUE_SHORT;
    } else if (cst instanceof CstChar) {
        return VALUE_CHAR;
    } else if (cst instanceof CstInteger) {
        return VALUE_INT;
    } else if (cst instanceof CstLong) {
        return VALUE_LONG;
    } else if (cst instanceof CstFloat) {
        return VALUE_FLOAT;
    } else if (cst instanceof CstDouble) {
        return VALUE_DOUBLE;
    } else if (cst instanceof CstString) {
        return VALUE_STRING;
    } else if (cst instanceof CstType) {
        return VALUE_TYPE;
    } else if (cst instanceof CstFieldRef) {
        return VALUE_FIELD;
    } else if (cst instanceof CstMethodRef) {
        return VALUE_METHOD;
    } else if (cst instanceof CstEnumRef) {
        return VALUE_ENUM;
    } else if (cst instanceof CstArray) {
        return VALUE_ARRAY;
    } else if (cst instanceof CstAnnotation) {
        return VALUE_ANNOTATION;
    } else if (cst instanceof CstKnownNull) {
        return VALUE_NULL;
    } else if (cst instanceof CstBoolean) {
        return VALUE_BOOLEAN;
    } else {
        throw new RuntimeException("Shouldn't happen");
    }
}