Class QName
java.lang.Object
org.opendaylight.yangtools.yang.common.AbstractQName
org.opendaylight.yangtools.yang.common.QName
- All Implemented Interfaces:
Serializable
,Comparable<QName>
,Identifier
,Immutable
,WritableObject
The QName from XML consists of local name of element and XML namespace, but for our use, we added module revision to
it.
In YANG context QName is full name of defined node, type, procedure or notification. QName consists of XML namespace, YANG model revision and local name of defined type. It is used to prevent name clashes between nodes with same local name, but from different schemas.
The local name must conform to RFC7950 Section 6.2.
- XMLNamespace -
getNamespace()
- the namespace assigned to the YANG module which defined element, type, procedure or notification. - Revision -
getRevision()
- the revision of the YANG module which describes the element - LocalName -
AbstractQName.getLocalName()
- the YANG schema identifier which were defined for this node in the YANG module
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NonNull QName
bindTo
(QNameModule namespace) Returns a QName with the specified namespace and the same local name as this one.int
static @NonNull QName
static @NonNull QName
Creates new QName.static @NonNull QName
Creates new QName.static @NonNull QName
Creates new QName.static @NonNull QName
create
(QNameModule qnameModule, String localName) Creates new QName.static @NonNull QName
static @NonNull QName
create
(XMLNamespace namespace, String localName) Creates new QName.static @NonNull QName
create
(XMLNamespace namespace, Optional<Revision> revision, String localName) Creates new QName.static @NonNull QName
create
(XMLNamespace namespace, @Nullable Revision revision, String localName) Creates new QName.boolean
Compares the specified object with this list for equality.static @Nullable String
formattedRevision
(Optional<Revision> revision) FormatsRevision
representing revision to formatYYYY-mm-dd
@NonNull QNameModule
Get the module component of the QName.@NonNull XMLNamespace
Returns XMLNamespace assigned to the YANG module.Returns revision of the YANG module if the module has defined revision.int
hashCode()
@NonNull QName
intern()
Return an interned reference to an equivalent object.boolean
isEqualWithoutRevision
(QName other) Compares this QName to other, without comparing revision.static @NonNull QName
Read a QName from a DataInput.@NonNull String
toString()
static @NonNull QName
unsafeOf
(@NonNull QNameModule qnameModule, @NonNull String localName) Creates new QName composed of specified module and local name.@NonNull QName
Returns a QName with the same namespace and local name, but with no revision.void
writeTo
(DataOutput out) Serialize this object into aDataOutput
as a fixed-format stream.Methods inherited from class org.opendaylight.yangtools.yang.common.AbstractQName
getLocalName, unbind
-
Method Details
-
create
-
create
-
create
Creates new QName.- Parameters:
qnameModule
- Namespace and revision enclosed as a QNameModulelocalName
- Local name part of QName. MUST NOT BE null.- Returns:
- Instance of QName
- Throws:
NullPointerException
- if any argument is nullIllegalArgumentException
- if localName is not a valid YANG identifier
-
create
public static @NonNull QName create(XMLNamespace namespace, @Nullable Revision revision, String localName) Creates new QName.- Parameters:
namespace
- Namespace of QName or null if namespace is undefined.revision
- Revision of namespace or null if revision is unspecified.localName
- Local name part of QName. MUST NOT BE null.- Returns:
- Instance of QName
-
create
public static @NonNull QName create(XMLNamespace namespace, Optional<Revision> revision, String localName) Creates new QName.- Parameters:
namespace
- Namespace of QName or null if namespace is undefined.revision
- Revision of namespace.localName
- Local name part of QName. MUST NOT BE null.- Returns:
- Instance of QName
-
create
Creates new QName.- Parameters:
namespace
- Namespace of QName or null if namespace is undefined.localName
- Local name part of QName. MUST NOT BE null.revision
- Revision of namespace or null if revision is unspecified.- Returns:
- Instance of QName
-
create
Creates new QName.- Parameters:
namespace
- Namespace of QName, MUST NOT BE Null.revision
- Revision of namespace / YANG module. MUST NOT BE null, MUST BE in formatYYYY-mm-dd
.localName
- Local name part of QName. MUST NOT BE null.- Returns:
- A new QName
- Throws:
NullPointerException
- If any of parameters is null.IllegalArgumentException
- Ifnamespace
is not valid URI orrevision
does not conform toYYYY-mm-dd
.
-
create
Creates new QName.- Parameters:
namespace
- Namespace of QName, MUST NOT BE Null.localName
- Local name part of QName. MUST NOT BE null.- Returns:
- A new QName
- Throws:
NullPointerException
- If any of parameters is null.IllegalArgumentException
- Ifnamespace
is not valid URI.
-
create
Creates new QName.- Parameters:
namespace
- Namespace of QName, MUST NOT BE null.localName
- Local name part of QName. MUST NOT BE null.- Returns:
- A new QName
- Throws:
NullPointerException
- If any of parameters is null.IllegalArgumentException
- Ifnamespace
is not valid URI.
-
readFrom
Read a QName from a DataInput. The format is expected to match the output format ofwriteTo(DataOutput)
.- Parameters:
in
- DataInput to read- Returns:
- A QName instance
- Throws:
IOException
- if I/O error occurs
-
unsafeOf
@Beta public static @NonNull QName unsafeOf(@NonNull QNameModule qnameModule, @NonNull String localName) Creates new QName composed of specified module and local name. This method does not perform lexical checking of localName, and it is the caller's responsibility to performs these checks.When in doubt, use
create(QNameModule, String)
instead.- Parameters:
qnameModule
- Namespace and revision enclosed as a QNameModulelocalName
- Local name part of QName, required to have been validated- Returns:
- Instance of QName
- Throws:
NullPointerException
- if any of the arguments is null
-
getModule
Get the module component of the QName.- Returns:
- Module component
-
getNamespace
Returns XMLNamespace assigned to the YANG module.- Returns:
- XMLNamespace assigned to the YANG module.
-
getRevision
Returns revision of the YANG module if the module has defined revision.- Returns:
- revision of the YANG module if the module has defined revision.
-
intern
Description copied from class:AbstractQName
Return an interned reference to an equivalent object.- Specified by:
intern
in classAbstractQName
- Returns:
- Interned reference, or this object if it was interned.
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceIdentifier
- Specified by:
hashCode
in classAbstractQName
-
equals
Compares the specified object with this list for equality. Returnstrue
if and only if the specified object is also instance ofQName
and itsAbstractQName.getLocalName()
,getNamespace()
andgetRevision()
are equals to same properties of this instance.- Specified by:
equals
in interfaceIdentifier
- Specified by:
equals
in classAbstractQName
- Parameters:
obj
- the object to be compared for equality with this QName- Returns:
true
if the specified object is equal to this QName
-
toString
- Specified by:
toString
in interfaceIdentifier
- Specified by:
toString
in classAbstractQName
-
bindTo
Description copied from class:AbstractQName
Returns a QName with the specified namespace and the same local name as this one.- Overrides:
bindTo
in classAbstractQName
- Parameters:
namespace
- New namespace to use- Returns:
- a QName with specified QNameModule and same local name as this one
-
withoutRevision
Returns a QName with the same namespace and local name, but with no revision. If this QName does not have a Revision, this object is returned.- Returns:
- a QName with the same namespace and local name, but with no revision.
-
formattedRevision
FormatsRevision
representing revision to formatYYYY-mm-dd
YANG Specification defines format for
revision<
as YYYY-mm-dd. This format for revision is reused across multiple places such as capabilities URI, YANG modules, etc.- Parameters:
revision
- Date object to format- Returns:
- String representation or null if the input was null.
-
isEqualWithoutRevision
Compares this QName to other, without comparing revision.Compares instance of this to other instance of QName and returns true if both instances have equal
localName
(AbstractQName.getLocalName()
) and @{code namespace} (getNamespace()
).- Parameters:
other
- Other QName. Must not be null.- Returns:
- true if this instance and other have equals localName and namespace.
- Throws:
NullPointerException
- ifother
is null.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<QName>
-
writeTo
Description copied from interface:WritableObject
Serialize this object into aDataOutput
as a fixed-format stream.- Specified by:
writeTo
in interfaceWritableObject
- Parameters:
out
- Data output- Throws:
IOException
- if an I/O error occurs
-