From f09a5b6c9c29e5d4c7fa79355af91b1869f7694c Mon Sep 17 00:00:00 2001
From: eugene7646 <elivis@basistech.com>
Date: Wed, 12 Jan 2022 16:12:17 -0500
Subject: [PATCH] Revert "8271 remove tsk visitor"

---
 .../datamodel/BlackboardArtifact.java         |  34 +-
 .../src/org/sleuthkit/datamodel/Content.java  |   2 +-
 .../sleuthkit/datamodel/ContentVisitor.java   |  46 +--
 .../org/sleuthkit/datamodel/DerivedFile.java  |  13 +
 .../org/sleuthkit/datamodel/Directory.java    |  13 +
 .../src/org/sleuthkit/datamodel/File.java     |  13 +
 .../org/sleuthkit/datamodel/FileSystem.java   |   5 +
 .../org/sleuthkit/datamodel/HostAddress.java  |   6 +
 .../src/org/sleuthkit/datamodel/Image.java    |   5 +
 .../org/sleuthkit/datamodel/LayoutFile.java   |  13 +
 .../sleuthkit/datamodel/LocalDirectory.java   |  13 +
 .../org/sleuthkit/datamodel/LocalFile.java    |  14 +
 .../datamodel/LocalFilesDataSource.java       |  14 +
 .../org/sleuthkit/datamodel/OsAccount.java    |   5 +
 .../src/org/sleuthkit/datamodel/Pool.java     |   5 +
 .../src/org/sleuthkit/datamodel/Report.java   |   5 +
 .../org/sleuthkit/datamodel/SlackFile.java    |  13 +
 .../datamodel/SleuthkitItemVisitor.java       | 316 ++++++++++++++++++
 .../datamodel/SleuthkitVisitableItem.java     |  35 ++
 .../datamodel/UnsupportedContent.java         |   5 +
 .../sleuthkit/datamodel/VirtualDirectory.java |  14 +
 .../src/org/sleuthkit/datamodel/Volume.java   |   5 +
 .../org/sleuthkit/datamodel/VolumeSystem.java |   5 +
 23 files changed, 567 insertions(+), 32 deletions(-)
 create mode 100644 bindings/java/src/org/sleuthkit/datamodel/SleuthkitItemVisitor.java
 create mode 100644 bindings/java/src/org/sleuthkit/datamodel/SleuthkitVisitableItem.java

diff --git a/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java b/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java
index b3990eb92..fba83e40e 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java
@@ -900,6 +900,21 @@ public String toString() {
 		return "BlackboardArtifact{" + "artifactID=" + artifactId + ", objID=" + getObjectID() + ", artifactObjID=" + artifactObjId + ", artifactTypeID=" + artifactTypeId + ", artifactTypeName=" + artifactTypeName + ", displayName=" + displayName + ", Case=" + getSleuthkitCase() + '}'; //NON-NLS
 	}
 
+	/**
+	 * Accepts a visitor SleuthkitItemVisitor that will perform an operation on
+	 * this artifact type and return some object as the result of the operation.
+	 *
+	 * @param visitor The visitor, where the type parameter of the visitor is
+	 *                the type of the object that will be returned as the result
+	 *                of the visit operation.
+	 *
+	 * @return An object of type T.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> visitor) {
+		return visitor.visit(this);
+	}
+
 	/**
 	 * Get the (reported) size of the content object. Artifact content is a
 	 * string dump of all its attributes.
@@ -1579,7 +1594,7 @@ public int hashCode() {
 	 * http://sleuthkit.org/sleuthkit/docs/jni-docs/latest/artifact_catalog_page.html
 	 * for details on the standard attributes for each artifact type.
 	 */
