GT-3294 Added support for sparse DB schemas. No need to version

ProgramUserData which does not utilize index tables
This commit is contained in:
ghidra1 2020-07-17 23:49:12 -04:00
parent fcb3151f94
commit 6783ae669f
34 changed files with 1306 additions and 379 deletions

View file

@ -22,7 +22,8 @@ import generic.util.UnsignedDataUtils;
import ghidra.util.BigEndianDataConverter;
/**
* <code>FixedField10</code> is a 10-byte fixed-length binary field.
* <code>FixedField10</code> provide an unsigned 10-byte fixed-length field value.
* The most-significant byte corresponds to index-0 (i.e., data[0]).
*/
public class FixedField10 extends FixedField {
@ -36,11 +37,16 @@ public class FixedField10 extends FixedField {
*/
public static FixedField10 MAX_VALUE = new FixedField10(-1L, (short) -1, true);
/**
* Zero fixed10 field value
*/
public static final FixedField10 ZERO_VALUE = new FixedField10(null, true);
/**
* Instance intended for defining a {@link Table} {@link Schema}
*/
@SuppressWarnings("hiding")
public static final FixedField10 INSTANCE = MIN_VALUE;
public static final FixedField10 INSTANCE = ZERO_VALUE;
// This implementation uses both a data byte array and short+long variables
// for data storage. While the short+long is always available, the data
@ -83,6 +89,11 @@ public class FixedField10 extends FixedField {
this.lo2 = lo2;
}
@Override
boolean isNull() {
return hi8 == 0 && lo2 == 0;
}
@Override
public int compareTo(Field o) {
if (!(o instanceof FixedField10)) {
@ -144,10 +155,15 @@ public class FixedField10 extends FixedField {
@Override
public void setBinaryData(byte[] data) {
this.data = data;
if (data == null) {
hi8 = 0;
lo2 = 0;
return;
}
if (data.length != 10) {
throw new IllegalArgumentException("Invalid FixedField10 length: " + data.length);
}
this.data = data;
hi8 = BigEndianDataConverter.INSTANCE.getLong(data, 0);
lo2 = BigEndianDataConverter.INSTANCE.getShort(data, 8);
}
@ -195,15 +211,19 @@ public class FixedField10 extends FixedField {
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
FixedField10 other = (FixedField10) obj;
if (hi8 != other.hi8)
if (hi8 != other.hi8) {
return false;
if (lo2 != other.lo2)
}
if (lo2 != other.lo2) {
return false;
}
return true;
}