Interface YangNamespaceContext
- All Superinterfaces:
Immutable
,Serializable
- All Known Implementing Classes:
BiMapYangNamespaceContext
,ModuleNameNamespaceContext
Interface for mapping between
String
prefixes and QNameModule
namespaces. The conceptual model
matches prefix mapping inside a YANG module
as defined through the use of prefix
and import
statements and detailed in RFC7950 Section 7.1.4.
Each namespace context has a set of prefix/namespace mappings. A namespace can be bound to multiple prefixes at the same time.
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull QName
createQName
(String prefix, String localName) Create aQName
by resolving a prefix against currently-bound prefixes and combining it with specified local name.default @NonNull Optional<QNameModule>
findNamespaceForPrefix
(String prefix) Return QNameModule to which a particular prefix is bound.findPrefixForNamespace
(QNameModule namespace) Return a prefix to which a particular QNameModule is bound.@Nullable QNameModule
namespaceForPrefix
(String prefix) Return QNameModule to which a particular prefix is bound.@Nullable String
prefixForNamespace
(QNameModule namespace) Return a prefix to which a particular QNameModule is bound.
-
Method Details
-
namespaceForPrefix
Return QNameModule to which a particular prefix is bound.- Parameters:
prefix
- Prefix to look up- Returns:
- QNameModule bound to specified prefix, or
null
- Throws:
NullPointerException
- ifprefix
isnull
-
findNamespaceForPrefix
Return QNameModule to which a particular prefix is bound.- Parameters:
prefix
- Prefix to look up- Returns:
- QNameModule bound to specified prefix
- Throws:
NullPointerException
- ifprefix
isnull
- Implementation Requirements:
- Default implementation defers to
namespaceForPrefix(String)
-
prefixForNamespace
Return a prefix to which a particular QNameModule is bound. If a namespace is bound to multiple prefixes, it is left unspecified which of those prefixes is returned.- Parameters:
namespace
- QNameModule to look up- Returns:
- Prefix to which the QNameModule is bound, or
null
- Throws:
NullPointerException
- ifmodule
isnull
-
findPrefixForNamespace
Return a prefix to which a particular QNameModule is bound. If a namespace is bound to multiple prefixes, it is left unspecified which of those prefixes is returned.- Parameters:
namespace
- QNameModule to look up- Returns:
- Prefix to which the QNameModule is bound
- Throws:
NullPointerException
- ifmodule
isnull
- Implementation Requirements:
- Default implementation defers to
prefixForNamespace(QNameModule)
-
createQName
Create aQName
by resolving a prefix against currently-bound prefixes and combining it with specified local name.- Parameters:
prefix
- Namespace prefixlocalName
- QName local name- Returns:
- A QName.
- Throws:
NullPointerException
- if any argument is nullIllegalArgumentException
- iflocalName
does not conform to local name requirements or if the prefix is not bound in this context.- Implementation Requirements:
- Default implementation defers to
namespaceForPrefix(String)
and constructs QName based on its return.
-