Select Default Language Display:

  • C++
  • Python
  • JavaScript
  • Java
  • All Languages

Interest Class

The Interest class represents an NDN Interest packet.

[C++]:
#include <ndn-cpp/interest.hpp>
Namespace: ndn
[Python]:Module: pyndn
[Java]:Package: net.named_data.jndn

Note

You don’t have to set the interest nonce. A nonce is automatically generated when the interest is wire encoded.

Interest Constructors

Interest Constructor (optional Name)

Create a new Interest with the optional name.

[C++]:
Interest(
    [const Name& name]
);
[Python]:
def __init__(self
    [, name  # Name]
)
[JavaScript]:
var Interest = function Interest (
    [name  // Name]
)
[Java]:
public Interest(
    [Name name]
)
Parameters:
  • name

    (optional) The name for the interest which is copied. If omitted, use a blank name.

Interest Constructor (copy)

Create a new Interest as a deep copy of the given interest.

[C++]:
Interest(
    const Interest& interest
);
[Python]:
def __init__(self,
    interest  # Interest
)
[JavaScript]:
var Interest = function Interest(
    interest  // Interest
)
[Java]:
public Interest(
    Interest interest
)
Parameters:
  • interest

    The Interest to copy.

Interest Get Methods

Interest.getChildSelector Method

Get the child selector.

[C++]:
int getChildSelector() const;
[Python]:
# Returns int
def getChildSelector(self)
[JavaScript]:
// Returns number
Interest.prototype.getChildSelector = function()
[Java]:
public final int getChildSelector()
Returns:

The child selector. If not specified, return -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Interest.getExclude Method

Get the interest Exclude object.

[C++]:
Exclude& getExclude();

const Exclude& getExclude() const;
[Python]:
# Returns Exclude
def getExclude(self)
[JavaScript]:
// Returns Exclude
Interest.prototype.getExclude = function()
[Java]:
public final Exclude getExclude()
Returns:

The Exclude object. If not specified, the exclude size() is 0.

Interest.getIncomingFaceId Method

Get the incoming face ID according to the incoming packet header (if the forwarder is configured to include it in the header).

[C++]:
uint64_t getIncomingFaceId() const;
[Python]:
# Returns int
def getIncomingFaceId(self)
[JavaScript]:
// Returns number
Interest.prototype.getIncomingFaceId = function()
[Java]:
public final long getIncomingFaceId()
Returns:

The incoming face ID. If not specified, return (uint64_t)-1 (C++) or None (Python) or undefined (JavaScript) or -1 (Java).

Interest.getInterestLifetimeMilliseconds Method

Get the interest lifetime.

[C++]:
Milliseconds getInterestLifetimeMilliseconds() const;
[Python]:
# Returns float
def getInterestLifetimeMilliseconds(self)
[JavaScript]:
// Returns number
Interest.prototype.getInterestLifetimeMilliseconds = function()
[Java]:
public final double getInterestLifetimeMilliseconds()
Returns:

The interest lifetime in milliseconds. If not specified, return -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Interest.getKeyLocator Method

Get the interest KeyLocator object.

[C++]:
KeyLocator& getKeyLocator();

const KeyLocator& getKeyLocator() const;
[Python]:
# Returns KeyLocator
def getKeyLocator(self)
[JavaScript]:
// Returns KeyLocator
Interest.prototype.getKeyLocator = function()
[Java]:
public final KeyLocator getKeyLocator()
Returns:

The KeyLocator object. If not specified, the key locator getType() is not specified.

Interest.getLinkWireEncoding Method

Get the wire encoding of the link object. If there is already a wire encoding then return it. Otherwise encode from the link object (if available).

[C++]:
Blob getLinkWireEncoding() const;
[Python]:
# Returns Blob
def getLinkWireEncoding(self)
[JavaScript]:
// Returns Blob
Interest.prototype.getLinkWireEncoding = function()
[Java]:
public final Blob getLinkWireEncoding()
Returns:

The wire encoding, or an isNull Blob if the link is not specified.

Throw:

Throw an exception for error encoding the link object.

Interest.getMaxSuffixComponents Method

Get the max suffix components count.

Note

The suffix components count includes the implicit digest component of the full name in the data packet. For example, if the interest name is the prefix /a/b and the data packet name is /a/b/c, then the data packet name has 2 suffix components: “c” and the implicit digest which is not shown.

[C++]:
int getMaxSuffixComponents() const;
[Python]:
# Returns int
def getMaxSuffixComponents(self)
[JavaScript]:
// Returns number
Interest.prototype.getMaxSuffixComponents = function()
[Java]:
public final int getMaxSuffixComponents()
Returns:

The max suffix components count. If not specified, return -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Interest.getMinSuffixComponents Method

Get the min suffix components count.

Note

The suffix components count includes the implicit digest component of the full name in the data packet. For example, if the interest name is the prefix /a/b and the data packet name is /a/b/c, then the data packet name has 2 suffix components: “c” and the implicit digest which is not shown.

[C++]:
int getMinSuffixComponents() const;
[Python]:
# Returns int
def getMinSuffixComponents(self)
[JavaScript]:
// Returns number
Interest.prototype.getMinSuffixComponents = function()
[Java]:
public final int getMinSuffixComponents()
Returns:

The min suffix components count. If not specified, return -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Interest.getMustBeFresh Method

Get the MustBeFresh flag.

[C++]:
bool getMustBeFresh() const;
[Python]:
# Returns bool
def getMustBeFresh(self)
[JavaScript]:
// Returns boolean
Interest.prototype.getMustBeFresh = function()
[Java]:
public final boolean getMustBeFresh()
Returns:

True if must be fresh, otherwise false. If not specified, the default is true.

Interest.getName Method

Get the interest name.

[C++]:
Name& getName();

const Name& getName() const;
[Python]:
# Returns Name
def getName(self)
[JavaScript]:
// Returns Name
Interest.prototype.getName = function()
[Java]:
public final Name getName()
Returns:

The name. If not specified, the name size() is 0.

Interest.getNonce Method

Get the nonce value from the incoming interest. If you change any of the fields in this Interest object, then the nonce value is cleared.

Note

When you create an interest, you don’t have to set the nonce. A nonce is automatically generated when the interest is wire encoded.

[C++]:
const Blob& getNonce() const;
[Python]:
# Returns Blob
def getNonce(self)
[JavaScript]:
// Returns Blob
Interest.prototype.getNonce = function()
[Java]:
public final Blob getNonce()
Returns:

The nonce. If not specified, the value isNull().

Interest.getSelectedDelegationIndex Method

Get the selected delegation index.

[C++]:
int getSelectedDelegationIndex() const;
[Python]:
# Returns int
def getSelectedDelegationIndex(self)
[JavaScript]:
// Returns number
Interest.prototype.getSelectedDelegationIndex = function()
[Java]:
public final int getSelectedDelegationIndex()
Returns:

The selected delegation index. If not specified, return -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Interest Set Methods

Interest.setChildSelector Method

Set the child selector.

[C++]:
Interest& setChildSelector(
    int childSelector
);
[Python]:
# Returns Interest
def setChildSelector(self,
    childSelector  # int
)
[JavaScript]:
// Returns Interest
Interest.prototype.setChildSelector = function(
    childSelector  // number
)
[Java]:
public final Interest setChildSelector(
    int childSelector
)
Parameters:
  • childSelector

    The child selector. If not specified, set to -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Returns:

This Interest so that you can chain calls to update values.

Interest.setExclude Method

Set this interest to use a copy of the given Exclude object.

Note

You can also call getExclude and change the exclude entries directly.

[C++]:
Interest& setExclude(
    const Exclude& exclude
);
[Python]:
# Returns Interest
def setExclude(self,
    exclude  # Exclude
)
[JavaScript]:
// Returns Interest
Interest.prototype.setExclude = function(
    exclude  // Exclude
)
[Java]:
public final Interest setExclude(
    Exclude exclude
)
Parameters:
  • exclude

    The Exclude object. This makes a copy of the object. If no exclude is specified, set to a new default Exclude(), or to an Exclude with size() 0.

Returns:

This Interest so that you can chain calls to update values.

Interest.setInterestLifetimeMilliseconds Method

Set the interest lifetime.

[C++]:
Interest& setInterestLifetimeMilliseconds(
    Milliseconds interestLifetimeMilliseconds
);
[Python]:
# Returns Interest
def setInterestLifetimeMilliseconds(self,
    interestLifetimeMilliseconds  # float
)
[JavaScript]:
// Returns Interest
Interest.prototype.setInterestLifetimeMilliseconds = function(
    interestLifetimeMilliseconds  // number
)
[Java]:
public final Interest setInterestLifetimeMilliseconds(
    double interestLifetimeMilliseconds
)
Parameters:
  • interestLifetimeMilliseconds

    The interest lifetime in milliseconds. If not specified, set to -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Returns:

This Interest so that you can chain calls to update values.

Interest.setKeyLocator Method

Set this interest to use a copy of the given KeyLocator object.

Note

You can also call getKeyLocator and change the key locator directly.

[C++]:
Interest& setKeyLocator(
    const KeyLocator& keyLocator
);
[Python]:
# Returns Interest
def setKeyLocator(self,
    keyLocator  # KeyLocator
)
[JavaScript]:
// Returns Interest
Interest.prototype.setKeyLocator = function(
    keyLocator  // KeyLocator
)
[Java]:
public final Interest setKeyLocator(
    KeyLocator keyLocator
)
Parameters:
  • keyLocator

    The KeyLocator object. This makes a copy of the object. If no key locator is specified, set to a new default KeyLocator(), or to a KeyLocator with an unspecified type.

Returns:

This Interest so that you can chain calls to update values.

Interest.setLinkWireEncoding Method

Set the link wire encoding bytes, without decoding them. If there is a link object, remove it. If you later call getLink(), it will decode the wireEncoding to create the link object.

[C++]:
Interest& setLinkWireEncoding(
    Blob encoding
);
[Python]:
# Returns Interest
def setLinkWireEncoding(self,
    encoding  # Blob
)
[JavaScript]:
// Returns Interest
Interest.prototype.setLinkWireEncoding = function(
    encoding  // Blob
)
[Java]:
public final Interest setLinkWireEncoding(
    Blob encoding
)
Parameters:
  • encoding

    The blob with the bytes of the link wire encoding. If no link is specified, set to an empty Blob() or call unsetLink.

Returns:

This Interest so that you can chain calls to update values.

Interest.setMustBeFresh Method

Set the MustBeFresh flag.

[C++]:
Interest& setMustBeFresh(
    bool mustBeFresh
);
[Python]:
# Returns Interest
def setMustBeFresh(self,
    mustBeFresh  # bool
)
[JavaScript]:
// Returns Interest
Interest.prototype.setMustBeFresh = function(
    mustBeFresh  // boolean
)
[Java]:
public final Interest setMustBeFresh(
    boolean mustBeFresh
)
Parameters:
  • mustBeFresh

    True if the content must be fresh, otherwise false. If you do not set this flag, the default value is true.

Returns:

This Interest so that you can chain calls to update values.

Interest.setMaxSuffixComponents Method

Set the max suffix components count.

Note

The suffix components count includes the implicit digest component of the full name in the data packet. For example, if the interest name is the prefix /a/b and the data packet name is /a/b/c, then the data packet name has 2 suffix components: “c” and the implicit digest which is not shown.

[C++]:
Interest& setMaxSuffixComponents(
    int maxSuffixComponents
);
[Python]:
# Returns Interest
def setMaxSuffixComponents(self,
    maxSuffixComponents  # int
)
[JavaScript]:
// Returns Interest
Interest.prototype.setMaxSuffixComponents = function(
    maxSuffixComponents  // number
)
[Java]:
public final Interest setMaxSuffixComponents(
    int maxSuffixComponents
)
Parameters:
  • maxSuffixComponents

    The max suffix components count. If not specified, set to -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Returns:

This Interest so that you can chain calls to update values.

Interest.setMinSuffixComponents Method

Set the min suffix components count.

Note

The suffix components count includes the implicit digest component of the full name in the data packet. For example, if the interest name is the prefix /a/b and the data packet name is /a/b/c, then the data packet name has 2 suffix components: “c” and the implicit digest which is not shown.

[C++]:
Interest& setMinSuffixComponents(
    int minSuffixComponents
);
[Python]:
# Returns Interest
def setMinSuffixComponents(self,
    minSuffixComponents  # int
)
[JavaScript]:
// Returns Interest
Interest.prototype.setMinSuffixComponents = function(
    minSuffixComponents  // number
)
[Java]:
public final Interest setMinSuffixComponents(
    int minSuffixComponents
)
Parameters:
  • minSuffixComponents

    The min suffix components count. If not specified, set to -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Returns:

This Interest so that you can chain calls to update values.

Interest.setName Method

Set the interest name.

Note

You can also call getName and change the name values directly.

[C++]:
Interest& setName(
    const Name& name
);
[Python]:
# Returns Interest
def setName(self,
    name  # Name
)
[JavaScript]:
// Returns Interest
Interest.prototype.setName = function(
    name  // Name
)
[Java]:
public final Interest setName(
    Name name
)
Parameters:
  • name

    The interest name. This makes a copy of the name.

Returns:

This Interest so that you can chain calls to update values.

Interest.setSelectedDelegationIndex Method

Set the selected delegation index.

[C++]:
Interest& setSelectedDelegationIndex(
    int selectedDelegationIndex
);
[Python]:
# Returns Interest
def setSelectedDelegationIndex(self,
    selectedDelegationIndex  # int
)
[JavaScript]:
// Returns Interest
Interest.prototype.setSelectedDelegationIndex = function(
    selectedDelegationIndex  // number
)
[Java]:
public final Interest setSelectedDelegationIndex(
    int selectedDelegationIndex
)
Parameters:
  • selectedDelegationIndex

    The selected delegation index. If not specified, set to -1 (C++ and Java) or None (Python) or undefined (JavaScript).

Returns:

This Interest so that you can chain calls to update values.

Interest.matchesData Method

Check if the given Data packet can satisfy this Interest. This method considers the Name, MinSuffixComponents, MaxSuffixComponents, PublisherPublicKeyLocator, and Exclude. It does not consider the ChildSelector or MustBeFresh.

[C++]:
bool matchesData(
    const Data& data
) const;
[Python]:
# Returns True or False
def matchesData(self,
    data  # Data
)
[JavaScript]:
// Returns boolean
Interest.prototype.matchesData = function(
    data  // Data
)
[Java]:
public final boolean matchesData(
    Data data
)
Parameters:
  • data

    The Data packet to check.

Returns:

True if the given Data packet can satisfy this Interest.

Interest.matchesName Method

Return true if the components of this Interest’s name are the same as the leading components of the given name, and the name conforms to the interest selectors.

[C++]:
bool matchesName(
    const Name& name
) const;
[Python]:
# Returns True or False
def matchesName(self,
    name  # Name
)
[JavaScript]:
// Returns boolean
Interest.prototype.matchesName = function(
    name  // Name
)
[Java]:
public final boolean matchesName(
    Name name
)
Parameters:
  • name

    The Name to check against this Interest.

Returns:

True if this interest’s name and interest selectors match the name.

Interest.refreshNonce Method

Update the bytes of the nonce with new random values. This ensures that the new nonce value is different than the current one. If the current nonce is not specified, this does nothing.

[C++]:
void refreshNonce();
[Python]:
def refreshNonce(self)
[JavaScript]:
Interest.prototype.refreshNonce = function()
[Java]:
public final void refreshNonce()

Interest.toUri Method

Experimental

This method is experimental. The NDN specifications don’t officially define how to add interest selectors to a URI.

Encode the name according to the “NDN URI Scheme”. If there are interest selectors, append ”?” and add the selectors as a query string. For example “/test/name?ndn.ChildSelector=1”.

[C++]:
std::string toUri() const;
[Python]:
# Returns str
def toUri(self)
[JavaScript]:
// Returns string
Interest.prototype.toUri = function()
[Java]:
public final String toUri()
Returns:

The URI string.

Interest.wireDecode Methods

Interest.wireDecode Method (from Blob)

Decode the input from wire format and update this Interest. Also keep a pointer to the immutable input Blob for later use.

[C++]:
void wireDecode(
    const Blob& input
);
[Python]:
def wireDecode(self,
    input  # Blob
)
[JavaScript]:
Interest.prototype.wireDecode = function(
    input  // Blob
)
[Java]:
public final void wireDecode(
    Blob content
)
Parameters:
  • input

    The immutable input byte array to be decoded.

Interest.wireDecode Method (copy from byte array)

Decode the input from wire format and update this Interest.

[C++]:
void wireDecode(
    const std::vector<uint8_t>& input
);

void wireDecode(
    const uint8_t *input,
    size_t inputLength
);
[Python]:
def wireDecode(self,
    input  # an array type with int elements
)
[JavaScript]:
Interest.prototype.wireDecode = function(
    input  // Buffer
)
[Java]:
public final void wireDecode(
    ByteBuffer input
)
Parameters:
  • input

    The input byte array to be decoded.

Interest.wireEncode Method

Encode this Interest to a wire format.

[C++]:
SignedBlob wireEncode() const;
[Python]:
# Returns SignedBlob
def wireEncode()
[JavaScript]:
// Returns SignedBlob
Interest.prototype.wireEncode = function()
[Java]:
public final SignedBlob wireEncode()
Returns:

The encoded byte array as a SignedBlob.