Class StaticDocumentLoader
java.lang.Object
de.wwu.scdh.annotation.selection.utils.StaticDocumentLoader
- All Implemented Interfaces:
com.apicatalog.jsonld.loader.DocumentLoader
public class StaticDocumentLoader
extends Object
implements com.apicatalog.jsonld.loader.DocumentLoader
The
StaticDocumentLoader is a DocumentLoader that returns local assets instead of remote one.
It is configured with a resource mapping that maps URIs to local assets. Its purpose is to speed up
JSON-LD processing with version pinned contexts, as for Web Annotations.
The loader delegated to a fallback loader when the requested URI is not in the resource mapping.
The structure of the resource mapping JSON file:
{
"https://www.w3.org/ns/anno.jsonld": {
"path": "anno.jsonld"
},
"http://www.w3.org/ns/anno.jsonld": {
"path": "anno.jsonld"
}
}
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newStaticDocumentLoaderfrom theCONTEXT_MAPPING.StaticDocumentLoader(File contextMap, com.apicatalog.jsonld.loader.DocumentLoader fallbackLoader, boolean delegateOnError) Creates a newStaticDocumentLoaderfrom a resource mapping given byFile. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTells whether this instance has a local version for a URI.com.apicatalog.jsonld.document.DocumentloadDocument(URI url, com.apicatalog.jsonld.loader.DocumentLoaderOptions options)
-
Field Details
-
CONTEXT_MAPPING
A default context mapping resource.
-
-
Constructor Details
-
StaticDocumentLoader
public StaticDocumentLoader(File contextMap, com.apicatalog.jsonld.loader.DocumentLoader fallbackLoader, boolean delegateOnError) Creates a newStaticDocumentLoaderfrom a resource mapping given byFile.- Parameters:
contextMap- - a JSON} with the resource mappinginvalid @link
{@link File>fallbackLoader- - aDocumentLoaderused to handle request for non-mapped resourcesdelegateOnError- - whether to delegate the request to the fallback, when loading of a local asset failed.
-
StaticDocumentLoader
public StaticDocumentLoader()Creates a newStaticDocumentLoaderfrom theCONTEXT_MAPPING.
-
-
Method Details
-
loadDocument
public com.apicatalog.jsonld.document.Document loadDocument(URI url, com.apicatalog.jsonld.loader.DocumentLoaderOptions options) throws com.apicatalog.jsonld.JsonLdError - Specified by:
loadDocumentin interfacecom.apicatalog.jsonld.loader.DocumentLoader- Throws:
com.apicatalog.jsonld.JsonLdError
-
hasLocal
Tells whether this instance has a local version for a URI.- Parameters:
uri- - the remote URI- Returns:
- -
trueif a local version is available.
-