Sleuth Kit Java Bindings (JNI)  4.3
Java bindings for using The Sleuth Kit
TagName.java
Go to the documentation of this file.
1 /*
2  * Sleuth Kit Data Model
3  *
4  * Copyright 2011-2016 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.datamodel;
20 
21 import java.io.Serializable;
22 import java.util.HashMap;
23 import java.util.Objects;
24 
30 public class TagName implements Comparable<TagName>, Serializable {
31 
32  private static final long serialVersionUID = 1L;
33 
34  public enum HTML_COLOR {
35 
36  NONE("None"), //NON-NLS
37  WHITE("White"), //NON-NLS
38  SILVER("Silver"), //NON-NLS
39  GRAY("Gray"), //NON-NLS
40  BLACK("Black"), //NON-NLS
41  RED("Red"), //NON-NLS
42  MAROON("Maron"), //NON-NLS
43  YELLOW("Yellow"), //NON-NLS
44  OLIVE("Olive"), //NON-NLS
45  LIME("Lime"), //NON-NLS
46  GREEN("Green"), //NON-NLS
47  AQUA("Aqua"), //NON-NLS
48  TEAL("Teal"), //NON-NLS
49  BLUE("Blue"), //NON-NLS
50  NAVY("Navy"), //NON-NLS
51  FUCHSIA("Fuchsia"), //NON-NLS
52  PURPLE("Purple"); //NON-NLS
53  private final static HashMap<String, HTML_COLOR> colorMap = new HashMap<String, HTML_COLOR>();
54  private final String name;
55 
56  static {
57  for (HTML_COLOR color : HTML_COLOR.values()) {
58  colorMap.put(color.name(), color);
59  }
60  }
61 
62  private HTML_COLOR(String name) {
63  this.name = name;
64  }
65 
66  String getName() {
67  return name;
68  }
69 
70  public static HTML_COLOR getColorByName(String colorName) {
71  if (colorMap.containsKey(colorName)) {
72  return colorMap.get(colorName);
73  } else {
74  return NONE;
75  }
76  }
77  }
78  private final long id;
79  private final String displayName;
80  private final String description;
81  private final HTML_COLOR color;
82 
83  // Clients of the org.sleuthkit.datamodel package should not directly create these objects.
84  TagName(long id, String displayName, String description, HTML_COLOR color) {
85  this.id = id;
86  this.displayName = displayName;
87  this.description = description;
88  this.color = color;
89  }
90 
91  public long getId() {
92  return id;
93  }
94 
95  public String getDisplayName() {
96  return displayName;
97  }
98 
99  public String getDescription() {
100  return description;
101  }
102 
103  public HTML_COLOR getColor() {
104  return color;
105  }
106 
114  @Override
115  public int compareTo(TagName other) {
116  return this.getDisplayName().compareTo(other.getDisplayName());
117  }
118 
119  @Override
120  public int hashCode() {
121  int hash = 5;
122  hash = 89 * hash + (int) (this.id ^ (this.id >>> 32));
123  hash = 89 * hash + (this.displayName != null ? this.displayName.hashCode() : 0);
124  hash = 89 * hash + (this.description != null ? this.description.hashCode() : 0);
125  hash = 89 * hash + (this.color != null ? this.color.hashCode() : 0);
126  return hash;
127  }
128 
129  @Override
130  public boolean equals(Object obj) {
131  if (obj == null) {
132  return false;
133  }
134  if (getClass() != obj.getClass()) {
135  return false;
136  }
137  final TagName other = (TagName) obj;
138  return (this.id == other.id
139  && Objects.equals(this.displayName, other.displayName)
140  && Objects.equals(this.description, other.description)
141  && Objects.equals(this.color, other.color));
142  }
143 }
int compareTo(TagName other)
Definition: TagName.java:115
static HTML_COLOR getColorByName(String colorName)
Definition: TagName.java:70
boolean equals(Object obj)
Definition: TagName.java:130
static final long serialVersionUID
Definition: TagName.java:32

Copyright © 2011-2015 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.