Package org.incenp.obofoundry.sssom.util
Class ExtendedPrefixMap
- java.lang.Object
-
- org.incenp.obofoundry.sssom.util.ExtendedPrefixMap
-
public class ExtendedPrefixMap extends Object
A basic implementation of the “Extended Prefix Map” concept promoted by the Bioregistry.The implementation is basic because it is never intended to actually be used to manage prefixes. The only purpose here is to be able to perform a single “reconciliation” operation, to force a mapping set to use the “canonical” prefixes set forth in a given extended prefix map.
This is another case of “the usual bioinformatics paradigm of ignoring the specs and inferring a format from a few examples”, but then again, the entire “spec” is nothing more than a single example, so we don’t have much choice.
- See Also:
- Extended prefix map specification
-
-
Constructor Summary
Constructors Constructor Description ExtendedPrefixMap(File file)Creates a new extended prefix map from the specified file.ExtendedPrefixMap(InputStream stream)Creates a new extended prefix map from the specified stream.ExtendedPrefixMap(String filename)Creates a new extended prefix map from the specified filename.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcanonicalise(String iri)Canonicalises an IRI.List<String>canonicalise(List<String> iris, boolean inPlace)Canonicalises a list of IRIs.voidcanonicalise(List<Mapping> mappings)Canonicalises a list of mappings.voidcanonicalise(MappingSet set)Canonicalises a mapping set.Map<String,String>getFullPrefixMap()Gets the full prefix map, associating every known prefix names to the canonical URL prefix.Map<String,String>getSimplePrefixMap()Gets a simple prefix map associating the canonical prefix name to the canonical URL prefix.
-
-
-
Constructor Detail
-
ExtendedPrefixMap
public ExtendedPrefixMap(File file) throws IOException
Creates a new extended prefix map from the specified file.- Parameters:
file- The file to read the map from.- Throws:
IOException- If any error occurs when reading the file (including a format error).
-
ExtendedPrefixMap
public ExtendedPrefixMap(String filename) throws IOException
Creates a new extended prefix map from the specified filename.- Parameters:
filename- The name of the file to read the map from.- Throws:
IOException- If any error occurs when reading the file (including a format error).
-
ExtendedPrefixMap
public ExtendedPrefixMap(InputStream stream) throws IOException
Creates a new extended prefix map from the specified stream.- Parameters:
stream- The stream to read the map from.- Throws:
IOException- If any error occurs when reading the file (including a format error).
-
-
Method Detail
-
getSimplePrefixMap
public Map<String,String> getSimplePrefixMap()
Gets a simple prefix map associating the canonical prefix name to the canonical URL prefix.- Returns:
- The simple, canonical prefix map.
-
getFullPrefixMap
public Map<String,String> getFullPrefixMap()
Gets the full prefix map, associating every known prefix names to the canonical URL prefix.- Returns:
- The full prefix map.
-
canonicalise
public String canonicalise(String iri)
Canonicalises an IRI. This method checks whether the specified IRI uses a prefix that is a synonym of a canonical prefix, and returns a new IRI using the corresponding canonical prefix.- Parameters:
iri- The IRI to canonicalise.- Returns:
- The canonical form of the IRI; may be identical to the original IRI if (1) that URI was already using the canonical prefix, or (2) no matching prefix was found in the extended map.
-
canonicalise
public List<String> canonicalise(List<String> iris, boolean inPlace)
Canonicalises a list of IRIs.- Parameters:
iris- The IRIs to canonicalise.inPlace- Iftrue, the original list will be modified and returned; otherwise a new list with canonicalised IRIs will be returned.- Returns:
- A list with canonicalised IRIs.
-
canonicalise
public void canonicalise(List<Mapping> mappings)
Canonicalises a list of mappings. This method performs a canonicalisation on the values of all slots of type EntityReference.- Parameters:
mappings- The mappings of canonicalise.
-
canonicalise
public void canonicalise(MappingSet set)
Canonicalises a mapping set. This performs a canonicalisation on the values of all slots of type EntityReference in the set itself, then in the individual mappings. The original prefix map of the set is updated with the canonical prefix map.- Parameters:
set- The mapping set to canonicalise.
-
-