1 6 7 package javax.emb; 8 9 import java.io.InputStream; 10 import java.net.URL; 11 12 29 public class GenericMediaFormat implements MediaFormat 30 { 31 public static final Media DEFAULT_PROXY = null; 33 34 49 public byte[] assembleContent( 50 URL mediaLocation, 51 MediaSegment[] mediaSegments) 52 throws MediaException 53 { 54 if (mediaSegments == null) 55 { 56 throw new NullPointerException(); 57 } 58 59 if (mediaSegments.length == 0) 60 { 61 return new byte[0]; 62 } 63 64 if (mediaSegments.length > 1) 65 { 66 throw new FormatSyntaxException("Media segment array contains more than one element."); 67 } 68 69 MediaSegment mediaSegment = mediaSegments[0]; 70 71 if (mediaSegment.getChildLocation() != null) 72 { 73 throw new FormatSyntaxException("Element passed contains a child link that is not null."); 74 } 75 76 return mediaSegment.getContent(); 77 } 78 79 91 public MediaSegment[] disassembleContent( 92 URL mediaLocation, 93 byte[] mediaContent) 94 throws MediaException 95 { 96 if (mediaContent == null) 97 { 98 throw new NullPointerException(); 99 } 100 101 MediaSegment mediaSegment = new MediaSegment(); 102 mediaSegment.setContent(mediaContent); 103 104 return new MediaSegment[] { mediaSegment }; 105 } 106 107 115 public MediaHeader extractHeader(InputStream mediaContent) 116 throws MediaException 117 { 118 if (mediaContent == null) 119 { 120 throw new NullPointerException(); 121 } 122 123 return new GenericMediaHeader(); 124 } 125 126 134 public Media extractProxy(InputStream mediaContent) throws MediaException 135 { 136 return null; 138 } 139 140 146 public String getDefaultMimeType() 147 { 148 return Media.MIME_TYPE_UNKNOWN; 149 } 150 151 156 public boolean isEmbedded() 157 { 158 return true; 159 } 160 161 167 public boolean isStreamingDesirable() 168 { 169 return false; 170 } 171 } | Popular Tags |