mil.navy.nps.logger
Class PduSelection

java.lang.Object
  extended bymil.navy.nps.logger.PduSelection
All Implemented Interfaces:
java.awt.datatransfer.ClipboardOwner, java.awt.datatransfer.Transferable

public class PduSelection
extends java.lang.Object
implements java.awt.datatransfer.Transferable, java.awt.datatransfer.ClipboardOwner

The clipboard needs some helper classes to transfer data of an arbitrary type, and this is one such class. It handles the selection and transfer of PDU objects. when the user selects a range of PDUs and selects copy or cut, an instance of this class is created. It manages queries about what type of data it can provide to people who do "paste", and holds data.

See http://www.vjinformant.com/features/1999/08/ji199908ps_f.asp for details.

Author:
DMcG

Field Summary
static java.awt.datatransfer.DataFlavor[] flavors
           
 
Constructor Summary
PduSelection(ProtocolDataUnit[] pdu)
          this constructor lists the PDUs we're going to be transfering.
PduSelection(java.util.Vector pPdus)
          Constructor, takes vector of PDUs and adds them to our selection.
 
Method Summary
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
          getTransferData returns an object that represents the data placed on the clipboard.
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
          getTransferDataFlavors returns a list of the data flavors (aka data formats) that it can provide data in.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
          Returns true if the DataFlavor passed in is one of the ones we support.
 void lostOwnership(java.awt.datatransfer.Clipboard clipboard, java.awt.datatransfer.Transferable contents)
          In general data transfer objects can implement "lazy transfer".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flavors

public static java.awt.datatransfer.DataFlavor[] flavors
Constructor Detail

PduSelection

public PduSelection(ProtocolDataUnit[] pdu)
this constructor lists the PDUs we're going to be transfering. Note that in general we have a list of PDUs; we transfer individual pdus by having a list of one. this is a little bad in that when we create the selection we go to the trouble of serializing the entire selection, which more or less negates the advantages of lazy data copy. c'est la vie.


PduSelection

public PduSelection(java.util.Vector pPdus)
Constructor, takes vector of PDUs and adds them to our selection.

Method Detail

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
                                 throws java.awt.datatransfer.UnsupportedFlavorException,
                                        java.io.IOException
getTransferData returns an object that represents the data placed on the clipboard. It takes as an argument the data flavor (data format) it wants.

Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
getTransferDataFlavors returns a list of the data flavors (aka data formats) that it can provide data in. This should be ordered in preference, from most "rich" to least "rich", for example you'd prefer RTF to plain text. In this case we provide only one data flavor, PDUs, which is our own extra-special data format.

Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returns true if the DataFlavor passed in is one of the ones we support. As it turns out we have only one dataflavor to support.

Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable

lostOwnership

public void lostOwnership(java.awt.datatransfer.Clipboard clipboard,
                          java.awt.datatransfer.Transferable contents)
In general data transfer objects can implement "lazy transfer". The data isn't actually moved anywhere until the user actually tries to paste. So we need to keep the data around for a while. But what if the user copies something else in the meantime? In that case we lose the requirement to keep the data around, and we can ditch it. That's what this hook is for. This method is part of the ClipboardOwner interface; we own the data, and are notified if the data is no longer needed.

Specified by:
lostOwnership in interface java.awt.datatransfer.ClipboardOwner