Class OslcNamespaces
java.lang.Object
com.sodius.oslc.core.process.query.OslcNamespaces
Defines prefix and namespace mappings of a given OSLC schema.
- Since:
- 3.6.0
-
Method Summary
Modifier and TypeMethodDescriptionand(OslcNamespaces... namespaces) Combines the receiver's namespaces with the given ones into a new instance.voidapplyTo(ServiceProvider provider) Adds the namespaces as prefix definitions on the given service providergetNamespace(String prefix) Returns the namespace associated with the given prefix, if any.Returns a non-modifiable map of prefix/namespace mappings.Returns the prefix associated with the given namespace, if any.getPrefixed(String uri) Gets the prefixed name of a given URI as long as the namespace is mapped in this instance.Splits a URI into a qualified name (namespace + localpart + prefix) as long as the namespace is mapped in this instance.static OslcNamespacesCreates a new instance with the given namespaces.static OslcNamespacesReturns the namespaces defined in theOslcSchemaannotation of the packages of the given classes.static OslcNamespacesReturns the set of well-known namespaces, which includes RDF and OSLC namespaces (Core and domains), as defined by the specifications.
-
Method Details
-
wellKnown
Returns the set of well-known namespaces, which includes RDF and OSLC namespaces (Core and domains), as defined by the specifications.- Returns:
- the well-known namespaces.
-
of
Returns the namespaces defined in theOslcSchemaannotation of the packages of the given classes.- Parameters:
resourceClasses- classes whose owning package defines aOslcSchemaannotation.- Returns:
- the namespaces defined in the
OslcSchemaannotations. - Throws:
IllegalArgumentException- if noOslcSchemaannotation is found on a package.
-
of
Creates a new instance with the given namespaces.- Parameters:
namespaces- the namespaces to add- Returns:
- the new instance
-
getPrefix
Returns the prefix associated with the given namespace, if any.- Parameters:
namespace- a namespace.- Returns:
- the associated prefix, or an empty
Optionalif none. - Throws:
NullPointerException- if namespace is null
-
getNamespace
Returns the namespace associated with the given prefix, if any.- Parameters:
prefix- a namespace prefix.- Returns:
- the associated namespace, or an empty
Optionalif none. - Throws:
NullPointerException- if prefix is null
-
getNamespaces
Returns a non-modifiable map of prefix/namespace mappings.- Returns:
- a map whose keys are prefixes and values are the associated namespaces.
-
and
Combines the receiver's namespaces with the given ones into a new instance. If the same namespace is bound to multiple prefixes, the prefix of the last namespace in the list is retained.- Parameters:
namespaces- the namespaces to combine- Returns:
- a new instance combining the given namespaces
-
applyTo
Adds the namespaces as prefix definitions on the given service provider- Parameters:
provider- the provider on which to add the prefix definitions- See Also:
-
getQName
Splits a URI into a qualified name (namespace + localpart + prefix) as long as the namespace is mapped in this instance.- Parameters:
uri- the URI to split.- Returns:
- the corresponding
QNameif the namespace is mapped in this instance; an emptyOptionalotherwise. - Throws:
NullPointerException- if the URI is null.IllegalArgumentException- if the URI is not a namespace URI.- Since:
- 3.7.0
-
getPrefixed
Gets the prefixed name of a given URI as long as the namespace is mapped in this instance.- Parameters:
uri- the given URI.- Returns:
- the corresponding prefixed name if the namespace is mapped in this instance; an empty
Optionalotherwise. - Throws:
NullPointerException- if the URI is null.IllegalArgumentException- if the URI is not a namespace URI.- Since:
- 3.7.0
-