Rev 1576 | Rev 1776 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1576 | jmachado | 1 | package pt.estgp.estgweb.web.controllers.utils; |
2 | |||
1711 | jmachado | 3 | |
1576 | jmachado | 4 | import com.owlike.genson.Genson; |
5 | import com.owlike.genson.TransformationException; |
||
1711 | jmachado | 6 | import org.json.JSONException; |
7 | import org.json.JSONObject; |
||
1576 | jmachado | 8 | |
9 | import java.io.IOException; |
||
10 | import java.io.Serializable; |
||
11 | import java.util.ArrayList; |
||
12 | |||
13 | /** |
||
14 | * Created by jorgemachado on 27/12/16. |
||
15 | */ |
||
16 | public class FilesUploadResult implements 1.5.0/docs/api/java/io/Serializable.html">Serializable |
||
17 | { |
||
18 | 1.5.0/docs/api/java/lang/String.html">String service; |
||
19 | ArrayList<FileUploaded> uploadedFiles = new ArrayList<FileUploaded>(); |
||
20 | |||
21 | public 1.5.0/docs/api/java/lang/String.html">String getService() |
||
22 | { |
||
23 | return service; |
||
24 | } |
||
25 | |||
26 | public void setService(1.5.0/docs/api/java/lang/String.html">String service) { |
||
27 | this.service = service; |
||
28 | } |
||
29 | |||
30 | public ArrayList<FileUploaded> getUploadedFiles() { |
||
31 | return uploadedFiles; |
||
32 | } |
||
33 | |||
34 | public void setUploadedFiles(ArrayList<FileUploaded> uploadedFiles) { |
||
35 | this.uploadedFiles = uploadedFiles; |
||
36 | } |
||
37 | |||
38 | public static Genson getGenson() |
||
39 | { |
||
40 | return new Genson.Builder() |
||
41 | .include(FilesUploadResult.class) |
||
42 | .include(FileUploaded.class) |
||
43 | .create(); |
||
44 | } |
||
45 | public static FilesUploadResult parse(1.5.0/docs/api/java/lang/String.html">String json) |
||
46 | throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException { |
||
47 | return getGenson().deserialize(json, FilesUploadResult.class); |
||
48 | } |
||
49 | |||
1711 | jmachado | 50 | public JSONObject toJsonObj() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException |
51 | { |
||
52 | return new JSONObject(getGenson().serialize(this)); |
||
53 | } |
||
54 | |||
55 | public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
||
56 | { |
||
57 | return getGenson().serialize(this); |
||
58 | } |
||
1576 | jmachado | 59 | public static 1.5.0/docs/api/java/lang/String.html">String serializeJson(FilesUploadResult result) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
60 | { |
||
61 | 1.5.0/docs/api/java/lang/String.html">String json = getGenson().serialize(result); |
||
62 | return json; |
||
63 | } |
||
64 | } |