public class KillRingTransferable
extends java.lang.Object
implements java.awt.datatransfer.Transferable
transferable string
with additional meta-information that describes the place
of the document that from there it was retrieved.
The main idea is that we want to be able to combine adjacent text into single unit like
emacs kill ring does.
E.g. if the user invokes 'cut to the line end' subsequently we may want to paste all of them, hence, we need to be able
to distinguish if particular copy-paste strings are adjacent.
Thread-safe.Constructor and Description |
---|
KillRingTransferable(java.lang.String data,
Document document,
int startOffset,
int endOffset,
boolean cut)
Creates new
KillRingTransferable object. |
Modifier and Type | Method and Description |
---|---|
Document |
getDocument() |
int |
getEndOffset() |
int |
getStartOffset() |
java.lang.Object |
getTransferData(java.awt.datatransfer.DataFlavor flavor) |
java.awt.datatransfer.DataFlavor[] |
getTransferDataFlavors() |
boolean |
isCut() |
boolean |
isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor) |
boolean |
isReadyToCombine() |
void |
setReadyToCombine(boolean readyToCombine)
Allows to define if current object can be combined with adjacent text.
|
java.lang.String |
toString() |
public KillRingTransferable(java.lang.String data, Document document, int startOffset, int endOffset, boolean cut)
KillRingTransferable
object.data
- target text to transferdocument
- document that contained given textstartOffset
- start offset of the given text at the given documentendOffset
- end offset of the given text during current object constructioncut
- flag that identifies whether target text was cut or copied from the documentpublic java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
getTransferDataFlavors
in interface java.awt.datatransfer.Transferable
public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
isDataFlavorSupported
in interface java.awt.datatransfer.Transferable
public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException
getTransferData
in interface java.awt.datatransfer.Transferable
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException
public Document getDocument()
public int getStartOffset()
public int getEndOffset()
public boolean isCut()
public boolean isReadyToCombine()
true
if current object can be combined with adjacent text; false
otherwise.
Default value is true
public void setReadyToCombine(boolean readyToCombine)
readyToCombine
- true
if current object can be combined with adjacent text; false
otherwisepublic java.lang.String toString()
toString
in class java.lang.Object