Name.Component Class¶
A Name.Component holds a read-only name component value
| [C++]: | #include <ndn-cpp/name.hpp>Namespace:  ndn | 
|---|---|
| [Python]: | Module: pyndn | 
| [Java]: | Package: net.named_data.jndn | 
Name.Component Constructors¶
Name.Component Constructor (copy optional byte array)¶
Create a new Name.Component, optionally copying from the byte array. (To create an ImplicitSha256Digest component, use fromImplicitSha256Digest.) (To create a ParametersSha256Digest component, use fromParametersSha256Digest.)
| [C++]: | Name::Component(
    [const std::vector<uint8_t>& value]
    [, ndn_NameComponentType type]
    [, int otherTypeCode]
);
 | 
|---|---|
| [Python]: | def __init__(self
    [, value  # bytearray|memoryview|other array of int]
    [, type  # int]
    [, otherTypeCode  # int]
)
 | 
| [JavaScript]: | Name.Component = function NameComponent(
    [value  // Array<number>|ArrayBuffer|Uint8Array]
    [, type  // number]
    [, otherTypeCode  // number]
)
 | 
| [Java]: | public Component(
    [byte[] value]
    [, ComponentType type]
    [, int otherTypeCode]
)
 | 
| Parameters: | 
 | 
Name.Component Constructor (from Unicode string)¶
Create a new Name.Component, converting the value to UTF8 bytes. This does not escape %XX values. If you need to escape, use Name.fromEscapedString.
| [Python]: |  def __init__(self,
    value  # unicode (Python 2) or str (Python 3)
    [, type  # int]
    [, otherTypeCode  # int]
)
 | 
|---|---|
| [JavaScript]: | Name.Component = function NameComponent(
    value  // string
    [, type  // number]
    [, otherTypeCode  // number]
)
 | 
| [Java]: | Component(
    String value
    [, ComponentType type]
    [, int otherTypeCode]
)
 | 
| Parameters: | 
 | 
Name.Component Constructor (from Blob)¶
Create a new Name.Component, taking another pointer to the byte array in the Blob. (To create an ImplicitSha256Digest component, use fromImplicitSha256Digest.) (To create a ParametersSha256Digest component, use fromParametersSha256Digest.)
| [C++]: | Name::Component(
    const Blob& value
    [, ndn_NameComponentType type]
    [, int otherTypeCode]
);
 | 
|---|---|
| [Python]: |  def __init__(self,
    value  # Blob
    [, type  # int]
    [, otherTypeCode  # int]
)
 | 
| [JavaScript]: | Name.Component = function NameComponent(
    value  // Blob
    [, type  // number]
    [, otherTypeCode  // number]
)
 | 
| [Java]: | Component(
    Blob value
    [, ComponentType type]
    [, int otherTypeCode]
)
 | 
| Parameters: | 
 | 
Name.Component Constructor (from Component)¶
Create a new Name.Component, taking another pointer to the component’s value.
| [C++]: | Name::Component(
    const Name::Component& component
);
 | 
|---|---|
| [Python]: | def __init__(self,
    component  # Name.Component
)
 | 
| [JavaScript]: | Name.Component = function NameComponent(
    component  // Name.Component
)
 | 
| [Java]: | Component(
    Component component
)
 | 
| Parameters: | 
 | 
Name.Component.compare Method¶
Compare this to the other Component using NDN canonical ordering.
See http://named-data.net/doc/0.2/technical/CanonicalOrder.html
| [C++]: | int compare(
    const Name::Component& other
) const;
 | 
|---|---|
| [Python]: | # Returns int
def compare(self,
    other  # Name.Component
)
 | 
| [JavaScript]: | // Returns number
Name.Component.prototype.compare = function(
    other  // Name.Component
)
 | 
| [Java]: | public final int other(
    Name.Component other
)
 | 
| Parameters: | 
 | 
| Returns: | 0 If they compare equal, -1 if this Name.Component comes before other in the canonical ordering, or 1 if this Name.Component comes after other in the canonical ordering. | 
Name.Component.equals Method¶
Check if this is the same component as other.
| [C++]: | bool equals(
    const Component& other
) const;
 | 
|---|---|
| [Python]: | # Returns bool
def equals(self,
    other  # Name.Component
)
 | 
| [JavaScript]: | // Returns boolean
Name.Component.prototype.equals = function(
    other  // Name.Component
)
 | 
| [Java]: | public boolean equals(
    Name.Component other
)
 | 
| Parameters: | 
 | 
| Returns: | True if the components are not equal, otherwise false. | 
Name.Component.fromImplicitSha256Digest Method¶
Create a component of type ImplicitSha256DigestComponent, so that isImplicitSha256Digest() is true.
| [C++]: | static Component fromImplicitSha256Digest(
    const Blob& digest
);
static Component fromImplicitSha256Digest(
    const uint8_t *digest,
    size_t digestLength
);
static Component fromImplicitSha256Digest(
    const std::vector<uint8_t>& digest
);
 | 
|---|---|
| [Python]: | # Returns Name.Component
@staticmethod
def fromImplicitSha256Digest(
    digest  # Blob or value for Blob constructor
)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.fromImplicitSha256Digest = function(
    digest  // Blob|Buffer
)
 | 
| [Java]: | public static Component fromImplicitSha256Digest(
    Blob digest
)
public static Component fromImplicitSha256Digest(
    byte[] digest
)
 | 
| Parameters: | 
 | 
| Returns: | The new component. | 
| Throw: | Throw an exception if the digest length is not 32 bytes. | 
Name.Component.fromParametersSha256Digest Method¶
Create a component of type ParametersSha256DigestComponent, so that isParametersSha256Digest() is true.
| [C++]: | static Component fromParametersSha256Digest(
    const Blob& digest
);
static Component fromParametersSha256Digest(
    const uint8_t *digest,
    size_t digestLength
);
static Component fromParametersSha256Digest(
    const std::vector<uint8_t>& digest
);
 | 
|---|---|
| [Python]: | # Returns Name.Component
@staticmethod
def fromParametersSha256Digest(
    digest  # Blob or value for Blob constructor
)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.fromParametersSha256Digest = function(
    digest  // Blob|Buffer
)
 | 
| [Java]: | public static Component fromParametersSha256Digest(
    Blob digest
)
public static Component fromParametersSha256Digest(
    byte[] digest
)
 | 
| Parameters: | 
 | 
| Returns: | The new component. | 
| Throw: | Throw an exception if the digest length is not 32 bytes. | 
Name.Component.getOtherTypeCode Method¶
Get the name component type code from the packet which is other than a recognized ComponentType enum value. This is only meaningful if getType() is OTHER_CODE.
| [C++]: | int getOtherTypeCode() const;
 | 
|---|---|
| [Python]: | # Returns int
def getOtherTypeCode(self)
 | 
| [JavaScript]: | // Returns number
Name.Component.prototype.getOtherTypeCode = function()
 | 
| [Java]: | public final int getOtherTypeCode()
 | 
| Returns: | The type code. | 
Name.Component.getSuccessor Method¶
Get the successor of this component, as described in Name.getSuccessor.
| [C++]: | Component getSuccessor() const;
 | 
|---|---|
| [Python]: | # Returns Name.Component
def getSuccessor(self)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.prototype.getSuccessor = function()
 | 
| [Java]: | public final Component getSuccessor()
 | 
| Returns: | A new Name.Component which is the successor of this. | 
Name.Component.getType Method¶
Get the name component type.
| [C++]: | ndn_NameComponentType getType() const;
 | 
|---|---|
| [Python]: | # Returns int
def getType(self)
 | 
| [JavaScript]: | // Returns number
MetaInfo.prototype.getType = function()
 | 
| [Java]: | public final ComponentType getType()
 | 
| Returns: | The name component type enum value which is GENERIC, IMPLICIT_SHA256_DIGEST, PARAMETERS_SHA256_DIGEST or OTHER_CODE as follows. If this is OTHER_CODE, then call getOtherTypeCode() to get the unrecognized component type code. 
 | 
Name.Component.getValue Method¶
Get the value of the component.
| [C++]: | const Blob& getValue() const;
 | 
|---|---|
| [Python]: | # Returns Blob
def getValue(self)
 | 
| [JavaScript]: | // Returns Blob
Name.Component.prototype.getValue = function()
 | 
| [Java]: | public final Blob getValue()
 | 
| Returns: | The component value. | 
Name.Component.isGeneric Method¶
Check if this component is a generic component.
| [C++]: | bool isGeneric() const;
 | 
|---|---|
| [Python]: | # Returns bool
def isGeneric(self)
 | 
| [JavaScript]: | // Returns boolean
Name.Component.prototype.isGeneric = function()
 | 
| [Java]: | public final boolean isGeneric()
 | 
| Returns: | True if this is an generic component. | 
Name.Component.isImplicitSha256Digest Method¶
Check if this component is an ImplicitSha256Digest component.
| [C++]: | bool isImplicitSha256Digest() const;
 | 
|---|---|
| [Python]: | # Returns bool
def isImplicitSha256Digest(self)
 | 
| [JavaScript]: | // Returns boolean
Name.Component.prototype.isImplicitSha256Digest = function()
 | 
| [Java]: | public final boolean isImplicitSha256Digest()
 | 
| Returns: | True if this is an ImplicitSha256Digest component. | 
Name.Component.isParametersSha256Digest Method¶
Check if this component is a ParametersSha256Digest component.
| [C++]: | bool isParametersSha256Digest() const;
 | 
|---|---|
| [Python]: | # Returns bool
def isParametersSha256Digest(self)
 | 
| [JavaScript]: | // Returns boolean
Name.Component.prototype.isParametersSha256Digest = function()
 | 
| [Java]: | public final boolean isParametersSha256Digest()
 | 
| Returns: | True if this is a ParametersSha256Digest component. | 
Name.Component.toEscapedString Method¶
Convert this component value by escaping characters according to the NDN URI Scheme. This also adds “…” to a value with zero or more “.”. This adds a type code prefix as needed, such as “sha256digest=”.
| [C++]: | std::string toEscapedString() const;
 | 
|---|---|
| [Python]: | # Returns str
def toEscapedString(self)
 | 
| [JavaScript]: | // Returns string
Name.Component.prototype.toEscapedString = function()
 | 
| [Java]: | public final String toEscapedString()
 | 
| Returns: | The escaped string. | 
Name.Component From Naming Convention Value Methods¶
Name.Component.fromNumber Method¶
Create a component whose value is the nonNegativeInteger encoding of the number. A nonNegativeInteger is always encoded as 1, 2, 4 or 8 bytes.
| [C++]: | static Component fromNumber(
    uint64_t number
    [, ndn_NameComponentType type]
    [, int otherTypeCode]
);
 | 
|---|---|
| [Python]: | # Returns Name.Component
@staticmethod
def fromNumber(
    number  # int
    [, type  # int]
    [, otherTypeCode  # int]
)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.fromNumber = function(
    number  // number
    [, type  // number]
    [, otherTypeCode  // number]
)
 | 
| [Java]: | public static Component fromNumber(
    long number
    [, ComponentType type]
    [, int otherTypeCode]
)
 | 
| Parameters: | 
 | 
| Returns: | The new component. | 
Name.Component.fromNumberWithMarker Method¶
Create a component whose value is the marker appended with the nonNegativeInteger encoding of the number. This is a static method. A nonNegativeInteger is always encoded as 1, 2, 4 or 8 bytes.
| [C++]: | static Component fromNumberWithMarker(
    uint64_t number,
    uint8_t marker
);
 | 
|---|---|
| [Python]: | # Returns Name.Component
@staticmethod
def fromNumberWithMarker(
    number,  # int
    marker   # int
)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.fromNumberWithMarker = function(
    number,  // number
    marker   // number
)
 | 
| [Java]: | public static Component fromNumberWithMarker(
    long number,
    int marker
)
 | 
| Parameters: | 
 | 
| Returns: | The new component. | 
Name.Component.fromSegment Method¶
Create a component with the encoded segment number according to NDN naming conventions for “Segment number” (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | static Component fromSegment(
    uint64_t segment
);
 | 
|---|---|
| [Python]: | # Returns Name.Component
@staticmethod
def fromSegment(
    segment  # int
)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.fromSegment = function(
    segment  // number
)
 | 
| [Java]: | public static Component fromSegment(
    long segment
)
 | 
| Parameters: | 
 | 
| Returns: | The new component. | 
Name.Component.fromSegmentOffset Method¶
Create a component with the encoded segment byte offset according to NDN naming conventions for segment “Byte offset” (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | static Component fromSegmentOffset(
    uint64_t segmentOffset
);
 | 
|---|---|
| [Python]: | # Returns Name.Component
@staticmethod
def fromSegmentOffset(
    segmentOffset  # int
)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.fromSegmentOffset = function(
    segmentOffset  // number
)
 | 
| [Java]: | public static Component fromSegmentOffset(
    long segmentOffset
)
 | 
| Parameters: | 
 | 
| Returns: | The new component. | 
Name.Component.fromSequenceNumber Method¶
Create a component with the encoded sequence number according to NDN naming conventions for “Sequencing” (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | static Component fromSequenceNumber(
    uint64_t segmentOffset
);
 | 
|---|---|
| [Python]: | # Returns Name.Component
@staticmethod
def fromSequenceNumber(
    segmentOffset  # int
)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.fromSequenceNumber = function(
    segmentOffset  // number
)
 | 
| [Java]: | public static Component fromSequenceNumber(
    long segmentOffset
)
 | 
| Parameters: | 
 | 
| Returns: | The new component. | 
Name.Component.fromTimestamp Method¶
Create a component with the encoded timestamp according to NDN naming conventions for “Timestamp” (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | static Component fromTimestamp(
    uint64_t timestamp
);
 | 
|---|---|
| [Python]: | # Returns Name.Component
@staticmethod
def fromTimestamp(
    timestamp  # int
)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.fromTimestamp = function(
    timestamp  // number
)
 | 
| [Java]: | public static Component fromTimestamp(
    long timestamp
)
 | 
| Parameters: | 
 | 
| Returns: | The new component. | 
Name.Component.fromVersion Method¶
Create a component with the encoded version number according to NDN naming conventions for “Versioning” (marker 0xFD). Note that this encodes the exact value of version without converting from a time representation. http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | static Component fromVersion(
    uint64_t version
);
 | 
|---|---|
| [Python]: | # Returns Name.Component
@staticmethod
def fromVersion(
    version  # int
)
 | 
| [JavaScript]: | // Returns Name.Component
Name.Component.fromVersion = function(
    version  // number
)
 | 
| [Java]: | public static Component fromVersion(
    long version
)
 | 
| Parameters: | 
 | 
| Returns: | The new component. | 
Name.Component Is Naming Convention Value Methods¶
Name.Component.isSegment Method¶
Check if this name component is a segment number according to NDN naming conventions for “Segment number” (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | bool isSegment() const;
 | 
|---|---|
| [Python]: | # Returns bool
def isSegment(self)
 | 
| [JavaScript]: | // Returns boolean
Name.Component.prototype.isSegment = function()
 | 
| [Java]: | public final boolean isSegment()
 | 
| Returns: | True if this is a segment number. | 
Name.Component.isSegmentOffset Method¶
Check if this name component is a segment byte offset according to NDN naming conventions for segment “Byte offset” (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | bool isSegmentOffset() const;
 | 
|---|---|
| [Python]: | # Returns bool
def isSegmentOffset(self)
 | 
| [JavaScript]: | // Returns boolean
Name.Component.prototype.isSegmentOffset = function()
 | 
| [Java]: | public final boolean isSegmentOffset()
 | 
| Returns: | True if this is a segment byte offset. | 
Name.Component.isSequenceNumber Method¶
Check if this name component is a sequence number according to NDN naming conventions for “Sequencing” (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | bool isSequenceNumber() const;
 | 
|---|---|
| [Python]: | # Returns bool
def isSequenceNumber(self)
 | 
| [JavaScript]: | // Returns boolean
Name.Component.prototype.isSequenceNumber = function()
 | 
| [Java]: | public final boolean isSequenceNumber()
 | 
| Returns: | True if this is a sequence number. | 
Name.Component.isTimestamp Method¶
Check if this name component is a timestamp according to NDN naming conventions for “Timestamp” (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | bool isTimestamp() const;
 | 
|---|---|
| [Python]: | # Returns bool
def isTimestamp(self)
 | 
| [JavaScript]: | // Returns boolean
Name.Component.prototype.isTimestamp = function()
 | 
| [Java]: | public final boolean isTimestamp()
 | 
| Returns: | True if this is a timestamp. | 
Name.Component.isVersion Method¶
Check if this name component is a version number according to NDN naming conventions for “Versioning” (marker 0xFD). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | bool isVersion() const;
 | 
|---|---|
| [Python]: | # Returns bool
def isVersion(self)
 | 
| [JavaScript]: | // Returns boolean
Name.Component.prototype.isVersion = function()
 | 
| [Java]: | public final boolean isVersion()
 | 
| Returns: | True if this is a version number. | 
Name.Component To Naming Convention Value Methods¶
Name.Component.toNumber Method¶
Interpret this name component as a network-ordered number and return an integer.
| [C++]: | uint64_t toNumber() const;
 | 
|---|---|
| [Python]: | # Returns int
def toNumber(self)
 | 
| [JavaScript]: | // Returns number
Name.Component.prototype.toNumber = function()
 | 
| [Java]: | public final long toNumber()
 | 
| Returns: | The integer number. | 
Name.Component.toNumberWithMarker Method¶
Interpret this name component as a network-ordered number with a marker and return an integer.
| [C++]: | uint64_t toNumberWithMarker(
    uint8_t marker
) const;
 | 
|---|---|
| [Python]: | # Returns int
def toNumberWithMarker(self,
    marker  # int
)
 | 
| [JavaScript]: | // Returns number
Name.Component.prototype.toNumberWithMarker = function(
    marker  // number
)
 | 
| [Java]: | public final long toNumberWithMarker(
    int marker
)
 | 
| Parameters: | 
 | 
| Returns: | The integer number. | 
| Throw: | Throw an exception if the first byte of the component does not equal the marker. | 
Name.Component.toSegment Method¶
Interpret this name component as a segment number according to NDN naming conventions for “Segment number” (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | uint64_t toSegment() const;
 | 
|---|---|
| [Python]: | # Returns int
def toSegment(self)
 | 
| [JavaScript]: | // Returns number
Name.Component.prototype.toSegment = function()
 | 
| [Java]: | public final long toSegment()
 | 
| Returns: | The integer segment number. | 
| Throw: | Throw an exception if the first byte of the component is not the expected marker. | 
Name.Component.toSegmentOffset Method¶
Interpret this name component as a segment byte offset according to NDN naming conventions for segment “Byte offset” (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | uint64_t toSegmentOffset() const;
 | 
|---|---|
| [Python]: | # Returns int
def toSegmentOffset(self)
 | 
| [JavaScript]: | // Returns number
Name.Component.prototype.toSegmentOffset = function()
 | 
| [Java]: | public final long toSegmentOffset()
 | 
| Returns: | The integer segment byte offset. | 
| Throw: | Throw an exception if the first byte of the component is not the expected marker. | 
Name.Component.toSequenceNumber Method¶
Interpret this name component as a sequence number according to NDN naming conventions for “Sequencing” (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | uint64_t toSequenceNumber() const;
 | 
|---|---|
| [Python]: | # Returns int
def toSequenceNumber(self)
 | 
| [JavaScript]: | // Returns number
Name.Component.prototype.toSequenceNumber = function()
 | 
| [Java]: | public final long toSequenceNumber()
 | 
| Returns: | The integer sequence number. | 
| Throw: | Throw an exception if the first byte of the component is not the expected marker. | 
Name.Component.toTimestamp Method¶
Interpret this name component as a timestamp according to NDN naming conventions for “Timestamp” (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | uint64_t toTimestamp() const;
 | 
|---|---|
| [Python]: | # Returns int
def toTimestamp(self)
 | 
| [JavaScript]: | // Returns number
Name.Component.prototype.toTimestamp = function()
 | 
| [Java]: | public final long toTimestamp()
 | 
| Returns: | The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds. | 
| Throw: | Throw an exception if the first byte of the component is not the expected marker. | 
Name.Component.toVersion Method¶
Interpret this name component as a version number according to NDN naming conventions for “Versioning” (marker 0xFD). Note that this returns the exact number from the component without converting it to a time representation. http://named-data.net/doc/tech-memos/naming-conventions.pdf
| [C++]: | uint64_t toVersion() const;
 | 
|---|---|
| [Python]: | # Returns int
def toVersion(self)
 | 
| [JavaScript]: | // Returns number
Name.Component.prototype.toVersion = function()
 | 
| [Java]: | public final long toVersion()
 | 
| Returns: | The integer version number. | 
| Throw: | Throw an exception if the first byte of the component is not the expected marker. | 
