|
| 1 | +package com.fasterxml.jackson.databind; |
| 2 | + |
| 3 | +import java.util.*; |
| 4 | + |
| 5 | +import com.fasterxml.jackson.annotation.JsonFormat; |
| 6 | +import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
| 7 | + |
| 8 | +@JsonFormat(shape=JsonFormat.Shape.ARRAY) |
| 9 | +@JsonPropertyOrder({"content", "images"}) |
| 10 | +public class MediaItem |
| 11 | +{ |
| 12 | + public enum Player { JAVA, FLASH; } |
| 13 | + public enum Size { SMALL, LARGE; } |
| 14 | + |
| 15 | + private List<Photo> _photos; |
| 16 | + private Content _content; |
| 17 | + |
| 18 | + public MediaItem() { } |
| 19 | + |
| 20 | + public MediaItem(Content c) |
| 21 | + { |
| 22 | + _content = c; |
| 23 | + } |
| 24 | + |
| 25 | + public void addPhoto(Photo p) { |
| 26 | + if (_photos == null) { |
| 27 | + _photos = new ArrayList<Photo>(); |
| 28 | + } |
| 29 | + _photos.add(p); |
| 30 | + } |
| 31 | + |
| 32 | + public List<Photo> getImages() { return _photos; } |
| 33 | + public void setImages(List<Photo> p) { _photos = p; } |
| 34 | + |
| 35 | + public Content getContent() { return _content; } |
| 36 | + public void setContent(Content c) { _content = c; } |
| 37 | + |
| 38 | + /* |
| 39 | + /********************************************************** |
| 40 | + /* Helper types |
| 41 | + /********************************************************** |
| 42 | + */ |
| 43 | + |
| 44 | + @JsonFormat(shape=JsonFormat.Shape.ARRAY) |
| 45 | + @JsonPropertyOrder({"uri","title","width","height","size"}) |
| 46 | + public static class Photo |
| 47 | + { |
| 48 | + private String _uri; |
| 49 | + private String _title; |
| 50 | + private int _width; |
| 51 | + private int _height; |
| 52 | + private Size _size; |
| 53 | + |
| 54 | + public Photo() {} |
| 55 | + public Photo(String uri, String title, int w, int h, Size s) |
| 56 | + { |
| 57 | + _uri = uri; |
| 58 | + _title = title; |
| 59 | + _width = w; |
| 60 | + _height = h; |
| 61 | + _size = s; |
| 62 | + } |
| 63 | + |
| 64 | + public String getUri() { return _uri; } |
| 65 | + public String getTitle() { return _title; } |
| 66 | + public int getWidth() { return _width; } |
| 67 | + public int getHeight() { return _height; } |
| 68 | + public Size getSize() { return _size; } |
| 69 | + |
| 70 | + public void setUri(String u) { _uri = u; } |
| 71 | + public void setTitle(String t) { _title = t; } |
| 72 | + public void setWidth(int w) { _width = w; } |
| 73 | + public void setHeight(int h) { _height = h; } |
| 74 | + public void setSize(Size s) { _size = s; } |
| 75 | + } |
| 76 | + |
| 77 | + @JsonFormat(shape=JsonFormat.Shape.ARRAY) |
| 78 | + @JsonPropertyOrder({"uri","title","width","height","format","duration","size","bitrate","persons","player","copyright"}) |
| 79 | + public static class Content |
| 80 | + { |
| 81 | + private Player _player; |
| 82 | + private String _uri; |
| 83 | + private String _title; |
| 84 | + private int _width; |
| 85 | + private int _height; |
| 86 | + private String _format; |
| 87 | + private long _duration; |
| 88 | + private long _size; |
| 89 | + private int _bitrate; |
| 90 | + private List<String> _persons; |
| 91 | + private String _copyright; |
| 92 | + |
| 93 | + public Content() { } |
| 94 | + |
| 95 | + public void addPerson(String p) { |
| 96 | + if (_persons == null) { |
| 97 | + _persons = new ArrayList<String>(); |
| 98 | + } |
| 99 | + _persons.add(p); |
| 100 | + } |
| 101 | + |
| 102 | + public Player getPlayer() { return _player; } |
| 103 | + public String getUri() { return _uri; } |
| 104 | + public String getTitle() { return _title; } |
| 105 | + public int getWidth() { return _width; } |
| 106 | + public int getHeight() { return _height; } |
| 107 | + public String getFormat() { return _format; } |
| 108 | + public long getDuration() { return _duration; } |
| 109 | + public long getSize() { return _size; } |
| 110 | + public int getBitrate() { return _bitrate; } |
| 111 | + public List<String> getPersons() { return _persons; } |
| 112 | + public String getCopyright() { return _copyright; } |
| 113 | + |
| 114 | + public void setPlayer(Player p) { _player = p; } |
| 115 | + public void setUri(String u) { _uri = u; } |
| 116 | + public void setTitle(String t) { _title = t; } |
| 117 | + public void setWidth(int w) { _width = w; } |
| 118 | + public void setHeight(int h) { _height = h; } |
| 119 | + public void setFormat(String f) { _format = f; } |
| 120 | + public void setDuration(long d) { _duration = d; } |
| 121 | + public void setSize(long s) { _size = s; } |
| 122 | + public void setBitrate(int b) { _bitrate = b; } |
| 123 | + public void setPersons(List<String> p) { _persons = p; } |
| 124 | + public void setCopyright(String c) { _copyright = c; } |
| 125 | + } |
| 126 | +} |
0 commit comments