Subversion Repositories bacoAlunos

Rev

Rev 1784 | 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;
1784 jmachado 5
import com.owlike.genson.GensonBuilder;
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
    {
1784 jmachado 40
        return new GensonBuilder()
1576 jmachado 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)
1776 jmachado 46
            throws 1.5.0/docs/api/java/io/IOException.html">IOException {
1576 jmachado 47
        return getGenson().deserialize(json, FilesUploadResult.class);
48
    }
49
 
1830 jmachado 50
    public static FileUploaded parseOneFileUploaded(1.5.0/docs/api/java/lang/String.html">String json)
51
            throws 1.5.0/docs/api/java/io/IOException.html">IOException {
52
        return getGenson().deserialize(json, FileUploaded.class);
53
    }
54
 
1776 jmachado 55
    public JSONObject toJsonObj() throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException
1711 jmachado 56
    {
57
        return new JSONObject(getGenson().serialize(this));
58
    }
59
 
1776 jmachado 60
    public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException
1711 jmachado 61
    {
62
        return getGenson().serialize(this);
63
    }
1776 jmachado 64
    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
1576 jmachado 65
    {
66
        1.5.0/docs/api/java/lang/String.html">String json = getGenson().serialize(result);
67
        return json;
68
    }
69
}