Java Code Examples for com.android.dx.rop.annotation.NameValuePair#getValue()

The following examples show how to use com.android.dx.rop.annotation.NameValuePair#getValue() . 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: AnnotationItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Write a (listing file) annotation for this instance to the given
 * output, that consumes no bytes of output. This is for annotating
 * a reference to this instance at the point of the reference.
 *
 * @param out {@code non-null;} where to output to
 * @param prefix {@code non-null;} prefix for each line of output
 */
public void annotateTo(AnnotatedOutput out, String prefix) {
    out.annotate(0, prefix + "visibility: " +
            annotation.getVisibility().toHuman());
    out.annotate(0, prefix + "type: " + annotation.getType().toHuman());

    for (NameValuePair pair : annotation.getNameValuePairs()) {
        CstString name = pair.getName();
        Constant value = pair.getValue();

        out.annotate(0, prefix + name.toHuman() + ": " +
                ValueEncoder.constantToHuman(value));
    }
}
 
Example 2
Source File: AnnotationItem.java    From Box with Apache License 2.0 5 votes vote down vote up
/**
 * Write a (listing file) annotation for this instance to the given
 * output, that consumes no bytes of output. This is for annotating
 * a reference to this instance at the point of the reference.
 *
 * @param out {@code non-null;} where to output to
 * @param prefix {@code non-null;} prefix for each line of output
 */
public void annotateTo(AnnotatedOutput out, String prefix) {
    out.annotate(0, prefix + "visibility: " +
            annotation.getVisibility().toHuman());
    out.annotate(0, prefix + "type: " + annotation.getType().toHuman());

    for (NameValuePair pair : annotation.getNameValuePairs()) {
        CstString name = pair.getName();
        Constant value = pair.getValue();

        out.annotate(0, prefix + name.toHuman() + ": " +
                ValueEncoder.constantToHuman(value));
    }
}
 
Example 3
Source File: AnnotationItem.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/**
 * Write a (listing file) annotation for this instance to the given
 * output, that consumes no bytes of output. This is for annotating
 * a reference to this instance at the point of the reference.
 *
 * @param out {@code non-null;} where to output to
 * @param prefix {@code non-null;} prefix for each line of output
 */
public void annotateTo(AnnotatedOutput out, String prefix) {
    out.annotate(0, prefix + "visibility: " +
            annotation.getVisibility().toHuman());
    out.annotate(0, prefix + "type: " + annotation.getType().toHuman());

    for (NameValuePair pair : annotation.getNameValuePairs()) {
        CstString name = pair.getName();
        Constant value = pair.getValue();

        out.annotate(0, prefix + name.toHuman() + ": " +
                ValueEncoder.constantToHuman(value));
    }
}
 
Example 4
Source File: AnnotationItem.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Write a (listing file) annotation for this instance to the given
 * output, that consumes no bytes of output. This is for annotating
 * a reference to this instance at the point of the reference.
 *
 * @param out {@code non-null;} where to output to
 * @param prefix {@code non-null;} prefix for each line of output
 */
public void annotateTo(AnnotatedOutput out, String prefix) {
    out.annotate(0, prefix + "visibility: " +
            annotation.getVisibility().toHuman());
    out.annotate(0, prefix + "type: " + annotation.getType().toHuman());

    for (NameValuePair pair : annotation.getNameValuePairs()) {
        CstString name = pair.getName();
        Constant value = pair.getValue();

        out.annotate(0, prefix + name.toHuman() + ": " +
                ValueEncoder.constantToHuman(value));
    }
}
 
Example 5
Source File: ValueEncoder.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Writes out the encoded form of the given annotation, that is,
 * as an {@code encoded_annotation} and not including a
 * {@code value_type} prefix. If the output stream keeps
 * (debugging) annotations and {@code topLevel} is
 * {@code true}, then this method will write (debugging)
 * annotations.
 *
 * @param annotation {@code non-null;} annotation instance to write
 * @param topLevel {@code true} iff the given annotation is the
 * top-level annotation or {@code false} if it is a sub-annotation
 * of some other annotation
 */
public void writeAnnotation(Annotation annotation, boolean topLevel) {
    boolean annotates = topLevel && out.annotates();
    StringIdsSection stringIds = file.getStringIds();
    TypeIdsSection typeIds = file.getTypeIds();

    CstType type = annotation.getType();
    int typeIdx = typeIds.indexOf(type);

    if (annotates) {
        out.annotate("  type_idx: " + Hex.u4(typeIdx) + " // " +
                type.toHuman());
    }

    out.writeUleb128(typeIds.indexOf(annotation.getType()));

    Collection<NameValuePair> pairs = annotation.getNameValuePairs();
    int size = pairs.size();

    if (annotates) {
        out.annotate("  size: " + Hex.u4(size));
    }

    out.writeUleb128(size);

    int at = 0;
    for (NameValuePair pair : pairs) {
        CstString name = pair.getName();
        int nameIdx = stringIds.indexOf(name);
        Constant value = pair.getValue();

        if (annotates) {
            out.annotate(0, "  elements[" + at + "]:");
            at++;
            out.annotate("    name_idx: " + Hex.u4(nameIdx) + " // " +
                    name.toHuman());
        }

        out.writeUleb128(nameIdx);

        if (annotates) {
            out.annotate("    value: " + constantToHuman(value));
        }

        writeConstant(value);
    }

    if (annotates) {
        out.endAnnotation();
    }
}
 
