001    package de.deepamehta.plugins.images;
002    
003    import org.codehaus.jettison.json.JSONException;
004    import org.codehaus.jettison.json.JSONObject;
005    
006    import de.deepamehta.core.JSONEnabled;
007    
008    public 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("name", name);
048            } catch (JSONException e) {
049                throw new RuntimeException(e);
050            }
051            return image;
052        }
053    
054    }