com.android.dx.command.dump
Class BaseDumper

java.lang.Object
  extended by com.android.dx.command.dump.BaseDumper
All Implemented Interfaces:
ParseObserver
Direct Known Subclasses:
BlockDumper, ClassDumper

public abstract class BaseDumper
extends Object
implements ParseObserver

Base class for the various human-friendly dumpers.


Field Summary
protected  com.android.dx.command.dump.Args args
          commandline parsedArgs
 
Constructor Summary
BaseDumper(byte[] bytes, PrintStream out, String filePath, com.android.dx.command.dump.Args args)
          Constructs an instance.
 
Method Summary
 void changeIndent(int indentDelta)
          Indicate that the level of indentation for a dump should increase or decrease (positive or negative argument, respectively).
 void endParsingMember(ByteArray bytes, int offset, String name, String descriptor, Member member)
          Indicate that a particular member is no longer being parsed.
protected  int getAt()
          Gets the current dump cursor (that is, the offset of the expected next byte to dump).
protected  byte[] getBytes()
          Gets the array of bytes to process.
protected  String getFilePath()
          Gets the filesystem/jar path of the file being dumped.
protected  boolean getRawBytes()
          Gets whether this dump is to include raw bytes.
protected  boolean getStrictParse()
          Gets whether to be strict about parsing.
protected  int getWidth1()
          Gets the width of the first column of output.
protected  int getWidth2()
          Gets the width of the second column of output.
protected  String hexDump(int offset, int len)
          Constructs a hex data dump of the given portion of bytes.
 void parsed(ByteArray bytes, int offset, int len, String human)
          Indicate that some parsing happened.
protected  void print(String s)
          Prints the given string to this instance's output stream.
protected  void println(String s)
          Prints the given string to this instance's output stream, followed by a newline.
protected  void setAt(ByteArray arr, int offset)
          Sets the dump cursor to the indicated offset in the given array.
 void startParsingMember(ByteArray bytes, int offset, String name, String descriptor)
          Indicate that a particular member is now being parsed.
protected  String twoColumns(String s1, String s2)
          Combines a pair of strings as two columns, or if this is one-column output, format the otherwise-second column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

args

protected com.android.dx.command.dump.Args args
commandline parsedArgs

Constructor Detail

BaseDumper

public BaseDumper(byte[] bytes,
                  PrintStream out,
                  String filePath,
                  com.android.dx.command.dump.Args args)
Constructs an instance.

Parameters:
bytes - non-null; bytes of the (alleged) class file on the left)
out - non-null; where to dump to
filePath - the file path for the class, excluding any base directory specification
Method Detail

changeIndent

public void changeIndent(int indentDelta)
Indicate that the level of indentation for a dump should increase or decrease (positive or negative argument, respectively).

Specified by:
changeIndent in interface ParseObserver
Parameters:
indentDelta - the amount to change indentation

parsed

public void parsed(ByteArray bytes,
                   int offset,
                   int len,
                   String human)
Indicate that some parsing happened.

Specified by:
parsed in interface ParseObserver
Parameters:
bytes - non-null; the source that was parsed
offset - offset into bytes for what was parsed
len - number of bytes parsed
human - non-null; human form for what was parsed

startParsingMember

public void startParsingMember(ByteArray bytes,
                               int offset,
                               String name,
                               String descriptor)
Indicate that a particular member is now being parsed.

Specified by:
startParsingMember in interface ParseObserver
Parameters:
bytes - non-null; the source that is being parsed
offset - offset into bytes for the start of the member
name - non-null; name of the member
descriptor - non-null; descriptor of the member

endParsingMember

public void endParsingMember(ByteArray bytes,
                             int offset,
                             String name,
                             String descriptor,
                             Member member)
Indicate that a particular member is no longer being parsed.

Specified by:
endParsingMember in interface ParseObserver
Parameters:
bytes - non-null; the source that was parsed
offset - offset into bytes for the end of the member
name - non-null; name of the member
descriptor - non-null; descriptor of the member
member - non-null; the actual member that was parsed

getAt

protected final int getAt()
Gets the current dump cursor (that is, the offset of the expected next byte to dump).

Returns:
>= 0; the dump cursor

setAt

protected final void setAt(ByteArray arr,
                           int offset)
Sets the dump cursor to the indicated offset in the given array.

Parameters:
arr - non-null; array in question
offset - >= 0; offset into the array

getBytes

protected final byte[] getBytes()
Gets the array of bytes to process.

Returns:
non-null; the bytes

getFilePath

protected final String getFilePath()
Gets the filesystem/jar path of the file being dumped.

Returns:
non-null; the path

getStrictParse

protected final boolean getStrictParse()
Gets whether to be strict about parsing.

Returns:
whether to be strict about parsing

print

protected final void print(String s)
Prints the given string to this instance's output stream.

Parameters:
s - null-ok; string to print

println

protected final void println(String s)
Prints the given string to this instance's output stream, followed by a newline.

Parameters:
s - null-ok; string to print

getRawBytes

protected final boolean getRawBytes()
Gets whether this dump is to include raw bytes.

Returns:
the raw bytes flag

getWidth1

protected final int getWidth1()
Gets the width of the first column of output. This is 0 unless raw bytes are being included in the output.

Returns:
>= 0; the width of the first column

getWidth2

protected final int getWidth2()
Gets the width of the second column of output.

Returns:
>= 0; the width of the second column

hexDump

protected final String hexDump(int offset,
                               int len)
Constructs a hex data dump of the given portion of bytes.

Parameters:
offset - offset to start dumping at
len - length to dump
Returns:
non-null; the dump

twoColumns

protected final String twoColumns(String s1,
                                  String s2)
Combines a pair of strings as two columns, or if this is one-column output, format the otherwise-second column.

Parameters:
s1 - non-null; the first column's string
s2 - non-null; the second column's string
Returns:
non-null; the combined output


Copyright © 2015. All rights reserved.