Class AbstractObjectTransferable<S>

java.lang.Object
io.guise.framework.component.transfer.AbstractObjectTransferable<S>
Type Parameters:
S - The source of the transfer.
All Implemented Interfaces:
Transferable<S>
Direct Known Subclasses:
TreeControl.TreeNodeTransferable

public abstract class AbstractObjectTransferable<S> extends Object implements Transferable<S>
A abstract transferable that carries one or more Java objects. A subclass must implement Transferable.transfer(Class).
Author:
Garret Wilson
  • Constructor Details

    • AbstractObjectTransferable

      public AbstractObjectTransferable(S source, Class<?>... objectClasses)
      Source and object esclass constructor.
      Parameters:
      source - The source of the transferable data.
      objectClasses - The classes indicating the typees of object to be transferred.
      Throws:
      NullPointerException - if the provided source and/or object classes is null.
  • Method Details

    • getSource

      public S getSource()
      Specified by:
      getSource in interface Transferable<S>
      Returns:
      The source of the transferable data.
    • getClass

      protected Class<?> getClass(com.globalmentor.net.MediaType contentType)
      Determines the class this content type matches. This method matches a content type against the "application" primary type and "x-java-object" subtype, with a "class" parameter indicating the given object class.
      Parameters:
      contentType - The type of data requested, which may include wildcards.
      Returns:
      The matching class, or null if no supported class matches the requested content type.
    • canTransfer

      public boolean canTransfer(com.globalmentor.net.MediaType contentType)
      Determines whether this transferable can transfer data with the given content type.

      This implementation matches a content type against the "application" primary type and "x-java-object" subtype, with a "class" parameter indicating the given object class.

      Specified by:
      canTransfer in interface Transferable<S>
      Parameters:
      contentType - The type of data requested, which may include wildcards.
      Returns:
      true if this object can transfer data with the requested content type.
    • transfer

      public Object transfer(com.globalmentor.net.MediaType contentType)
      Transfers data using the given content type.

      This implementation delegates to Transferable.transfer(Class).

      Specified by:
      transfer in interface Transferable<S>
      Parameters:
      contentType - The type of data expected.
      Returns:
      The transferred data, which may be null.
    • getContentTypes

      public com.globalmentor.net.MediaType[] getContentTypes()

      This implementation returns content types in the form application/x-java-object;class=package.Class.

      Specified by:
      getContentTypes in interface Transferable<S>
      Returns:
      The content types available for this transfer.