mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Addressed code review feedback and codacy warnings
This commit is contained in:
parent
945572ef76
commit
13bfb09e20
@ -44,7 +44,7 @@ final class XRYCallsFileParser extends AbstractSingleKeyValueParser {
|
|||||||
/**
|
/**
|
||||||
* All of the known XRY keys for call reports.
|
* All of the known XRY keys for call reports.
|
||||||
*/
|
*/
|
||||||
private static enum XRY_KEY {
|
private enum XryKey {
|
||||||
TEL("tel"),
|
TEL("tel"),
|
||||||
NAME_MATCHED("name (matched)"),
|
NAME_MATCHED("name (matched)"),
|
||||||
TIME("time"),
|
TIME("time"),
|
||||||
@ -57,19 +57,19 @@ final class XRYCallsFileParser extends AbstractSingleKeyValueParser {
|
|||||||
NUMBER("number");
|
NUMBER("number");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
XRY_KEY(String name) {
|
XryKey(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the XRY key is a recognized type.
|
* Indicates if the display name of the XRY key is a recognized type.
|
||||||
*
|
*
|
||||||
* @param xryKey
|
* @param xryKey
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean contains(String xryKey) {
|
public static boolean contains(String xryKey) {
|
||||||
String normalizedKey = xryKey.trim().toLowerCase();
|
String normalizedKey = xryKey.trim().toLowerCase();
|
||||||
for(XRY_KEY keyChoice : XRY_KEY.values()) {
|
for(XryKey keyChoice : XryKey.values()) {
|
||||||
if(keyChoice.name.equals(normalizedKey)) {
|
if(keyChoice.name.equals(normalizedKey)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ final class XRYCallsFileParser extends AbstractSingleKeyValueParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the enum type for the given XRY key.
|
* Matches the display name of the xry key to the appropriate enum type.
|
||||||
*
|
*
|
||||||
* It is assumed that XRY key string is recognized. Otherwise,
|
* It is assumed that XRY key string is recognized. Otherwise,
|
||||||
* an IllegalArgumentException is thrown. Test all membership
|
* an IllegalArgumentException is thrown. Test all membership
|
||||||
@ -88,9 +88,9 @@ final class XRYCallsFileParser extends AbstractSingleKeyValueParser {
|
|||||||
* @param xryKey
|
* @param xryKey
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static XRY_KEY fromName(String xryKey) {
|
public static XryKey fromDisplayName(String xryKey) {
|
||||||
String normalizedKey = xryKey.trim().toLowerCase();
|
String normalizedKey = xryKey.trim().toLowerCase();
|
||||||
for(XRY_KEY keyChoice : XRY_KEY.values()) {
|
for(XryKey keyChoice : XryKey.values()) {
|
||||||
if(keyChoice.name.equals(normalizedKey)) {
|
if(keyChoice.name.equals(normalizedKey)) {
|
||||||
return keyChoice;
|
return keyChoice;
|
||||||
}
|
}
|
||||||
@ -104,25 +104,25 @@ final class XRYCallsFileParser extends AbstractSingleKeyValueParser {
|
|||||||
/**
|
/**
|
||||||
* All known XRY namespaces for call reports.
|
* All known XRY namespaces for call reports.
|
||||||
*/
|
*/
|
||||||
private static enum XRY_NAMESPACE {
|
private enum XryNamespace {
|
||||||
TO("to"),
|
TO("to"),
|
||||||
FROM("from"),
|
FROM("from"),
|
||||||
NONE(null);
|
NONE(null);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
XRY_NAMESPACE(String name) {
|
XryNamespace(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the XRY namespace is a recognized type.
|
* Indicates if the display name of the XRY namespace is a recognized type.
|
||||||
*
|
*
|
||||||
* @param xryNamespace
|
* @param xryNamespace
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean contains(String xryNamespace) {
|
public static boolean contains(String xryNamespace) {
|
||||||
String normalizedNamespace = xryNamespace.trim().toLowerCase();
|
String normalizedNamespace = xryNamespace.trim().toLowerCase();
|
||||||
for(XRY_NAMESPACE keyChoice : XRY_NAMESPACE.values()) {
|
for(XryNamespace keyChoice : XryNamespace.values()) {
|
||||||
if(normalizedNamespace.equals(keyChoice.name)) {
|
if(normalizedNamespace.equals(keyChoice.name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ final class XRYCallsFileParser extends AbstractSingleKeyValueParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the enum type for the given XRY namespace.
|
* Matches the display name of the xry namespace to the appropriate enum type.
|
||||||
*
|
*
|
||||||
* It is assumed that XRY namespace string is recognized. Otherwise,
|
* It is assumed that XRY namespace string is recognized. Otherwise,
|
||||||
* an IllegalArgumentException is thrown. Test all membership
|
* an IllegalArgumentException is thrown. Test all membership
|
||||||
@ -141,9 +141,9 @@ final class XRYCallsFileParser extends AbstractSingleKeyValueParser {
|
|||||||
* @param xryNamespace
|
* @param xryNamespace
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static XRY_NAMESPACE fromName(String xryNamespace) {
|
public static XryNamespace fromName(String xryNamespace) {
|
||||||
String normalizedNamespace = xryNamespace.trim().toLowerCase();
|
String normalizedNamespace = xryNamespace.trim().toLowerCase();
|
||||||
for(XRY_NAMESPACE keyChoice : XRY_NAMESPACE.values()) {
|
for(XryNamespace keyChoice : XryNamespace.values()) {
|
||||||
if(normalizedNamespace.equals(keyChoice.name)) {
|
if(normalizedNamespace.equals(keyChoice.name)) {
|
||||||
return keyChoice;
|
return keyChoice;
|
||||||
}
|
}
|
||||||
@ -156,20 +156,20 @@ final class XRYCallsFileParser extends AbstractSingleKeyValueParser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isKey(String key) {
|
boolean isKey(String key) {
|
||||||
return XRY_KEY.contains(key);
|
return XryKey.contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean isNamespace(String nameSpace) {
|
boolean isNamespace(String nameSpace) {
|
||||||
return XRY_NAMESPACE.contains(nameSpace);
|
return XryNamespace.contains(nameSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Optional<BlackboardAttribute> makeAttribute(String nameSpace, String key, String value) {
|
Optional<BlackboardAttribute> makeAttribute(String nameSpace, String key, String value) {
|
||||||
XRY_KEY xryKey = XRY_KEY.fromName(key);
|
XryKey xryKey = XryKey.fromDisplayName(key);
|
||||||
XRY_NAMESPACE xryNamespace = XRY_NAMESPACE.NONE;
|
XryNamespace xryNamespace = XryNamespace.NONE;
|
||||||
if(XRY_NAMESPACE.contains(nameSpace)) {
|
if(XryNamespace.contains(nameSpace)) {
|
||||||
xryNamespace = XRY_NAMESPACE.fromName(nameSpace);
|
xryNamespace = XryNamespace.fromName(nameSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (xryKey) {
|
switch (xryKey) {
|
||||||
@ -283,7 +283,7 @@ final class XRYCallsFileParser extends AbstractSingleKeyValueParser {
|
|||||||
String reversedDateTime = reverseOrderOfDateTimeComponents(dateTimeWithoutLocale);
|
String reversedDateTime = reverseOrderOfDateTimeComponents(dateTimeWithoutLocale);
|
||||||
/**
|
/**
|
||||||
* Furthermore, the DateTimeFormatter's timezone offset letter ('O') does
|
* Furthermore, the DateTimeFormatter's timezone offset letter ('O') does
|
||||||
* not recognized UTC but recognizes GMT. According to
|
* not recognize UTC but recognizes GMT. According to
|
||||||
* https://en.wikipedia.org/wiki/Coordinated_Universal_Time,
|
* https://en.wikipedia.org/wiki/Coordinated_Universal_Time,
|
||||||
* GMT only differs from UTC by at most 1 second and so substitution
|
* GMT only differs from UTC by at most 1 second and so substitution
|
||||||
* will only introduce a trivial amount of error.
|
* will only introduce a trivial amount of error.
|
||||||
|
@ -116,7 +116,8 @@ final class XRYDeviceGenInfoFileParser implements XRYFileParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the XRY entity and extracts all BlackboardAttributes that are
|
* Parses the XRY entity, extracts key value pairs and creates blackboard
|
||||||
|
* attributes from these key value pairs.
|
||||||
*
|
*
|
||||||
* @param xryEntity
|
* @param xryEntity
|
||||||
* @return A collection of attributes from the XRY entity.
|
* @return A collection of attributes from the XRY entity.
|
||||||
@ -191,11 +192,11 @@ final class XRYDeviceGenInfoFileParser implements XRYFileParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the appropriate BlackboardAttribute given the XRY Key Value pair.
|
* Creates the appropriate blackboard attribute given the XRY Key Value pair.
|
||||||
* If the attribute value is recognized but has no corresponding Blackboard
|
* If the value is recognized but has no corresponding Blackboard
|
||||||
* attribute type, the Optional will be empty.
|
* attribute type, the Optional will be empty.
|
||||||
*
|
*
|
||||||
* An INFO message will be logged for all recognized values that don't have
|
* A WARNING message will be logged for all recognized values that don't have
|
||||||
* a type. More data is needed to make a decision about the appropriate type.
|
* a type. More data is needed to make a decision about the appropriate type.
|
||||||
*
|
*
|
||||||
* @param normalizedAttributeValue Normalized (trimmed and lowercased)
|
* @param normalizedAttributeValue Normalized (trimmed and lowercased)
|
||||||
|
@ -59,7 +59,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
/**
|
/**
|
||||||
* All of the known XRY keys for message reports.
|
* All of the known XRY keys for message reports.
|
||||||
*/
|
*/
|
||||||
private static enum XRY_KEY {
|
private enum XryKey {
|
||||||
TEXT("text"),
|
TEXT("text"),
|
||||||
DIRECTION("direction"),
|
DIRECTION("direction"),
|
||||||
TIME("time"),
|
TIME("time"),
|
||||||
@ -75,19 +75,19 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
XRY_KEY(String name) {
|
XryKey(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the XRY key is a recognized type.
|
* Indicates if the display name of the XRY key is a recognized type.
|
||||||
*
|
*
|
||||||
* @param xryKey
|
* @param xryKey
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean contains(String xryKey) {
|
public static boolean contains(String xryKey) {
|
||||||
String normalizedKey = xryKey.trim().toLowerCase();
|
String normalizedKey = xryKey.trim().toLowerCase();
|
||||||
for(XRY_KEY keyChoice : XRY_KEY.values()) {
|
for(XryKey keyChoice : XryKey.values()) {
|
||||||
if(keyChoice.name.equals(normalizedKey)) {
|
if(keyChoice.name.equals(normalizedKey)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the enum type for the given XRY key.
|
* Matches the display name of the xry key to the appropriate enum type.
|
||||||
*
|
*
|
||||||
* It is assumed that XRY key string is recognized. Otherwise,
|
* It is assumed that XRY key string is recognized. Otherwise,
|
||||||
* an IllegalArgumentException is thrown. Test all membership
|
* an IllegalArgumentException is thrown. Test all membership
|
||||||
@ -106,9 +106,9 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
* @param xryKey
|
* @param xryKey
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static XRY_KEY fromName(String xryKey) {
|
public static XryKey fromDisplayName(String xryKey) {
|
||||||
String normalizedKey = xryKey.trim().toLowerCase();
|
String normalizedKey = xryKey.trim().toLowerCase();
|
||||||
for(XRY_KEY keyChoice : XRY_KEY.values()) {
|
for(XryKey keyChoice : XryKey.values()) {
|
||||||
if(keyChoice.name.equals(normalizedKey)) {
|
if(keyChoice.name.equals(normalizedKey)) {
|
||||||
return keyChoice;
|
return keyChoice;
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
/**
|
/**
|
||||||
* All of the known XRY namespaces for message reports.
|
* All of the known XRY namespaces for message reports.
|
||||||
*/
|
*/
|
||||||
private static enum XRY_NAMESPACE {
|
private enum XryNamespace {
|
||||||
TO("to"),
|
TO("to"),
|
||||||
FROM("from"),
|
FROM("from"),
|
||||||
PARTICIPANT("participant"),
|
PARTICIPANT("participant"),
|
||||||
@ -130,19 +130,19 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
XRY_NAMESPACE(String name) {
|
XryNamespace(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the XRY namespace is a recognized type.
|
* Indicates if the display name of the XRY namespace is a recognized type.
|
||||||
*
|
*
|
||||||
* @param xryNamespace
|
* @param xryNamespace
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean contains(String xryNamespace) {
|
public static boolean contains(String xryNamespace) {
|
||||||
String normalizedNamespace = xryNamespace.trim().toLowerCase();
|
String normalizedNamespace = xryNamespace.trim().toLowerCase();
|
||||||
for(XRY_NAMESPACE keyChoice : XRY_NAMESPACE.values()) {
|
for(XryNamespace keyChoice : XryNamespace.values()) {
|
||||||
if(normalizedNamespace.equals(keyChoice.name)) {
|
if(normalizedNamespace.equals(keyChoice.name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the enum type for the given XRY namespace.
|
* Matches the display name of the xry namespace to the appropriate enum type.
|
||||||
*
|
*
|
||||||
* It is assumed that XRY namespace string is recognized. Otherwise,
|
* It is assumed that XRY namespace string is recognized. Otherwise,
|
||||||
* an IllegalArgumentException is thrown. Test all membership
|
* an IllegalArgumentException is thrown. Test all membership
|
||||||
@ -161,9 +161,9 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
* @param xryNamespace
|
* @param xryNamespace
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static XRY_NAMESPACE fromName(String xryNamespace) {
|
public static XryNamespace fromDisplayName(String xryNamespace) {
|
||||||
String normalizedNamespace = xryNamespace.trim().toLowerCase();
|
String normalizedNamespace = xryNamespace.trim().toLowerCase();
|
||||||
for(XRY_NAMESPACE keyChoice : XRY_NAMESPACE.values()) {
|
for(XryNamespace keyChoice : XryNamespace.values()) {
|
||||||
if(normalizedNamespace.equals(keyChoice.name)) {
|
if(normalizedNamespace.equals(keyChoice.name)) {
|
||||||
return keyChoice;
|
return keyChoice;
|
||||||
}
|
}
|
||||||
@ -177,26 +177,26 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
/**
|
/**
|
||||||
* All known XRY meta keys for message reports.
|
* All known XRY meta keys for message reports.
|
||||||
*/
|
*/
|
||||||
private static enum XRY_META_KEY {
|
private enum XryMetaKey {
|
||||||
REFERENCE_NUMBER("reference number"),
|
REFERENCE_NUMBER("reference number"),
|
||||||
SEGMENT_NUMBER("segment number"),
|
SEGMENT_NUMBER("segment number"),
|
||||||
SEGMENT_COUNT("segments");
|
SEGMENT_COUNT("segments");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
XRY_META_KEY(String name) {
|
XryMetaKey(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the XRY meta key is a recognized type.
|
* Indicates if the display name of the XRY meta key is a recognized type.
|
||||||
*
|
*
|
||||||
* @param xryMetaKey
|
* @param xryMetaKey
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean contains(String xryMetaKey) {
|
public static boolean contains(String xryMetaKey) {
|
||||||
String normalizedMetaKey = xryMetaKey.trim().toLowerCase();
|
String normalizedMetaKey = xryMetaKey.trim().toLowerCase();
|
||||||
for(XRY_META_KEY keyChoice : XRY_META_KEY.values()) {
|
for(XryMetaKey keyChoice : XryMetaKey.values()) {
|
||||||
if(keyChoice.name.equals(normalizedMetaKey)) {
|
if(keyChoice.name.equals(normalizedMetaKey)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the enum type for the given XRY meta key.
|
* Matches the display name of the xry meta key to the appropriate enum type.
|
||||||
*
|
*
|
||||||
* It is assumed that XRY meta key string is recognized. Otherwise,
|
* It is assumed that XRY meta key string is recognized. Otherwise,
|
||||||
* an IllegalArgumentException is thrown. Test all membership
|
* an IllegalArgumentException is thrown. Test all membership
|
||||||
@ -215,9 +215,9 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
* @param xryMetaKey
|
* @param xryMetaKey
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static XRY_META_KEY fromName(String xryMetaKey) {
|
public static XryMetaKey fromDisplayName(String xryMetaKey) {
|
||||||
String normalizedMetaKey = xryMetaKey.trim().toLowerCase();
|
String normalizedMetaKey = xryMetaKey.trim().toLowerCase();
|
||||||
for(XRY_META_KEY keyChoice : XRY_META_KEY.values()) {
|
for(XryMetaKey keyChoice : XryMetaKey.values()) {
|
||||||
if(keyChoice.name.equals(normalizedMetaKey)) {
|
if(keyChoice.name.equals(normalizedMetaKey)) {
|
||||||
return keyChoice;
|
return keyChoice;
|
||||||
}
|
}
|
||||||
@ -265,12 +265,12 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
|
|
||||||
List<BlackboardAttribute> attributes = new ArrayList<>();
|
List<BlackboardAttribute> attributes = new ArrayList<>();
|
||||||
|
|
||||||
XRY_NAMESPACE namespace = XRY_NAMESPACE.NONE;
|
XryNamespace namespace = XryNamespace.NONE;
|
||||||
for (int i = 1; i < xryLines.length; i++) {
|
for (int i = 1; i < xryLines.length; i++) {
|
||||||
String xryLine = xryLines[i];
|
String xryLine = xryLines[i];
|
||||||
|
|
||||||
if (XRY_NAMESPACE.contains(xryLine)) {
|
if (XryNamespace.contains(xryLine)) {
|
||||||
namespace = XRY_NAMESPACE.fromName(xryLine);
|
namespace = XryNamespace.fromDisplayName(xryLine);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,12 +289,12 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
String key = xryLine.substring(0, keyDelimiter);
|
String key = xryLine.substring(0, keyDelimiter);
|
||||||
String value = xryLine.substring(keyDelimiter + 1).trim();
|
String value = xryLine.substring(keyDelimiter + 1).trim();
|
||||||
|
|
||||||
if (XRY_META_KEY.contains(key)) {
|
if (XryMetaKey.contains(key)) {
|
||||||
//Skip meta keys, they are being handled seperately.
|
//Skip meta keys, they are being handled seperately.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!XRY_KEY.contains(key)) {
|
if (!XryKey.contains(key)) {
|
||||||
logger.log(Level.SEVERE, String.format("[XRY DSP] The following key, "
|
logger.log(Level.SEVERE, String.format("[XRY DSP] The following key, "
|
||||||
+ "value pair (in brackets, respectively) [ %s ], [ %s ] "
|
+ "value pair (in brackets, respectively) [ %s ], [ %s ] "
|
||||||
+ "was not recognized. Discarding... Here is the previous line "
|
+ "was not recognized. Discarding... Here is the previous line "
|
||||||
@ -311,10 +311,10 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
XRY_KEY xryKey = XRY_KEY.fromName(key);
|
XryKey xryKey = XryKey.fromDisplayName(key);
|
||||||
|
|
||||||
//Assume text is the only field that can span multiple lines.
|
//Assume text is the only field that can span multiple lines.
|
||||||
if (xryKey.equals(XRY_KEY.TEXT)) {
|
if (xryKey.equals(XryKey.TEXT)) {
|
||||||
//Build up multiple lines.
|
//Build up multiple lines.
|
||||||
for (; (i + 1) < xryLines.length
|
for (; (i + 1) < xryLines.length
|
||||||
&& !hasKey(xryLines[i + 1])
|
&& !hasKey(xryLines[i + 1])
|
||||||
@ -324,7 +324,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
value = value + " " + continuedValue;
|
value = value + " " + continuedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Integer> referenceNumber = getMetaInfo(xryLines, XRY_META_KEY.REFERENCE_NUMBER);
|
Optional<Integer> referenceNumber = getMetaInfo(xryLines, XryMetaKey.REFERENCE_NUMBER);
|
||||||
//Check if there is any segmented text.
|
//Check if there is any segmented text.
|
||||||
if (referenceNumber.isPresent()) {
|
if (referenceNumber.isPresent()) {
|
||||||
logger.log(Level.INFO, String.format("[XRY DSP] Message entity "
|
logger.log(Level.INFO, String.format("[XRY DSP] Message entity "
|
||||||
@ -340,7 +340,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
|
|
||||||
referenceNumbersSeen.add(referenceNumber.get());
|
referenceNumbersSeen.add(referenceNumber.get());
|
||||||
|
|
||||||
Optional<Integer> segmentNumber = getMetaInfo(xryLines, XRY_META_KEY.SEGMENT_NUMBER);
|
Optional<Integer> segmentNumber = getMetaInfo(xryLines, XryMetaKey.SEGMENT_NUMBER);
|
||||||
if(segmentNumber.isPresent()) {
|
if(segmentNumber.isPresent()) {
|
||||||
//Unify segmented text
|
//Unify segmented text
|
||||||
String segmentedText = getSegmentedText(referenceNumber.get(),
|
String segmentedText = getSegmentedText(referenceNumber.get(),
|
||||||
@ -388,7 +388,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
//Peek at the next to see if it has the same reference number.
|
//Peek at the next to see if it has the same reference number.
|
||||||
String nextEntity = reader.peek();
|
String nextEntity = reader.peek();
|
||||||
String[] nextEntityLines = nextEntity.split("\n");
|
String[] nextEntityLines = nextEntity.split("\n");
|
||||||
Optional<Integer> nextReferenceNumber = getMetaInfo(nextEntityLines, XRY_META_KEY.REFERENCE_NUMBER);
|
Optional<Integer> nextReferenceNumber = getMetaInfo(nextEntityLines, XryMetaKey.REFERENCE_NUMBER);
|
||||||
|
|
||||||
if (!nextReferenceNumber.isPresent() || nextReferenceNumber.get() != referenceNumber) {
|
if (!nextReferenceNumber.isPresent() || nextReferenceNumber.get() != referenceNumber) {
|
||||||
//Don't consume the next entity. It is not related
|
//Don't consume the next entity. It is not related
|
||||||
@ -399,7 +399,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
//Consume the entity, it is a part of the message thread.
|
//Consume the entity, it is a part of the message thread.
|
||||||
reader.nextEntity();
|
reader.nextEntity();
|
||||||
|
|
||||||
Optional<Integer> nextSegmentNumber = getMetaInfo(nextEntityLines, XRY_META_KEY.SEGMENT_NUMBER);
|
Optional<Integer> nextSegmentNumber = getMetaInfo(nextEntityLines, XryMetaKey.SEGMENT_NUMBER);
|
||||||
|
|
||||||
logger.log(Level.INFO, String.format("[XRY DSP] Processing [ %s ] "
|
logger.log(Level.INFO, String.format("[XRY DSP] Processing [ %s ] "
|
||||||
+ "segment with reference number [ %d ]", nextEntityLines[0], referenceNumber));
|
+ "segment with reference number [ %d ]", nextEntityLines[0], referenceNumber));
|
||||||
@ -426,7 +426,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
|
|
||||||
//Extract the text key from the entity
|
//Extract the text key from the entity
|
||||||
String key = xryLine.substring(0, keyDelimiter);
|
String key = xryLine.substring(0, keyDelimiter);
|
||||||
if(XRY_KEY.contains(key) && XRY_KEY.fromName(key).equals(XRY_KEY.TEXT)) {
|
if(XryKey.contains(key) && XryKey.fromDisplayName(key).equals(XryKey.TEXT)) {
|
||||||
String value = xryLine.substring(keyDelimiter + 1).trim();
|
String value = xryLine.substring(keyDelimiter + 1).trim();
|
||||||
segmentedText.append(value).append(' ');
|
segmentedText.append(value).append(' ');
|
||||||
|
|
||||||
@ -465,7 +465,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String key = xryLine.substring(0, delimiter);
|
String key = xryLine.substring(0, delimiter);
|
||||||
return XRY_KEY.contains(key);
|
return XryKey.contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -475,7 +475,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean hasNamespace(String xryLine) {
|
private boolean hasNamespace(String xryLine) {
|
||||||
return XRY_NAMESPACE.contains(xryLine);
|
return XryNamespace.contains(xryLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -487,18 +487,18 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
* @return The interpreted integer value or Integer.MIN_VALUE if
|
* @return The interpreted integer value or Integer.MIN_VALUE if
|
||||||
* no meta key was found.
|
* no meta key was found.
|
||||||
*/
|
*/
|
||||||
private Optional<Integer> getMetaInfo(String[] xryLines, XRY_META_KEY metaKey) {
|
private Optional<Integer> getMetaInfo(String[] xryLines, XryMetaKey metaKey) {
|
||||||
for (int i = 0; i < xryLines.length; i++) {
|
for (int i = 0; i < xryLines.length; i++) {
|
||||||
String xryLine = xryLines[i];
|
String xryLine = xryLines[i];
|
||||||
|
|
||||||
int firstDelimiter = xryLine.indexOf(KEY_VALUE_DELIMITER);
|
int firstDelimiter = xryLine.indexOf(KEY_VALUE_DELIMITER);
|
||||||
if (firstDelimiter != -1) {
|
if (firstDelimiter != -1) {
|
||||||
String key = xryLine.substring(0, firstDelimiter);
|
String key = xryLine.substring(0, firstDelimiter);
|
||||||
if(!XRY_META_KEY.contains(key)) {
|
if(!XryMetaKey.contains(key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
XRY_META_KEY currentMetaKey = XRY_META_KEY.fromName(key);
|
XryMetaKey currentMetaKey = XryMetaKey.fromDisplayName(key);
|
||||||
if (currentMetaKey.equals(metaKey)) {
|
if (currentMetaKey.equals(metaKey)) {
|
||||||
String value = xryLine.substring(firstDelimiter + 1).trim();
|
String value = xryLine.substring(firstDelimiter + 1).trim();
|
||||||
try {
|
try {
|
||||||
@ -523,7 +523,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
* @param value The value associated with that key.
|
* @param value The value associated with that key.
|
||||||
* @return Corresponding blackboard attribute, if any.
|
* @return Corresponding blackboard attribute, if any.
|
||||||
*/
|
*/
|
||||||
private Optional<BlackboardAttribute> makeAttribute(XRY_NAMESPACE namespace, XRY_KEY key, String value) {
|
private Optional<BlackboardAttribute> makeAttribute(XryNamespace namespace, XryKey key, String value) {
|
||||||
String normalizedValue = value.toLowerCase().trim();
|
String normalizedValue = value.toLowerCase().trim();
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case DIRECTION:
|
case DIRECTION:
|
||||||
@ -535,7 +535,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME_PERSON,
|
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME_PERSON,
|
||||||
PARSER_NAME, value));
|
PARSER_NAME, value));
|
||||||
case TEL:
|
case TEL:
|
||||||
if(namespace.equals(XRY_NAMESPACE.FROM)) {
|
if(namespace.equals(XryNamespace.FROM)) {
|
||||||
return Optional.of(new BlackboardAttribute(
|
return Optional.of(new BlackboardAttribute(
|
||||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM,
|
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM,
|
||||||
PARSER_NAME, value));
|
PARSER_NAME, value));
|
||||||
@ -568,12 +568,12 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
case "submit":
|
case "submit":
|
||||||
case "status report":
|
case "status report":
|
||||||
//Ignore for now.
|
//Ignore for now.
|
||||||
break;
|
return Optional.empty();
|
||||||
default:
|
default:
|
||||||
logger.log(Level.WARNING, String.format("[XRY DSP] Unrecognized "
|
logger.log(Level.WARNING, String.format("[XRY DSP] Unrecognized "
|
||||||
+ "type value [ %s ]", value));
|
+ "type value [ %s ]", value));
|
||||||
}
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
}
|
||||||
case SERVICE_CENTER:
|
case SERVICE_CENTER:
|
||||||
return Optional.of(new BlackboardAttribute(
|
return Optional.of(new BlackboardAttribute(
|
||||||
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER,
|
BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER,
|
||||||
@ -593,12 +593,12 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
case "unsent":
|
case "unsent":
|
||||||
case "sent":
|
case "sent":
|
||||||
//Ignore for now.
|
//Ignore for now.
|
||||||
break;
|
return Optional.empty();
|
||||||
default:
|
default:
|
||||||
logger.log(Level.WARNING, String.format("[XRY DSP] Unrecognized "
|
logger.log(Level.WARNING, String.format("[XRY DSP] Unrecognized "
|
||||||
+ "status value [ %s ].", value));
|
+ "status value [ %s ].", value));
|
||||||
}
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
}
|
||||||
case STORAGE:
|
case STORAGE:
|
||||||
case INDEX:
|
case INDEX:
|
||||||
case FOLDER:
|
case FOLDER:
|
||||||
@ -656,7 +656,7 @@ final class XRYMessagesFileParser implements XRYFileParser {
|
|||||||
String reversedDateTime = reverseOrderOfDateTimeComponents(dateTimeWithoutLocale);
|
String reversedDateTime = reverseOrderOfDateTimeComponents(dateTimeWithoutLocale);
|
||||||
/**
|
/**
|
||||||
* Furthermore, the DateTimeFormatter's timezone offset letter ('O') does
|
* Furthermore, the DateTimeFormatter's timezone offset letter ('O') does
|
||||||
* not recognized UTC but recognizes GMT. According to
|
* not recognize UTC but recognizes GMT. According to
|
||||||
* https://en.wikipedia.org/wiki/Coordinated_Universal_Time,
|
* https://en.wikipedia.org/wiki/Coordinated_Universal_Time,
|
||||||
* GMT only differs from UTC by at most 1 second and so substitution
|
* GMT only differs from UTC by at most 1 second and so substitution
|
||||||
* will only introduce a trivial amount of error.
|
* will only introduce a trivial amount of error.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user