Package com.android.dx.command.dump
Class BaseDumper
java.lang.Object
com.android.dx.command.dump.BaseDumper
- All Implemented Interfaces:
ParseObserver
- Direct Known Subclasses:
BlockDumper
,ClassDumper
Base class for the various human-friendly dumpers.
-
Field Summary
Modifier and TypeFieldDescriptionprotected com.android.dx.command.dump.Args
commandline parsedArgsprotected final DexOptions
non-null;
options for dex output, always set to the defaults for now -
Constructor Summary
ConstructorDescriptionBaseDumper
(byte[] bytes, PrintStream out, String filePath, com.android.dx.command.dump.Args args) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 final byte[]
getBytes()
Gets the array ofbyte
s to process.protected final String
Gets the filesystem/jar path of the file being dumped.protected final boolean
Gets whether this dump is to include raw bytes.protected final int
Gets the current number of read bytes.protected final boolean
Gets whether to be strict about parsing.protected final int
Gets the width of the first column of output.protected final int
Gets the width of the second column of output.protected final String
hexDump
(int offset, int len) Constructs a hex data dump of the given portion ofbytes
.void
Indicate that some parsing happened.protected final void
Prints the given string to this instance's output stream.protected final void
Prints the given string to this instance's output stream, followed by a newline.void
startParsingMember
(ByteArray bytes, int offset, String name, String descriptor) Indicate that a particular member is now being parsed.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.
-
Field Details
-
args
protected com.android.dx.command.dump.Args argscommandline parsedArgs -
dexOptions
non-null;
options for dex output, always set to the defaults for now
-
-
Constructor Details
-
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 tofilePath
- the file path for the class, excluding any base directory specification
-
-
Method Details
-
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 interfaceParseObserver
- Parameters:
indentDelta
- the amount to change indentation
-
parsed
Indicate that some parsing happened.- Specified by:
parsed
in interfaceParseObserver
- Parameters:
bytes
-non-null;
the source that was parsedoffset
- offset intobytes
for what was parsedlen
- number of bytes parsedhuman
-non-null;
human form for what was parsed
-
startParsingMember
Indicate that a particular member is now being parsed.- Specified by:
startParsingMember
in interfaceParseObserver
- Parameters:
bytes
-non-null;
the source that is being parsedoffset
- offset intobytes
for the start of the membername
-non-null;
name of the memberdescriptor
-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 interfaceParseObserver
- Parameters:
bytes
-non-null;
the source that was parsedoffset
- offset intobytes
for the end of the membername
-non-null;
name of the memberdescriptor
-non-null;
descriptor of the membermember
-non-null;
the actual member that was parsed
-
getReadBytes
protected final int getReadBytes()Gets the current number of read bytes.- Returns:
>= 0;
the dump cursor
-
getBytes
protected final byte[] getBytes()Gets the array ofbyte
s to process.- Returns:
non-null;
the bytes
-
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
Prints the given string to this instance's output stream.- Parameters:
s
-null-ok;
string to print
-
println
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 is0
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
Constructs a hex data dump of the given portion ofbytes
.- Parameters:
offset
- offset to start dumping atlen
- length to dump- Returns:
non-null;
the dump
-
twoColumns
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 strings2
-non-null;
the second column's string- Returns:
non-null;
the combined output
-