Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
OtherOccurrencesCasesTableModel.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2019 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.centralrepository.contentviewer;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.table.AbstractTableModel;
24 import org.openide.util.NbBundle.Messages;
26 
31 public class OtherOccurrencesCasesTableModel extends AbstractTableModel {
32 
33  private static final long serialVersionUID = 1L;
34  private final List<CorrelationCaseWrapper> correlationCaseList = new ArrayList<>();
35 
40  // This constructor is intentionally empty.
41  }
42 
43  @Override
44  public int getColumnCount() {
45  return 1;
46  }
47 
48  @Override
49  public int getRowCount() {
50  return correlationCaseList.size();
51  }
52 
53  @Messages({"OtherOccurrencesCasesTableModel.case=Case",})
54  @Override
55  public String getColumnName(int colIdx) {
56  return Bundle.OtherOccurrencesCasesTableModel_case();
57  }
58 
59  @Messages({"OtherOccurrencesCasesTableModel.noData=No Data."})
60  @Override
61  public Object getValueAt(int rowIdx, int colIdx) {
62  //if anything would prevent this from working we will consider it no data for the sake of simplicity
63  if (correlationCaseList.isEmpty() || rowIdx < 0
64  || rowIdx >= correlationCaseList.size()
65  || correlationCaseList.get(rowIdx) == null
66  || correlationCaseList.get(rowIdx).getMessage() == null
67  || correlationCaseList.get(rowIdx).getMessage().isEmpty()) {
68  return Bundle.OtherOccurrencesCasesTableModel_noData();
69  }
70  return correlationCaseList.get(rowIdx).getMessage();
71  }
72 
83  CorrelationCase getCorrelationCase(int rowIdx) {
84  //if anything would prevent this from working we will return null
85  if (correlationCaseList.isEmpty() || rowIdx < 0
86  || rowIdx >= correlationCaseList.size()
87  || correlationCaseList.get(rowIdx) == null) {
88  return null;
89  }
90  return correlationCaseList.get(rowIdx).getCorrelationCase();
91  }
92 
93  @Override
94  public Class<String> getColumnClass(int colIdx) {
95  return String.class;
96  }
97 
103  void addCorrelationCase(CorrelationCaseWrapper newCorrelationCaseWrapper) {
104  correlationCaseList.add(newCorrelationCaseWrapper);
105  fireTableDataChanged();
106  }
107 
111  void clearTable() {
112  correlationCaseList.clear();
113  fireTableDataChanged();
114  }
115 }

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.