Sleuth Kit Java Bindings (JNI)  4.2
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 2013 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.util.HashMap;
22 import java.util.Objects;
23 
29 public class TagName implements Comparable<TagName> {
30 
31  public enum HTML_COLOR {
32 
33  NONE("None"), //NON-NLS
34  WHITE("White"), //NON-NLS
35  SILVER("Silver"), //NON-NLS
36  GRAY("Gray"), //NON-NLS
37  BLACK("Black"), //NON-NLS
38  RED("Red"), //NON-NLS
39  MAROON("Maron"), //NON-NLS
40  YELLOW("Yellow"), //NON-NLS
41  OLIVE("Olive"), //NON-NLS
42  LIME("Lime"), //NON-NLS
43  GREEN("Green"), //NON-NLS
44  AQUA("Aqua"), //NON-NLS
45  TEAL("Teal"), //NON-NLS
46  BLUE("Blue"), //NON-NLS
47  NAVY("Navy"), //NON-NLS
48  FUCHSIA("Fuchsia"), //NON-NLS
49  PURPLE("Purple"); //NON-NLS
50  private final static HashMap<String, HTML_COLOR> colorMap = new HashMap<String, HTML_COLOR>();
51  private String name;
52 
53  static {
54  for (HTML_COLOR color : HTML_COLOR.values()) {
55  colorMap.put(color.name(), color);
56  }
57  }
58 
59  private HTML_COLOR(String name) {
60  this.name = name;
61  }
62 
63  String getName() {
64  return name;
65  }
66 
67  public static HTML_COLOR getColorByName(String colorName) {
68  if (colorMap.containsKey(colorName)) {
69  return colorMap.get(colorName);
70  } else {
71  return NONE;
72  }
73  }
74  }
75  private final long id;
76  private final String displayName;
77  private final String description;
78  private final HTML_COLOR color;
79 
80  // Clients of the org.sleuthkit.datamodel package should not directly create these objects.
81  TagName(long id, String displayName, String description, HTML_COLOR color) {
82  this.id = id;
83  this.displayName = displayName;
84  this.description = description;
85  this.color = color;
86  }
87 
88  public long getId() {
89  return id;
90  }
91 
92  public String getDisplayName() {
93  return displayName;
94  }
95 
96  public String getDescription() {
97  return description;
98  }
99 
100  public HTML_COLOR getColor() {
101  return color;
102  }
103 
111  @Override
112  public int compareTo(TagName other) {
113  return this.getDisplayName().compareTo(other.getDisplayName());
114  }
115 
116  @Override
117  public int hashCode() {
118  int hash = 5;
119  hash = 89 * hash + (int) (this.id ^ (this.id >>> 32));
120  hash = 89 * hash + (this.displayName != null ? this.displayName.hashCode() : 0);
121  hash = 89 * hash + (this.description != null ? this.description.hashCode() : 0);
122  hash = 89 * hash + (this.color != null ? this.color.hashCode() : 0);
123  return hash;
124  }
125 
126  @Override
127  public boolean equals(Object obj) {
128  if (obj == null) {
129  return false;
130  }
131  if (getClass() != obj.getClass()) {
132  return false;
133  }
134  final TagName other = (TagName) obj;
135  if (this.id != other.id) {
136  return false;
137  }
138 
139  if (false == Objects.equals(this.displayName, other.displayName)) {
140  return false;
141  }
142  if (false == Objects.equals(this.description, other.description)) {
143  return false;
144  }
145 
146  return this.color == other.color;
147  }
148 }
int compareTo(TagName other)
Definition: TagName.java:112
static HTML_COLOR getColorByName(String colorName)
Definition: TagName.java:67
boolean equals(Object obj)
Definition: TagName.java:127

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.