-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
beta
-
sparc
-
solaris_2.5
Name: sdC67446 Date: 09/09/98
The specification for
java.awt.datatransfer.DataFlavor(String mimeType),
java.awt.datatransfer.DataFlavor(String mimeType,
String humanRepresentableName)
java.awt.datatransfer.DataFlavor(String primaryType,
String subType,
MimeTypeParameterList params,
Class representationClass,
String humanPresentableName)
doesn't specify behavior if 'mimeType' or 'primaryType'+"/"+'subType'
describes invalid MimeType.
Currently 1st ctor throws java.util.mime.MimeTypeParseException,
2nd - IllegalArgumentException,
3rd - IllegalArgumentException.
Should be fixed for consistency.
The doc says:
-------------------------------------------------------------
public DataFlavor(String mimeType)
throws MimeTypeParseException,
ClassNotFoundException
construct a DataFlavor from a Mime Type string.
The string must specify a "class=" parameter in
order to succeed in constructing a DataFlavor.
public DataFlavor(String primaryType,
String subType,
MimeTypeParameterList params,
Class representationClass,
String humanPresentableName)
Construct a fully specified DataFlavor
public DataFlavor(Class representationClass,
String humanPresentableName)
Construct a DataFlavor that represents a Java class
The returned DataFlavor will have the following characteristics
representationClass = representationClass
mimeType = application/x-java-serialized-object
Parameters:
representationClass - the class used to transfer
data in this flavor
humanPresentableName - the human-readible string
used to identify this flavor
The test demonstrating the bug:
------------------------------------------------------------
import java.awt.datatransfer.*;
import java.util.mime.*;
public class Test {
public static void main(String[] args) {
String mimeType = "";
String primaryType = "";
String subType = "";
String humanPresentableName = "MyType";
DataFlavor df = null;
try {
df = new DataFlavor(mimeType);
} catch (Exception e) {
System.out.println(e);
}
try {
df = new DataFlavor(mimeType, humanPresentableName);
} catch (Exception e) {
System.out.println(e);
}
try {
df = new DataFlavor(primaryType, subType,
new MimeTypeParameterList(),
java.lang.Integer.class,
humanPresentableName);
} catch (Exception e) {
System.out.println(e);
}
}
}
------------------------------------------------------------
Test output:
java.util.mime.MimeTypeParseException: Unable to find a sub type.
java.lang.IllegalArgumentException: failed to parse:
java.lang.IllegalArgumentException: MimeType Parse Exception: Primary type is invalid.
------------------------------------------------------------
======================================================================