Class InMemoryDataLoader

java.lang.Object
com.luciad.loaders.InMemoryDataLoader
All Implemented Interfaces:
IDataLoader, AutoCloseable

public final class InMemoryDataLoader extends Object implements AutoCloseable, IDataLoader
An IDataLoader implementation that returns in-memory data.

This loader ignores the requested path and always returns the ByteBuffer provided at construction time. It is intended for feeding in-memory content (e.g. a GML or GeoJSON document) to model decoders that accept an IDataLoader via their Options.

Since:
2026.1
  • Constructor Details

    • InMemoryDataLoader

      public InMemoryDataLoader(@NotNull ByteBuffer data, @NotNull String mimeType)
      Creates an in-memory data loader that returns the given data for every load() call.
      Parameters:
      data - the data to return.
      mimeType - the MIME type to associate with the data. Defaults to an empty string.
    • InMemoryDataLoader

      public InMemoryDataLoader(@NotNull ByteBuffer data)
      Creates an in-memory data loader that returns the given data for every load() call.

      This constructor sets an empty string as MIME type.

      Parameters:
      data - the data to return.
  • Method Details

    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • load

      @NotNull public DataEntity load(@NotNull String path, @NotNull CancellationToken token) throws IOException, UnsupportedOperationException
      Returns the data resource loaded from the given path.

      The download process can be canceled by the means of the cancellation token. It is up to the implementer to verify that the cancellation token state is set to true during the operation. When it is set to true, it indicates that a resource is no longer needed. Throwing a java.util.concurrent.CancellationException then reports the load as canceled rather than as failed.

      Specified by:
      load in interface IDataLoader
      Parameters:
      path - Path to the resource.
      token - Cancellation token.
      Returns:
      the data resources as DataEntity.
      Throws:
      IOException - when loading the data fails.
      UnsupportedOperationException - when the loader cannot handle the given path (for example, an unsupported scheme or protocol).