Ejemplo n.º 1
0
        /// <summary>
        /// Set the Exclude object from the list of ExcludeEntry.
        /// </summary>
        ///
        /// <param name="exclude">The Exclude object to update.</param>
        /// <param name="entries">The list of ExcludeEntry.</param>
        private static void setExcludeEntries(Exclude exclude, ArrayList entries)
        {
            exclude.clear();

            for (int i = 0; i < entries.Count; ++i) {
                Producer.ExcludeEntry  entry = (Producer.ExcludeEntry ) entries[i];

                if (i == 0 && entry.component_.getValue().size() == 0
                        && entry.anyFollowsComponent_)
                    // This is a "beginning ANY".
                    exclude.appendAny();
                else {
                    exclude.appendComponent(entry.component_);
                    if (entry.anyFollowsComponent_)
                        exclude.appendAny();
                }
            }
        }
Ejemplo n.º 2
0
        private static void decodeExclude(Exclude exclude, TlvDecoder decoder,
				bool copy)
        {
            int endOffset = decoder.readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.Exclude);

            exclude.clear();
            while (decoder.getOffset() < endOffset) {
                if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Any, endOffset)) {
                    // Read past the Any TLV.
                    decoder.readBooleanTlv(net.named_data.jndn.encoding.tlv.Tlv.Any, endOffset);
                    exclude.appendAny();
                } else
                    exclude.appendComponent(decodeNameComponent(decoder, copy));
            }

            decoder.finishNestedTlvs(endOffset);
        }
Ejemplo n.º 3
0
        public void testExcludeMatches()
        {
            Exclude exclude = new Exclude();
            exclude.appendComponent(new Name("%00%02").get(0));
            exclude.appendAny();
            exclude.appendComponent(new Name("%00%20").get(0));

            Name.Component component;
            component = new Name("%00%01").get(0);
            Assert.AssertFalse(component.toEscapedString() + " should not match "
                    + exclude.toUri(), exclude.matches(component));
            component = new Name("%00%0F").get(0);
            Assert.AssertTrue(
                    component.toEscapedString() + " should match "
                            + exclude.toUri(), exclude.matches(component));
            component = new Name("%00%21").get(0);
            Assert.AssertFalse(component.toEscapedString() + " should not match "
                    + exclude.toUri(), exclude.matches(component));
        }