001package de.deepamehta.plugins.images;
002
003import org.codehaus.jettison.json.JSONException;
004import org.codehaus.jettison.json.JSONObject;
005
006import de.deepamehta.core.JSONEnabled;
007
008public class Image implements JSONEnabled {
009
010    private final Long size;
011
012    private final String src;
013
014    private final String type;
015    
016    private final String name;
017    
018    public Image(String src, String mediaType, Long size, String fileName) {
019        this.size = size;
020        this.src = src;
021        this.type = mediaType;
022        this.name = fileName;
023    }
024
025    public Long getSize() {
026        return size;
027    }
028
029    public String getSrc() {
030        return src;
031    }
032
033    public String getType() {
034        return type;
035    }
036
037    public String getName() {
038        return name;
039    }
040
041    @Override
042    public JSONObject toJSON() {
043        JSONObject image = new JSONObject();
044        try {
045            image.put("src", src);
046            image.put("type", type);
047            image.put("size", size);
048            image.put("name", name);
049        } catch (JSONException e) {
050            throw new RuntimeException(e);
051        }
052        return image;
053    }
054
055}