/// <summary>
 /// Test encoding/decoding
 /// </summary>
 ///
 /// <exception cref="EncodingException"></exception>
 public void testEncodeDecode()
 {
     ControlParameters controlParameters = new ControlParameters();
     controlParameters.setName(new Name("/test/control/parameters"));
     controlParameters.setFaceId(1);
     // encode
     Blob encoded = controlParameters.wireEncode();
     // decode
     ControlParameters decodedControlParameters = new ControlParameters();
     decodedControlParameters.wireDecode(encoded);
     // compare
     Assert.AssertEquals(controlParameters.getName().toUri(),
             decodedControlParameters.getName().toUri());
     Assert.AssertEquals(controlParameters.getFaceId(),
             decodedControlParameters.getFaceId());
     Assert.AssertEquals("decoded forwarding flags childInherit is different",
             controlParameters.getForwardingFlags().getChildInherit(),
             decodedControlParameters.getForwardingFlags().getChildInherit());
     Assert.AssertEquals("decoded forwarding flags capture is different",
             controlParameters.getForwardingFlags().getCapture(),
             decodedControlParameters.getForwardingFlags().getCapture());
 }
        private static void decodeControlParameters(
				ControlParameters controlParameters, TlvDecoder decoder,
				bool copy)
        {
            controlParameters.clear();

            int endOffset = decoder
                    .readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_ControlParameters);

            // decode name
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Name, endOffset)) {
                Name name = new Name();
                decodeName(name, new int[1], new int[1], decoder, copy);
                controlParameters.setName(name);
            }

            // decode face ID
            controlParameters.setFaceId((int) decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_FaceId, endOffset));

            // decode URI
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Uri, endOffset)) {
                // Set copy false since we just immediately get the string.
                Blob uri = new Blob(decoder.readOptionalBlobTlv(
                        net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Uri, endOffset), false);
                controlParameters.setUri("" + uri);
            }

            // decode integers
            controlParameters.setLocalControlFeature((int) decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_LocalControlFeature, endOffset));
            controlParameters.setOrigin((int) decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Origin, endOffset));
            controlParameters.setCost((int) decoder
                    .readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Cost,
                            endOffset));

            // set forwarding flags
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Flags, endOffset)) {
                ForwardingFlags flags = new ForwardingFlags();
                flags.setNfdForwardingFlags((int) decoder
                        .readNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Flags));
                controlParameters.setForwardingFlags(flags);
            }

            // decode strategy
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Strategy, endOffset)) {
                int strategyEndOffset = decoder
                        .readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_Strategy);
                decodeName(controlParameters.getStrategy(), new int[1], new int[1],
                        decoder, copy);
                decoder.finishNestedTlvs(strategyEndOffset);
            }

            // decode expiration period
            controlParameters.setExpirationPeriod(decoder
                    .readOptionalNonNegativeIntegerTlv(
                            net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_ExpirationPeriod, endOffset));

            decoder.finishNestedTlvs(endOffset);
        }