本文整理汇总了Java中java.awt.datatransfer.SystemFlavorMap.decodeDataFlavor方法的典型用法代码示例。如果您正苦于以下问题:Java SystemFlavorMap.decodeDataFlavor方法的具体用法?Java SystemFlavorMap.decodeDataFlavor怎么用?Java SystemFlavorMap.decodeDataFlavor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.datatransfer.SystemFlavorMap
的用法示例。
在下文中一共展示了SystemFlavorMap.decodeDataFlavor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test4
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
/**
* Verifies that the encoded native is added only for DataFlavors
* that has no mappings and that DataFlavor is properly encoded.
*/
public static void test4() throws ClassNotFoundException {
final DataFlavor flavor =
new DataFlavor("unknown/unknown");
final java.util.List natives = fm.getNativesForFlavor(flavor);
if (natives.size() == 1) {
String element = (String) natives.get(0);
if (SystemFlavorMap.isJavaMIMEType(element)) {
final DataFlavor decodedFlavor =
SystemFlavorMap.decodeDataFlavor(element);
if (!flavor.equals(decodedFlavor)) {
System.err.println("DataFlavor is not properly incoded:");
System.err.println(" encoded flavor: " + flavor);
System.err.println(" decoded flavor: " + decodedFlavor);
throw new RuntimeException("getFlavorsForNative() returns:"
+ natives);
}
}
} else {
throw new RuntimeException("getFlavorsForNative() returns:"
+ natives);
}
}
示例2: initMappings
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
public void initMappings() throws Exception {
//initialize mapping variables used in this test
//create a DataFlavor from Button class
test_flavor1 = new DataFlavor(Class.forName("java.awt.Button"), "Button");
//create an Encoded String native using Button class MIME Type
String buttonMIME = test_flavor1.getMimeType();
test_encoded = SystemFlavorMap.encodeJavaMIMEType(buttonMIME);
//create a DataFlavor from the Encoded String native
test_flavor2 = SystemFlavorMap.decodeDataFlavor(test_encoded);
//create and initialize DataFlavor arrays
test_flavors_set = new DataFlavor[] {test_flavor1};
//create and initialize String native arrays
test_natives_set = new String[] {test_encoded};
}
示例3: initMappings
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
public void initMappings() throws Exception {
//initialize mapping variables used in this test
//create an Unencoded String native
test_native1 = "TEST1";
//create a DataFlavor from Button class
test_flavor1 = new DataFlavor(Class.forName("java.awt.Button"), "Button");
//create an Encoded String native using Button class MIME Type
String buttonMIME = test_flavor1.getMimeType();
test_encoded = SystemFlavorMap.encodeJavaMIMEType(buttonMIME);
//create a DataFlavor from the Encoded String native
test_flavor2 = SystemFlavorMap.decodeDataFlavor(test_encoded);
//create and initialize DataFlavor arrays
test_flavors_set = new DataFlavor[] {test_flavor2};
//create and initialize String native arrays
test_natives_set = new String[] {test_encoded};
}
示例4: DataSnapshot
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
/**
* @param dataObject
*/
public DataSnapshot(DataProvider data) {
nativeFormats = data.getNativeFormats();
text = data.getText();
fileList = data.getFileList();
url = data.getURL();
html = data.getHTML();
rawBitmap = data.getRawBitmap();
serializedObjects = Collections.synchronizedMap(new HashMap<Class<?>, byte[]>());
for (int i = 0; i < nativeFormats.length; i++) {
DataFlavor df = null;
try {
df = SystemFlavorMap.decodeDataFlavor(nativeFormats[i]);
} catch (ClassNotFoundException e) {}
if (df != null) {
Class<?> clazz = df.getRepresentationClass();
byte[] bytes = data.getSerializedObject(clazz);
if (bytes != null) {
serializedObjects.put(clazz, bytes);
}
}
}
// TODO: refine the list of native formats
}
示例5: isNativeFormatAvailable
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
public boolean isNativeFormatAvailable(String nativeFormat) {
if (nativeFormat == null) {
return false;
}
if (nativeFormat.equals(FORMAT_TEXT)) {
return (text != null);
}
if (nativeFormat.equals(FORMAT_FILE_LIST)) {
return (fileList != null);
}
if (nativeFormat.equals(FORMAT_URL)) {
return (url != null);
}
if (nativeFormat.equals(FORMAT_HTML)) {
return (html != null);
}
if (nativeFormat.equals(FORMAT_IMAGE)) {
return (rawBitmap != null);
}
try {
DataFlavor df = SystemFlavorMap.decodeDataFlavor(nativeFormat);
return serializedObjects.containsKey(df.getRepresentationClass());
} catch (Exception e) {
return false;
}
}
示例6: isNativeFormatAtailable
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
public boolean isNativeFormatAtailable(String nativeFormat) {
if (nativeFormat == null) {
return false;
}
if (nativeFormat.equals(FORMAT_TEXT)) {
return (text != null);
}
if (nativeFormat.equals(FORMAT_FILE_LIST)) {
return (fileList != null);
}
if (nativeFormat.equals(FORMAT_URL)) {
return (url != null);
}
if (nativeFormat.equals(FORMAT_HTML)) {
return (html != null);
}
if (nativeFormat.equals(FORMAT_IMAGE)) {
return (rawBitmap != null);
}
try {
DataFlavor df = SystemFlavorMap.decodeDataFlavor(nativeFormat);
return serializedObjects.containsKey(df.getRepresentationClass());
} catch (Exception e) {
return false;
}
}
示例7: getSerializedObject
import java.awt.datatransfer.SystemFlavorMap; //导入方法依赖的package包/类
public byte[] getSerializedObject(String nativeFormat) {
try {
DataFlavor df = SystemFlavorMap.decodeDataFlavor(nativeFormat);
return getSerializedObject(df.getRepresentationClass());
} catch (Exception e) {
return null;
}
}