From 8f8741da27ddbcbc7266b793dbbad3c92c8511b7 Mon Sep 17 00:00:00 2001 From: Kelly Kelly <kelly@basistech.com> Date: Wed, 9 Jun 2021 17:07:12 -0400 Subject: [PATCH] Added support for LocalFilesDataSource in SleuthkitItemVisitor --- .../datamodel/LocalFilesDataSource.java | 30 ++++++++++++++++++- .../datamodel/SleuthkitItemVisitor.java | 16 +++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java index fbf5449a8..ae5652c88 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java +++ b/bindings/java/src/org/sleuthkit/datamodel/LocalFilesDataSource.java @@ -1,7 +1,7 @@ /* * Sleuth Kit Data Model * - * Copyright 2011-2017 Basis Technology Corp. + * Copyright 2011-2021 Basis Technology Corp. * Contact: carrier <at> sleuthkit <dot> org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -314,6 +314,34 @@ private static void closeStatement(Statement statement) { } } + /** + * Accepts a content visitor (Visitor design pattern). + * + * @param <T> The type returned by the visitor. + * @param visitor A ContentVisitor supplying an algorithm to run using this + * virtual directory as input. + * + * @return The output of the algorithm. + */ + @Override + 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/SleuthkitItemVisitor.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitItemVisitor.java index 45927b109..5e90113f9 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitItemVisitor.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitItemVisitor.java @@ -1,7 +1,7 @@ /* * Sleuth Kit Data Model * - * Copyright 2011-2018 Basis Technology Corp. + * Copyright 2011-2021 Basis Technology Corp. * Contact: carrier <at> sleuthkit <dot> org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -195,6 +195,15 @@ public interface SleuthkitItemVisitor<T> { * @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. @@ -298,5 +307,10 @@ public T visit(OsAccount account) { public T visit(UnsupportedContent unsupportedContent) { return defaultVisit(unsupportedContent); } + + @Override + public T visit(LocalFilesDataSource localFilesDataSource) { + return defaultVisit(localFilesDataSource); + } } } -- GitLab