Example 6
Source File: ValueEncoder.java    From Box with Apache License 2.0 4 votes vote down vote up
/**
 * Writes out the encoded form of the given annotation, that is,
 * as an {@code encoded_annotation} and not including a
 * {@code value_type} prefix. If the output stream keeps
 * (debugging) annotations and {@code topLevel} is
 * {@code true}, then this method will write (debugging)
 * annotations.
 *
 * @param annotation {@code non-null;} annotation instance to write
 * @param topLevel {@code true} iff the given annotation is the
 * top-level annotation or {@code false} if it is a sub-annotation
 * of some other annotation
 */
public void writeAnnotation(Annotation annotation, boolean topLevel) {
    boolean annotates = topLevel && out.annotates();
    StringIdsSection stringIds = file.getStringIds();
    TypeIdsSection typeIds = file.getTypeIds();

    CstType type = annotation.getType();
    int typeIdx = typeIds.indexOf(type);

    if (annotates) {
        out.annotate("  type_idx: " + Hex.u4(typeIdx) + " // " +
                type.toHuman());
    }

    out.writeUleb128(typeIds.indexOf(annotation.getType()));

    Collection<NameValuePair> pairs = annotation.getNameValuePairs();
    int size = pairs.size();

    if (annotates) {
        out.annotate("  size: " + Hex.u4(size));
    }

    out.writeUleb128(size);

    int at = 0;
    for (NameValuePair pair : pairs) {
        CstString name = pair.getName();
        int nameIdx = stringIds.indexOf(name);
        Constant value = pair.getValue();

        if (annotates) {
            out.annotate(0, "  elements[" + at + "]:");
            at++;
            out.annotate("    name_idx: " + Hex.u4(nameIdx) + " // " +
                    name.toHuman());
        }

        out.writeUleb128(nameIdx);

        if (annotates) {
            out.annotate("    value: " + constantToHuman(value));
        }

        writeConstant(value);
    }

    if (annotates) {
        out.endAnnotation();
    }
}
 
Example 7
Source File: ValueEncoder.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
/**
 * Writes out the encoded form of the given annotation, that is,
 * as an {@code encoded_annotation} and not including a
 * {@code value_type} prefix. If the output stream keeps
 * (debugging) annotations and {@code topLevel} is
 * {@code true}, then this method will write (debugging)
 * annotations.
 *
 * @param annotation {@code non-null;} annotation instance to write
 * @param topLevel {@code true} iff the given annotation is the
 * top-level annotation or {@code false} if it is a sub-annotation
 * of some other annotation
 */
public void writeAnnotation(Annotation annotation, boolean topLevel) {
    boolean annotates = topLevel && out.annotates();
    StringIdsSection stringIds = file.getStringIds();
    TypeIdsSection typeIds = file.getTypeIds();

    CstType type = annotation.getType();
    int typeIdx = typeIds.indexOf(type);

    if (annotates) {
        out.annotate("  type_idx: " + Hex.u4(typeIdx) + " // " +
                type.toHuman());
    }

    out.writeUleb128(typeIds.indexOf(annotation.getType()));

    Collection<NameValuePair> pairs = annotation.getNameValuePairs();
    int size = pairs.size();

    if (annotates) {
        out.annotate("  size: " + Hex.u4(size));
    }

    out.writeUleb128(size);

    int at = 0;
    for (NameValuePair pair : pairs) {
        CstString name = pair.getName();
        int nameIdx = stringIds.indexOf(name);
        Constant value = pair.getValue();

        if (annotates) {
            out.annotate(0, "  elements[" + at + "]:");
            at++;
            out.annotate("    name_idx: " + Hex.u4(nameIdx) + " // " +
                    name.toHuman());
        }

        out.writeUleb128(nameIdx);

        if (annotates) {
            out.annotate("    value: " + constantToHuman(value));
        }

        writeConstant(value);
    }

    if (annotates) {
        out.endAnnotation();
    }
}
 
Example 8
Source File: ValueEncoder.java    From buck with Apache License 2.0 4 votes vote down vote up
/**
 * Writes out the encoded form of the given annotation, that is,
 * as an {@code encoded_annotation} and not including a
 * {@code value_type} prefix. If the output stream keeps
 * (debugging) annotations and {@code topLevel} is
 * {@code true}, then this method will write (debugging)
 * annotations.
 *
 * @param annotation {@code non-null;} annotation instance to write
 * @param topLevel {@code true} iff the given annotation is the
 * top-level annotation or {@code false} if it is a sub-annotation
 * of some other annotation
 */
public void writeAnnotation(Annotation annotation, boolean topLevel) {
    boolean annotates = topLevel && out.annotates();
    StringIdsSection stringIds = file.getStringIds();
    TypeIdsSection typeIds = file.getTypeIds();

    CstType type = annotation.getType();
    int typeIdx = typeIds.indexOf(type);

    if (annotates) {
        out.annotate("  type_idx: " + Hex.u4(typeIdx) + " // " +
                type.toHuman());
    }

    out.writeUleb128(typeIds.indexOf(annotation.getType()));

    Collection<NameValuePair> pairs = annotation.getNameValuePairs();
    int size = pairs.size();

    if (annotates) {
        out.annotate("  size: " + Hex.u4(size));
    }

    out.writeUleb128(size);

    int at = 0;
    for (NameValuePair pair : pairs) {
        CstString name = pair.getName();
        int nameIdx = stringIds.indexOf(name);
        Constant value = pair.getValue();

        if (annotates) {
            out.annotate(0, "  elements[" + at + "]:");
            at++;
            out.annotate("    name_idx: " + Hex.u4(nameIdx) + " // " +
                    name.toHuman());
        }

        out.writeUleb128(nameIdx);

        if (annotates) {
            out.annotate("    value: " + constantToHuman(value));
        }

        writeConstant(value);
    }

    if (annotates) {
        out.endAnnotation();
    }
}