示例#1
0
 /**
  * Constructs a <code>DataFlavor</code> from a <code>mimeType</code> string. The string can
  * specify a "class=<fully specified Java class name>" parameter to create a <code>DataFlavor
  * </code> with the desired representation class. If the string does not contain "class="
  * parameter, <code>java.io.InputStream</code> is used as default.
  *
  * @param mimeType the string used to identify the MIME type for this flavor; if the class
  *     specified by "class=" parameter is not successfully loaded, then an <code>
  *     ClassNotFoundException</code> is thrown
  * @exception ClassNotFoundException if the class is not loaded
  * @exception IllegalArgumentException if <code>mimeType</code> is invalid
  * @exception NullPointerException if <code>mimeType</code> is null
  */
 public DataFlavor(String mimeType) throws ClassNotFoundException {
   super();
   if (mimeType == null) {
     throw new NullPointerException("mimeType");
   }
   try {
     initialize(mimeType, null, this.getClass().getClassLoader());
   } catch (MimeTypeParseException mtpe) {
     throw new IllegalArgumentException("failed to parse:" + mimeType);
   }
 }
示例#2
0
 /**
  * Constructs a <code>DataFlavor</code> that represents a <code>MimeType</code>.
  *
  * <p>The returned <code>DataFlavor</code> will have the following characteristics:
  *
  * <p>If the mimeType is "application/x-java-serialized-object; class=&lt;representation
  * class&gt;", the result is the same as calling <code>
  * new DataFlavor(Class:forName(&lt;representation class&gt;)</code>.
  *
  * <p>Otherwise:
  *
  * <pre>
  *     representationClass = InputStream
  *     mimeType            = mimeType
  * </pre>
  *
  * @param mimeType the string used to identify the MIME type for this flavor
  * @param humanPresentableName the human-readable string used to identify this flavor
  * @param classLoader the class loader to use
  * @exception ClassNotFoundException if the class is not loaded
  * @exception IllegalArgumentException if <code>mimeType</code> is invalid
  * @exception NullPointerException if <code>mimeType</code> is null
  */
 public DataFlavor(String mimeType, String humanPresentableName, ClassLoader classLoader)
     throws ClassNotFoundException {
   super();
   if (mimeType == null) {
     throw new NullPointerException("mimeType");
   }
   try {
     initialize(mimeType, humanPresentableName, classLoader);
   } catch (MimeTypeParseException mtpe) {
     throw new IllegalArgumentException("failed to parse:" + mimeType);
   }
 }
示例#3
0
 /**
  * Constructs a <code>DataFlavor</code> that represents a <code>MimeType</code>.
  *
  * <p>The returned <code>DataFlavor</code> will have the following characteristics:
  *
  * <p>If the <code>mimeType</code> is "application/x-java-serialized-object;
  * class=&lt;representation class&gt;", the result is the same as calling <code>
  * new DataFlavor(Class:forName(&lt;representation class&gt;)</code>.
  *
  * <p>Otherwise:
  *
  * <pre>
  *     representationClass = InputStream
  *     mimeType            = mimeType
  * </pre>
  *
  * @param mimeType the string used to identify the MIME type for this flavor; if the the <code>
  *     mimeType</code> does not specify a "class=" parameter, or if the class is not successfully
  *     loaded, then an <code>IllegalArgumentException</code> is thrown
  * @param humanPresentableName the human-readable string used to identify this flavor; if this
  *     parameter is <code>null</code> then the value of the the MIME Content Type is used
  * @exception IllegalArgumentException if <code>mimeType</code> is invalid or if the class is not
  *     successfully loaded
  * @exception NullPointerException if <code>mimeType</code> is null
  */
 public DataFlavor(String mimeType, String humanPresentableName) {
   super();
   if (mimeType == null) {
     throw new NullPointerException("mimeType");
   }
   try {
     initialize(mimeType, humanPresentableName, this.getClass().getClassLoader());
   } catch (MimeTypeParseException mtpe) {
     throw new IllegalArgumentException("failed to parse:" + mimeType);
   } catch (ClassNotFoundException cnfe) {
     throw new IllegalArgumentException("can't find specified class: " + cnfe.getMessage());
   }
 }