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.
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 module
QName may also have prefix
assigned, but prefix does not
affect equality and identity of two QNames and carry only information
which may be useful for serializers / deserializers.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(QName o) |
static QName |
create(QNameModule qnameModule,
String localName)
Creates new QName.
|
static QName |
create(QName base,
String localName) |
static QName |
create(String input) |
static QName |
create(String namespace,
String localName)
Creates new QName.
|
static QName |
create(String namespace,
String localName,
Revision revision)
Creates new QName.
|
static QName |
create(String namespace,
String revision,
String localName)
Creates new QName.
|
static QName |
create(URI namespace,
Optional<Revision> revision,
String localName)
Creates new QName.
|
static QName |
create(URI namespace,
@Nullable Revision revision,
String localName)
Creates new QName.
|
static QName |
create(URI namespace,
String localName)
Creates new QName.
|
boolean |
equals(Object obj)
Compares the specified object with this list for equality.
|
static String |
formattedRevision(Optional<Revision> revision)
Formats
Revision representing revision to format YYYY-mm-dd |
String |
getLocalName()
Returns YANG schema identifier which were defined for this node in the
YANG module.
|
QNameModule |
getModule()
Get the module component of the QName.
|
URI |
getNamespace()
Returns XMLNamespace assigned to the YANG module.
|
Optional<Revision> |
getRevision()
Returns revision of the YANG module if the module has defined revision.
|
int |
hashCode() |
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.
|
String |
toString() |
QName |
withModule(@NonNull QNameModule newModule)
Returns a QName with the specified QNameModule and the same localname as this one.
|
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 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 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 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 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 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
is not according to format
YYYY-mm-dd
.public static 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 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 QNameModule getModule()
public URI getNamespace()
public String getLocalName()
public Optional<Revision> getRevision()
public 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 String toString()
toString
in interface Identifier
toString
in class Object
public QName withModule(@NonNull QNameModule newModule)
newModule
- New QNameModule to usepublic QName withoutRevision()
public static 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 accross 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 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.