Class ContentSerializer

All Implemented Interfaces:
AsyncResult, Proxy

@Generated("org.javagi.JavaGI") public class ContentSerializer extends GObject implements AsyncResult

Serializes content for inter-application data transfers.

The GdkContentSerializer transforms an object that is identified by a GType into a serialized form (i.e. a byte stream) that is identified by a mime type.

GTK provides serializers and deserializers for common data types such as text, colors, images or file lists. To register your own serialization functions, use Gdk.contentRegisterSerializer(Type, String, ContentSerializeFunc).

Also see ContentDeserializer.

  • Constructor Details

    • ContentSerializer

      public ContentSerializer(MemorySegment address)
      Create a ContentSerializer instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ContentSerializer

      public ContentSerializer()
      Create a new ContentSerializer.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the ContentSerializer class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected ContentSerializer asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getCancellable

      public @Nullable Cancellable getCancellable()

      Gets the cancellable for the current operation.

      This is the GCancellable that was passed to Gdk.contentSerializeAsync(OutputStream, String, Value, int, Cancellable, AsyncReadyCallback).

      Returns:
      the cancellable for the current operation
    • getGtype

      public Type getGtype()
      Gets the GType to of the object to serialize.
      Returns:
      the GType for the current operation
    • getMimeType

      public String getMimeType()
      Gets the mime type to serialize to.
      Returns:
      the mime type for the current operation
    • getOutputStream

      public OutputStream getOutputStream()

      Gets the output stream for the current operation.

      This is the stream that was passed to Gdk.contentSerializeAsync(OutputStream, String, Value, int, Cancellable, AsyncReadyCallback).

      Returns:
      the output stream for the current operation
    • getPriority

      public int getPriority()

      Gets the I/O priority for the current operation.

      This is the priority that was passed to Gdk.contentSerializeAsync(OutputStream, String, Value, int, Cancellable, AsyncReadyCallback).

      Returns:
      the I/O priority for the current operation
    • getTaskData

      public @Nullable MemorySegment getTaskData()

      Gets the data that was associated with the current operation.

      See setTaskData(MemorySegment).

      Returns:
      the task data for this ContentSerializer
    • getUserData

      public @Nullable MemorySegment getUserData()
      Gets the user data that was passed when the serializer was registered.
      Specified by:
      getUserData in interface AsyncResult
      Returns:
      the user data for this serializer
    • getValue

      public Value getValue()
      Gets the GValue to read the object to serialize from.
      Returns:
      the GValue for the current operation
    • returnError

      public void returnError(GError error)

      Indicate that the serialization has ended with an error.

      This function consumes error.

      Parameters:
      error - a GError
    • returnSuccess

      public void returnSuccess()
      Indicate that the serialization has been successfully completed.
    • setTaskData

      public void setTaskData(@Nullable MemorySegment data)
      Associate data with the current serialization operation.
      Parameters:
      data - data to associate with this operation
    • builder

      public static ContentSerializer.Builder<? extends ContentSerializer.Builder> builder()
      A ContentSerializer.Builder object constructs a ContentSerializer with the specified properties. Use the various set...() methods to set properties, and finish construction with ContentSerializer.Builder.build().
      Returns:
      the builder object