本文整理汇总了Java中java.awt.datatransfer.DataFlavor.isRepresentationClassReader方法的典型用法代码示例。如果您正苦于以下问题:Java DataFlavor.isRepresentationClassReader方法的具体用法?Java DataFlavor.isRepresentationClassReader怎么用?Java DataFlavor.isRepresentationClassReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.datatransfer.DataFlavor
的用法示例。
在下文中一共展示了DataFlavor.isRepresentationClassReader方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isDragOk
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/** Determine if the dragged data is a file list. */
private boolean isDragOk( final java.io.PrintStream out, final java.awt.dnd.DropTargetDragEvent evt )
{ boolean ok = false;
// Get data flavors being dragged
java.awt.datatransfer.DataFlavor[] flavors = evt.getCurrentDataFlavors();
// See if any of the flavors are a file list
int i = 0;
while( !ok && i < flavors.length )
{
// BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
// Is the flavor a file list?
final DataFlavor curFlavor = flavors[i];
if( curFlavor.equals( java.awt.datatransfer.DataFlavor.javaFileListFlavor ) ||
curFlavor.isRepresentationClassReader()){
ok = true;
}
// END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
i++;
} // end while: through flavors
// If logging is enabled, show data flavors
if( out != null )
{ if( flavors.length == 0 )
log( out, "FileDrop: no data flavors." );
for( i = 0; i < flavors.length; i++ )
log( out, flavors[i].toString() );
} // end if: logging enabled
return ok;
}
示例2: isDragOk
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/** Determine if the dragged data is a file list. */
private boolean isDragOk(final java.io.PrintStream out,
final java.awt.dnd.DropTargetDragEvent evt) {
boolean ok = false;
// Get data flavors being dragged
java.awt.datatransfer.DataFlavor[] flavors = evt
.getCurrentDataFlavors();
// See if any of the flavors are a file list
int i = 0;
while (!ok && i < flavors.length) {
// BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support
// added.
// Is the flavor a file list?
final DataFlavor curFlavor = flavors[i];
if (curFlavor
.equals(java.awt.datatransfer.DataFlavor.javaFileListFlavor)
|| curFlavor.isRepresentationClassReader()) {
ok = true;
}
// END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support
// added.
i++;
} // end while: through flavors
// If logging is enabled, show data flavors
if (out != null) {
if (flavors.length == 0)
log(out, "FileDrop: no data flavors.");
for (i = 0; i < flavors.length; i++)
log(out, flavors[i].toString());
} // end if: logging enabled
return ok;
}
示例3: supportsNativeFileDrop
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
public static boolean supportsNativeFileDrop(DropTargetDragEvent e)
{
for( DataFlavor flavor : e.getCurrentDataFlavors() )
{
if( flavor.equals(DataFlavor.javaFileListFlavor) || flavor.isRepresentationClassReader() )
{
return true;
}
}
return false;
}
示例4: isFlavorCharsetTextType
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/**
* Returns whether this flavor is a text type which supports the
* 'charset' parameter.
*/
public static boolean isFlavorCharsetTextType(DataFlavor flavor) {
// Although stringFlavor doesn't actually support the charset
// parameter (because its primary MIME type is not "text"), it should
// be treated as though it does. stringFlavor is semantically
// equivalent to "text/plain" data.
if (DataFlavor.stringFlavor.equals(flavor)) {
return true;
}
if (!"text".equals(flavor.getPrimaryType()) ||
!doesSubtypeSupportCharset(flavor))
{
return false;
}
Class rep_class = flavor.getRepresentationClass();
if (flavor.isRepresentationClassReader() ||
String.class.equals(rep_class) ||
flavor.isRepresentationClassCharBuffer() ||
char[].class.equals(rep_class))
{
return true;
}
if (!(flavor.isRepresentationClassInputStream() ||
flavor.isRepresentationClassByteBuffer() ||
byte[].class.equals(rep_class))) {
return false;
}
String charset = flavor.getParameter("charset");
return (charset != null)
? DataTransferer.isEncodingSupported(charset)
: true; // null equals default encoding which is always supported
}
示例5: isFlavorCharsetTextType
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
/**
* Returns whether this flavor is a text type which supports the 'charset'
* parameter.
*/
public static boolean isFlavorCharsetTextType(DataFlavor flavor) {
// Although stringFlavor doesn't actually support the charset
// parameter (because its primary MIME type is not "text"), it should
// be treated as though it does. stringFlavor is semantically
// equivalent to "text/plain" data.
if (DataFlavor.stringFlavor.equals(flavor)) {
return true;
}
if (!"text".equals(flavor.getPrimaryType()) ||
!doesSubtypeSupportCharset(flavor))
{
return false;
}
Class<?> rep_class = flavor.getRepresentationClass();
if (flavor.isRepresentationClassReader() ||
String.class.equals(rep_class) ||
flavor.isRepresentationClassCharBuffer() ||
char[].class.equals(rep_class))
{
return true;
}
if (!(flavor.isRepresentationClassInputStream() ||
flavor.isRepresentationClassByteBuffer() ||
byte[].class.equals(rep_class))) {
return false;
}
String charset = flavor.getParameter("charset");
// null equals default encoding which is always supported
return (charset == null) || isEncodingSupported(charset);
}
示例6: getDroppedNativeFiles
import java.awt.datatransfer.DataFlavor; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static List<File> getDroppedNativeFiles(Transferable t) throws UnsupportedFlavorException, IOException
{
// This works for Windows
if( t.isDataFlavorSupported(DataFlavor.javaFileListFlavor) )
{
return (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
}
// This works for Gnome and KDE
for( DataFlavor flavor : t.getTransferDataFlavors() )
{
if( flavor.isRepresentationClassReader() )
{
try( BufferedReader reader = new BufferedReader(flavor.getReaderForText(t)) )
{
List<File> list = new ArrayList<File>();
String line = null;
while( (line = reader.readLine()) != null )
{
try
{
if( ZERO_CHAR_STRING.equals(line) )
{
continue;
}
list.add(new File(new java.net.URI(line)));
}
catch( Exception ex )
{
ex.printStackTrace();
}
}
return list;
}
}
}
throw new UnsupportedFlavorException(null);
}