Ejemplo n.º 1
0
        /// <summary>
        /// Create a Link, copying values from the other Data object. If the content
        /// can be decoded using the default wire encoding, then update the list
        /// of delegations.
        /// </summary>
        ///
        /// <param name="data">The Data object to copy values from.</param>
        public Link(Data data)
            : base(data)
        {
            this.delegations_ = new DelegationSet();

            if (!getContent().isNull()) {
                try {
                    delegations_.wireDecode(getContent());
                    getMetaInfo().setType(net.named_data.jndn.ContentType.LINK);
                } catch (EncodingException ex) {
                    delegations_.clear();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Decode input as a sequence of NDN-TLV Delegation and set the fields of the
        /// delegationSet object. Note that the sequence of Delegation does not have an
        /// outer TLV type and length because it is intended to use the type and length
        /// of a Data packet's Content. This ignores any elements after the sequence
        /// of Delegation and before input.limit().
        /// </summary>
        ///
        /// <param name="delegationSet">The DelegationSet object whose fields are updated.</param>
        /// <param name="input"></param>
        /// <param name="copy">unchanged while the Blob values are used.</param>
        /// <exception cref="EncodingException">For invalid encoding.</exception>
        public override void decodeDelegationSet(DelegationSet delegationSet,
				ByteBuffer input, bool copy)
        {
            TlvDecoder decoder = new TlvDecoder(input);
            int endOffset = input.limit();

            delegationSet.clear();
            while (decoder.getOffset() < endOffset) {
                decoder.readTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.Link_Delegation);
                int preference = (int) decoder
                        .readNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.Link_Preference);
                Name name = new Name();
                decodeName(name, new int[1], new int[1], decoder, copy);

                // Add unsorted to preserve the order so that Interest selected delegation
                // index will work.
                delegationSet.addUnsorted(preference, name);
            }
        }