java.awt.datatransfer.Transferable Java Examples

The following examples show how to use java.awt.datatransfer.Transferable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileDrop.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
public void dragEnter(DropTargetDragEvent e){
	
	Transferable transferable = e.getTransferable();
	DataFlavor[] types = transferable.getTransferDataFlavors();
	
	
       for(DataFlavor type : types){
          try{
             if(type.equals(DataFlavor.javaFileListFlavor)){
           	 e.acceptDrag(DnDConstants.ACTION_COPY);
                Iterator iterator = ((List) transferable.getTransferData(type)).iterator();
                File file = (File) iterator.next();
                
                if(isFileAcceptable(file)){
               	 e.acceptDrag(1);
                }else{
               	 e.rejectDrag();
                }
             }
          }catch (Exception e1){ e1.printStackTrace(); }
       }
}
 
Example #2
Source File: OutputTabOperatorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait until clipboard contains string data and returns the text. */
private String getClipboardText() throws Exception {
    Waiter waiter = new Waiter(new Waitable() {

        @Override
        public Object actionProduced(Object obj) {
            Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
            if (contents == null) {
                return null;
            } else {
                return contents.isDataFlavorSupported(DataFlavor.stringFlavor) ? Boolean.TRUE : null;
            }
        }

        @Override
        public String getDescription() {
            return ("Wait clipboard contains string data");
        }
    });
    waiter.waitAction(null);
    return Toolkit.getDefaultToolkit().getSystemClipboard().
            getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
}
 
Example #3
Source File: WDataTransferer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public byte[] translateTransferable(Transferable contents,
                                    DataFlavor flavor,
                                    long format) throws IOException
{
    byte[] bytes = null;
    if (format == CF_HTML) {
        if (contents.isDataFlavorSupported(DataFlavor.selectionHtmlFlavor)) {
            // if a user provides data represented by
            // DataFlavor.selectionHtmlFlavor format, we use this
            // type to store the data in the native clipboard
            bytes = super.translateTransferable(contents,
                    DataFlavor.selectionHtmlFlavor,
                    format);
        } else if (contents.isDataFlavorSupported(DataFlavor.allHtmlFlavor)) {
            // if we cannot get data represented by the
            // DataFlavor.selectionHtmlFlavor format
            // but the DataFlavor.allHtmlFlavor format is avialable
            // we belive that the user knows how to represent
            // the data and how to mark up selection in a
            // system specific manner. Therefor, we use this data
            bytes = super.translateTransferable(contents,
                    DataFlavor.allHtmlFlavor,
                    format);
        } else {
            // handle other html flavor types, including custom and
            // fragment ones
            bytes = HTMLCodec.convertToHTMLFormat(super.translateTransferable(contents, flavor, format));
        }
    } else {
        // we handle non-html types basing on  their
        // flavors
        bytes = super.translateTransferable(contents, flavor, format);
    }
    return bytes;
}
 
Example #4
Source File: DropTargetContext.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * get the Transferable (proxy) operand of this operation
 * <P>
 * @throws InvalidDnDOperationException if a drag is not outstanding/extant
 * <P>
 * @return the <code>Transferable</code>
 */

protected Transferable getTransferable() throws InvalidDnDOperationException {
    DropTargetContextPeer peer = getDropTargetContextPeer();
    if (peer == null) {
        throw new InvalidDnDOperationException();
    } else {
        if (transferable == null) {
            Transferable t = peer.getTransferable();
            boolean isLocal = peer.isTransferableJVMLocal();
            synchronized (this) {
                if (transferable == null) {
                    transferable = createTransferableProxy(t, isLocal);
                }
            }
        }

        return transferable;
    }
}
 
Example #5
Source File: Lizzie.java    From mylizzie with GNU General Public License v3.0 6 votes vote down vote up
public static void pasteGameFromClipboardInSgf() {
    try {
        String sgfContent = null;
        // Read from clipboard
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable clipboardContents = clipboard.getContents(null);
        if (clipboardContents != null) {
            if (clipboardContents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                sgfContent = (String) clipboardContents.getTransferData(DataFlavor.stringFlavor);
            }
        }

        if (StringUtils.isNotEmpty(sgfContent)) {
            Game game = Sgf.createFromString(sgfContent);
            loadGameToBoard(game);
        }
    } catch (Exception e) {
        logger.error("Error in copying game from clipboard.");
    }
}
 
