19 package org.sleuthkit.datamodel;
21 import java.util.Arrays;
22 import java.util.Objects;
30 private static final char[] HEX_ARRAY =
"0123456789ABCDEF".toCharArray();
34 private final int valueInt;
35 private final long valueLong;
36 private final double valueDouble;
37 private final String valueString;
38 private final byte[] valueBytes;
54 throw new IllegalArgumentException(
"Type mismatched with value type");
56 this.attributeType = attributeType;
57 this.valueInt = valueInt;
60 this.valueString =
"";
61 this.valueBytes =
new byte[0];
79 throw new IllegalArgumentException(
"Type mismatched with value type");
81 this.attributeType = attributeType;
83 this.valueLong = valueLong;
85 this.valueString =
"";
86 this.valueBytes =
new byte[0];
101 throw new IllegalArgumentException(
"Type mismatched with value type");
103 this.attributeType = attributeType;
106 this.valueDouble = valueDouble;
107 this.valueString =
"";
108 this.valueBytes =
new byte[0];
124 throw new IllegalArgumentException(
"Type mismatched with value type");
126 this.attributeType = attributeType;
129 this.valueDouble = 0;
130 if (valueString == null) {
131 this.valueString =
"";
133 this.valueString = replaceNulls(valueString).trim();
135 this.valueBytes =
new byte[0];
150 throw new IllegalArgumentException(
"Type mismatched with value type");
152 this.attributeType = attributeType;
155 this.valueDouble = 0;
156 this.valueString =
"";
157 if (valueBytes == null) {
158 this.valueBytes =
new byte[0];
160 this.valueBytes = valueBytes;
178 int valueInt,
long valueLong,
double valueDouble, String valueString, byte[] valueBytes,
181 this.attributeType = attributeType;
182 this.valueInt = valueInt;
183 this.valueLong = valueLong;
184 this.valueDouble = valueDouble;
185 if (valueString == null) {
186 this.valueString =
"";
188 this.valueString = replaceNulls(valueString).trim();
190 if (valueBytes == null) {
191 this.valueBytes =
new byte[0];
193 this.valueBytes = valueBytes;
195 this.sleuthkitCase = sleuthkitCase;
238 return this.attributeType;
298 return Arrays.copyOf(valueBytes, valueBytes.length);
308 return this.sleuthkitCase;
317 void setCaseDatabase(SleuthkitCase sleuthkitCase) {
318 this.sleuthkitCase = sleuthkitCase;
328 static String bytesToHexString(byte[] bytes) {
330 char[] hexChars =
new char[bytes.length * 2];
331 for (
int j = 0; j < bytes.length; j++) {
332 int v = bytes[j] & 0xFF;
333 hexChars[j * 2] = HEX_ARRAY[v >>> 4];
334 hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
336 return new String(hexChars);
346 static String replaceNulls(String text) {
347 return text.replace((
char) 0x00, (
char) 0x1A);
358 boolean areValuesEqual(Object that) {
363 Object[] otherObject =
new Object[]{other.getAttributeType(), other.getValueInt(), other.getValueLong(), other.getValueDouble(),
364 other.getValueString(), other.getValueBytes()};
365 return Objects.deepEquals(thisObject, otherObject);
static String epochToTime(long epoch)
BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE getValueType()
AbstractAttribute(BlackboardAttribute.Type attributeType, int valueInt)
AbstractAttribute(BlackboardAttribute.Type attributeType, long valueLong)
AbstractAttribute(BlackboardAttribute.Type attributeType, double valueDouble)
AbstractAttribute(BlackboardAttribute.Type attributeType, byte[] valueBytes)
String getDisplayString()
AbstractAttribute(BlackboardAttribute.Type attributeType, String valueString)
BlackboardAttribute.Type getAttributeType()