-	public enum ARTIFACT_TYPE {
+	public enum ARTIFACT_TYPE implements SleuthkitVisitableItem {
 
 		/**
 		 * A generic information artifact.
@@ -2101,6 +2116,23 @@ static public ARTIFACT_TYPE fromID(int id) {
 		public String getDisplayName() {
 			return displayName;
 		}
+
+		/**
+		 * Accepts a visitor SleuthkitItemVisitor that will perform an operation
+		 * on this artifact type and return some object as the result of the
+		 * operation.
+		 *
+		 * @param visitor The visitor, where the type parameter of the visitor
+		 *                is the type of the object that will be returned as the
+		 *                result of the visit operation.
+		 *
+		 * @return An object of type T.
+		 */
+		@Override
+		public <T> T accept(SleuthkitItemVisitor<T> visitor) {
+			return visitor.visit(this);
+		}
+
 	}
 
 	/**
diff --git a/bindings/java/src/org/sleuthkit/datamodel/Content.java b/bindings/java/src/org/sleuthkit/datamodel/Content.java
index a8779ad1e..5993ac460 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/Content.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/Content.java
@@ -30,7 +30,7 @@
  * interface defines the basic methods for reading the content associated with
  * this object, the parent and children, and adding artifacts.
  */
-public interface Content {
+public interface Content extends SleuthkitVisitableItem {
 
 	/**
 	 * Reads data that this content object is associated with (file contents,
diff --git a/bindings/java/src/org/sleuthkit/datamodel/ContentVisitor.java b/bindings/java/src/org/sleuthkit/datamodel/ContentVisitor.java
index 875f9bad1..7d922b9f1 100755
--- a/bindings/java/src/org/sleuthkit/datamodel/ContentVisitor.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/ContentVisitor.java
@@ -66,7 +66,7 @@ public interface ContentVisitor<T> {
 	 * @return result of the visit
 	 */
 	T visit(Image i);
-
+	
 	/**
 	 * Act on (visit) a Pool content object
 	 *
@@ -74,7 +74,7 @@ public interface ContentVisitor<T> {
 	 *
 	 * @return result of the visit
 	 */
-	T visit(Pool p);
+	T visit(Pool p);	
 
 	/**
 	 * Act on (visit) a Volume content object
@@ -111,7 +111,7 @@ public interface ContentVisitor<T> {
 	 * @return result of the visit
 	 */
 	T visit(VirtualDirectory vd);
-
+	
 	/**
 	 * Act on (visit) a LocalDirectory content object
 	 *
@@ -119,7 +119,7 @@ public interface ContentVisitor<T> {
 	 *
 	 * @return result of the visit
 	 */
-	T visit(LocalDirectory ld);
+	T visit(LocalDirectory ld);	
 
 	/**
 	 * Act on (visit) a DerivedFile content object
@@ -138,7 +138,7 @@ public interface ContentVisitor<T> {
 	 * @return result of the visit
 	 */
 	T visit(LocalFile df);
-
+	
 	/**
 	 * Act on (visit) a SlackFile content object
 	 *
@@ -146,7 +146,7 @@ public interface ContentVisitor<T> {
 	 *
 	 * @return result of the visit
 	 */
-	T visit(SlackFile sf);
+	T visit(SlackFile sf);	
 
 	/**
 	 * Act on (visit) a blackboard artifact object
@@ -155,17 +155,8 @@ public interface ContentVisitor<T> {
 	 *
 	 * @return result of the visit
 	 */
-	T visit(BlackboardArtifact ba);
-
-	/**
-	 * Act on (visit) a local files data source object
-	 *
-	 * @param ds The local files data source object
-	 *
-	 * @return result of the visit
-	 */
-	T visit(LocalFilesDataSource lfds);
-
+	T visit(BlackboardArtifact ba);	
+	
 	/**
 	 * Act on (visit) a Report object
 	 *
@@ -174,7 +165,7 @@ public interface ContentVisitor<T> {
 	 * @return result of the visit
 	 */
 	T visit(Report r);
-
+	
 	/**
 	 * Act on (visit) a OsAccount object
 	 *
@@ -183,7 +174,7 @@ public interface ContentVisitor<T> {
 	 * @return result of the visit
 	 */
 	T visit(OsAccount act);
-
+	
 	/**
 	 * Act on (visit) an UnsupportedContent object
 	 *
@@ -231,7 +222,7 @@ public T visit(Image i) {
 		public T visit(Volume v) {
 			return defaultVisit(v);
 		}
-
+		
 		@Override
 		public T visit(Pool p) {
 			return defaultVisit(p);
@@ -251,7 +242,7 @@ public T visit(LayoutFile lf) {
 		public T visit(VirtualDirectory ld) {
 			return defaultVisit(ld);
 		}
-
+		
 		@Override
 		public T visit(LocalDirectory ld) {
 			return defaultVisit(ld);
@@ -266,32 +257,27 @@ public T visit(DerivedFile df) {
 		public T visit(LocalFile lf) {
 			return defaultVisit(lf);
 		}
-
+		
 		@Override
 		public T visit(SlackFile sf) {
 			return defaultVisit(sf);
 		}
-
+		
 		@Override
 		public T visit(BlackboardArtifact ba) {
 			return defaultVisit(ba);
 		}
 
-		@Override
-		public T visit(LocalFilesDataSource lfds) {
-			return defaultVisit(lfds);
-		}
-
 		@Override
 		public T visit(Report r) {
 			return defaultVisit(r);
 		}
-
+		
 		@Override
 		public T visit(OsAccount act) {
 			return defaultVisit(act);
 		}
-
+		
 		@Override
 		public T visit(UnsupportedContent uc) {
 			return defaultVisit(uc);
diff --git a/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java b/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java
index c06dab730..274100654 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java
@@ -150,6 +150,19 @@ public synchronized DerivedMethod getDerivedMethod() throws TskCoreException {
 		return derivedMethod;
 	}
 
+	/**
+	 * Accepts a content visitor (Visitor design pattern).
+	 *
+	 * @param visitor A ContentVisitor supplying an algorithm to run using this
+	 *                derived file as input.
+	 *
+	 * @return The output of the algorithm.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
+
 	/**
 	 * Accepts a Sleuthkit item visitor (Visitor design pattern).
 	 *
diff --git a/bindings/java/src/org/sleuthkit/datamodel/Directory.java b/bindings/java/src/org/sleuthkit/datamodel/Directory.java
index ffebd6b2c..f0d376b38 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/Directory.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/Directory.java
@@ -94,6 +94,19 @@ public class Directory extends FsContent {
 		super(db, objId, dataSourceObjectId, fsObjId, attrType, attrId, name, TskData.TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, null, null, ownerUid, osAccountObjId, Collections.emptyList());
 	}
 
+	/**
+	 * Accepts a content visitor (Visitor design pattern).
+	 *
+	 * @param visitor A ContentVisitor supplying an algorithm to run using this
+	 *                directory as input.
+	 *
+	 * @return The output of the algorithm.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
+
 	/**
 	 * Accepts a Sleuthkit item visitor (Visitor design pattern).
 	 *
diff --git a/bindings/java/src/org/sleuthkit/datamodel/File.java b/bindings/java/src/org/sleuthkit/datamodel/File.java
index f3da36861..659ed70ac 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/File.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/File.java
@@ -102,6 +102,19 @@ public class File extends FsContent {
 		super(db, objId, dataSourceObjectId, fsObjId, attrType, attrId, name, TskData.TSK_DB_FILES_TYPE_ENUM.FS, metaAddr, metaSeq, dirType, metaType, dirFlag, metaFlags, size, ctime, crtime, atime, mtime, modes, uid, gid, md5Hash, sha256Hash, knownState, parentPath, mimeType, extension, ownerUid, osAccountObjId, fileAttributes);
 	}
 
+	/**
+	 * Accepts a content visitor (Visitor design pattern).
+	 *
+	 * @param visitor A ContentVisitor supplying an algorithm to run using this
+	 *                file as input.
+	 *
+	 * @return The output of the algorithm.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> visitor) {
+		return visitor.visit(this);
+	}
+
 	/**
 	 * Accepts a Sleuthkit item visitor (Visitor design pattern).
 	 *
diff --git a/bindings/java/src/org/sleuthkit/datamodel/FileSystem.java b/bindings/java/src/org/sleuthkit/datamodel/FileSystem.java
index 25ce946a4..d20f8b7df 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/FileSystem.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/FileSystem.java
@@ -207,6 +207,11 @@ public void finalize() throws Throwable {
 		}
 	}
 	
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
+
 	@Override
 	public <T> T accept(ContentVisitor<T> v) {
 		return v.visit(this);
diff --git a/bindings/java/src/org/sleuthkit/datamodel/HostAddress.java b/bindings/java/src/org/sleuthkit/datamodel/HostAddress.java
index 191c759de..4b545baee 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/HostAddress.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/HostAddress.java
@@ -128,6 +128,12 @@ public <T> T accept(ContentVisitor<T> v) {
 		throw new UnsupportedOperationException("Not supported yet.");
 	}
 
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		// TODO
+		throw new UnsupportedOperationException("Not supported yet.");
+	}
+
 	/**
 	 * A host may have different types of addresses at a given point in time.
 	 */
diff --git a/bindings/java/src/org/sleuthkit/datamodel/Image.java b/bindings/java/src/org/sleuthkit/datamodel/Image.java
index 670449a00..7e2d793a2 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/Image.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/Image.java
@@ -275,6 +275,11 @@ public String getTimeZone() {
 		return timezone;
 	}
 
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
+
 	@Override
 	public <T> T accept(ContentVisitor<T> v) {
 		return v.visit(this);
diff --git a/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java b/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java
index 39a4709c4..311dc8318 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java
@@ -230,6 +230,19 @@ public <T> T accept(ContentVisitor<T> visitor) {
 		return visitor.visit(this);
 	}
 
+	/**
+	 * Accepts a Sleuthkit item visitor (Visitor design pattern).
+	 *
+	 * @param visitor A SleuthkitItemVisitor supplying an algorithm to run using
+	 *                this file as input.
+	 *
+	 * @return The output of the algorithm.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> visitor) {
+		return visitor.visit(this);
+	}
+
 	/**
 	 * Provides a string representation of this file.
 	 *
diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java b/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java
index 1183899ea..2b90de830 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java
@@ -109,6 +109,19 @@ public <T> T accept(ContentVisitor<T> visitor) {
 		return visitor.visit(this);
 	}
 
+	/**
+	 * Accepts a Sleuthkit item visitor (Visitor design pattern).
+	 *
+	 * @param visitor A SleuthkitItemVisitor supplying an algorithm to run using
+	 *                this local directory as input.
+	 *
+	 * @return The output of the algorithm.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> visitor) {
+		return visitor.visit(this);
+	}
+
 	/**
 	 * Provides a string representation of this local directory.
 	 *
diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java b/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java
index 405e2e199..1e5dcf6bf 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java
@@ -146,6 +146,20 @@ public <T> T accept(ContentVisitor<T> visitor) {
 		return visitor.visit(this);
 	}
 
+	/**
+	 * Accepts a Sleuthkit item visitor (Visitor design pattern).
+	 *
+	 * @param <T>     The type returned by the visitor.
+	 * @param visitor A SleuthkitItemVisitor supplying an algorithm to run using
+	 *                this local file as input.
+	 *
+	 * @return The output of the algorithm.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> visitor) {
+		return visitor.visit(this);
+	}
+
 	/**
 	 * Provides a string representation of this local file.
 	 *
diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java
index 96a99de8d..871d292c9 100755
--- a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java
@@ -333,6 +333,20 @@ public <T> T accept(ContentVisitor<T> visitor) {
 		return visitor.visit(this);
 	}
 	
+	/**
+	 * Accepts a Sleuthkit item visitor (Visitor design pattern).
+	 *
+	 * @param <T>     The type returned by the visitor.
+	 * @param visitor A SleuthkitItemVisitor supplying an algorithm to run using
+	 *                this virtual directory as input.
+	 *
+	 * @return The output of the algorithm.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> visitor) {
+		return visitor.visit(this);
+	}
+	
 	/**
 	 * Constructs a local/logical files and/or directories data source.
 	 *
diff --git a/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java b/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java
index feb54bfc4..d78434f4c 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java
@@ -399,6 +399,11 @@ public <T> T accept(ContentVisitor<T> v) {
 		throw new UnsupportedOperationException("Not supported yet.");
 	}
 
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
+
 	/**
 	 * Abstracts attributes of an OS account. An attribute may be specific to a
 	 * host, or applicable across all hosts.
diff --git a/bindings/java/src/org/sleuthkit/datamodel/Pool.java b/bindings/java/src/org/sleuthkit/datamodel/Pool.java
index 436d58a21..2a6e712e7 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/Pool.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/Pool.java
@@ -133,6 +133,11 @@ protected void finalize() throws Throwable {
 		}
 	}
 	
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
+
 	@Override
 	public <T> T accept(ContentVisitor<T> v) {
 		return v.visit(this);
diff --git a/bindings/java/src/org/sleuthkit/datamodel/Report.java b/bindings/java/src/org/sleuthkit/datamodel/Report.java
index 089363d4a..3b6928cfa 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/Report.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/Report.java
@@ -403,4 +403,9 @@ public long getArtifactsCount(BlackboardArtifact.ARTIFACT_TYPE type) throws TskC
 	public long getAllArtifactsCount() throws TskCoreException {
 		return db.getBlackboardArtifactsCount(objectId);
 	}
+
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
 }
diff --git a/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java b/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java
index e0350d5a9..8cf9407e5 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java
@@ -124,6 +124,19 @@ protected int readInt(byte[] buf, long offset, long len) throws TskCoreException
 		return SleuthkitJNI.readFileSlack(fileHandle, buf, offset, len);
 	}
 
+	/**
+	 * Accepts a content visitor (Visitor design pattern).
+	 *
+	 * @param v A ContentVisitor supplying an algorithm to run using this file
+	 *          as input.
+	 *
+	 * @return The output of the algorithm.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
+
 	/**
 	 * Accepts a Sleuthkit item visitor (Visitor design pattern).
 	 *
diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitItemVisitor.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitItemVisitor.java
new file mode 100644
index 000000000..5e90113f9
--- /dev/null
+++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitItemVisitor.java
@@ -0,0 +1,316 @@
+/*
+ * Sleuth Kit Data Model
+ *
+ * Copyright 2011-2021 Basis Technology Corp.
+ * Contact: carrier <at> sleuthkit <dot> org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.sleuthkit.datamodel;
+
+/**
+ * Interface for implementing a visitor pattern on all displayable items:
+ * Content implementations and blackboard artifacts.
+ *
+ * Visitor implements an algorithm on the content and blackboard artifacts
+ * objects. The algorithm is completely decoupled from the data object. The
+ * visitor pattern emulates double dispatch mechanism. It allows to act
+ * differently depending on the instance type, without need to test what the
+ * actual type is. E.g. it allows for processing an object hierarchy without
+ * using instanceof statements. Generic type parameter T is a return type from
+ * the visit methods.
+ *
+ * @param <T> return type of visit methods
+ */
+public interface SleuthkitItemVisitor<T> {
+
+	/**
+	 * Act on (visit) a Directory content object
+	 *
+	 * @param d the directory to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(Directory d);
+
+	/**
+	 * Act on (visit) a File content object
+	 *
+	 * @param f the file to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(File f);
+
+	/**
+	 * Act on (visit) a FileSystem content object
+	 *
+	 * @param fs the filesystem to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(FileSystem fs);
+
+	/**
+	 * Act on (visit) an Image content object
+	 *
+	 * @param i the image to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(Image i);
+
+	/**
+	 * Act on (visit) a Volume content object
+	 *
+	 * @param v the volume to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(Volume v);
+
+	/**
+	 * Act on (visit) a VolumeSystem content object
+	 *
+	 * @param vs the volume system to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(VolumeSystem vs);
+	
+	/**
+	 * Act on (visit) a Pool content object
+	 *
+	 * @param pool the volume system to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(Pool pool);
+
+	/**
+	 * Act on (visit) a blackboard artifact object
+	 *
+	 * @param ba blackboard artifact object to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(BlackboardArtifact ba);
+
+	/**
+	 * Act on (visit) a blackboard artifact type
+	 *
+	 * @param tw blackboard artifact type to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(BlackboardArtifact.ARTIFACT_TYPE tw);
+
+	/**
+	 * Act on (visit) a layout file content object
+	 *
+	 * @param lf layout file to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(LayoutFile lf);
+
+	/**
+	 * Act on (visit) a VirtualDirectory content object
+	 *
+	 * @param ld layout dir to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(VirtualDirectory ld);
+
+	/**
+	 * Act on (visit) a LocalDirectory content object
+	 *
+	 * @param ld layout dir to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(LocalDirectory ld);
+
+	/**
+	 * Act on (visit) a DerivedFile content object
+	 *
+	 * @param df derived file to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(DerivedFile df);
+
+	/**
+	 * Act on (visit) a LocalFile content object
+	 *
+	 * @param lf local file to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(LocalFile lf);
+
+	/**
+	 * Act on (visit) a SlackFile content object
+	 *
+	 * @param sf slack file to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(SlackFile sf);
+
+	/**
+	 * Act on (visit) a Report content object
+	 *
+	 * @param report report to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(Report report);
+	
+	/**
+	 * Act on (visit) a OsAccount content object
+	 *
+	 * @param account report to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(OsAccount account);
+	
+	/**
+	 * Act on (visit) an UnsupportedContent object
+	 *
+	 * @param unsupportedContent content to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(UnsupportedContent unsupportedContent);
+	
+	/**
+	 * Act on (visit) a LocalFilesDataSource content object
+	 *
+	 * @param localFilesDataSource report to visit / act on
+	 *
+	 * @return result of the visit
+	 */
+	T visit(LocalFilesDataSource localFilesDataSource);
+
+	/**
+	 * The default visitor - quickest method for implementing a custom visitor.
+	 * Every visit method delegates to the defaultVisit method, the only
+	 * required method to be implemented. Then, implement the specific visit
+	 * methods for the objects on which the algorithm needs to act differently.
+	 *
+	 * @param <T> generic type, signifies the object type to be returned from
+	 *            visit()
+	 */
+	static abstract public class Default<T> implements SleuthkitItemVisitor<T> {
+
+		protected abstract T defaultVisit(SleuthkitVisitableItem s);
+
+		@Override
+		public T visit(Directory d) {
+			return defaultVisit(d);
+		}
+
+		@Override
+		public T visit(File f) {
+			return defaultVisit(f);
+		}
+
+		@Override
+		public T visit(FileSystem fs) {
+			return defaultVisit(fs);
+		}
+
+		@Override
+		public T visit(Image i) {
+			return defaultVisit(i);
+		}
+
+		@Override
+		public T visit(Volume v) {
+			return defaultVisit(v);
+		}
+
+		@Override
+		public T visit(VolumeSystem vs) {
+			return defaultVisit(vs);
+		}
+		
+		@Override
+		public T visit(Pool p) {
+			return defaultVisit(p);
+		}
+
+		@Override
+		public T visit(BlackboardArtifact ba) {
+			return defaultVisit(ba);
+		}
+
+		@Override
+		public T visit(BlackboardArtifact.ARTIFACT_TYPE tw) {
+			return defaultVisit(tw);
+		}
+
+		@Override
+		public T visit(LayoutFile lf) {
+			return defaultVisit(lf);
+		}
+
+		@Override
+		public T visit(VirtualDirectory vd) {
+			return defaultVisit(vd);
+		}
+
+		@Override
+		public T visit(LocalDirectory ld) {
+			return defaultVisit(ld);
+		}
+
+		@Override
+		public T visit(DerivedFile df) {
+			return defaultVisit(df);
+		}
+
+		@Override
+		public T visit(LocalFile lf) {
+			return defaultVisit(lf);
+		}
+
+		@Override
+		public T visit(SlackFile sf) {
+			return defaultVisit(sf);
+		}
+
+		@Override
+		public T visit(Report report) {
+			return defaultVisit(report);
+		}
+		
+		@Override
+		public T visit(OsAccount account) {
+			return defaultVisit(account);
+		}
+		
+		@Override
+		public T visit(UnsupportedContent unsupportedContent) {
+			return defaultVisit(unsupportedContent);
+		}
+		
+		@Override
+		public T visit(LocalFilesDataSource localFilesDataSource) {
+			return defaultVisit(localFilesDataSource);
+		}
+	}
+}
diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitVisitableItem.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitVisitableItem.java
new file mode 100644
index 000000000..ed17d61d7
--- /dev/null
+++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitVisitableItem.java
@@ -0,0 +1,35 @@
+/*
+ * Sleuth Kit Data Model
+ * 
+ * Copyright 2011 Basis Technology Corp.
+ * Contact: carrier <at> sleuthkit <dot> org
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.sleuthkit.datamodel;
+
+/**
+ * Interface for all visitable datatypes that can be found in the tsk database
+ */
+public interface SleuthkitVisitableItem {
+
+	/**
+	 * visitor pattern support
+	 *
+	 * @param v visitor
+	 *
+	 * @return visitor return value
+	 */
+	public <T> T accept(SleuthkitItemVisitor<T> v);
+
+}
diff --git a/bindings/java/src/org/sleuthkit/datamodel/UnsupportedContent.java b/bindings/java/src/org/sleuthkit/datamodel/UnsupportedContent.java
index 120a4988c..d9bbca1bd 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/UnsupportedContent.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/UnsupportedContent.java
@@ -55,4 +55,9 @@ public long getSize() {
 	public <T> T accept(ContentVisitor<T> v) {
 		return v.visit(this);
 	}
+
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
 }
diff --git a/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java b/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java
index 4c22cc728..7d2c4519e 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java
@@ -117,6 +117,20 @@ public <T> T accept(ContentVisitor<T> visitor) {
 		return visitor.visit(this);
 	}
 
+	/**
+	 * Accepts a Sleuthkit item visitor (Visitor design pattern).
+	 *
+	 * @param <T>     The type returned by the visitor.
+	 * @param visitor A SleuthkitItemVisitor supplying an algorithm to run using
+	 *                this virtual directory as input.
+	 *
+	 * @return The output of the algorithm.
+	 */
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> visitor) {
+		return visitor.visit(this);
+	}
+
 	/**
 	 * Provides a string representation of this virtual directory.
 	 *
diff --git a/bindings/java/src/org/sleuthkit/datamodel/Volume.java b/bindings/java/src/org/sleuthkit/datamodel/Volume.java
index 6d07dd9f4..f63557cda 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/Volume.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/Volume.java
@@ -255,6 +255,11 @@ public static String vsFlagToString(long vsFlag) {
 		return result;
 	}
 
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
+
 	@Override
 	public <T> T accept(ContentVisitor<T> v) {
 		return v.visit(this);
diff --git a/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java b/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java
index 7b1f74d7d..e40357614 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java
@@ -131,6 +131,11 @@ public void finalize() throws Throwable {
 			super.finalize();
 		}
 	}
+	
+	@Override
+	public <T> T accept(SleuthkitItemVisitor<T> v) {
+		return v.visit(this);
+	}
 
 	@Override
 	public <T> T accept(ContentVisitor<T> v) {
-- 
GitLab