Example #6
Source File: ArtWorkController.java    From AudioBookConverter with GNU General Public License v2.0 6 votes vote down vote up
public void pasteImage(ActionEvent actionEvent) {
    try {
        Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
        if (transferable != null) {
            if (transferable.isDataFlavorSupported(DataFlavor.imageFlavor)) {
                java.awt.Image image = (java.awt.Image) transferable.getTransferData(DataFlavor.imageFlavor);
                Image fimage = awtImageToFX(image);
                ConverterApplication.getContext().addPosterIfMissingWithDelay(new ArtWorkImage(fimage));
            } else if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                java.util.List<String> artFiles = (java.util.List<String>) transferable.getTransferData(DataFlavor.javaFileListFlavor);

                artFiles.stream().filter(s -> ArrayUtils.contains(ArtWork.IMAGE_EXTENSIONS, FilenameUtils.getExtension(s))).forEach(f -> {
                    ConverterApplication.getContext().addPosterIfMissingWithDelay(new ArtWorkBean(f));
                });
            }
        }
    } catch (Exception e) {
        logger.error("Failed to load from clipboard", e);
        e.printStackTrace();
    }
}
 
Example #7
Source File: TabFrameTransferHandler.java    From darklaf with MIT License 6 votes vote down vote up
protected Transferable createTransferable(final JComponent c, final DragGestureEvent dge) {
    JTabFrame tabFrame = (JTabFrame) c;
    if (tabFrame.isInTransfer()) {
        currentTransferable = new TabTransferable(tabFrame, tabFrame.getTransferInfo());
    } else {
        JTabFrame.TabFramePosition ind = getUI(tabFrame).getTabIndexAt(tabFrame, dge.getDragOrigin());
        tabFrame.initTransfer(ind.getAlignment(), ind.getIndex());
        currentTransferable = new TabTransferable(tabFrame, ind);
    }
    TabFrameUI ui = getUI(c);
    createDragImage(ui);
    Alignment a = currentTransferable.transferData.tabAlignment;
    int index = currentTransferable.transferData.tabIndex;
    ui.setSourceIndicator(a, index);
    startTimer.start();
    lastTabFrame = currentTransferable.transferData.sourceTabFrame;
    return currentTransferable;
}
 
Example #8
Source File: OutputOperatorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait until clipboard contains string data and returns the text. */
private String getClipboardText() throws Exception {
    Waiter waiter = new Waiter(new Waitable() {

        @Override
        public Object actionProduced(Object obj) {
            Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
            if (contents == null) {
                return null;
            } else {
                return contents.isDataFlavorSupported(DataFlavor.stringFlavor) ? Boolean.TRUE : null;
            }
        }

        @Override
        public String getDescription() {
            return ("Wait clipboard contains string data");
        }
    });
    waiter.waitAction(null);
    return Toolkit.getDefaultToolkit().getSystemClipboard().
            getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
}
 
