Select Default Language Display:

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

Data Class

The Data class represents an NDN Data packet.

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

Data Constructor

Create a new Data object with the optional name.

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

    (optional) The name for the data packet. If omitted, use a blank name.

Data Get Methods

Data.getContent Method

Get content of the Data packet.

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

The data packet content as a Blob.

Data.getFullName Method

Get the data packet’s full Name, which includes the final ImplicitSha256Digest.

[C++]:
ptr_lib::shared_ptr<Name> getFullName() const;
[Python]:
# Returns Name
def getFullName(self)
[JavaScript]:
// Returns Name
Data.prototype.getFullName = function()
[Java]:
public final Name getFullName()
Returns:

The full name. You must not change the Name object - if you need to change it then make a copy.

Data.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
Data.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).

Data.getMetaInfo Method

Get the data packet’s MetaInfo object.

[C++]:
MetaInfo& getMetaInfo();

const MetaInfo& getMetaInfo() const;
[Python]:
# Returns MetaInfo
def getMetaInfo(self)
[JavaScript]:
// Returns MetaInfo
Data.prototype.getMetaInfo = function()
[Java]:
public final MetaInfo getMetaInfo()
Returns:

The meta info object.

Data.getName Method

Get the data packet’s Name.

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

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

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

Data.getSignature Method

Get the data packet’s Signature object. If not null, the object is a subclass of Signature such as Sha256WithRsaSignature

[C++]:
Signature* getSignature();

const Signature* getSignature() const;
[Python]:
# Returns a subclass of Signature such as Sha256WithRsaSignature
def getSignature(self)
[JavaScript]:
// Returns a subclass of Signature such as Sha256WithRsaSignature
Data.prototype.getSignature = function()
[Java]:
public final Signature getSignature()
Returns:

The signature object. To read the fields of the object, you must check for the type of subclass of Signature (such as Sha256WithRsaSignature), and in C++ and Java you must cast to the subclass. If the signature is not specified, return null (or None in Python).

Data Set Methods

Data.setContent Method

Set the content to the given value.

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

    A Blob with the content.

Returns:

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

Data.setMetaInfo Method

Set the meta info to a copy of the given MetaInfo object.

Note

You can also call getMetaInfo and change the fields directly.

[C++]:
Data& setMetaInfo(
    const MetaInfo& metaInfo
);
[Python]:
# Returns Data
def setMetaInfo(self,
    metaInfo  # MetaInfo
)
[JavaScript]:
// Returns Data
Data.prototype.setMetaInfo = function(
    metaInfo  // MetaInfo
)
[Java]:
public final Data setMetaInfo(
    MetaInfo metaInfo
)
Parameters:
  • metaInfo

    The MetaInfo object which is copied.

Returns:

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

Data.setName Method

Set the data packet’s Name.

Note

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

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

    The data packet’s name. This makes a copy of the name.

Returns:

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

Data.setSignature Method

Set the signature to a copy of the given Signature object.

Note

You can also call getSignature and change the fields directly.

[C++]:
Data& setSignature(
    const Signature& signature
);
[Python]:
# Returns Data
def setSignature(self,
    signature  # a subclass of Signature such as Sha256WithRsaSignature
)
[JavaScript]:
// Returns Data
Data.prototype.setSignature = function(
    signature  // a subclass of Signature such as Sha256WithRsaSignature
)
[Java]:
public final Data setSignature(
    Signature signature
)
Parameters:
  • signature

    An object of a subclass of Signature such as Sha256WithRsaSignature. This calls signature.clone() to make a copy.

Returns:

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

Data.wireDecode Methods

Data.wireDecode Method (from Blob)

Decode the input from wire format and update this Data. 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]:
Data.prototype.wireDecode = function(
    input  // Blob
)
[Java]:
public final void wireDecode(
    Blob content
)
Parameters:
  • input

    The immutable input byte array to be decoded.

Data.wireDecode Method (copy from byte array)

Decode the input from wire format and update this Data. Also save a copy of the input for later use. (To not copy the input, see wireDecode(Blob).)

[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]:
Data.prototype.wireDecode = function(
    input  // Buffer
)
[Java]:
public final void wireDecode(
    ByteBuffer input
)
Parameters:
  • input

    The input byte array to be decoded.

Data.wireEncode Method

Encode this Data to wire format.

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

The encoded byte array as a SignedBlob.