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 QNamebindTo(QNameModule namespace) Returns a QName with the specified namespace and the same local name as this one.intstatic @NonNull QNamestatic @NonNull QNameCreates new QName.static @NonNull QNameCreates new QName.static @NonNull QNameCreates new QName.static @NonNull QNamecreate(QNameModule qnameModule, String localName) Creates new QName.static @NonNull QNamestatic @NonNull QNamecreate(XMLNamespace namespace, @Nullable Revision revision, String localName) Creates new QName.static @NonNull QNamecreate(XMLNamespace namespace, String localName) Creates new QName.static @NonNull QNamecreate(XMLNamespace namespace, Optional<Revision> revision, String localName) Creates new QName.booleanCompares the specified object with this list for equality.static @Nullable StringformattedRevision(Optional<Revision> revision) FormatsRevisionrepresenting revision to formatYYYY-mm-dd@NonNull QNameModuleGet the module component of the QName.@NonNull XMLNamespaceReturns XMLNamespace assigned to the YANG module.Returns revision of the YANG module if the module has defined revision.inthashCode()@NonNull QNameintern()Return an interned reference to an equivalent object.booleanisEqualWithoutRevision(QName other) Compares this QName to other, without comparing revision.static @NonNull QNameRead a QName from a DataInput.@NonNull StringtoString()static @NonNull QNameunsafeOf(@NonNull QNameModule qnameModule, @NonNull String localName) Creates new QName composed of specified module and local name.@NonNull QNameReturns a QName with the same namespace and local name, but with no revision.voidwriteTo(DataOutput out) 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.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
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- Ifnamespaceis not valid URI orrevisiondoes 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- Ifnamespaceis 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- Ifnamespaceis 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:AbstractQNameReturn an interned reference to an equivalent object.- Specified by:
internin classAbstractQName- Returns:
- Interned reference, or this object if it was interned.
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceIdentifier- Specified by:
hashCodein classAbstractQName
-
equals
Compares the specified object with this list for equality. Returnstrueif and only if the specified object is also instance ofQNameand itsAbstractQName.getLocalName(),getNamespace()andgetRevision()are equals to same properties of this instance.- Specified by:
equalsin interfaceIdentifier- Specified by:
equalsin classAbstractQName- Parameters:
obj- the object to be compared for equality with this QName- Returns:
trueif the specified object is equal to this QName
-
toString
- Specified by:
toStringin interfaceIdentifier- Specified by:
toStringin classAbstractQName
-
bindTo
Description copied from class:AbstractQNameReturns a QName with the specified namespace and the same local name as this one.- Overrides:
bindToin 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
FormatsRevisionrepresenting revision to formatYYYY-mm-ddYANG 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- ifotheris null.
-
compareTo
- Specified by:
compareToin interfaceComparable<QName>
-
writeTo
- Specified by:
writeToin interfaceWritableObject- Throws:
IOException
-