1 21 22 27 28 package javax.activation; 29 30 import java.awt.datatransfer.DataFlavor ; 31 import java.io.IOException ; 32 import javax.activation.MimeType ; 33 34 42 43 public class ActivationDataFlavor extends DataFlavor { 44 45 53 54 private String mimeType = null; 58 private MimeType mimeObject = null; 59 private String humanPresentableName = null; 60 private Class representationClass = null; 61 62 79 public ActivationDataFlavor(Class representationClass, 80 String mimeType, String humanPresentableName) { 81 super(mimeType, humanPresentableName); 83 this.mimeType = mimeType; 85 this.humanPresentableName = humanPresentableName; 86 this.representationClass = representationClass; 87 } 88 89 106 public ActivationDataFlavor(Class representationClass, 107 String humanPresentableName) { 108 super(representationClass, humanPresentableName); 109 this.mimeType = super.getMimeType(); 110 this.representationClass = representationClass; 111 this.humanPresentableName = humanPresentableName; 112 } 113 114 129 public ActivationDataFlavor(String mimeType, String humanPresentableName) { 130 super(mimeType, humanPresentableName); 131 this.mimeType = mimeType; 132 try { 133 this.representationClass = Class.forName("java.io.InputStream"); 134 } catch (ClassNotFoundException ex) { 135 } 137 this.humanPresentableName = humanPresentableName; 138 } 139 140 145 public String getMimeType() { 146 return mimeType; 147 } 148 149 154 public Class getRepresentationClass() { 155 return representationClass; 156 } 157 158 163 public String getHumanPresentableName() { 164 return humanPresentableName; 165 } 166 167 172 public void setHumanPresentableName(String humanPresentableName) { 173 this.humanPresentableName = humanPresentableName; 174 } 175 176 184 public boolean equals(DataFlavor dataFlavor) { 185 return (isMimeTypeEqual(dataFlavor) && 186 dataFlavor.getRepresentationClass() == representationClass); 187 } 188 189 201 public boolean isMimeTypeEqual(String mimeType) { 202 MimeType mt = null; 203 try { 204 if (mimeObject == null) 205 mimeObject = new MimeType (this.mimeType); 206 mt = new MimeType (mimeType); 207 } catch (MimeTypeParseException e) {} 208 209 return mimeObject.match(mt); 210 } 211 212 227 protected String normalizeMimeTypeParameter(String parameterName, 228 String parameterValue) { 229 return parameterValue; 230 } 231 232 244 protected String normalizeMimeType(String mimeType) { 245 return mimeType; 246 } 247 } 248 | Popular Tags |