Example #9
Source File: NodeTransfer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Find an intelligent source of paste types in a transferable.
* Note that {@link AbstractNode#createPasteTypes} looks for this
* by default, so cut/copied nodes may specify how they may be pasted
* to some external node target.
* @param t the transferable to test
* @return the intelligent source or <code>null</code> if none is in the transferable
*/
public static Paste findPaste(Transferable t) {
    try {
        if (t.isDataFlavorSupported(nodePasteFlavor)) {
            return (Paste) t.getTransferData(nodePasteFlavor);
        }
    } catch (ClassCastException cce) {
        maybeReportException(cce);
    } catch (IOException ioe) {
        maybeReportException(ioe);
    } catch (UnsupportedFlavorException ufe) {
        maybeReportException(ufe);
    }

    return null;
}
 
Example #10
Source File: SunClipboard.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public synchronized void setContents(Transferable contents,
                                     ClipboardOwner owner) {
    // 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
    // should throw NPE
    if (contents == null) {
        throw new NullPointerException("contents");
    }

    initContext();

    final ClipboardOwner oldOwner = this.owner;
    final Transferable oldContents = this.contents;

    try {
        this.owner = owner;
        this.contents = new TransferableProxy(contents, true);

        setContentsNative(contents);
    } finally {
        if (oldOwner != null && oldOwner != owner) {
            EventQueue.invokeLater(() -> oldOwner.lostOwnership(SunClipboard.this, oldContents));
        }
    }
}
 
Example #11
Source File: ViewNodeTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testClipboardCopy() throws Exception {
    String tablename = "testtable";
    String pkName = "id";
    createBasicTable(tablename, pkName);

    String viewname = "testview";
    createView(viewname, "select id from testtable");

    ViewNode viewNode = getViewNode(viewname);
    assertNotNull(viewNode);
    assertTrue(viewNode.canCopy());

    Transferable transferable = (Transferable)viewNode.clipboardCopy();
    Set mimeTypes = new HashSet();
    DataFlavor[] flavors = transferable.getTransferDataFlavors();
    for (int i = 0; i < flavors.length; i++) {
        mimeTypes.add(flavors[i].getMimeType());
    }

    assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-view; class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$View"));
    assertTrue(mimeTypes.contains("application/x-java-openide-nodednd; mask=1; class=org.openide.nodes.Node"));

    dropView(viewname);
    dropTable(tablename);
}
 
Example #12
Source File: ConnectionNodeTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testClipboardCopy() throws Exception {
    JDBCDriver driver = JDBCDriver.create("foo", "Foo", "org.example.Foo", new URL[0]);
    JDBCDriverManager.getDefault().addDriver(driver);
    DatabaseConnection dbconn = DatabaseConnection.create(driver, "url", "user", "schema", "pwd", false);
    ConnectionManager.getDefault().addConnection(dbconn);

    ConnectionNode connectionNode = getConnectionNode();
    assertTrue(connectionNode != null);

    assertTrue(connectionNode.canCopy());

    Transferable transferable = (Transferable)connectionNode.clipboardCopy();
    Set mimeTypes = new HashSet();
    DataFlavor[] flavors = transferable.getTransferDataFlavors();
    for (int i = 0; i < flavors.length; i++) {
        mimeTypes.add(flavors[i].getMimeType());
    }
    assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-connection; class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Connection"));
    assertTrue(mimeTypes.contains("application/x-java-openide-nodednd; mask=1; class=org.openide.nodes.Node"));
}
 
Example #13
Source File: DataTransferSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Paste.
*/
public final Transferable paste () throws IOException {
    try {
        Class<?> clazz = cookie.instanceClass ();
        
        // create the instance
        InstanceDataObject.create(getTargetFolder(), null, clazz);
    } catch (ClassNotFoundException ex) {
        throw new IOException (ex.getMessage ());
    }

    // preserve clipboard
    return null;
}
 
Example #14
Source File: Models.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public int getAllowedDropActions(Transferable t) {
    if (dndNodeModel != null) {
        return dndNodeModel.getAllowedDropActions(t);
    } else {
        return DEFAULT_DRAG_DROP_ALLOWED_ACTIONS;
    }
}
 
Example #15
Source File: SunDropTargetContextPeer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void setCurrentJVMLocalSourceTransferable(Transferable t) throws InvalidDnDOperationException {
    synchronized(_globalLock) {
        if (t != null && currentJVMLocalSourceTransferable != null) {
                throw new InvalidDnDOperationException();
        } else {
            currentJVMLocalSourceTransferable = t;
        }
    }
}
 
Example #16
Source File: NbClipboardTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void setContents(Transferable contents, ClipboardOwner owner) {
    setContentsCounter++;
    if( pretendToBeBusy ) {
        pretendToBeBusy = false;
        throw new IllegalStateException();
    }
    super.setContents(contents, owner);
}
 
Example #17
Source File: SunClipboard.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void setContents(Transferable contents,
                                     ClipboardOwner owner) {
    // 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
    // should throw NPE
    if (contents == null) {
        throw new NullPointerException("contents");
    }

    initContext();

    final ClipboardOwner oldOwner = this.owner;
    final Transferable oldContents = this.contents;

    try {
        this.owner = owner;
        this.contents = new TransferableProxy(contents, true);

        setContentsNative(contents);
    } finally {
        if (oldOwner != null && oldOwner != owner) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    oldOwner.lostOwnership(SunClipboard.this, oldContents);
                }
            });
        }
    }
}
 
Example #18
Source File: SunDropTargetContextPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void setCurrentJVMLocalSourceTransferable(Transferable t) throws InvalidDnDOperationException {
    synchronized(_globalLock) {
        if (t != null && currentJVMLocalSourceTransferable != null) {
                throw new InvalidDnDOperationException();
        } else {
            currentJVMLocalSourceTransferable = t;
        }
    }
}
 
