2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.io
.common
;
11 import java
.io
.Serializable
;
12 import java
.util
.ArrayList
;
13 import java
.util
.HashMap
;
14 import java
.util
.List
;
22 public class ExportDataWrapper
<T
> implements Serializable
{
24 private static final long serialVersionUID
= 4500184563547082579L;
27 private ExportResultType type
;
29 private ExportDataWrapper(){
32 public ExportResultType
getType() {
36 public void setType(ExportResultType type
) {
40 public static final ExportDataWrapper
<List
<byte[]>> NewListByteArrayInstance(){
41 ExportDataWrapper
<List
<byte[]>> result
= new ExportDataWrapper
<>();
42 result
.type
= ExportResultType
.LIST_BYTE_ARRAY
;
43 result
.exportData
= new ArrayList
<>();
47 public static final ExportDataWrapper
<Map
<String
,byte[]>> NewMapByteArrayInstance(){
48 ExportDataWrapper
<Map
<String
, byte[]>> result
= new ExportDataWrapper
<>();
49 result
.type
= ExportResultType
.MAP_BYTE_ARRAY
;
50 result
.exportData
= new HashMap
<>();
54 public static final ExportDataWrapper
<byte[]> NewByteArrayInstance(){
55 ExportDataWrapper
<byte[]> result
= new ExportDataWrapper
<>();
56 result
.type
= ExportResultType
.BYTE_ARRAY
;
61 public void setValue(T value
){this.exportData
= value
;}
63 public T
getExportData(){return this.exportData
;}
65 public void addExportData(byte[] data
){
66 if (type
.equals(ExportResultType
.BYTE_ARRAY
)){
68 } else if (type
.equals(ExportResultType
.LIST_BYTE_ARRAY
)){
69 ((List
<byte[]>)exportData
).add(data
);
73 public void putExportData(String key
, byte[] data
){
74 if (type
.equals(ExportResultType
.MAP_BYTE_ARRAY
)){
75 ((Map
<String
, byte[]>)exportData
).put(key
,data
);