com.android.dx.dex.file
Class DexFile

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

public final class DexFile
extends Object

Representation of an entire .dex (Dalvik EXecutable) file, which itself consists of a set of Dalvik classes.


Constructor Summary
DexFile(DexOptions dexOptions)
          Constructs an instance.
 
Method Summary
 void add(ClassDefItem clazz)
          Adds a class to this instance.
 ClassDefItem getClassOrNull(String name)
          Gets the class definition with the given name, if any.
 DexOptions getDexOptions()
          Gets the dex-creation options object.
 Statistics getStatistics()
          Generates and returns statistics for all the items in the file.
 boolean isEmpty()
          Returns true if this dex doesn't contain any class defs.
 void setDumpWidth(int dumpWidth)
          Sets the maximum width of the human-oriented dump of the instance.
 byte[] toDex(Writer humanOut, boolean verbose)
          Returns the contents of this instance as a .dex file, in byte[] form.
 void writeTo(OutputStream out, Writer humanOut, boolean verbose)
          Writes the contents of this instance as either a binary or a human-readable form, or both.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DexFile

public DexFile(DexOptions dexOptions)
Constructs an instance. It is initially empty.

Method Detail

isEmpty

public boolean isEmpty()
Returns true if this dex doesn't contain any class defs.


getDexOptions

public DexOptions getDexOptions()
Gets the dex-creation options object.


add

public void add(ClassDefItem clazz)
Adds a class to this instance. It is illegal to attempt to add more than one class with the same name.

Parameters:
clazz - non-null; the class to add

getClassOrNull

public ClassDefItem getClassOrNull(String name)
Gets the class definition with the given name, if any.

Parameters:
name - non-null; the class name to look for
Returns:
null-ok; the class with the given name, or null if there is no such class

writeTo

public void writeTo(OutputStream out,
                    Writer humanOut,
                    boolean verbose)
             throws IOException
Writes the contents of this instance as either a binary or a human-readable form, or both.

Parameters:
out - null-ok; where to write to
humanOut - null-ok; where to write human-oriented output to
verbose - whether to be verbose when writing human-oriented output
Throws:
IOException

toDex

public byte[] toDex(Writer humanOut,
                    boolean verbose)
             throws IOException
Returns the contents of this instance as a .dex file, in byte[] form.

Parameters:
humanOut - null-ok; where to write human-oriented output to
verbose - whether to be verbose when writing human-oriented output
Returns:
non-null; a .dex file for this instance
Throws:
IOException

setDumpWidth

public void setDumpWidth(int dumpWidth)
Sets the maximum width of the human-oriented dump of the instance.

Parameters:
dumpWidth - >= 40; the width

getStatistics

public Statistics getStatistics()
Generates and returns statistics for all the items in the file.

Returns:
non-null; the statistics


Copyright © 2013. All Rights Reserved.