Example #19
Source File: TradeRouteInputPanel.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Transferable createTransferable(JComponent c) {
    JList list = (JList)c;
    final DefaultListModel model = (DefaultListModel)list.getModel();
    int[] indicies = list.getSelectedIndices();
    List<TradeRouteStop> stops = new ArrayList<>(indicies.length);
    for (int i : indicies) stops.add(i, (TradeRouteStop)model.get(i));
    return new StopListTransferable(stops);
}
 
Example #20
Source File: ItemNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Transferable clipboardCopy() throws IOException {
    ExTransferable t = ExTransferable.create( super.clipboardCopy() );
    
    customizeTransferable( t );
    t.put( createTransferable() );
    
    return t;
}
 
Example #21
Source File: DragAndDropHandler.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String extractText( Transferable t, DataFlavor flavor ) 
        throws IOException, UnsupportedFlavorException {
    
    Reader reader = flavor.getReaderForText(t);
    if( null == reader )
        return null;
    StringBuffer res = new StringBuffer();
    char[] buffer = new char[4*1024];
    int len;
    while( (len=reader.read( buffer )) > 0 ) {
        res.append(buffer, 0, len);
    }
    
    return res.toString();
}
 
Example #22
Source File: SunDropTargetContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return current DataFlavors available
 */
// NOTE: This method may be called by privileged threads.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!

public DataFlavor[] getTransferDataFlavors() {
    final Transferable    localTransferable = local;

    if (localTransferable != null) {
        return localTransferable.getTransferDataFlavors();
    } else {
        return DataTransferer.getInstance().getFlavorsForFormatsAsArray
            (currentT, DataTransferer.adaptFlavorMap
                (currentDT.getFlavorMap()));
    }
}
 
Example #23
Source File: SunClipboard.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.awt.Clipboard#isDataFlavorAvailable
 * @since 1.5
 */
public boolean isDataFlavorAvailable(DataFlavor flavor) {
    if (flavor == null) {
        throw new NullPointerException("flavor");
    }

    Transferable cntnts = getContextContents();
    if (cntnts != null) {
        return cntnts.isDataFlavorSupported(flavor);
    }

    long[] formats = getClipboardFormatsOpenClose();

    return formatArrayAsDataFlavorSet(formats).contains(flavor);
}
 
Example #24
Source File: ListTransferHandler.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean importData(TransferHandler.TransferSupport info) {
    if (!info.isDrop()) {
        return false;
    }

    JList list = (JList) info.getComponent();
    DefaultListModel listModel = (DefaultListModel) list.getModel();
    JList.DropLocation dl = (JList.DropLocation) info.getDropLocation();
    int index = dl.getIndex();
    boolean insert = dl.isInsert();

    // Get the string that is being dropped.
    Transferable t = info.getTransferable();
    String data;
    try {
        data = (String) t.getTransferData(DataFlavor.stringFlavor);
    } catch (Exception e) {
        return false;
    }

    // Perform the actual import.
    if (insert) {
        listModel.add(index, data);
    } else {
        listModel.set(index, data);
    }
    return true;
}
 
Example #25
Source File: DataTransferer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a Map whose keys are all of the possible formats into which the
 * Transferable's transfer data flavors can be translated. The value of
 * each key is the DataFlavor in which the Transferable's data should be
 * requested when converting to the format.
 * <p>
 * The map keys are sorted according to the native formats preference
 * order.
 */
public SortedMap<Long,DataFlavor> getFormatsForTransferable(Transferable contents,
                                                            FlavorTable map)
{
    DataFlavor[] flavors = contents.getTransferDataFlavors();
    if (flavors == null) {
        return Collections.emptySortedMap();
    }
    return getFormatsForFlavors(flavors, map);
}
 
Example #26
Source File: SunDragSourceContextPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * initiate a DnD operation ...
 */

public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point p)
  throws InvalidDnDOperationException {

    /* Fix for 4354044: don't initiate a drag if event sequence provided by
     * DragGestureRecognizer is empty */
    if (getTrigger().getTriggerEvent() == null) {
        throw new InvalidDnDOperationException("DragGestureEvent has a null trigger");
    }

    dragSourceContext = dsc;
    cursor            = c;
    sourceActions     = getDragSourceContext().getSourceActions();
    dragImage         = di;
    dragImageOffset   = p;

    Transferable transferable  = getDragSourceContext().getTransferable();
    SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().
        getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap
            (getTrigger().getDragSource().getFlavorMap()));
    long[] formats = DataTransferer.getInstance().
        keysToLongArray(formatMap);
    startDrag(transferable, formats, formatMap);

    /*
     * Fix for 4613903.
     * Filter out all mouse events that are currently on the event queue.
     */
    discardingMouseEvents = true;
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                discardingMouseEvents = false;
            }
        });
}
 
