Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
DefaultCellModel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2021 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.report.modules.datasourcesummaryexport;
20 
21 import java.util.function.Function;
25 class DefaultCellModel<T> implements CellModel {
26 
27  private final T data;
28  private final String text;
29  private CellModel.HorizontalAlign horizontalAlignment;
30  private final String excelFormatString;
31 
37  DefaultCellModel(T data) {
38  this(data, null, null);
39  }
40 
48  DefaultCellModel(T data, Function<T, String> stringConverter) {
49  this(data, stringConverter, null);
50  }
51 
64  DefaultCellModel(T data, Function<T, String> stringConverter, String excelFormatString) {
65  this.data = data;
66  this.excelFormatString = excelFormatString;
67 
68  if (stringConverter == null) {
69  text = this.data == null ? "" : this.data.toString();
70  } else {
71  text = stringConverter.apply(this.data);
72  }
73  }
74 
75  @Override
76  public T getData() {
77  return this.data;
78  }
79 
80  @Override
81  public String getText() {
82  return text;
83  }
84 
85  @Override
86  public HorizontalAlign getHorizontalAlignment() {
87  return horizontalAlignment;
88  }
89 
90  @Override
91  public String getExcelFormatString() {
92  return this.excelFormatString;
93  }
94 
102  DefaultCellModel<T> setHorizontalAlignment(CellModel.HorizontalAlign alignment) {
103  this.horizontalAlignment = alignment;
104  return this;
105  }
106 
107  @Override
108  public String toString() {
109  return getText();
110  }
111 }

Copyright © 2012-2022 Basis Technology. Generated on: Sun Oct 2 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.