Package com.github.jsonldjava.core
Class Context
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,
,Object> SequencedMap<String,
Object>
A helper class which still stores all the values in a map but gives member
variables easily access certain keys
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JsonLdOptions
private static final long
private static final Pattern
-
Constructor Summary
ConstructorsConstructorDescriptionContext()
Context
(JsonLdOptions opts) Context
(Object context, JsonLdOptions opts) Context
(Map<String, Object> map, JsonLdOptions opts) -
Method Summary
Modifier and TypeMethodDescriptionstatic String
_iriCompactionStep5point4
(String iri, Object value, String compactIRI, String candidate, Map<String, Object> termDefinitions) private void
checkEmptyKey
(Map<String, Object> map) clone()
(package private) String
compactIri
(String iri) (package private) String
compactIri
(String iri, boolean relativeToVocab) (package private) String
compactIri
(String iri, Object value, boolean relativeToVocab, boolean reverse) IRI Compaction Algorithm http://json-ld.org/spec/latest/json-ld-api/#iri-compaction Compacts an IRI or keyword into a term or prefix if it can be.compactValue
(String activeProperty, Map<String, Object> value) Value Compaction Algorithm http://json-ld.org/spec/latest/json-ld-api/#value-compactionprivate void
Create Term Definition Algorithm http://json-ld.org/spec/latest/json-ld-api/#create-term-definition(package private) String
expandIri
(String value, boolean relative, boolean vocab, Map<String, Object> context, Map<String, Boolean> defined) IRI Expansion Algorithm http://json-ld.org/spec/latest/json-ld-api/#iri-expansionexpandValue
(String activeProperty, Object value) getContainer
(String property) Retrieve container mapping.Inverse Context Creation http://json-ld.org/spec/latest/json-ld-api/#inverse-context-creation Generates an inverse context for use in the compaction algorithm, if not already generated for the given active context.getLanguageMapping
(String property) getPrefixes
(boolean onlyCommonPrefixes) Return a map of potential RDF prefixes based on the JSON-LD Term Definitions in this context.getTermDefinition
(String key) getTypeMapping
(String property) private void
init
(JsonLdOptions options) isReverseProperty
(String property) Context Processing Algorithm http://json-ld.org/spec/latest/json-ld-api/#context-processing-algorithmsprivate Context
Helper method used to work around logic errors related to the recursive nature of the JSONLD-API Context Processing Algorithm.private String
Term Selection http://json-ld.org/spec/latest/json-ld-api/#term-selection This algorithm, invoked via the IRI Compaction algorithm, makes use of an active context's inverse context to find the term that is best used to compact an IRI.Deprecated.Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, removeEldestEntry, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, values
Methods inherited from class java.util.HashMap
compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from interface java.util.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
URL_PATTERN
-
options
-
termDefinitions
-
inverse
-
-
Constructor Details
-
Context
public Context() -
Context
-
Context
-
Context
-
Context
-
-
Method Details
-
init
-
compactValue
Value Compaction Algorithm http://json-ld.org/spec/latest/json-ld-api/#value-compaction- Parameters:
activeProperty
- The Active Propertyvalue
- The value to compact- Returns:
- The compacted value
-
parse
Context Processing Algorithm http://json-ld.org/spec/latest/json-ld-api/#context-processing-algorithms- Parameters:
localContext
- The Local Context object.remoteContexts
- The list of Strings denoting the remote Context URLs.- Returns:
- The parsed and merged Context.
- Throws:
JsonLdError
- If there is an error parsing the contexts.
-
parse
private Context parse(Object localContext, List<String> remoteContexts, boolean parsingARemoteContext) throws JsonLdError Helper method used to work around logic errors related to the recursive nature of the JSONLD-API Context Processing Algorithm.- Parameters:
localContext
- The Local Context object.remoteContexts
- The list of Strings denoting the remote Context URLs.parsingARemoteContext
- True if localContext represents a remote context that has been parsed and sent into this method and false otherwise. This must be set to know whether to propagate the @code key from the context to the result.- Returns:
- The parsed and merged Context.
- Throws:
JsonLdError
- If there is an error parsing the contexts.
-
checkEmptyKey
-
parse
- Throws:
JsonLdError
-
createTermDefinition
private void createTermDefinition(Map<String, Object> context, String term, Map<String, throws JsonLdErrorBoolean> defined) Create Term Definition Algorithm http://json-ld.org/spec/latest/json-ld-api/#create-term-definition- Parameters:
context
-defined
-- Throws:
JsonLdError
-
expandIri
String expandIri(String value, boolean relative, boolean vocab, Map<String, Object> context, Map<String, throws JsonLdErrorBoolean> defined) IRI Expansion Algorithm http://json-ld.org/spec/latest/json-ld-api/#iri-expansion- Parameters:
value
-relative
-vocab
-context
-defined
-- Returns:
- Throws:
JsonLdError
-
compactIri
IRI Compaction Algorithm http://json-ld.org/spec/latest/json-ld-api/#iri-compaction Compacts an IRI or keyword into a term or prefix if it can be. If the IRI has an associated value it may be passed.- Parameters:
iri
- the IRI to compact.value
- the value to check or null.relativeToVocab
- options for how to compact IRIs: vocab: true to split after @vocab, false not to.reverse
- true if a reverse property is being compacted, false if not.- Returns:
- the compacted term, prefix, keyword alias, or the original IRI.
-
_iriCompactionStep5point4
-
getPrefixes
Return a map of potential RDF prefixes based on the JSON-LD Term Definitions in this context.No guarantees of the prefixes are given, beyond that it will not contain ":".
- Parameters:
onlyCommonPrefixes
- Iftrue
, the result will not include "not so useful" prefixes, such as "term1": "http://example.com/term1", e.g. all IRIs will end with "/" or "#". Iffalse
, all potential prefixes are returned.- Returns:
- A map from prefix string to IRI string
-
compactIri
-
compactIri
-
clone
-
getInverse
Inverse Context Creation http://json-ld.org/spec/latest/json-ld-api/#inverse-context-creation Generates an inverse context for use in the compaction algorithm, if not already generated for the given active context.- Returns:
- the inverse context.
-
selectTerm
private String selectTerm(String iri, List<String> containers, String typeLanguage, List<String> preferredValues) Term Selection http://json-ld.org/spec/latest/json-ld-api/#term-selection This algorithm, invoked via the IRI Compaction algorithm, makes use of an active context's inverse context to find the term that is best used to compact an IRI. Other information about a value associated with the IRI is given, including which container mappings and which type mapping or language mapping would be best used to express the value.- Returns:
- the selected term.
-
getContainer
Retrieve container mapping.- Parameters:
property
- The Property to get a container mapping for.- Returns:
- The container mapping if any, else null
-
isReverseProperty
-
getTypeMapping
-
getLanguageMapping
-
getTermDefinition
-
expandValue
- Throws:
JsonLdError
-
serialize
Deprecated.
-