當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。