diff --git a/bindings/java/src/org/sleuthkit/datamodel/TagName.java b/bindings/java/src/org/sleuthkit/datamodel/TagName.java index a18f1c2406b20b3e0aec26410a9a834bc1d14bea..131073bf5f44245861df7f8bdd36f18de86120e7 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/TagName.java +++ b/bindings/java/src/org/sleuthkit/datamodel/TagName.java @@ -22,8 +22,6 @@ import java.util.HashMap; import java.util.List; import java.util.Objects; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Instances of this class are data transfer objects (DTOs) that represent the @@ -36,23 +34,23 @@ public class TagName implements Comparable<TagName>, Serializable { public enum HTML_COLOR { - NONE ("None", ""), //NON-NLS - WHITE ("White", "#FFFFFF"), //NON-NLS - SILVER ("Silver", "#C0C0C0"), //NON-NLS - GRAY ("Gray", "#808080"), //NON-NLS - BLACK ("Black", "#000000"), //NON-NLS - RED ("Red", "#FF0000"), //NON-NLS - MAROON ("Maron", "#800000"), //NON-NLS - YELLOW ("Yellow", "#FFFF00"), //NON-NLS - OLIVE ("Olive", "#808000"), //NON-NLS - LIME ("Lime", "#00FF00"), //NON-NLS - GREEN ("Green", "#008000"), //NON-NLS - AQUA ("Aqua", "#00FFFF"), //NON-NLS - TEAL ("Teal", "#008080"), //NON-NLS - BLUE ("Blue", "#0000FF"), //NON-NLS - NAVY ("Navy", "#000080"), //NON-NLS - FUCHSIA ("Fuchsia", "#FF00FF"), //NON-NLS - PURPLE ("Purple", "#800080"); //NON-NLS + NONE("None", ""), //NON-NLS + WHITE("White", "#FFFFFF"), //NON-NLS + SILVER("Silver", "#C0C0C0"), //NON-NLS + GRAY("Gray", "#808080"), //NON-NLS + BLACK("Black", "#000000"), //NON-NLS + RED("Red", "#FF0000"), //NON-NLS + MAROON("Maron", "#800000"), //NON-NLS + YELLOW("Yellow", "#FFFF00"), //NON-NLS + OLIVE("Olive", "#808000"), //NON-NLS + LIME("Lime", "#00FF00"), //NON-NLS + GREEN("Green", "#008000"), //NON-NLS + AQUA("Aqua", "#00FFFF"), //NON-NLS + TEAL("Teal", "#008080"), //NON-NLS + BLUE("Blue", "#0000FF"), //NON-NLS + NAVY("Navy", "#000080"), //NON-NLS + FUCHSIA("Fuchsia", "#FF00FF"), //NON-NLS + PURPLE("Purple", "#800080"); //NON-NLS private final static HashMap<String, HTML_COLOR> colorMap = new HashMap<String, HTML_COLOR>(); private final String name; private final String hexString; @@ -71,7 +69,7 @@ public enum HTML_COLOR { String getName() { return name; } - + public String getRgbValue() { return hexString; } @@ -85,21 +83,18 @@ public static HTML_COLOR getColorByName(String colorName) { } } private final long id; - private final String name; + private final String displayName; private final String description; private final HTML_COLOR color; private final TskData.FileKnown knownStatus; private final long tagSetId; private final int rank; private final SleuthkitCase skCase; - - // Build this when needed - private String displayName = null; // Clients of the org.sleuthkit.datamodel package should not directly create these objects. - TagName(SleuthkitCase sleuthkitCase, long id, String name, String description, HTML_COLOR color, TskData.FileKnown knownStatus, long tagSetId, int rank) { + TagName(SleuthkitCase sleuthkitCase, long id, String displayName, String description, HTML_COLOR color, TskData.FileKnown knownStatus, long tagSetId, int rank) { this.id = id; - this.name = name; + this.displayName = displayName; this.description = description; this.color = color; this.knownStatus = knownStatus; @@ -112,32 +107,7 @@ public long getId() { return id; } - /** - * Returns a formatted TagName display name that includes the TagName's - * TagSet name notable status. - * - * @return Returns TagName display name. - */ public String getDisplayName() { - if(displayName == null) { - try { - TagSet set = getTagSet(); - displayName = new String(); - - if(set != null) { - displayName += set.getName() + " "; - } - } catch (TskCoreException ex) { - Logger.getLogger(TagName.class.getName()).log(Level.SEVERE, "Unable to add TagSet name to TagName displayName", ex); - } - - displayName += name; - - if(knownStatus == TskData.FileKnown.BAD) { - displayName += " (Notable)"; - } - } - return displayName; } @@ -156,37 +126,29 @@ public TskData.FileKnown getKnownStatus() { long getTagSetId() { return tagSetId; } - + public int getRank() { return rank; } - - /** - * Returns the TagName name. A TagName name is not unique. - * - * @return The TagName name. - */ - public String getName() { - return name; - } - + /** * Returns the TagName TagSet object. - * - * @return TagName TagSet object or null if the TagName is not a part of a TagSet. - * - * @throws TskCoreException + * + * @return TagName TagSet object or null if the TagName is not a part of a + * TagSet. + * + * @throws TskCoreException */ public TagSet getTagSet() throws TskCoreException { - if(tagSetId != 0) { + if (tagSetId != 0) { List<TagSet> tagSets = skCase.getTaggingManager().getTagSets(); - for(TagSet set: tagSets) { - if(tagSetId == set.getId()) { + for (TagSet set : tagSets) { + if (tagSetId == set.getId()) { return set; } } } - + return null; } @@ -206,7 +168,7 @@ public int compareTo(TagName other) { public int hashCode() { int hash = 5; hash = 89 * hash + (int) (this.id ^ (this.id >>> 32)); - hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 89 * hash + (this.displayName != null ? this.displayName.hashCode() : 0); hash = 89 * hash + (this.description != null ? this.description.hashCode() : 0); hash = 89 * hash + (this.color != null ? this.color.hashCode() : 0); hash = 89 * hash + (this.knownStatus != null ? this.knownStatus.hashCode() : 0); @@ -224,7 +186,7 @@ public boolean equals(Object obj) { } final TagName other = (TagName) obj; return (this.id == other.id - && Objects.equals(this.name, other.name) + && Objects.equals(this.displayName, other.displayName) && Objects.equals(this.description, other.description) && Objects.equals(this.color, other.color) && Objects.equals(this.knownStatus, other.knownStatus) diff --git a/bindings/java/src/org/sleuthkit/datamodel/TagSet.java b/bindings/java/src/org/sleuthkit/datamodel/TagSet.java index ae4ab5c2603fe6a9334d983728e384d86a62ae92..31e86808e21e04a915bb1ecb40da58b7c175469b 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/TagSet.java +++ b/bindings/java/src/org/sleuthkit/datamodel/TagSet.java @@ -111,7 +111,7 @@ private class TagNameComparator implements Comparator<TagName> { public int compare(TagName tagName1, TagName tagName2) { int result = ((Integer)tagName1.getRank()).compareTo(tagName2.getRank()); if(result == 0) { - result = tagName1.getName().compareTo(tagName2.getName()); + result = tagName1.getDisplayName().compareTo(tagName2.getDisplayName()); } return result; }