com.android.dx.dex.file
Class ValueEncoder

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

public final class ValueEncoder
extends Object

Handler for writing out encoded_values and parts thereof.


Constructor Summary
ValueEncoder(DexFile file, AnnotatedOutput out)
          Construct an instance.
 
Method Summary
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.
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.
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.
 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.
 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.
 void writeConstant(Constant cst)
          Writes out the encoded form of the given constant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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


Copyright © 2015. All rights reserved.