Package com.luciad.loaders
Class InMemoryDataLoader
java.lang.Object
com.luciad.loaders.InMemoryDataLoader
- All Implemented Interfaces:
IDataLoader,AutoCloseable
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 Summary
ConstructorsConstructorDescriptionInMemoryDataLoader(ByteBuffer data) Creates an in-memory data loader that returns the given data for everyload()call.InMemoryDataLoader(ByteBuffer data, String mimeType) Creates an in-memory data loader that returns the given data for everyload()call. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected voidfinalize()load(String path, CancellationToken token) Returns the data resource loaded from the given path.
-
Constructor Details
-
InMemoryDataLoader
Creates an in-memory data loader that returns the given data for everyload()call.- Parameters:
data- the data to return.mimeType- the MIME type to associate with the data. Defaults to an empty string.
-
InMemoryDataLoader
Creates an in-memory data loader that returns the given data for everyload()call.This constructor sets an empty string as MIME type.
- Parameters:
data- the data to return.
-
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
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 totrueduring the operation. When it is set totrue, it indicates that a resource is no longer needed. Throwing ajava.util.concurrent.CancellationExceptionthen reports the load as canceled rather than as failed.- Specified by:
loadin interfaceIDataLoader- 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).
-