Skip to content

Commit

Permalink
#11 DEX format - rename items
Browse files Browse the repository at this point in the history
  • Loading branch information
amosshi committed Aug 16, 2021
1 parent 7ac8c87 commit 196aa88
Show file tree
Hide file tree
Showing 16 changed files with 445 additions and 372 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ public String getText() {
public Icon getIcon() {
return this.icon;
}

/**
* Setter for {@link #icon}.
*
* @param icon value for {@link #icon}
*/
public void setIcon(Icon icon) {
this.icon = icon;
}

/**
* Setter for {@link #description}.
Expand Down Expand Up @@ -176,7 +185,7 @@ public String getDescription() {
public void setDetailPanel(final JPanel p) {
this.panelDetail = p;
}

/**
* Indicates whether we have a detailed panel {@link #panelDetail}.
*
Expand Down
46 changes: 22 additions & 24 deletions FormatDEX/src/main/java/org/freeinternals/format/dex/DexFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
import java.util.SortedMap;
import java.util.TreeMap;
import javax.swing.tree.DefaultMutableTreeNode;
import org.freeinternals.biv.ui.dex.TreeNodeGenerator;
import org.freeinternals.commonlib.core.FileComponent;
import org.freeinternals.commonlib.core.FileFormat;
import org.freeinternals.commonlib.core.PosByteArrayInputStream;
import org.freeinternals.commonlib.core.PosDataInputStream;
import org.freeinternals.commonlib.core.BytesTool;
import org.freeinternals.commonlib.core.FileFormatException;
import org.freeinternals.format.dex.HeaderItem.Endian;
import org.freeinternals.format.dex.header_item.Endian;

/**
*
Expand Down Expand Up @@ -67,17 +66,16 @@ public class DexFile extends FileFormat {
/**
* The file header.
*/
public HeaderItem header;
public header_item header;
/**
* String identifiers list, or <code>null</code> if
* {@link HeaderItem#string_ids_off} is <code>0</code>.
* String identifiers list, or <code>null{@link header_item#string_ids_off} is <code>0
*/
public StringIdItem[] string_ids;
public TypeIdItem[] type_ids;
public ProtoIdItem[] proto_ids;
public FieldIdItem[] field_ids;
public MethodIdItem[] method_ids;
public ClassDefItem[] class_defs;
public string_id_item[] string_ids;
public type_id_item[] type_ids;
public proto_id_item[] proto_ids;
public field_id_item[] field_ids;
public method_id_item[] method_ids;
public class_def_item[] class_defs;
// public Dex_ubyte[] data;
/**
* The parsed file components.
Expand Down Expand Up @@ -172,16 +170,16 @@ private void parse() throws IOException, FileFormatException {
// Header
BytesTool.skip(stream, DEX_FILE_MAGIC1.size());
BytesTool.skip(stream, DEX_FILE_MAGIC2.size());
this.header = new HeaderItem(stream);
this.header = new header_item(stream);

// string_ids
if (this.header.string_ids_off.intValue() == 0) {
this.string_ids = null;
} else {
stream.flyTo(this.header.string_ids_off.intValue());
this.string_ids = new StringIdItem[this.header.string_ids_size.intValue()];
this.string_ids = new string_id_item[this.header.string_ids_size.intValue()];
for (int i = 0; i < this.string_ids.length; i++) {
this.string_ids[i] = new StringIdItem(stream);
this.string_ids[i] = new string_id_item(stream);
todoData.put(this.string_ids[i].string_data_off.value, StringDataItem.class);
}
}
Expand All @@ -191,9 +189,9 @@ private void parse() throws IOException, FileFormatException {
this.type_ids = null;
} else {
stream.flyTo(this.header.type_ids_off.intValue());
this.type_ids = new TypeIdItem[this.header.type_ids_size.intValue()];
this.type_ids = new type_id_item[this.header.type_ids_size.intValue()];
for (int i = 0; i < this.type_ids.length; i++) {
this.type_ids[i] = new TypeIdItem(stream);
this.type_ids[i] = new type_id_item(stream);
}
}

Expand All @@ -202,9 +200,9 @@ private void parse() throws IOException, FileFormatException {
this.proto_ids = null;
} else {
stream.flyTo(this.header.proto_ids_off.intValue());
this.proto_ids = new ProtoIdItem[this.header.proto_ids_size.intValue()];
this.proto_ids = new proto_id_item[this.header.proto_ids_size.intValue()];
for (int i = 0; i < this.proto_ids.length; i++) {
this.proto_ids[i] = new ProtoIdItem(stream);
this.proto_ids[i] = new proto_id_item(stream);
}
}

Expand All @@ -213,9 +211,9 @@ private void parse() throws IOException, FileFormatException {
this.field_ids = null;
} else {
stream.flyTo(this.header.field_ids_off.intValue());
this.field_ids = new FieldIdItem[this.header.field_ids_size.intValue()];
this.field_ids = new field_id_item[this.header.field_ids_size.intValue()];
for (int i = 0; i < this.field_ids.length; i++) {
this.field_ids[i] = new FieldIdItem(stream);
this.field_ids[i] = new field_id_item(stream);
}
}

Expand All @@ -224,9 +222,9 @@ private void parse() throws IOException, FileFormatException {
this.method_ids = null;
} else {
stream.flyTo(this.header.method_ids_off.intValue());
this.method_ids = new MethodIdItem[this.header.method_ids_size.intValue()];
this.method_ids = new method_id_item[this.header.method_ids_size.intValue()];
for (int i = 0; i < this.method_ids.length; i++) {
this.method_ids[i] = new MethodIdItem(stream);
this.method_ids[i] = new method_id_item(stream);
}
}

Expand All @@ -235,9 +233,9 @@ private void parse() throws IOException, FileFormatException {
this.class_defs = null;
} else {
stream.flyTo(this.header.class_defs_off.intValue());
this.class_defs = new ClassDefItem[this.header.class_defs_size.intValue()];
this.class_defs = new class_def_item[this.header.class_defs_size.intValue()];
for (int i = 0; i < this.class_defs.length; i++) {
this.class_defs[i] = new ClassDefItem(stream);
this.class_defs[i] = new class_def_item(stream);
}
}

Expand Down
166 changes: 0 additions & 166 deletions FormatDEX/src/main/java/org/freeinternals/format/dex/HeaderItem.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.freeinternals.commonlib.core.PosByteArrayInputStream;
import org.freeinternals.commonlib.core.PosDataInputStream;
import org.freeinternals.commonlib.core.FileFormatException;
import org.freeinternals.format.dex.HeaderItem.Endian;
import org.freeinternals.format.dex.header_item.Endian;

/**
*
Expand All @@ -28,14 +28,14 @@ public class PosDataInputStreamDex extends PosDataInputStream {
* {@link HeaderItem.Endian#ENDIAN_CONSTANT}, as the DEX format
* specification said.
*/
protected final HeaderItem.Endian endian;
protected final header_item.Endian endian;

public PosDataInputStreamDex(PosByteArrayInputStream in) {
super(in);
this.endian = Endian.ENDIAN_CONSTANT;
}

public PosDataInputStreamDex(PosByteArrayInputStream in, HeaderItem.Endian e) {
public PosDataInputStreamDex(PosByteArrayInputStream in, header_item.Endian e) {
super(in);
this.endian = e;
}
Expand Down Expand Up @@ -67,7 +67,7 @@ public Type_ubyte Dex_ubyte() throws IOException {
* @throws java.io.IOException I/O Error
*/
public Type_short Dex_short() throws IOException {
if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) {
if (this.endian == header_item.Endian.ENDIAN_CONSTANT) {
return new Type_short(this.readShort());
} else {
return new Type_short(this.readShortInLittleEndian());
Expand All @@ -81,7 +81,7 @@ public Type_short Dex_short() throws IOException {
* @throws java.io.IOException I/O Error
*/
public Type_ushort Dex_ushort() throws IOException {
if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) {
if (this.endian == header_item.Endian.ENDIAN_CONSTANT) {
return new Type_ushort(this.readUnsignedShort());
} else {
return new Type_ushort(this.readUnsignedShortInLittleEndian());
Expand All @@ -95,7 +95,7 @@ public Type_ushort Dex_ushort() throws IOException {
* @throws java.io.IOException I/O Error
*/
public Type_int Dex_int() throws IOException {
if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) {
if (this.endian == header_item.Endian.ENDIAN_CONSTANT) {
return new Type_int(this.readInt());
} else {
return new Type_int(this.readIntInLittleEndian());
Expand All @@ -109,7 +109,7 @@ public Type_int Dex_int() throws IOException {
* @throws java.io.IOException I/O Error
*/
public Type_uint Dex_uint() throws IOException {
if (this.endian.value == HeaderItem.Endian.ENDIAN_CONSTANT.value) {
if (this.endian.value == header_item.Endian.ENDIAN_CONSTANT.value) {
return new Type_uint(this.readUnsignedInt());
} else {
return new Type_uint(this.readUnsignedIntInLittleEndian());
Expand All @@ -123,7 +123,7 @@ public Type_uint Dex_uint() throws IOException {
* @throws java.io.IOException I/O Error
*/
public Type_long Dex_long() throws IOException {
if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) {
if (this.endian == header_item.Endian.ENDIAN_CONSTANT) {
return new Type_long(this.readLong());
} else {
return new Type_long(this.readLongInLittleEndian());
Expand All @@ -137,7 +137,7 @@ public Type_long Dex_long() throws IOException {
* @throws java.io.IOException I/O Error
*/
public Type_ulong Dex_ulong() throws IOException {
if (this.endian == HeaderItem.Endian.ENDIAN_CONSTANT) {
if (this.endian == header_item.Endian.ENDIAN_CONSTANT) {
return new Type_ulong(this.readUnsignedLong());
} else {
return new Type_ulong(this.readUnsignedLongInLittleEndian());
Expand Down
Loading

0 comments on commit 196aa88

Please sign in to comment.