Java 8 DataFlavor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DataFlavor class.

This code example shows how to use the following methods:equals, getDefaultRepresentationClass, getHumanPresentableName, getMimeType
    public DataFlavor[] getTransferDataFlavors() {
        return new DataFlavor[] {DataFlavor.javaFileListFlavor};//, DataFlavor.stringFlavor};
    } 
 
    public boolean isDataFlavorSupported(DataFlavor dataFlavor) {
        System.out.println("Query: "+dataFlavor.getHumanPresentableName()+" , "+
            dataFlavor.getDefaultRepresentationClass()+" , "+dataFlavor.getMimeType());
        return dataFlavor.equals(DataFlavor.javaFileListFlavor)
                || dataFlavor.equals(DataFlavor.stringFlavor);
    } 
 
    public Object getTransferData(DataFlavor dataFlavor) throws UnsupportedFlavorException, IOException {
        //if (dataFlavor.equals(DataFlavor.javaFileListFlavor)) 
            return fileList;
        //else 
        //    return "test"; 
    } 
    /* 
    private StringSelection ss; 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
     * java.awt.datatransfer.Transferable#getTransferData(java.awt.datatransfer 
     * .DataFlavor) 
     */ 
    public Object getTransferData(DataFlavor flavor)
            throws UnsupportedFlavorException, IOException {
        if (flavor.equals(nodeViewerDataFlavor)) {
            return this.getClass().getCanonicalName();
        } else { 
            return null; 
        } 
    } 
 
    /* 
     * (non-Javadoc) 
     *  
     * @see java.awt.datatransfer.Transferable#getTransferDataFlavors() 
     */ 
    public DataFlavor[] getTransferDataFlavors() {
        return new DataFlavor[] { nodeViewerDataFlavor };
    } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMimeType, isMimeTypeEqual
     * this object. 
     * @param flavor the requested flavor for the data 
     * @return boolean indicating whether or not the data flavor is supported 
     */ 
    public boolean isDataFlavorSupported(DataFlavor flavor) {
        String mimeType = flavor.getMimeType();
        return flavor.isMimeTypeEqual(RTF_MIME_TYPE) || flavor.isMimeTypeEqual(HTML_MIME_TYPE) || flavor.isMimeTypeEqual(PLAIN_TEXT_MIME_TYPE);
    } 
 
    /** 
     * Returns an object which represents the data to be transferred.  The class 
     * of the object returned is defined by the representation class of the flavor. 
     * @param flavor the requested flavor for the data 
     * @throws java.io.IOException if the data is no longer available 
     *                             in the requested flavor. 
     * @throws java.awt.datatransfer.UnsupportedFlavorException 
     *                             if the requested data flavor is 
     *                             not supported. 
     * @see java.awt.datatransfer.DataFlavor#getRepresentationClass 
     */ 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
     * @param flavor  the flavor. 
     * 
     * @return A boolean. 
     */ 
    public boolean isDataFlavorSupported(DataFlavor flavor) {
        return this.imageFlavor.equals(flavor);
    } 
 
    /** 
     * Returns the content for the requested flavor, if it is supported. 
     * 
     * @param flavor  the requested flavor. 
     * 
     * @return The content. 
     * 
     * @throws java.awt.datatransfer.UnsupportedFlavorException 
     * @throws java.io.IOException 
     */ 
    public Object getTransferData(DataFlavor flavor)
            throws UnsupportedFlavorException, IOException {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
     *         itself 
     */ 
    public void addDataSource( DataSource datsrc, String mimeType ) {
        String fullMimeType = mimeType; 
        try { 
            DataFlavor flavor = new DataFlavor( fullMimeType );
            store( flavor, datsrc );
        } 
        catch ( ClassNotFoundException e ) {
            throw new AssertionError( e );
        } 
    } 
 
    /** 
     * Stores a supported flavor with the object on which the transfer  
     * data is based for that flavor. 
     * 
     * @param  flavor  the supported DataFlavor 
     * @param  obj   the object from which the transfer data can be derived. 
     *               How this is done depends on the flavor 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMediaSubtype, getMimeType
 */ 
public class DocFlavorComparator implements Comparator<DocFlavor> {
 
	public int compare(DocFlavor docFlavor1, DocFlavor docFlavor2) {
 
		int comparison = docFlavor1.getMimeType().compareTo(docFlavor2.getMimeType());
 
		if (comparison == 0) {
			return docFlavor1.getMediaSubtype().compareTo(docFlavor2.getMediaSubtype());
		} 
 
		return comparison;
	} 
 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	public PrintMessageHandler(PrintServiceExecutor printServiceExecutor, String mimeType, String className) {
 
		Assert.hasText(className, "'className' must be neither null nor empty.");
		Assert.hasText(mimeType, "'mimeType' must be neither null nor empty.");
 
		this.docFlavor = new DocFlavor(mimeType, className);
		this.printServiceExecutor = printServiceExecutor;
 
	} 
 
	public PrintMessageHandler(PrintServiceExecutor printServiceExecutor) {
		this.docFlavor = DocFlavor.STRING.TEXT_PLAIN;
		this.printServiceExecutor = printServiceExecutor;
	} 
 
	@Override 
	protected void handleMessageInternal(Message<?> message) throws Exception {
 
		if (LOG.isDebugEnabled()) {
			LOG.debug("Printing using printer '" + this.printServiceExecutor.getPrintService().getName() + "'.");
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
    public Object getTransferData( final DataFlavor flavor ) {
        return this;
    } 
 
    public boolean isDataFlavorSupported( final DataFlavor flavor ) {
        return ( flavor.equals(flavors[0]) );
    } 
 
    public DataFlavor[] getTransferDataFlavors() {
        return flavors.clone();
    } 
     
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
		return new DataFlavor[] { ROCKET_COMPONENT_DATA_FLAVOR };
	} 
	 
	@Override 
	public boolean isDataFlavorSupported(DataFlavor flavor) {
		return flavor.equals(ROCKET_COMPONENT_DATA_FLAVOR);
	} 
	 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:equals
            else 
                throw new UnsupportedFlavorException(df);
        } 
 
        public boolean isDataFlavorSupported(DataFlavor df) {
            return (df.equals(localObjectFlavor));
        } 
 
        public DataFlavor[] getTransferDataFlavors() {
            return supportedFlavors;
        } 
    } 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 DataFlavor Methods: