Exemplo n.º 1
0
        /// <summary>
        /// Encode this Interest for a particular wire format. If wireFormat is the
        /// default wire format, also set the defaultWireEncoding field to the encoded
        /// result.
        /// </summary>
        ///
        /// <param name="wireFormat">A WireFormat object used to encode this Interest.</param>
        /// <returns>The encoded buffer.</returns>
        public SignedBlob wireEncode(WireFormat wireFormat)
        {
            if (!getDefaultWireEncoding().isNull() &&
                getDefaultWireEncodingFormat() == wireFormat)
            {
                // We already have an encoding in the desired format.
                return(getDefaultWireEncoding());
            }

            int[] signedPortionBeginOffset = new int[1];
            int[] signedPortionEndOffset   = new int[1];
            Blob  encoding = wireFormat.encodeInterest(this,
                                                       signedPortionBeginOffset, signedPortionEndOffset);
            SignedBlob wireEncoding = new SignedBlob(encoding,
                                                     signedPortionBeginOffset[0], signedPortionEndOffset[0]);

            if (wireFormat == net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat())
            {
                // This is the default wire encoding.
                setDefaultWireEncoding(wireEncoding,
                                       net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
            }

            return(wireEncoding);
        }