1 |
c5e92bc3
|
Katja Luther
|
/**
|
2 |
|
|
* Copyright (C) 2017 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
|
|
*/
|
9 |
|
|
package eu.etaxonomy.cdm.io.common;
|
10 |
|
|
|
11 |
|
|
import java.io.Serializable;
|
12 |
5711e069
|
Katja Luther
|
import java.util.ArrayList;
|
13 |
|
|
import java.util.HashMap;
|
14 |
c5e92bc3
|
Katja Luther
|
import java.util.List;
|
15 |
|
|
import java.util.Map;
|
16 |
|
|
|
17 |
|
|
/**
|
18 |
|
|
* @author k.luther
|
19 |
|
|
* @date 17.03.2017
|
20 |
|
|
*
|
21 |
|
|
*/
|
22 |
|
|
public class ExportDataWrapper<T> implements Serializable{
|
23 |
|
|
|
24 |
|
|
private static final long serialVersionUID = 4500184563547082579L;
|
25 |
|
|
|
26 |
c62f0e82
|
unknown
|
private T exportData;
|
27 |
|
|
private ExportResultType type;
|
28 |
c5e92bc3
|
Katja Luther
|
|
29 |
03ebde9e
|
Katja Luther
|
/**
|
30 |
|
|
* @return the type
|
31 |
|
|
*/
|
32 |
|
|
public ExportResultType getType() {
|
33 |
|
|
return type;
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
/**
|
37 |
|
|
* @param type the type to set
|
38 |
|
|
*/
|
39 |
|
|
public void setType(ExportResultType type) {
|
40 |
|
|
this.type = type;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
c5e92bc3
|
Katja Luther
|
private ExportDataWrapper(){
|
44 |
|
|
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
public static final ExportDataWrapper<List<byte[]>> NewListByteArrayInstance(){
|
48 |
|
|
ExportDataWrapper<List<byte[]>> result = new ExportDataWrapper<>();
|
49 |
|
|
result.type = ExportResultType.LIST_BYTE_ARRAY;
|
50 |
c62f0e82
|
unknown
|
result.exportData = new ArrayList<>();
|
51 |
c5e92bc3
|
Katja Luther
|
return result;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
public static final ExportDataWrapper<Map<String,byte[]>> NewMapByteArrayInstance(){
|
55 |
|
|
ExportDataWrapper<Map<String, byte[]>> result = new ExportDataWrapper<>();
|
56 |
|
|
result.type = ExportResultType.MAP_BYTE_ARRAY;
|
57 |
c62f0e82
|
unknown
|
result.exportData = new HashMap<>();
|
58 |
c5e92bc3
|
Katja Luther
|
return result;
|
59 |
|
|
}
|
60 |
|
|
|
61 |
c62f0e82
|
unknown
|
public static final ExportDataWrapper<byte[]> NewByteArrayInstance(){
|
62 |
c5e92bc3
|
Katja Luther
|
ExportDataWrapper<byte[]> result = new ExportDataWrapper<>();
|
63 |
|
|
result.type = ExportResultType.BYTE_ARRAY;
|
64 |
5711e069
|
Katja Luther
|
|
65 |
c5e92bc3
|
Katja Luther
|
return result;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
public void setValue(T value){this.exportData = value;}
|
69 |
|
|
|
70 |
|
|
public T getExportData(){return this.exportData;}
|
71 |
|
|
|
72 |
|
|
public void addExportData(byte[] data){
|
73 |
|
|
if (type.equals(ExportResultType.BYTE_ARRAY)){
|
74 |
|
|
exportData = (T)data;
|
75 |
|
|
} else if (type.equals(ExportResultType.LIST_BYTE_ARRAY)){
|
76 |
|
|
((List<byte[]>)exportData).add(data);
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
|
80 |
6e8bb9fc
|
Katja Luther
|
public void putExportData(String key, byte[] data){
|
81 |
c5e92bc3
|
Katja Luther
|
if (type.equals(ExportResultType.MAP_BYTE_ARRAY)){
|
82 |
|
|
((Map<String, byte[]>)exportData).put(key,data);
|
83 |
|
|
}
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
}
|