Class DefaultBoundLoader
- java.lang.Object
-
- gov.nist.secauto.metaschema.core.resource.AbstractResourceLoader
-
- gov.nist.secauto.metaschema.databind.io.DefaultBoundLoader
-
- All Implemented Interfaces:
IConfiguration<DeserializationFeature<?>>
,IMutableConfiguration<DeserializationFeature<?>>
,IDocumentLoader
,IResourceLoader
,IBoundLoader
public class DefaultBoundLoader extends AbstractResourceLoader implements IBoundLoader
A default implementation of anIBoundLoader
.
-
-
Field Summary
Fields Modifier and Type Field Description static int
LOOK_AHEAD_BYTES
-
Constructor Summary
Constructors Constructor Description DefaultBoundLoader(IBindingContext bindingContext)
Construct a new OSCAL loader instance, using the providedIBindingContext
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IBoundLoader
applyConfiguration(IConfiguration<DeserializationFeature<?>> other)
FormatDetector.Result
detectFormat(InputStream is)
Determine the format of the provided resource.FormatDetector.Result
detectFormat(URI uri)
Determine the format of the resource identified by the provideduri
.IBindingContext
getBindingContext()
Get the configured Module binding context to use to load Java types.Map<DeserializationFeature<?>,Object>
getFeatureValues()
boolean
isFeatureEnabled(DeserializationFeature<?> feature)
<CLASS> CLASS
load(InputStream is, URI documentUri)
Load data from the provided resource into a bound object.<CLASS> CLASS
load(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> CLASS
load(Class<CLASS> clazz, URI uri)
Load data from the specified resource into a bound object with the type of the specified Java class.<CLASS> CLASS
load(URI uri)
Load data from the resource identified by the provideduri
into a bound object.IDocumentNodeItem
loadAsNodeItem(Format format, InputStream is, URI documentUri)
Load data expressed using the providedformat
and return that data as a Metapath node item.IDocumentNodeItem
loadAsNodeItem(Format format, URI uri)
Load data expressed using the providedformat
and return that data as a Metapath node item.IDocumentNodeItem
loadAsNodeItem(InputStream is, URI documentUri)
IDocumentNodeItem
loadAsNodeItem(URI uri)
IBoundLoader
set(DeserializationFeature<?> feature, Object value)
-
Methods inherited from class gov.nist.secauto.metaschema.core.resource.AbstractResourceLoader
getUriResolver, resolve, setUriResolver
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nist.secauto.metaschema.databind.io.IBoundLoader
convert, convert, detectFormat, detectFormat, detectFormat, disableFeature, enableFeature, load, load, load, load, load, load, loadAsNodeItem
-
Methods inherited from interface gov.nist.secauto.metaschema.core.configuration.IConfiguration
get
-
Methods inherited from interface gov.nist.secauto.metaschema.core.metapath.IDocumentLoader
loadAsNodeItem, loadAsNodeItem, loadAsNodeItem, setUriResolver
-
Methods inherited from interface gov.nist.secauto.metaschema.core.model.IResourceLoader
getUriResolver
-
-
-
-
Field Detail
-
LOOK_AHEAD_BYTES
public static final int LOOK_AHEAD_BYTES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultBoundLoader
public DefaultBoundLoader(@NonNull IBindingContext bindingContext)
Construct a new OSCAL loader instance, using the providedIBindingContext
.- Parameters:
bindingContext
- the Module binding context to use to load Java types
-
-
Method Detail
-
isFeatureEnabled
public boolean isFeatureEnabled(DeserializationFeature<?> feature)
- Specified by:
isFeatureEnabled
in interfaceIConfiguration<DeserializationFeature<?>>
-
getFeatureValues
public Map<DeserializationFeature<?>,Object> getFeatureValues()
- Specified by:
getFeatureValues
in interfaceIConfiguration<DeserializationFeature<?>>
-
applyConfiguration
public IBoundLoader applyConfiguration(@NonNull IConfiguration<DeserializationFeature<?>> other)
- Specified by:
applyConfiguration
in interfaceIBoundLoader
- Specified by:
applyConfiguration
in interfaceIMutableConfiguration<DeserializationFeature<?>>
-
set
public IBoundLoader set(DeserializationFeature<?> feature, Object value)
- Specified by:
set
in interfaceIBoundLoader
- Specified by:
set
in interfaceIMutableConfiguration<DeserializationFeature<?>>
-
getBindingContext
public IBindingContext getBindingContext()
Description copied from interface:IBoundLoader
Get the configured Module binding context to use to load Java types.- Specified by:
getBindingContext
in interfaceIBoundLoader
- Returns:
- the binding context
-
detectFormat
public FormatDetector.Result detectFormat(@NonNull URI uri) throws IOException
Description copied from interface:IBoundLoader
Determine the format of the resource identified by the provideduri
.- Specified by:
detectFormat
in interfaceIBoundLoader
- Parameters:
uri
- the resource- Returns:
- the format information for the provided resource
- Throws:
IOException
- if an error occurred while reading the resource
-
detectFormat
public FormatDetector.Result detectFormat(@NonNull InputStream is) throws IOException
Description copied from interface:IBoundLoader
Determine 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:
detectFormat
in interfaceIBoundLoader
- Parameters:
is
- an input stream for the resource- Returns:
- the format information for the provided resource
- Throws:
IOException
- if an error occurred while reading the resource
-
load
public <CLASS> CLASS load(@NonNull URI uri) throws IOException
Description copied from interface:IBoundLoader
Load data from the resource identified by the provideduri
into a bound object.This method will auto-detect the format of the provided resource.
- Specified by:
load
in 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:
IBoundLoader.detectFormat(URL)
-
load
@NonNull public <CLASS> CLASS load(@NonNull InputStream is, @NonNull URI documentUri) throws IOException
Description copied from interface:IBoundLoader
Load 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:
load
in interfaceIBoundLoader
- Type Parameters:
CLASS
- the type of the bound object to return- Parameters:
is
- the resource streamdocumentUri
- 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:
IBoundLoader.detectFormat(InputStream)
-
load
public <CLASS> CLASS load(Class<CLASS> clazz, URI uri) throws IOException
Description copied from interface:IBoundLoader
Load data from the specified resource into a bound object with the type of the specified Java class.- Specified by:
load
in 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> CLASS load(Class<CLASS> clazz, InputStream is, URI documentUri) throws IOException
Description copied from interface:IBoundLoader
Load 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
InputStream
at 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:
load
in 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
-
loadAsNodeItem
public IDocumentNodeItem loadAsNodeItem(URI uri) throws IOException
- Specified by:
loadAsNodeItem
in interfaceIDocumentLoader
- Throws:
IOException
-
loadAsNodeItem
public IDocumentNodeItem loadAsNodeItem(InputStream is, URI documentUri) throws IOException
- Specified by:
loadAsNodeItem
in interfaceIDocumentLoader
- Throws:
IOException
-
loadAsNodeItem
public IDocumentNodeItem loadAsNodeItem(Format format, URI uri) throws IOException
Description copied from interface:IBoundLoader
Load data expressed using the providedformat
and 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:
loadAsNodeItem
in 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 documentUri) throws IOException
Description copied from interface:IBoundLoader
Load data expressed using the providedformat
and 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:
loadAsNodeItem
in interfaceIBoundLoader
- Parameters:
format
- the expected format of the data to parseis
- the resource streamdocumentUri
- 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
-
-