- All Implemented Interfaces:
PrefixMap
PrefixMap.
This also provides fast URI to prefix name calculation suitable for output. For output, calculating possible prefix names from a URI happens on every URI so this operations needs to be efficient. Normally, a prefix map is "prefix to URI" and the abbreviation is a reverse lookup, which is a scan of the value of the map. This class keeps a reverse lookup map of URI to prefix which combined with a fast, approximate for determining the split point exploiting the most common use cases, provides efficient abbreviation.
Usage for abbreviation: call PrefixMapFactory.createForOutput(PrefixMap) which copies the argument prefix map into an instance of this class, setting up the reverse lookup. This copy is cheaper than repeated reverse lookups would be.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty prefix mappingPrefixMapStd(PrefixMap prefixMap) Creates a new prefix mapping copied from an existing map -
Method Summary
Modifier and TypeMethodDescriptionAbbreviate an IRI and return a pair of prefix and local parts, or null.abbreviate(String uriStr) Abbreviate an IRI or return nullvoidAdd a prefix, overwrites any existing associationvoidclear()Clear all prefixes.booleancontainsPrefix(String prefix) Gets whether the map contains a given prefixvoidDelete a prefixReturn the URI for the prefix, or null if there is no entry for this prefix.Return the underlying mapping, this is generally unsafe to modify and implementations may opt to return an unmodifiable view of the mapping if they wish.booleanisEmpty()Return whether the prefix map is empty or not.intsize()Return the number of entries in the prefix map.Methods inherited from class org.apache.jena.riot.system.PrefixMapBase
expand, expand, forEach, getMappingCopy, putAll, putAll, putAll, stream, toString
-
Constructor Details
-
PrefixMapStd
public PrefixMapStd()Creates a new empty prefix mapping -
PrefixMapStd
Creates a new prefix mapping copied from an existing map- Parameters:
prefixMap- Prefix Map
-
-
Method Details
-
getMapping
Description copied from interface:PrefixMapReturn the underlying mapping, this is generally unsafe to modify and implementations may opt to return an unmodifiable view of the mapping if they wish.- Returns:
- Underlying mapping
- See Also:
-
get
Description copied from interface:PrefixMapReturn the URI for the prefix, or null if there is no entry for this prefix. -
add
Description copied from interface:PrefixMapAdd a prefix, overwrites any existing association- Parameters:
prefix- Prefixiri- Namespace IRI
-
delete
Description copied from interface:PrefixMapDelete a prefix- Parameters:
prefix- Prefix to delete
-
clear
public void clear()Description copied from interface:PrefixMapClear all prefixes. -
containsPrefix
Description copied from interface:PrefixMapGets whether the map contains a given prefix- Parameters:
prefix- Prefix- Returns:
- True if the prefix is contained in the map, false otherwise
-
abbreviate
Description copied from interface:PrefixMapAbbreviate an IRI or return null- Specified by:
abbreviatein interfacePrefixMap- Overrides:
abbreviatein classPrefixMapBase- Parameters:
uriStr- URI to abbreviate- Returns:
- URI in prefixed name form if possible, null otherwise
-
abbrev
Description copied from interface:PrefixMapAbbreviate an IRI and return a pair of prefix and local parts, or null.- Specified by:
abbrevin interfacePrefixMap- Overrides:
abbrevin classPrefixMapBase- Parameters:
uriStr- URI string to abbreviate- Returns:
- Pair of prefix and local name
- See Also:
-
isEmpty
public boolean isEmpty()Description copied from interface:PrefixMapReturn whether the prefix map is empty or not. -
size
public int size()Description copied from interface:PrefixMapReturn the number of entries in the prefix map.
-