-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta
-
sparc
-
solaris_2.6
Name: sdC67446 Date: 12/08/99
1) Two similar methods has different behaviors if input param == null:
public static String encodeJavaMIMEType(String mimeType)
public static String encodeDataFlavor(DataFlavor df)
The first one returns empty encoded string,
the second one - throws NPE.
2) Also the problem with the pair of methods:
public static String encodeJavaMIMEType(String mimeType)
public static String decodeJavaMIMEType(String atom)
decodeJavaMIMEType(encodeJavaMIMEType(null)) != null
3) The doc should clarify what the "encoded" mimetype string looks
like.
The javadoc says:
--------------------------------------------------
public static String encodeJavaMIMEType(String mimeType)
Returns:
encode a Java MIMEType for use as a native type name
public static String encodeDataFlavor(DataFlavor df)
Returns:
encode a Java MIMEType for use as a native type name
public static boolean isJavaMIMEType(String atom)
Returns:
if the native type string is an encoded Java MIMEType
the test demonstraiting the 1st point:
--------------------------------------------------
import java.awt.datatransfer.*;
public class Test {
public static void main(String[] args) {
System.out.println(" --- 1 --- ");
System.out.println(SystemFlavorMap.encodeJavaMIMEType(null));
System.out.println(" --- 2 --- ");
try {
System.out.println(SystemFlavorMap.encodeDataFlavor(null));
} catch (NullPointerException e) {
System.out.println("Unexpected: "+e);
}
System.out.println(" --- 3 --- ");
if (
SystemFlavorMap.decodeJavaMIMEType(SystemFlavorMap.encodeJavaMIMEType(null)) != null ) {
System.out.println("decodeJavaMIMEType(encodeDataFlavor(null)) != null");
}
}
}
output:
--------------------------------------------------
--- 1 ---
JAVA_DATAFLAVOR:null
--- 2 ---
Unexpected: java.lang.NullPointerException
--- 3 ---
decodeJavaMIMEType(encodeDataFlavor(null)) != null
--------------------------------------------------
======================================================================