当前位置: 首页>>代码示例>>Java>>正文


Java DataFlavor.isRepresentationClassReader方法代码示例

本文整理汇总了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;
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:33,代码来源:FileDrop.java

示例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;
}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:37,代码来源:FileDrop.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:12,代码来源:DnDUtils.java

示例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
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:42,代码来源:DataTransferer.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:DataFlavorUtil.java

示例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);
}
 
开发者ID:equella,项目名称:Equella,代码行数:44,代码来源:DnDUtils.java


注:本文中的java.awt.datatransfer.DataFlavor.isRepresentationClassReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。