new Data(name, metaInfo, content)
Create a new Data with the optional values. There are 2 forms of constructor:
new Data([name] [, content]);
new Data(name, metaInfo [, content]);
Parameters:
Name | Type | Description |
---|---|---|
name |
Name | |
metaInfo |
MetaInfo | |
content |
Buffer |
Methods
getChangeCount() → {number}
Get the change count, which is incremented each time this object (or a child
object) is changed.
Returns:
The change count.
- Type
- number
getCongestionMark() → {number}
Get the congestion mark according to the incoming packet header.
Returns:
The congestion mark. If not specified, return 0.
- Type
- number
getContent() → {Blob}
Get the data packet's content.
Returns:
The content as a Blob, which isNull() if unspecified.
- Type
- Blob
getContentAsBuffer()
- Deprecated:
- Use getContent. This method returns a Buffer which is the former behavior of getContent, and should only be used while updating your code.
- Source:
getDefaultWireEncoding() → {SignedBlob}
Return the default wire encoding, which was encoded with
getDefaultWireEncodingFormat().
Returns:
The default wire encoding, whose isNull() may be true
if there is no default wire encoding.
- Type
- SignedBlob
getDefaultWireEncodingFormat() → {WireFormat}
Get the WireFormat which is used by getDefaultWireEncoding().
Returns:
The WireFormat, which is only meaningful if the
getDefaultWireEncoding() is not isNull().
- Type
- WireFormat
getFullName(wireFormat) → {Name}
Get the Data packet's full name, which includes the final
ImplicitSha256Digest component based on the wire encoding for a particular
wire format.
Parameters:
Name | Type | Description |
---|---|---|
wireFormat |
WireFormat | (optional) A WireFormat object used to encode this object. If omitted, use WireFormat.getDefaultWireFormat(). |
Returns:
The full name. You must not change the Name object - if you
need to change it then make a copy.
- Type
- Name
getIncomingFaceId() → {number}
Get the incoming face ID according to the incoming packet header.
Returns:
The incoming face ID. If not specified, return null.
- Type
- number
getMetaInfo() → {MetaInfo}
Get the data packet's meta info.
Returns:
The meta info.
- Type
- MetaInfo
getName() → {Name}
Get the data packet's name.
Returns:
The name. If not specified, the name size() is 0.
- Type
- Name
getSignature() → {Signature}
Get the data packet's signature object.
Returns:
The signature object.
- Type
- Signature
setContent(content) → {Data}
Set the content to the given value.
Parameters:
Name | Type | Description |
---|---|---|
content |
Blob | Buffer | The content bytes. If content is not a Blob, then create a new Blob to copy the bytes (otherwise take another pointer to the same Blob). |
Returns:
This Data so that you can chain calls to update values.
- Type
- Data
setLpPacket(lpPacket) → {Data}
An internal library method to set the LpPacket for an incoming packet. The
application should not call this.
Parameters:
Name | Type | Description |
---|---|---|
lpPacket |
LpPacket | The LpPacket. This does not make a copy. |
Returns:
This Data so that you can chain calls to update values.
- Type
- Data
setMetaInfo(metaInfo) → {Data}
Set metaInfo to a copy of the given MetaInfo.
Parameters:
Name | Type | Description |
---|---|---|
metaInfo |
MetaInfo | The MetaInfo which is copied. |
Returns:
This Data so that you can chain calls to update values.
- Type
- Data
setName(name) → {Data}
Set name to a copy of the given Name.
Parameters:
Name | Type | Description |
---|---|---|
name |
Name | The Name which is copied. |
Returns:
This Data so that you can chain calls to update values.
- Type
- Data
setSignature(signature) → {Data}
Set the signature to a copy of the given signature.
Parameters:
Name | Type | Description |
---|---|---|
signature |
Signature | The signature object which is cloned. |
Returns:
This Data so that you can chain calls to update values.
- Type
- Data
wireDecode(input, wireFormat)
Decode the input using a particular wire format and update this Data. If
wireFormat is the default wire format, also set the defaultWireEncoding to
another pointer to the input.
Parameters:
Name | Type | Description |
---|---|---|
input |
Blob | Buffer | The buffer with the bytes to decode. |
wireFormat |
WireFormat | (optional) A WireFormat object used to decode this object. If omitted, use WireFormat.getDefaultWireFormat(). |
wireEncode(wireFormat) → {SignedBlob}
Encode this Data for a particular wire format. If wireFormat is the default
wire format, also set the defaultWireEncoding field to the encoded result.
Parameters:
Name | Type | Description |
---|---|---|
wireFormat |
WireFormat | (optional) A WireFormat object used to encode this object. If omitted, use WireFormat.getDefaultWireFormat(). |
Returns:
The encoded buffer in a SignedBlob object.
- Type
- SignedBlob