19 package org.sleuthkit.autopsy.datasourceprocessors.xry;
30 class XRYKeyValuePair {
32 private static final char KEY_VALUE_DELIMITER =
':';
34 private final String key;
35 private final String value;
36 private final String
namespace;
38 XRYKeyValuePair(String key, String value, String
namespace) {
39 this.key = key.trim();
40 this.value = value.trim();
41 this.
namespace = namespace.trim();
52 boolean hasKey(String targetKey) {
53 String normalizedKey = key.toLowerCase();
54 String normalizedTargetKey = targetKey.trim().toLowerCase();
55 return normalizedKey.equals(normalizedTargetKey);
75 String getNamespace() {
84 static boolean isPair(String input) {
85 int dataKeyIndex = input.indexOf(KEY_VALUE_DELIMITER);
87 return dataKeyIndex != -1;
100 static XRYKeyValuePair from(String input, String
namespace) {
102 throw new IllegalArgumentException(
"Input does not have the structure"
103 +
" of a key value pair");
106 int keyIndex = input.indexOf(KEY_VALUE_DELIMITER);
107 String parsedKey = input.substring(0, keyIndex);
108 String parsedValue = input.substring(keyIndex + 1);
109 return new XRYKeyValuePair(parsedKey, parsedValue,
namespace);
121 static XRYKeyValuePair from(String input) {
122 return from(input,
"");
126 public String toString() {
127 if(
namespace.isEmpty()) {
128 return key +
" : " + value;
130 return "(Namespace: " +
namespace +") " + key + " : " + value;