Package org.incenp.obofoundry.sssom
Class PrefixManager
- java.lang.Object
-
- org.incenp.obofoundry.sssom.PrefixManager
-
public class PrefixManager extends Object
-
-
Constructor Summary
Constructors Constructor Description PrefixManager()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String prefixName, String prefix)Adds a new prefix.voidadd(Map<? extends String,? extends String> map)Adds new prefixes.StringexpandIdentifier(String curie)Expands a shortened identifier into its long, canonical form.List<String>expandIdentifiers(List<String> curies)Expands all identifiers in the given list.List<String>expandIdentifiers(List<String> curies, boolean inPlace)Expands all identifiers in the given list.StringgetLocalName(String iri)Gets the local part of the shortened form of given identifier.StringgetPrefix(String prefixName)Gets the prefix associated with the given prefix name.Map<String,String>getPrefixMap()Gets the underlying map of prefix names to URL prefixes.StringgetPrefixName(String iri)Gets the name of the best (longest) prefix for a given identifier.Set<String>getUnresolvedPrefixNames()Gets the prefix names that this resolver could not expand.Set<String>getUnshortenedIRIs()Gets the IRIs that could not be shortened byshortenIdentifier(String)for lack of a suitable prefix declaration.StringshortenIdentifier(String iri)Shortens an identifier according to the prefix map.List<String>shortenIdentifiers(List<String> iris)Shortens all identifiers in the given list.List<String>shortenIdentifiers(List<String> iris, boolean inPlace)Shortens all identifiers in the given list.
-
-
-
Method Detail
-
add
public void add(String prefixName, String prefix)
Adds a new prefix.- Parameters:
prefixName- The short name of the prefix, as it would appear in a CURIE. It should not include the colon.prefix- The expanded URL prefix;
-
add
public void add(Map<? extends String,? extends String> map)
Adds new prefixes.- Parameters:
map- A map associating prefix names to prefixes.
-
getPrefixMap
public Map<String,String> getPrefixMap()
Gets the underlying map of prefix names to URL prefixes.- Returns:
- The prefix map used by this prefix manager.
-
getUnresolvedPrefixNames
public Set<String> getUnresolvedPrefixNames()
Gets the prefix names that this resolver could not expand.- Returns:
- The set of all prefixes encountered in the lifetime of this object that could not be expanded because the prefix was unknown.
-
getUnshortenedIRIs
public Set<String> getUnshortenedIRIs()
Gets the IRIs that could not be shortened byshortenIdentifier(String)for lack of a suitable prefix declaration.- Returns:
- The set of all IRIs encountered in the lifetime of this object that could not be shortened.
-
getPrefix
public String getPrefix(String prefixName)
Gets the prefix associated with the given prefix name.- Parameters:
prefixName- The name of the prefix to retrieve.- Returns:
- The corresponding prefix, or
nullif the name is not the name of a registered prefix.
-
getPrefixName
public String getPrefixName(String iri)
Gets the name of the best (longest) prefix for a given identifier.- Parameters:
iri- The identifier for which to search the longest prefix.- Returns:
- The name of the best prefix, or
nullif no registered prefix is suitable for the given identifier.
-
getLocalName
public String getLocalName(String iri)
Gets the local part of the shortened form of given identifier.- Parameters:
iri- The identifier for which to get the local part.- Returns:
- The local name of the identifier, that is, everything after the
longest matching prefix; or
nullif the original identifier could not be shortened.
-
shortenIdentifier
public String shortenIdentifier(String iri)
Shortens an identifier according to the prefix map.- Parameters:
iri- The identifier to shorten.- Returns:
- The shortened identifier, or the original identifier if it could not be shortened.
-
shortenIdentifiers
public List<String> shortenIdentifiers(List<String> iris)
Shortens all identifiers in the given list. The original list is left untouched.- Parameters:
iris- The list of identifiers to shorten.- Returns:
- A new list with the shortened identifiers.
-
shortenIdentifiers
public List<String> shortenIdentifiers(List<String> iris, boolean inPlace)
Shortens all identifiers in the given list.- Parameters:
iris- The list of identifiers to shorten.inPlace- Iftrue, the original list is modified; otherwise it is left untouched and a new list is returned.- Returns:
- A list with the shortened identifiers. If
inPlaceistrue, this is the original list.
-
expandIdentifier
public String expandIdentifier(String curie)
Expands a shortened identifier into its long, canonical form.- Parameters:
curie- The short identifier to expand.- Returns:
- The full-length identifier, or the original identifier if it was not in CURIE form or the prefix name is unknown.
-
expandIdentifiers
public List<String> expandIdentifiers(List<String> curies)
Expands all identifiers in the given list. The original list is left untouched.- Parameters:
curies- The list of short identifiers to expand.- Returns:
- A new list with the expanded identifiers..
-
expandIdentifiers
public List<String> expandIdentifiers(List<String> curies, boolean inPlace)
Expands all identifiers in the given list.- Parameters:
curies- The list of short identifiers to expand.inPlace- Iftrue, the original list is modified; otherwise it is left untouched and a new list is returned.- Returns:
- A list with the expanded identifiers. If
inPlaceistrue, this is the original list.
-
-