19 package org.sleuthkit.autopsy.keywordsearch;
33 class KeywordHit
implements Comparable<KeywordHit> {
35 private final String solrDocumentId;
36 private final long solrObjectId;
37 private final int chunkId;
38 private final String snippet;
39 private final Content content;
40 private final BlackboardArtifact artifact;
41 private final String hit;
43 public String getHit() {
47 KeywordHit(String solrDocumentId, String snippet)
throws TskCoreException {
48 this(solrDocumentId, snippet, null);
51 KeywordHit(String solrDocumentId, String snippet, String hit)
throws TskCoreException {
55 this.solrDocumentId = solrDocumentId;
66 final int separatorIndex = solrDocumentId.indexOf(Server.CHUNK_ID_SEPARATOR);
67 if (-1 != separatorIndex) {
68 this.solrObjectId = Long.parseLong(solrDocumentId.substring(0, separatorIndex));
69 this.chunkId = Integer.parseInt(solrDocumentId.substring(separatorIndex + 1));
71 this.solrObjectId = Long.parseLong(solrDocumentId);
80 SleuthkitCase caseDb = Case.getCurrentCase().getSleuthkitCase();
82 if (this.solrObjectId < 0) {
83 this.artifact = caseDb.getBlackboardArtifact(this.solrObjectId);
84 fileId = artifact.getObjectID();
87 fileId = this.solrObjectId;
89 this.content = caseDb.getContentById(fileId);
94 this.snippet = snippet;
98 String getSolrDocumentId() {
99 return this.solrDocumentId;
102 long getSolrObjectId() {
103 return this.solrObjectId;
106 boolean hasChunkId() {
107 return this.chunkId != 0;
114 boolean hasSnippet() {
115 return !this.snippet.isEmpty();
118 String getSnippet() {
122 Content getContent() {
131 boolean isArtifactHit() {
132 return (null != this.artifact);
141 BlackboardArtifact getArtifact() {
142 return this.artifact;
146 public boolean equals(Object obj) {
150 if (getClass() != obj.getClass()) {
153 final KeywordHit other = (KeywordHit) obj;
154 return (this.solrObjectId == other.solrObjectId &&
this.chunkId == other.chunkId);
158 public int hashCode() {
160 hash = 41 * hash + (int) this.solrObjectId + this.chunkId;
165 public int compareTo(KeywordHit o) {
166 if (this.solrObjectId < o.solrObjectId) {
169 }
else if (this.solrObjectId == o.solrObjectId) {
171 if (this.chunkId < o.chunkId) {
176 return this.chunkId == o.chunkId ? 0 : 1;