public final class QName extends Object implements Immutable, Serializable, Comparable<QName>, Identifier, WritableObject
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.
getNamespace()
- the namespace assigned to the YANG module which
defined element, type, procedure or notification.getRevision()
- the revision of the YANG module which describes the
elementgetLocalName()
- the YANG schema identifier which were defined for this
node in the YANG moduleModifier and Type | Method and Description |
---|---|
int |
compareTo(QName o) |
static @NonNull QName |
create(QNameModule qnameModule,
String localName)
Creates new QName.
|
static @NonNull QName |
create(QName base,
String localName) |
static @NonNull QName |
create(String input) |
static @NonNull QName |
create(String namespace,
String localName)
Creates new QName.
|
static @NonNull QName |
create(String namespace,
String localName,
Revision revision)
Creates new QName.
|
static @NonNull QName |
create(String namespace,
String revision,
String localName)
Creates new QName.
|
static @NonNull QName |
create(URI namespace,
Optional<Revision> revision,
String localName)
Creates new QName.
|
static @NonNull QName |
create(URI namespace,
@Nullable Revision revision,
String localName)
Creates new QName.
|
static @NonNull QName |
create(URI namespace,
String localName)
Creates new QName.
|
boolean |
equals(Object obj)
Compares the specified object with this list for equality.
|
static @Nullable String |
formattedRevision(Optional<Revision> revision)
Formats
Revision representing revision to format YYYY-mm-dd |
@NonNull String |
getLocalName()
Returns YANG schema identifier which were defined for this node in the
YANG module.
|
@NonNull QNameModule |
getModule()
Get the module component of the QName.
|
@NonNull URI |
getNamespace()
Returns XMLNamespace assigned to the YANG module.
|
@NonNull Optional<Revision> |
getRevision()
Returns revision of the YANG module if the module has defined revision.
|
int |
hashCode() |
@NonNull QName |
intern()
Return an interned reference to a equivalent QName.
|
boolean |
isEqualWithoutRevision(QName other)
Compares this QName to other, without comparing revision.
|
static QName |
readFrom(DataInput in)
Read a QName from a DataInput.
|
@NonNull String |
toString() |
@NonNull QName |
withModule(QNameModule newModule)
Returns a QName with the specified QNameModule and the same localname as this one.
|
@NonNull QName |
withoutRevision()
Returns a QName with the same namespace and local name, but with no revision.
|
void |
writeTo(DataOutput out)
Serialize this object into a
DataOutput as a fixed-format stream. |
public static @NonNull QName create(QNameModule qnameModule, String localName)
qnameModule
- Namespace and revision enclosed as a QNameModulelocalName
- Local name part of QName. MUST NOT BE null.public static @NonNull QName create(URI namespace, @Nullable Revision revision, String localName)
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.public static @NonNull QName create(URI namespace, Optional<Revision> revision, String localName)
namespace
- Namespace of QName or null if namespace is undefined.revision
- Revision of namespace.localName
- Local name part of QName. MUST NOT BE null.public static @NonNull QName create(String namespace, String localName, Revision revision)
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.public static @NonNull QName create(String namespace, String revision, String localName)
namespace
- Namespace of QName, MUST NOT BE Null.revision
- Revision of namespace / YANG module. MUST NOT BE null, MUST BE in format YYYY-mm-dd
.localName
- Local name part of QName. MUST NOT BE null.NullPointerException
- If any of parameters is null.IllegalArgumentException
- If namespace
is not valid URI or revision
does not conform
to YYYY-mm-dd
.public static @NonNull QName create(String namespace, String localName)
namespace
- Namespace of QName, MUST NOT BE Null.localName
- Local name part of QName. MUST NOT BE null.NullPointerException
- If any of parameters is null.IllegalArgumentException
- If namespace
is not valid URI.public static @NonNull QName create(URI namespace, String localName)
namespace
- Namespace of QName, MUST NOT BE null.localName
- Local name part of QName. MUST NOT BE null.NullPointerException
- If any of parameters is null.IllegalArgumentException
- If namespace
is not valid URI.public static QName readFrom(DataInput in) throws IOException
writeTo(DataOutput)
.in
- DataInput to readIOException
- if I/O error occurspublic @NonNull QNameModule getModule()
public @NonNull URI getNamespace()
public @NonNull String getLocalName()
public @NonNull Optional<Revision> getRevision()
public @NonNull QName intern()
public int hashCode()
hashCode
in interface Identifier
hashCode
in class Object
public boolean equals(Object obj)
QName
and its getLocalName()
, getNamespace()
and
getRevision()
are equals to same properties of this instance.equals
in interface Identifier
equals
in class Object
obj
- the object to be compared for equality with this QNamepublic @NonNull String toString()
toString
in interface Identifier
toString
in class Object
public @NonNull QName withModule(QNameModule newModule)
newModule
- New QNameModule to usepublic @NonNull QName withoutRevision()
public static @Nullable String formattedRevision(Optional<Revision> revision)
Revision
representing revision to format YYYY-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.
revision
- Date object to formatpublic boolean isEqualWithoutRevision(QName other)
Compares instance of this to other instance of QName and returns true if both instances have equal
localName
(getLocalName()
) and @{code namespace} (getNamespace()
).
other
- Other QName. Must not be null.NullPointerException
- if other
is null.public int compareTo(QName o)
compareTo
in interface Comparable<QName>
public void writeTo(DataOutput out) throws IOException
WritableObject
DataOutput
as a fixed-format stream.writeTo
in interface WritableObject
out
- Data outputIOException
- if an I/O error occursCopyright © 2019 OpenDaylight. All rights reserved.