mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-1068 revised null state for primitive and fixed-length fields for
sparse records
This commit is contained in:
parent
0cba2319fb
commit
7a43d3bdf1
15 changed files with 477 additions and 179 deletions
74
Ghidra/Framework/DB/src/main/java/db/PrimitiveField.java
Normal file
74
Ghidra/Framework/DB/src/main/java/db/PrimitiveField.java
Normal file
|
@ -0,0 +1,74 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package db;
|
||||
|
||||
/**
|
||||
* <code>PrimitiveField</code> provides a base implementation for
|
||||
* all primitive value {@link Field}s.
|
||||
* <br>
|
||||
* When a {@link PrimitiveField} associated with a {@link SparseRecord}
|
||||
* has a null state it will have a zero (0) value.
|
||||
*/
|
||||
abstract class PrimitiveField extends Field {
|
||||
|
||||
private boolean isNull = false;
|
||||
|
||||
/**
|
||||
* Abstract PrimitiveField Constructor for a mutable instance
|
||||
*/
|
||||
PrimitiveField() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract PrimitiveField Constructor
|
||||
* @param immutable true if field value is immutable
|
||||
*/
|
||||
PrimitiveField(boolean immutable) {
|
||||
super(immutable);
|
||||
}
|
||||
|
||||
@Override
|
||||
final boolean isNull() {
|
||||
return isNull;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setNull() {
|
||||
checkImmutable();
|
||||
this.isNull = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked prior to setting the field's primitive value this
|
||||
* method will perform an immutable check and set to a non-null
|
||||
* state.
|
||||
*/
|
||||
final void updatingPrimitiveValue() {
|
||||
checkImmutable();
|
||||
this.isNull = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String nullState = "";
|
||||
if (isNull()) {
|
||||
nullState = "(NULL)";
|
||||
}
|
||||
return getClass().getSimpleName() + nullState + ": " + getValueAsString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue