Subversion Repositories bacoAlunos

Rev

Rev 1675 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1670 jmachado 1
package pt.estgp.estgweb.domain;
2
 
3
import com.owlike.genson.Genson;
4
import com.owlike.genson.TransformationException;
5
import org.json.JSONException;
6
import org.json.JSONObject;
7
 
8
import java.io.IOException;
9
import java.io.Serializable;
10
import java.util.List;
11
 
12
/**
13
 * Created by jorgemachado on 23/02/17.
14
 */
15
public class RepositoryDocumentCollectionImpl extends RepositoryDocumentCollection {
16
    @1.5.0/docs/api/java/lang/Override.html">Override
17
    public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() {
18
        return getId();
19
    }
20
 
21
 
22
    static Genson genson = new Genson.Builder()
23
            .exclude(5+0%2Fdocs%2Fapi+Object">Object.class)
24
            .include(RepositoryDocumentCollectionImpl.class)
25
            .include(1.5.0/docs/api/java/lang/String.html">String.class)
26
            .create();
27
 
28
    public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException
29
    {
30
        return genson.serialize(this);
31
    }
32
 
33
    public static 1.5.0/docs/api/java/lang/String.html">String toJson(List<RepositoryDocumentCollection> collections) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException
34
    {
35
        return genson.serialize(collections);
36
    }
37
 
38
    public static RepositoryDocumentCollectionImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException {
39
        return genson.deserialize(json, RepositoryDocumentCollectionImpl.class);
40
    }
41
 
42
    public JSONObject toJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException {
43
        return new JSONObject(toJson());
44
    }
45
}
46