1 29 30 package nextapp.echo2.webrender; 31 32 import java.io.Serializable ; 33 34 40 public class ContentType 41 implements Serializable { 42 43 public static final ContentType IMAGE_GIF = new ContentType("image/gif", true); 44 public static final ContentType IMAGE_PNG = new ContentType("image/png", true); 45 public static final ContentType IMAGE_JPEG = new ContentType("image/jpeg", true); 46 public static final ContentType MULTIPART_FORM_DATA = new ContentType("multipart/form-data", false); 47 public static final ContentType TEXT_HTML = new ContentType("text/html", false); 48 public static final ContentType TEXT_JAVASCRIPT = new ContentType("text/javascript", false); 49 public static final ContentType TEXT_PLAIN = new ContentType("text/plain", false); 50 public static final ContentType TEXT_XML = new ContentType("text/xml", false); 51 52 private String mimeType = null; 53 private boolean binary = false; 54 55 62 public ContentType(String mimeType, boolean binary) { 63 super(); 64 65 if (mimeType == null) { 66 throw new NullPointerException ("Cannot create content type with null MIME type"); 67 } 68 69 this.mimeType = mimeType; 70 this.binary = binary; 71 } 72 73 76 public boolean equals(Object o) { 77 boolean equal; 78 79 if (o instanceof ContentType) { 80 ContentType that = (ContentType) o; 81 equal = this.mimeType.equals(that.mimeType); 82 } else { 83 equal = false; 84 } 85 86 return equal; 87 } 88 89 94 public String getMimeType() { 95 return mimeType; 96 } 97 98 104 public boolean isBinary() { 105 return binary; 106 } 107 108 111 public String toString() { 112 return mimeType; 113 } 114 } 115 | Popular Tags |