1 package com.fasterxml.jackson.databind.testutil; 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 MediaItem()18 public MediaItem() { } 19 MediaItem(Content c)20 public MediaItem(Content c) 21 { 22 _content = c; 23 } 24 addPhoto(Photo p)25 public void addPhoto(Photo p) { 26 if (_photos == null) { 27 _photos = new ArrayList<Photo>(); 28 } 29 _photos.add(p); 30 } 31 getImages()32 public List<Photo> getImages() { return _photos; } setImages(List<Photo> p)33 public void setImages(List<Photo> p) { _photos = p; } 34 getContent()35 public Content getContent() { return _content; } setContent(Content c)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 Photo()54 public Photo() {} Photo(String uri, String title, int w, int h, Size s)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 getUri()64 public String getUri() { return _uri; } getTitle()65 public String getTitle() { return _title; } getWidth()66 public int getWidth() { return _width; } getHeight()67 public int getHeight() { return _height; } getSize()68 public Size getSize() { return _size; } 69 setUri(String u)70 public void setUri(String u) { _uri = u; } setTitle(String t)71 public void setTitle(String t) { _title = t; } setWidth(int w)72 public void setWidth(int w) { _width = w; } setHeight(int h)73 public void setHeight(int h) { _height = h; } setSize(Size s)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 Content()93 public Content() { } 94 addPerson(String p)95 public void addPerson(String p) { 96 if (_persons == null) { 97 _persons = new ArrayList<String>(); 98 } 99 _persons.add(p); 100 } 101 getPlayer()102 public Player getPlayer() { return _player; } getUri()103 public String getUri() { return _uri; } getTitle()104 public String getTitle() { return _title; } getWidth()105 public int getWidth() { return _width; } getHeight()106 public int getHeight() { return _height; } getFormat()107 public String getFormat() { return _format; } getDuration()108 public long getDuration() { return _duration; } getSize()109 public long getSize() { return _size; } getBitrate()110 public int getBitrate() { return _bitrate; } getPersons()111 public List<String> getPersons() { return _persons; } getCopyright()112 public String getCopyright() { return _copyright; } 113 setPlayer(Player p)114 public void setPlayer(Player p) { _player = p; } setUri(String u)115 public void setUri(String u) { _uri = u; } setTitle(String t)116 public void setTitle(String t) { _title = t; } setWidth(int w)117 public void setWidth(int w) { _width = w; } setHeight(int h)118 public void setHeight(int h) { _height = h; } setFormat(String f)119 public void setFormat(String f) { _format = f; } setDuration(long d)120 public void setDuration(long d) { _duration = d; } setSize(long s)121 public void setSize(long s) { _size = s; } setBitrate(int b)122 public void setBitrate(int b) { _bitrate = b; } setPersons(List<String> p)123 public void setPersons(List<String> p) { _persons = p; } setCopyright(String c)124 public void setCopyright(String c) { _copyright = c; } 125 } 126 } 127