Package org.incenp.obofoundry.sssom
Class PrefixManager
java.lang.Object
org.incenp.obofoundry.sssom.PrefixManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new prefix.void
Adds new prefixes.expandIdentifier
(String curie) Expands a shortened identifier into its long, canonical form.expandIdentifiers
(List<String> curies) Expands all identifiers in the given list.expandIdentifiers
(List<String> curies, boolean inPlace) Expands all identifiers in the given list.Gets the prefix associated with the given prefix name.Gets the underlying map of prefix names to URL prefixes.getPrefixName
(String iri) Gets the name of the best (longest) prefix for a given identifier.Gets the prefix names that this resolver could not expand.Gets the IRIs that could not be shortened byshortenIdentifier(String)
for lack of a suitable prefix declaration.shortenIdentifier
(String iri) Shortens an identifier according to the prefix map.shortenIdentifiers
(List<String> iris) Shortens all identifiers in the given list.shortenIdentifiers
(List<String> iris, boolean inPlace) Shortens all identifiers in the given list.
-
Constructor Details
-
PrefixManager
public PrefixManager()Creates a new instance.
-
-
Method Details
-
add
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
Adds new prefixes.- Parameters:
map
- A map associating prefix names to prefixes.
-
getPrefixMap
Gets the underlying map of prefix names to URL prefixes.- Returns:
- The prefix map used by this prefix manager.
-
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
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
Gets the prefix associated with the given prefix name.- Parameters:
prefixName
- The name of the prefix to retrieve.- Returns:
- The corresponding prefix, or
null
if the name is not the name of a registered prefix.
-
getPrefixName
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
null
if no registered prefix is suitable for the given identifier.
-
shortenIdentifier
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
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
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
inPlace
istrue
, this is the original list.
-
expandIdentifier
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
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
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
inPlace
istrue
, this is the original list.
-