List<Action> prefixMatch(ElementPath elementPath) { int max = 0; ElementSelector longestMatchingElementSelector = null; for (ElementSelector selector : rules.keySet()) { String last = selector.peekLast(); if (isKleeneStar(last)) { int r = selector.getPrefixMatchLength(elementPath); // to qualify the match length must equal p's size omitting the '*' if ((r == selector.size() - 1) && (r > max)) { max = r; longestMatchingElementSelector = selector; } } } if (longestMatchingElementSelector != null) { return rules.get(longestMatchingElementSelector); } else { return null; } }
String last = selector.peekLast(); String first = null; if(selector.size() > 1) {
List<Action> prefixMatch(ElementPath elementPath) { int max = 0; ElementSelector longestMatchingElementSelector = null; for (ElementSelector selector : rules.keySet()) { String last = selector.peekLast(); if (isKleeneStar(last)) { int r = selector.getPrefixMatchLength(elementPath); // to qualify the match length must equal p's size omitting the '*' if ((r == selector.size() - 1) && (r > max)) { max = r; longestMatchingElementSelector = selector; } } } if (longestMatchingElementSelector != null) { return rules.get(longestMatchingElementSelector); } else { return null; } }
List<Action> prefixMatch(ElementPath elementPath) { int max = 0; ElementSelector longestMatchingElementSelector = null; for (ElementSelector selector : rules.keySet()) { String last = selector.peekLast(); if (isKleeneStar(last)) { int r = selector.getPrefixMatchLength(elementPath); // to qualify the match length must equal p's size omitting the '*' if ((r == selector.size() - 1) && (r > max)) { max = r; longestMatchingElementSelector = selector; } } } if (longestMatchingElementSelector != null) { return rules.get(longestMatchingElementSelector); } else { return null; } }
List<Action> prefixMatch(ElementPath elementPath) { int max = 0; ElementSelector longestMatchingElementSelector = null; for (ElementSelector selector : rules.keySet()) { String last = selector.peekLast(); if (isKleeneStar(last)) { int r = selector.getPrefixMatchLength(elementPath); // to qualify the match length must equal p's size omitting the '*' if ((r == selector.size() - 1) && (r > max)) { max = r; longestMatchingElementSelector = selector; } } } if (longestMatchingElementSelector != null) { return rules.get(longestMatchingElementSelector); } else { return null; } }
List<Action> prefixMatch(ElementPath elementPath) { int max = 0; ElementSelector longestMatchingElementSelector = null; for (ElementSelector selector : rules.keySet()) { String last = selector.peekLast(); if (isKleeneStar(last)) { int r = selector.getPrefixMatchLength(elementPath); // to qualify the match length must equal p's size omitting the '*' if ((r == selector.size() - 1) && (r > max)) { max = r; longestMatchingElementSelector = selector; } } } if (longestMatchingElementSelector != null) { return rules.get(longestMatchingElementSelector); } else { return null; } }
List<Action> prefixMatch(ElementPath elementPath) { int max = 0; ElementSelector longestMatchingElementSelector = null; for (ElementSelector selector : rules.keySet()) { String last = selector.peekLast(); if (isKleeneStar(last)) { int r = selector.getPrefixMatchLength(elementPath); // to qualify the match length must equal p's size omitting the '*' if ((r == selector.size() - 1) && (r > max)) { max = r; longestMatchingElementSelector = selector; } } } if (longestMatchingElementSelector != null) { return rules.get(longestMatchingElementSelector); } else { return null; } }
String last = selector.peekLast(); String first = null; if(selector.size() > 1) {
String last = selector.peekLast(); String first = null; if (selector.size() > 1) {
String last = selector.peekLast(); String first = null; if(selector.size() > 1) {
String last = selector.peekLast(); String first = null; if (selector.size() > 1) {
String last = selector.peekLast(); String first = null; if (selector.size() > 1) {
@Test public void testSuffix() { ElementSelector p = new ElementSelector("a/"); assertEquals(1, p.size()); assertEquals("a", p.peekLast()); assertEquals("a", p.get(0)); }
@Test public void test1() { ElementSelector p = new ElementSelector("a"); assertEquals(1, p.size()); assertEquals("a", p.peekLast()); assertEquals("a", p.get(0)); }
@Test public void test2() { ElementSelector p = new ElementSelector("a/b"); assertEquals(2, p.size()); assertEquals("b", p.peekLast()); assertEquals("a", p.get(0)); assertEquals("b", p.get(1)); }