下面列出了java.awt.datatransfer.DataFlavor#match ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void main(String[] args) throws Exception {
boolean passed = true;
try {
df1 = new DataFlavor("application/postscript");
df2 = new DataFlavor();
df3 = new DataFlavor();
} catch (ClassNotFoundException e1) {
throw new RuntimeException("Could not create DataFlavors. This should never happen.");
} catch (IllegalArgumentException e2) {
passed = false;
}
try {
boolean b;
b = df1.match(df2);
b = df2.match(df1);
b = df2.match(df3);
} catch (NullPointerException e) {
throw new RuntimeException("The test FAILED: DataFlavor.match still throws NPE");
}
if (!passed) {
throw new RuntimeException("Test FAILED");
}
System.out.println("Test PASSED");
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
if (flavor.match(DataFlavor.plainTextFlavor)) {
return true;
}
return false;
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
if (flavor.match(DataTableColumnCollection.DATATABLE_COLUMN_COLLECTION_FLAVOR)) {
return true;
}
return false;
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
if (flavor.match(VALUE_SOURCE_FLAVOR)) {
return true;
}
return false;
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
if (flavor.match(RANGE_AXIS_CONFIG_FLAVOR)) {
return true;
}
return false;
}
public boolean isDataFlavorSupported(DataFlavor flavor) {
for (int i = 0; i < flavors.length; i++) {
if (flavor.match(flavors[i])) {
return true;
}
}
return false;
}