@Test public void testPrefixMatch() { { ElementPath p = new ElementPath("/a/b"); ElementSelector ruleElementSelector = new ElementSelector("/x/*"); assertEquals(0, ruleElementSelector.getPrefixMatchLength(p)); } { ElementPath p = new ElementPath("/a"); ElementSelector ruleElementSelector = new ElementSelector("/x/*"); assertEquals(0, ruleElementSelector.getPrefixMatchLength(p)); } { ElementPath p = new ElementPath("/a/b"); ElementSelector ruleElementSelector = new ElementSelector("/a/*"); assertEquals(1, ruleElementSelector.getPrefixMatchLength(p)); } { ElementPath p = new ElementPath("/a/b"); ElementSelector ruleElementSelector = new ElementSelector("/A/*"); assertEquals(1, ruleElementSelector.getPrefixMatchLength(p)); } { ElementPath p = new ElementPath("/A/b"); ElementSelector ruleElementSelector = new ElementSelector("/a/*"); assertEquals(1, ruleElementSelector.getPrefixMatchLength(p)); } { ElementPath p = new ElementPath("/a/b"); ElementSelector ruleElementSelector = new ElementSelector("/a/b/*"); assertEquals(2, ruleElementSelector.getPrefixMatchLength(p)); } { ElementPath p = new ElementPath("/a/b"); ElementSelector ruleElementSelector = new ElementSelector("/*"); assertEquals(0, ruleElementSelector.getPrefixMatchLength(p)); } }
public int getPrefixMatchLength(ElementPath p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); if ((lSize == 0) || (rSize == 0)) { return 0; } int minLen = (lSize <= rSize) ? lSize : rSize; int match = 0; for (int i = 0; i < minLen; i++) { String l = this.partList.get(i); String r = p.partList.get(i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; }
ElementSelector extends ElementPath { public int getPrefixMatchLength(ElementPath p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); if ((lSize == 0) || (rSize == 0)) { return 0; } int minLen = (lSize <= rSize) ? lSize : rSize; int match = 0; for (int i = 0; i < minLen; i++) { String l = this.partList.get(i); String r = p.partList.get(i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; } }
ElementSelector extends ElementPath { public int getPrefixMatchLength(ElementPath p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); if ((lSize == 0) || (rSize == 0)) { return 0; } int minLen = (lSize <= rSize) ? lSize : rSize; int match = 0; for (int i = 0; i < minLen; i++) { String l = this.partList.get(i); String r = p.partList.get(i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; } ElementSelector();  ElementSelector(List<String> list);  ElementSelector(String p); }
ElementSelector extends ElementPath { public int getPrefixMatchLength(ElementPath p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); if ((lSize == 0) || (rSize == 0)) { return 0; } int minLen = (lSize <= rSize) ? lSize : rSize; int match = 0; for (int i = 0; i < minLen; i++) { String l = this.partList.get(i); String r = p.partList.get(i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; } ElementSelector();  ElementSelector(List<String> list);  ElementSelector(String p); boolean fullPathMatch(ElementPath path); int getTailMatchLength(ElementPath p); boolean isContainedIn(ElementPath p); int getPrefixMatchLength(ElementPath p); @Override boolean equals(Object o); @Override int hashCode(); }
ElementSelector extends ElementPath { public int getPrefixMatchLength(ElementPath p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); if ((lSize == 0) || (rSize == 0)) { return 0; } int minLen = (lSize <= rSize) ? lSize : rSize; int match = 0; for (int i = 0; i < minLen; i++) { String l = this.partList.get(i); String r = p.partList.get(i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; } ElementSelector();  ElementSelector(List<String> list);  ElementSelector(String p); boolean fullPathMatch(ElementPath path); int getTailMatchLength(ElementPath p); boolean isContainedIn(ElementPath p); int getPrefixMatchLength(ElementPath p); @Override boolean equals(Object o); @Override int hashCode();  }