|
| 1 | +/* |
| 2 | + * Autopsy Forensic Browser |
| 3 | + * |
| 4 | + * Copyright 2018 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.autopsy.corecomponents; |
| 20 | + |
| 21 | +import org.sleuthkit.datamodel.Content; |
| 22 | +import org.openide.nodes.Node; |
| 23 | +import org.sleuthkit.datamodel.BlackboardArtifact; |
| 24 | + |
| 25 | +/** |
| 26 | + * Utility classes for content viewers. |
| 27 | + * In theory, this would live in the contentviewer package, |
| 28 | + * but the initial method was needed only be viewers in |
| 29 | + * corecomponents and therefore can stay out of public API. |
| 30 | + */ |
| 31 | +class DataContentViewerUtility { |
| 32 | + /** |
| 33 | + * Returns the first non-Blackboard Artifact from a Node. |
| 34 | + * Needed for (at least) Hex and Strings that want to view |
| 35 | + * all types of content (not just AbstractFile), but don't want |
| 36 | + * to display an artifact unless that's the only thing there. |
| 37 | + * Scenario is hash hit or interesting item hit. |
| 38 | + * |
| 39 | + * @param node Node passed into content viewer |
| 40 | + * @return highest priority content or null if there is no content |
| 41 | + */ |
| 42 | + static Content getDefaultContent(Node node) { |
| 43 | + Content bbContentSeen = null; |
| 44 | + for (Content content : (node).getLookup().lookupAll(Content.class)) { |
| 45 | + if (content instanceof BlackboardArtifact) { |
| 46 | + bbContentSeen = content; |
| 47 | + } |
| 48 | + else { |
| 49 | + return content; |
| 50 | + } |
| 51 | + } |
| 52 | + return bbContentSeen; |
| 53 | + } |
| 54 | +} |
0 commit comments