public ConfigHyperRelationChecker(String packetNameRegexString,
                                   String packetNameExpansion, String keyNameRegexString,
                                   String keyNameExpansion, ConfigNameRelation.Relation hyperRelation)
 {
     packetNameRegex_     = new NdnRegexTopMatcher(packetNameRegexString);
     packetNameExpansion_ = packetNameExpansion;
     keyNameRegex_        = new NdnRegexTopMatcher(keyNameRegexString);
     keyNameExpansion_    = keyNameExpansion;
     hyperRelation_       = hyperRelation;
 }
Beispiel #2
0
        public void testTopMatcher()
        {
            NdnRegexTopMatcher cm = new NdnRegexTopMatcher("^<a><b><c>");
            bool res = cm.match(new Name("/a/b/c/d"));

            Assert.AssertEquals(true, res);
            Assert.AssertEquals(4, cm.getMatchResult().Count);
            Assert.AssertEquals("a", cm.getMatchResult()[0].toEscapedString());
            Assert.AssertEquals("b", cm.getMatchResult()[1].toEscapedString());
            Assert.AssertEquals("c", cm.getMatchResult()[2].toEscapedString());
            Assert.AssertEquals("d", cm.getMatchResult()[3].toEscapedString());

            cm  = new NdnRegexTopMatcher("<b><c><d>$");
            res = cm.match(new Name("/a/b/c/d"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(4, cm.getMatchResult().Count);
            Assert.AssertEquals("a", cm.getMatchResult()[0].toEscapedString());
            Assert.AssertEquals("b", cm.getMatchResult()[1].toEscapedString());
            Assert.AssertEquals("c", cm.getMatchResult()[2].toEscapedString());
            Assert.AssertEquals("d", cm.getMatchResult()[3].toEscapedString());

            cm  = new NdnRegexTopMatcher("^<a><b><c><d>$");
            res = cm.match(new Name("/a/b/c/d"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(4, cm.getMatchResult().Count);
            Assert.AssertEquals("a", cm.getMatchResult()[0].toEscapedString());
            Assert.AssertEquals("b", cm.getMatchResult()[1].toEscapedString());
            Assert.AssertEquals("c", cm.getMatchResult()[2].toEscapedString());
            Assert.AssertEquals("d", cm.getMatchResult()[3].toEscapedString());

            res = cm.match(new Name("/a/b/c/d/e"));
            Assert.AssertEquals(false, res);
            Assert.AssertEquals(0, cm.getMatchResult().Count);

            cm  = new NdnRegexTopMatcher("<a><b><c><d>");
            res = cm.match(new Name("/a/b/c/d"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(4, cm.getMatchResult().Count);
            Assert.AssertEquals("a", cm.getMatchResult()[0].toEscapedString());
            Assert.AssertEquals("b", cm.getMatchResult()[1].toEscapedString());
            Assert.AssertEquals("c", cm.getMatchResult()[2].toEscapedString());
            Assert.AssertEquals("d", cm.getMatchResult()[3].toEscapedString());

            cm  = new NdnRegexTopMatcher("<b><c>");
            res = cm.match(new Name("/a/b/c/d"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(4, cm.getMatchResult().Count);
            Assert.AssertEquals("a", cm.getMatchResult()[0].toEscapedString());
            Assert.AssertEquals("b", cm.getMatchResult()[1].toEscapedString());
            Assert.AssertEquals("c", cm.getMatchResult()[2].toEscapedString());
            Assert.AssertEquals("d", cm.getMatchResult()[3].toEscapedString());
        }
Beispiel #3
0
        public void testTopMatcherAdvanced()
        {
            NdnRegexTopMatcher cm = new NdnRegexTopMatcher("^(<.*>*)<.*>");
            bool res = cm.match(new Name("/n/a/b/c"));

            Assert.AssertEquals(true, res);
            Assert.AssertEquals(4, cm.getMatchResult().Count);
            Assert.AssertEquals(new Name("/n/a/b/"), cm.expand("\\1"));

            cm  = new NdnRegexTopMatcher("^(<.*>*)<.*><c>(<.*>)<.*>");
            res = cm.match(new Name("/n/a/b/c/d/e/"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(6, cm.getMatchResult().Count);
            Assert.AssertEquals(new Name("/n/a/d/"), cm.expand("\\1\\2"));

            cm  = new NdnRegexTopMatcher("(<.*>*)<.*>$");
            res = cm.match(new Name("/n/a/b/c/"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(4, cm.getMatchResult().Count);
            Assert.AssertEquals(new Name("/n/a/b/"), cm.expand("\\1"));

            cm  = new NdnRegexTopMatcher("<.*>(<.*>*)<.*>$");
            res = cm.match(new Name("/n/a/b/c/"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(4, cm.getMatchResult().Count);
            Assert.AssertEquals(new Name("/a/b/"), cm.expand("\\1"));

            cm  = new NdnRegexTopMatcher("<a>(<>*)<>$");
            res = cm.match(new Name("/n/a/b/c/"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(4, cm.getMatchResult().Count);
            Assert.AssertEquals(new Name("/b/"), cm.expand("\\1"));

            cm  = new NdnRegexTopMatcher("^<ndn><(.*)\\.(.*)><DNS>(<>*)<>");
            res = cm.match(new Name("/ndn/ucla.edu/DNS/yingdi/mac/ksk-1/"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(6, cm.getMatchResult().Count);
            Assert.AssertEquals(new Name("/ndn/edu/ucla/yingdi/mac/"),
                                cm.expand("<ndn>\\2\\1\\3"));

            cm = new NdnRegexTopMatcher("^<ndn><(.*)\\.(.*)><DNS>(<>*)<>",
                                        "<ndn>\\2\\1\\3");
            res = cm.match(new Name("/ndn/ucla.edu/DNS/yingdi/mac/ksk-1/"));
            Assert.AssertEquals(true, res);
            Assert.AssertEquals(6, cm.getMatchResult().Count);
            Assert.AssertEquals(new Name("/ndn/edu/ucla/yingdi/mac/"), cm.expand());
        }
Beispiel #4
0
 /// <summary>
 /// Create a ConfigRegexNameFilter from the regex string.
 /// </summary>
 ///
 /// <param name="regexString">The regex string.</param>
 internal ConfigRegexNameFilter(String regexString)
 {
     regex_ = new NdnRegexTopMatcher(regexString);
 }
 public ConfigRegexChecker(String regexString)
 {
     regex_ = new NdnRegexTopMatcher(regexString);
 }