Example #27
Source File: PasteImageActionTest.java    From markdown-image-kit with MIT License 5 votes vote down vote up
@Test
public void test() throws IOException, UnsupportedFlavorException {
    Clipboard clipboard = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
    Transferable cc = clipboard.getContents(null);
    if (cc != null && cc.isDataFlavorSupported(DataFlavor.imageFlavor)) {
        Image image = (Image) cc.getTransferData(DataFlavor.imageFlavor);
        // 保存图片
        BufferedImage bufferedImage = ImageUtils.toBufferedImage(image);
        File imageFile = new File("/Users/dong4j/Develop/",  "test.png");
        ImageIO.write(bufferedImage, "png", imageFile);
    }
}
 
Example #28
Source File: DoubleInterpolator.java    From GIFKR with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void createMenuBar() {
	JMenuItem copy = new JMenuItem("Copy");
	copy.addActionListener(ae -> TransferableUtils.copyObject(Keyframe.deepCopy(keyframes)));
	copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.META_MASK));
	
	JMenuItem paste = new JMenuItem("Paste");
	paste.addActionListener(ae -> {
		Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this);
		try {
			
			ArrayList<Keyframe<Serializable>> data = (ArrayList<Keyframe<Serializable>>) t.getTransferData(TransferableUtils.objectDataFlavor);
			if(data.isEmpty())
				return;
			//Yes this is ugly. There is really no better way of doing it though. Forgive me
			if(data.get(0).getValue() instanceof Double)
				keyframes = (ArrayList<Keyframe<Double>>) (Object) data;
			if(data.get(0).getValue() instanceof Float)
				keyframes = Keyframe.floatToDouble((ArrayList<Keyframe<Float>>) (Object) data);
			if(data.get(0).getValue() instanceof Integer)
				keyframes = Keyframe.intToDouble((ArrayList<Keyframe<Integer>>) (Object) data);
			
			refresh(false);
		} catch (UnsupportedFlavorException | IOException e1) {
			System.err.println("Invalid data copied");
		}
	});
	paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.META_MASK));
	
	JMenuBar bar = new JMenuBar();
	JMenu edit = new JMenu("Edit");
	edit.add(copy);
	edit.add(paste);
	bar.add(edit);
	setJMenuBar(bar);
}
 
Example #29
Source File: Models.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Transferable clipboardCopy(Object node) throws IOException,
                                                      UnknownTypeException {
    if (filter instanceof ExtendedNodeModelFilter) {
        return ((ExtendedNodeModelFilter) filter).clipboardCopy(model, node);
    } else {
        return model.clipboardCopy(node);
    }
}
 
Example #30
Source File: NodeTransfer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Obtain a node from a transferable.
* Probes the transferable in case it includes a flavor corresponding
* to a node operation (which you must specify a mask for).
*
* @param t transferable
* @param action one of the <code>DND_*</code> or <code>CLIPBOARD_*</code> constants
* @return the node or <code>null</code>
*/
public static Node node(Transferable t, int action) {
    DataFlavor[] flavors = t.getTransferDataFlavors();

    if (flavors == null) {
        return null;
    }

    int len = flavors.length;

    String subtype = "x-java-openide-nodednd"; // NOI18N
    String primary = "application"; // NOI18N
    String mask = "mask"; // NOI18N

    for (int i = 0; i < len; i++) {
        DataFlavor df = flavors[i];

        if (df.getSubType().equals(subtype) && df.getPrimaryType().equals(primary)) {
            try {
                int m = Integer.valueOf(df.getParameter(mask)).intValue();

                if ((m & action) != 0) {
                    // found the node
                    return (Node) t.getTransferData(df);
                }
            } catch (NumberFormatException nfe) {
                maybeReportException(nfe);
            } catch (ClassCastException cce) {
                maybeReportException(cce);
            } catch (IOException ioe) {
                maybeReportException(ioe);
            } catch (UnsupportedFlavorException ufe) {
                maybeReportException(ufe);
            }
        }
    }

    return null;
}