- All Implemented Interfaces:
IConfiguration<DeserializationFeature<?>>,IMutableConfiguration<DeserializationFeature<?>>,IDocumentLoader,IResourceResolver,IBoundLoader
IBoundLoader.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe number of bytes to read ahead when determining the source format. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultBoundLoader(IBindingContext bindingContext) Construct a new loader instance, using the providedIBindingContext. -
Method Summary
Modifier and TypeMethodDescriptionReplace this configuration with theotherconfiguration.detectFormat(InputStream is, URI resource) Determine the format of the provided resource.detectFormat(URI uri) Determine the format of the resource identified by the provideduri.@Owning ModelDetector.ResultdetectModel(InputStream is, URI resource, Format format) Determine the model of the provided resource.Get the configured Module binding context to use to load Java types.Get the mapping of each feature mapped to its value.booleanisFeatureEnabled(DeserializationFeature<?> feature) Determines if a specific feature is enabled.<CLASS extends IBoundObject>
CLASSload(InputStream is, URI resource) Load data from the provided resource into a bound object.<CLASS extends IBoundObject>
CLASSload(Class<CLASS> clazz, Format format, InputStream is, URI documentUri) Load data from the specified resource into a bound object with the type of the specified Java class.<CLASS extends IBoundObject>
CLASSload(Class<CLASS> clazz, InputStream is, URI documentUri) Load data from the specified resource into a bound object with the type of the specified Java class.<CLASS extends IBoundObject>
CLASSLoad data from the specified resource into a bound object with the type of the specified Java class.<CLASS extends IBoundObject>
CLASSLoad data from the resource identified by the provideduriinto a bound object.loadAsNodeItem(Format format, InputStream is, URI resource) Load data expressed using the providedformatand return that data as a Metapath node item.loadAsNodeItem(Format format, URI uri) Load data expressed using the providedformatand return that data as a Metapath node item.loadAsNodeItem(URI uri) Load a Metaschema-based document from a URI resource.set(DeserializationFeature<?> feature, Object value) Set the value of the providedfeatureto the provided value.Methods inherited from class dev.metaschema.core.model.AbstractResourceResolver
getUriResolver, setUriResolverMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.metaschema.databind.io.IBoundLoader
convert, convert, convert, convert, convert, detectFormat, detectFormat, detectFormat, disableFeature, enableFeature, load, load, load, load, load, load, loadAsNodeItemMethods inherited from interface dev.metaschema.core.configuration.IConfiguration
getMethods inherited from interface dev.metaschema.core.metapath.IDocumentLoader
loadAsNodeItem, loadAsNodeItem, loadAsNodeItem, setUriResolverMethods inherited from interface dev.metaschema.core.model.IResourceResolver
getUriResolver, resolve
-
Field Details
-
LOOK_AHEAD_BYTES
public static final int LOOK_AHEAD_BYTESThe number of bytes to read ahead when determining the source format.- See Also:
-
-
Constructor Details
-
DefaultBoundLoader
Construct a new loader instance, using the providedIBindingContext.- Parameters:
bindingContext- the Module binding context to use to load Java types
-
-
Method Details
-
isFeatureEnabled
Description copied from interface:IConfigurationDetermines if a specific feature is enabled.- Specified by:
isFeatureEnabledin interfaceIConfiguration<DeserializationFeature<?>>- Parameters:
feature- the feature to check for- Returns:
trueif the feature is enabled, orfalseotherwise- See Also:
-
getFeatureValues
Description copied from interface:IConfigurationGet the mapping of each feature mapped to its value.- Specified by:
getFeatureValuesin interfaceIConfiguration<DeserializationFeature<?>>- Returns:
- the mapping
-
applyConfiguration
Description copied from interface:IMutableConfigurationReplace this configuration with theotherconfiguration.- Specified by:
applyConfigurationin interfaceIBoundLoader- Specified by:
applyConfigurationin interfaceIMutableConfiguration<DeserializationFeature<?>>- Parameters:
other- the new configuration- Returns:
- the updated configuration
-
set
Description copied from interface:IMutableConfigurationSet the value of the providedfeatureto the provided value.- Specified by:
setin interfaceIBoundLoader- Specified by:
setin interfaceIMutableConfiguration<DeserializationFeature<?>>- Parameters:
feature- the feature to setvalue- the value to set- Returns:
- the updated configuration
- See Also:
-
getBindingContext
Description copied from interface:IBoundLoaderGet the configured Module binding context to use to load Java types.- Specified by:
getBindingContextin interfaceIBoundLoader- Returns:
- the binding context
-
detectFormat
Description copied from interface:IBoundLoaderDetermine the format of the resource identified by the provideduri.- Specified by:
detectFormatin interfaceIBoundLoader- Parameters:
uri- the resource- Returns:
- the format information for the provided resource
- Throws:
IOException- if an error occurred while reading the resource
-
detectFormat
Description copied from interface:IBoundLoaderDetermine the format of the provided resource.This method will consume data from the provided
InputStream. If the caller of this method intends to read data from the stream after determining the format, the caller should pass in a stream that can be reset.This method will not close the provided
InputStream, since it does not own the stream.- Specified by:
detectFormatin interfaceIBoundLoader- Parameters:
is- an input stream for the resourceresource- the URI of the resource- Returns:
- the format information for the provided resource
- Throws:
IOException- if an error occurred while reading the resource
-
detectModel
@Owning public @Owning ModelDetector.Result detectModel(@NotOwning InputStream is, URI resource, Format format) throws IOException Description copied from interface:IBoundLoaderDetermine the model of the provided resource.This method will consume data from any
InputStreamprovided by theInputSource. If the caller of this method intends to read data from the stream after determining the format, the caller should pass in a stream that can be reset.This method will not close any
InputStreamprovided by theInputSource, since it does not own the stream.The caller owns the returned result and is responsible for closing it.
- Specified by:
detectModelin interfaceIBoundLoader- Parameters:
is- an input stream for the resourceresource- the URI of the resourceformat- the format of the provided resource- Returns:
- the model of the provided resource
- Throws:
IOException- if an error occurred while reading the resource
-
load
Description copied from interface:IBoundLoaderLoad data from the resource identified by the provideduriinto a bound object.This method will auto-detect the format of the provided resource.
- Specified by:
loadin interfaceIBoundLoader- Type Parameters:
CLASS- the type of the bound object to return- Parameters:
uri- the resource- Returns:
- a bound object containing the loaded data
- Throws:
IOException- if an error occurred while reading the resource- See Also:
-
load
@NonNull public <CLASS extends IBoundObject> CLASS load(@NotOwning @NonNull InputStream is, @NonNull URI resource) throws IOException Description copied from interface:IBoundLoaderLoad data from the provided resource into a bound object.This method should auto-detect the format of the provided resource.
This method will not close the provided
InputStream, since it does not own the stream.- Specified by:
loadin interfaceIBoundLoader- Type Parameters:
CLASS- the type of the bound object to return- Parameters:
is- the resource streamresource- the URI of the resource- Returns:
- a bound object containing the loaded data
- Throws:
IOException- if an error occurred while reading the resource- See Also:
-
load
Description copied from interface:IBoundLoaderLoad data from the specified resource into a bound object with the type of the specified Java class.- Specified by:
loadin interfaceIBoundLoader- Type Parameters:
CLASS- the Java type to load data into- Parameters:
clazz- the class for the java typeuri- the resource to load- Returns:
- the loaded instance data
- Throws:
IOException- if an error occurred while loading the data in the specified file
-
load
public <CLASS extends IBoundObject> CLASS load(Class<CLASS> clazz, InputStream is, URI documentUri) throws IOException Description copied from interface:IBoundLoaderLoad data from the specified resource into a bound object with the type of the specified Java class.This method will not close the provided
InputStream, since it does not own the stream.Implementations of this method will do format detection. This process might leave the provided
InputStreamat a position beyond the last parsed location. If you want to avoid this possibility, use and implementation ofIDeserializer.deserialize(InputStream, URI)instead, such as what is provided byDefaultBindingContext.newDeserializer(Format, Class).- Specified by:
loadin interfaceIBoundLoader- Type Parameters:
CLASS- the Java type to load data into- Parameters:
clazz- the class for the java typeis- the resource streamdocumentUri- the URI of the resource- Returns:
- the loaded data
- Throws:
IOException- if an error occurred while loading the data from the specified resource
-
load
@NonNull public <CLASS extends IBoundObject> CLASS load(@NonNull Class<CLASS> clazz, @NonNull Format format, @NonNull InputStream is, @NonNull URI documentUri) throws IOException Description copied from interface:IBoundLoaderLoad data from the specified resource into a bound object with the type of the specified Java class.This method will not close the provided
InputStream, since it does not own the stream.- Specified by:
loadin interfaceIBoundLoader- Type Parameters:
CLASS- the Java type to load data into- Parameters:
clazz- the class for the java typeformat- the format to parseis- the resource streamdocumentUri- the URI of the resource- Returns:
- the loaded data
- Throws:
IOException- if an error occurred while loading the data from the specified resource
-
loadAsNodeItem
Description copied from interface:IDocumentLoaderLoad a Metaschema-based document from a URI resource.This is the expected, primary entry point for implementations.
- Specified by:
loadAsNodeItemin interfaceIDocumentLoader- Parameters:
uri- the resource to load- Returns:
- a document item representing the contents of the document.
- Throws:
IOException- if an error occurred while parsing the resource
-
loadAsNodeItem
Description copied from interface:IBoundLoaderLoad data expressed using the providedformatand return that data as a Metapath node item.The specific Module model is auto-detected by analyzing the source. The class reported is implementation specific.
- Specified by:
loadAsNodeItemin interfaceIBoundLoader- Parameters:
format- the expected format of the data to parseuri- the resource- Returns:
- the Metapath node item for the parsed data
- Throws:
IOException- if an error occurred while loading the data from the specified resource
-
loadAsNodeItem
public IDocumentNodeItem loadAsNodeItem(Format format, InputStream is, URI resource) throws IOException Description copied from interface:IBoundLoaderLoad data expressed using the providedformatand return that data as a Metapath node item.The specific Module model is auto-detected by analyzing the source. The class reported is implementation specific.
- Specified by:
loadAsNodeItemin interfaceIBoundLoader- Parameters:
format- the expected format of the data to parseis- the resource streamresource- the URI of the resource- Returns:
- the Metapath node item for the parsed data
- Throws:
IOException- if an error occurred while loading the data from the specified resource
-