Example usage for java.awt.datatransfer DataFlavor equals

List of usage examples for java.awt.datatransfer DataFlavor equals

Introduction

In this page you can find the example usage for java.awt.datatransfer DataFlavor equals.

Prototype

@Deprecated
public boolean equals(String s) 

Source Link

Document

Compares only the mimeType against the passed in String and representationClass is not considered in the comparison.

Usage

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.stringFlavor;
    System.out.println(df.equals((Object) "string"));
}

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.stringFlavor;
    System.out.println(df.equals(DataFlavor.imageFlavor));
}

From source file:ComplexExample.java

public boolean isDataFlavorSupported(DataFlavor flavor) {
    if (flavor.equals(colorFlavor) || flavor.equals(DataFlavor.stringFlavor))
        return true;
    return false;
}

From source file:Main.java

public boolean canImport(JComponent com, DataFlavor[] dataFlavors) {
    for (int i = 0; i < dataFlavors.length; i++) {
        DataFlavor flavor = dataFlavors[i];
        if (flavor.equals(DataFlavor.javaFileListFlavor)) {
            System.out.println("canImport: JavaFileList FLAVOR: " + flavor);
            return true;
        }//from  w  w  w.j a  va 2 s .  co m
        if (flavor.equals(DataFlavor.stringFlavor)) {
            System.out.println("canImport: String FLAVOR: " + flavor);
            return true;
        }
        System.err.println("canImport: Rejected Flavor: " + flavor);
    }
    return false;
}

From source file:net.sf.jabref.exporter.RtfSelection.java

@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
    return flavor.equals(rtfFlavor) || flavor.equals(DataFlavor.stringFlavor);
}

From source file:TransferableColor.java

/** Check whether a specified DataFlavor is available */
public boolean isDataFlavorSupported(DataFlavor flavor) {
    if (flavor.equals(colorFlavor) || flavor.equals(DataFlavor.stringFlavor)
            || flavor.equals(DataFlavor.plainTextFlavor))
        return true;
    return false;
}

From source file:ComplexExample.java

public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
    if (flavor.equals(colorFlavor))
        return color;
    else if (flavor.equals(DataFlavor.stringFlavor))
        return color.toString();
    else//from   w w w.j  a  v a  2s  .c  o  m
        throw new UnsupportedFlavorException(flavor);
}

From source file:Main.java

public boolean importData(JComponent comp, Transferable t) {
    DataFlavor[] flavors = t.getTransferDataFlavors();
    System.out.println("Trying to import:" + t);
    for (int i = 0; i < flavors.length; i++) {
        DataFlavor flavor = flavors[i];
        try {//w  w w  .ja  va 2  s  . c o m
            if (flavor.equals(DataFlavor.javaFileListFlavor)) {
                System.out.println("importData: FileListFlavor");
                List l = (List) t.getTransferData(DataFlavor.javaFileListFlavor);
                Iterator iter = l.iterator();
                while (iter.hasNext()) {
                    File file = (File) iter.next();
                    System.out.println("GOT FILE: " + file.getCanonicalPath());
                }
                return true;
            } else if (flavor.equals(DataFlavor.stringFlavor)) {
                System.out.println("importData: String Flavor");
                String fileOrURL = (String) t.getTransferData(flavor);
                System.out.println("GOT STRING: " + fileOrURL);
                try {
                    URL url = new URL(fileOrURL);
                    System.out.println("Valid URL: " + url.toString());
                    return true;
                } catch (MalformedURLException ex) {
                    System.err.println("Not a valid URL");
                    return false;
                }
            } else {
                System.out.println("importData rejected: " + flavor);
            }
        } catch (IOException ex) {
            System.err.println("IOError getting data: " + ex);
        } catch (UnsupportedFlavorException e) {
            System.err.println("Unsupported Flavor: " + e);
        }
    }
    return false;
}

From source file:TransferableColor.java

/** 
 * Transfer the data.  Given a specified DataFlavor, return an Object
 * appropriate for that flavor.  Throw UnsupportedFlavorException if we
 * don't support the requested flavor./*w ww. j a  v a  2s.c om*/
 */
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    if (flavor.equals(colorFlavor))
        return color;
    else if (flavor.equals(DataFlavor.stringFlavor))
        return color.toString();
    else if (flavor.equals(DataFlavor.plainTextFlavor))
        return new ByteArrayInputStream(color.toString().getBytes("Unicode"));
    else
        throw new UnsupportedFlavorException(flavor);
}

From source file:net.sf.jabref.exporter.RtfSelection.java

@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {

    if (flavor.equals(DataFlavor.stringFlavor)) {
        return content;
    } else if (flavor.equals(rtfFlavor)) {
        byte[] byteArray = content.getBytes();
        return new ByteArrayInputStream(byteArray);
    }//from w  w  w . j  av a  2  s  . c  om
    throw new UnsupportedFlavorException(flavor);
}