Class ValueEncoder

java.lang.Object
com.android.dx.dex.file.ValueEncoder

public final class ValueEncoder extends Object
Handler for writing out encoded_values and parts thereof.
  • Constructor Details

    • ValueEncoder

      public ValueEncoder(DexFile file, AnnotatedOutput out)
      Construct an instance.
      Parameters:
      file - non-null; file being written
      out - non-null; output stream to write to
  • Method Details

    • writeConstant

      public void writeConstant(Constant cst)
      Writes out the encoded form of the given constant.
      Parameters:
      cst - non-null; the constant to write
    • writeArray

      public void writeArray(CstArray array, boolean topLevel)
      Writes out the encoded form of the given array, that is, as an encoded_array and not including a value_type prefix. If the output stream keeps (debugging) annotations and topLevel is true, then this method will write (debugging) annotations.
      Parameters:
      array - non-null; array instance to write
      topLevel - true iff the given annotation is the top-level annotation or false if it is a sub-annotation of some other annotation
    • writeAnnotation

      public void writeAnnotation(Annotation annotation, boolean topLevel)
      Writes out the encoded form of the given annotation, that is, as an encoded_annotation and not including a value_type prefix. If the output stream keeps (debugging) annotations and topLevel is true, then this method will write (debugging) annotations.
      Parameters:
      annotation - non-null; annotation instance to write
      topLevel - true iff the given annotation is the top-level annotation or false if it is a sub-annotation of some other annotation
    • constantToHuman

      public static String constantToHuman(Constant cst)
      Gets the colloquial type name and human form of the type of the given constant, when used as an encoded value.
      Parameters:
      cst - non-null; the constant
      Returns:
      non-null; its type name and human form
    • addContents

      public static void addContents(DexFile file, Annotation annotation)
      Helper for addContents() methods, which adds contents for a particular Annotation, calling itself recursively should it encounter a nested annotation.
      Parameters:
      file - non-null; the file to add to
      annotation - non-null; the annotation to add contents for
    • addContents

      public static void addContents(DexFile file, Constant cst)
      Helper for addContents() methods, which adds contents for a particular constant, calling itself recursively should it encounter a CstArray and calling addContents(DexFile,Annotation) recursively should it encounter a CstAnnotation.
      Parameters:
      file - non-null; the file to add to
      cst - non-null; the constant to add contents for