From f145759431e9d79a16939ad26559975b3d85f50b Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro <gregd@basistech.com> Date: Thu, 13 Jan 2022 16:06:36 -0500 Subject: [PATCH] Revert "Revert "8271 remove tsk visitor"" This reverts commit f09a5b6c9c29e5d4c7fa79355af91b1869f7694c. --- .../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, 32 insertions(+), 567 deletions(-) delete mode 100644 bindings/java/src/org/sleuthkit/datamodel/SleuthkitItemVisitor.java delete 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 fba83e40e..b3990eb92 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java +++ b/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java @@ -900,21 +900,6 @@ 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. @@ -1594,7 +1579,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 implements SleuthkitVisitableItem { + public enum ARTIFACT_TYPE { /** * A generic information artifact. @@ -2116,23 +2101,6 @@ 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 5993ac460..a8779ad1e 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 extends SleuthkitVisitableItem { +public interface Content { /** * 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 7d922b9f1..875f9bad1 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,8 +155,17 @@ public interface ContentVisitor<T> { * * @return result of the visit */ - T visit(BlackboardArtifact ba); - + 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); + /** * Act on (visit) a Report object * @@ -165,7 +174,7 @@ public interface ContentVisitor<T> { * @return result of the visit */ T visit(Report r); - + /** * Act on (visit) a OsAccount object * @@ -174,7 +183,7 @@ public interface ContentVisitor<T> { * @return result of the visit */ T visit(OsAccount act); - + /** * Act on (visit) an UnsupportedContent object * @@ -222,7 +231,7 @@ public T visit(Image i) { public T visit(Volume v) { return defaultVisit(v); } - + @Override public T visit(Pool p) { return defaultVisit(p); @@ -242,7 +251,7 @@ public T visit(LayoutFile lf) { public T visit(VirtualDirectory ld) { return defaultVisit(ld); } - + @Override public T visit(LocalDirectory ld) { return defaultVisit(ld); @@ -257,27 +266,32 @@ 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 274100654..c06dab730 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/DerivedFile.java @@ -150,19 +150,6 @@ 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 f0d376b38..ffebd6b2c 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Directory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Directory.java @@ -94,19 +94,6 @@ 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 659ed70ac..f3da36861 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/File.java +++ b/bindings/java/src/org/sleuthkit/datamodel/File.java @@ -102,19 +102,6 @@ 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 d20f8b7df..25ce946a4 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/FileSystem.java +++ b/bindings/java/src/org/sleuthkit/datamodel/FileSystem.java @@ -207,11 +207,6 @@ 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 4b545baee..191c759de 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/HostAddress.java +++ b/bindings/java/src/org/sleuthkit/datamodel/HostAddress.java @@ -128,12 +128,6 @@ 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 7e2d793a2..670449a00 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Image.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Image.java @@ -275,11 +275,6 @@ 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 311dc8318..39a4709c4 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LayoutFile.java @@ -230,19 +230,6 @@ 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 2b90de830..1183899ea 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalDirectory.java @@ -109,19 +109,6 @@ 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 1e5dcf6bf..405e2e199 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFile.java @@ -146,20 +146,6 @@ 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 871d292c9..96a99de8d 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java @@ -333,20 +333,6 @@ 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 d78434f4c..feb54bfc4 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java +++ b/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java @@ -399,11 +399,6 @@ 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 2a6e712e7..436d58a21 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Pool.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Pool.java @@ -133,11 +133,6 @@ 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 3b6928cfa..089363d4a 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Report.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Report.java @@ -403,9 +403,4 @@ 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 8cf9407e5..e0350d5a9 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SlackFile.java @@ -124,19 +124,6 @@ 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 deleted file mode 100644 index 5e90113f9..000000000 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitItemVisitor.java +++ /dev/null @@ -1,316 +0,0 @@ -/* - * 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 deleted file mode 100644 index ed17d61d7..000000000 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitVisitableItem.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 d9bbca1bd..120a4988c 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/UnsupportedContent.java +++ b/bindings/java/src/org/sleuthkit/datamodel/UnsupportedContent.java @@ -55,9 +55,4 @@ 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 7d2c4519e..4c22cc728 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java +++ b/bindings/java/src/org/sleuthkit/datamodel/VirtualDirectory.java @@ -117,20 +117,6 @@ 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 f63557cda..6d07dd9f4 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/Volume.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Volume.java @@ -255,11 +255,6 @@ 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 e40357614..7b1f74d7d 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java +++ b/bindings/java/src/org/sleuthkit/datamodel/VolumeSystem.java @@ -131,11 +131,6 @@ 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