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 intLOOK_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 IBoundLoaderapplyConfiguration(IConfiguration<DeserializationFeature<?>> other)FormatDetector.ResultdetectFormat(InputStream is)Determine the format of the provided resource.FormatDetector.ResultdetectFormat(URI uri)Determine the format of the resource identified by the provideduri.IBindingContextgetBindingContext()Get the configured Module binding context to use to load Java types.Map<DeserializationFeature<?>,Object>getFeatureValues()booleanisFeatureEnabled(DeserializationFeature<?> feature)<CLASS> CLASSload(InputStream is, URI documentUri)Load data from the provided resource into a bound object.<CLASS> 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> CLASSload(Class<CLASS> clazz, URI uri)Load data from the specified resource into a bound object with the type of the specified Java class.<CLASS> CLASSload(URI uri)Load data from the resource identified by the provideduriinto a bound object.IDocumentNodeItemloadAsNodeItem(Format format, InputStream is, URI documentUri)Load data expressed using the providedformatand return that data as a Metapath node item.IDocumentNodeItemloadAsNodeItem(Format format, URI uri)Load data expressed using the providedformatand return that data as a Metapath node item.IDocumentNodeItemloadAsNodeItem(InputStream is, URI documentUri)IDocumentNodeItemloadAsNodeItem(URI uri)IBoundLoaderset(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:
isFeatureEnabledin interfaceIConfiguration<DeserializationFeature<?>>
-
getFeatureValues
public Map<DeserializationFeature<?>,Object> getFeatureValues()
- Specified by:
getFeatureValuesin interfaceIConfiguration<DeserializationFeature<?>>
-
applyConfiguration
public IBoundLoader applyConfiguration(@NonNull IConfiguration<DeserializationFeature<?>> other)
- Specified by:
applyConfigurationin interfaceIBoundLoader- Specified by:
applyConfigurationin interfaceIMutableConfiguration<DeserializationFeature<?>>
-
set
public IBoundLoader set(DeserializationFeature<?> feature, Object value)
- Specified by:
setin interfaceIBoundLoader- Specified by:
setin interfaceIMutableConfiguration<DeserializationFeature<?>>
-
getBindingContext
public IBindingContext 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
public FormatDetector.Result detectFormat(@NonNull URI uri) throws IOException
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
public FormatDetector.Result detectFormat(@NonNull InputStream is) throws IOException
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 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: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:
IBoundLoader.detectFormat(URL)
-
load
@NonNull public <CLASS> CLASS load(@NonNull InputStream is, @NonNull URI documentUri) 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 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: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> 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
-
loadAsNodeItem
public IDocumentNodeItem loadAsNodeItem(URI uri) throws IOException
- Specified by:
loadAsNodeItemin interfaceIDocumentLoader- Throws:
IOException
-
loadAsNodeItem
public IDocumentNodeItem loadAsNodeItem(InputStream is, URI documentUri) throws IOException
- Specified by:
loadAsNodeItemin interfaceIDocumentLoader- Throws:
IOException
-
loadAsNodeItem
public IDocumentNodeItem loadAsNodeItem(Format format, URI uri) 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 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: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 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
-
-