mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
DB-1283 corrected copyField to preserve null state for PrimitiveField's
This commit is contained in:
parent
497fe46d19
commit
17c6f5b1e8
9 changed files with 38 additions and 1 deletions
|
@ -188,6 +188,11 @@ public class BinaryField extends Field {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryField copyField() {
|
public BinaryField copyField() {
|
||||||
|
if (isNull()) {
|
||||||
|
BinaryField copy = new BinaryField();
|
||||||
|
copy.setNull();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
return new BinaryField(getBinaryData().clone());
|
return new BinaryField(getBinaryData().clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,11 @@ public final class BooleanField extends PrimitiveField {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BooleanField copyField() {
|
public BooleanField copyField() {
|
||||||
|
if (isNull()) {
|
||||||
|
BooleanField copy = new BooleanField();
|
||||||
|
copy.setNull();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
return new BooleanField(getLongValue() != 0);
|
return new BooleanField(getLongValue() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,11 @@ public final class ByteField extends PrimitiveField {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ByteField copyField() {
|
public ByteField copyField() {
|
||||||
|
if (isNull()) {
|
||||||
|
ByteField copy = new ByteField();
|
||||||
|
copy.setNull();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
return new ByteField((byte) getLongValue());
|
return new ByteField((byte) getLongValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,11 @@ public class FixedField10 extends FixedField {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FixedField copyField() {
|
public FixedField copyField() {
|
||||||
|
if (isNull()) {
|
||||||
|
FixedField10 copy = new FixedField10();
|
||||||
|
copy.setNull();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
return new FixedField10(hi8, lo2, false);
|
return new FixedField10(hi8, lo2, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ class IndexField extends Field {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexField copyField() {
|
public IndexField copyField() { // null state not supported
|
||||||
return new IndexField(indexedField.copyField(), primaryKey.copyField());
|
return new IndexField(indexedField.copyField(), primaryKey.copyField());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,11 @@ public final class IntField extends PrimitiveField {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IntField copyField() {
|
public IntField copyField() {
|
||||||
|
if (isNull()) {
|
||||||
|
IntField copy = new IntField();
|
||||||
|
copy.setNull();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
return new IntField((int) getLongValue());
|
return new IntField((int) getLongValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,11 @@ public final class LongField extends PrimitiveField {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongField copyField() {
|
public LongField copyField() {
|
||||||
|
if (isNull()) {
|
||||||
|
LongField copy = new LongField();
|
||||||
|
copy.setNull();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
return new LongField(getLongValue());
|
return new LongField(getLongValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,11 @@ public final class ShortField extends PrimitiveField {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShortField copyField() {
|
public ShortField copyField() {
|
||||||
|
if (isNull()) {
|
||||||
|
ShortField copy = new ShortField();
|
||||||
|
copy.setNull();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
return new ShortField((short) getLongValue());
|
return new ShortField((short) getLongValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,7 @@ public class DBFixedKeySparseIndexedTableTest extends AbstractGenericTest {
|
||||||
// all fields correspond to a sparse columns and
|
// all fields correspond to a sparse columns and
|
||||||
// should have a null state initially
|
// should have a null state initially
|
||||||
assertTrue(f.isNull());
|
assertTrue(f.isNull());
|
||||||
|
assertTrue(f.copyField().isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < cnt) {
|
if (i < cnt) {
|
||||||
|
@ -254,6 +255,7 @@ public class DBFixedKeySparseIndexedTableTest extends AbstractGenericTest {
|
||||||
for (int n = columnIndex + 1; n < cnt; n++) {
|
for (int n = columnIndex + 1; n < cnt; n++) {
|
||||||
Field f = r.getField(n);
|
Field f = r.getField(n);
|
||||||
assertTrue(f.isNull());
|
assertTrue(f.isNull());
|
||||||
|
assertTrue(f.copyField().isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
++recordIndex;
|
++recordIndex;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue