@Test public void testTailMatch() { { ElementPath p = new ElementPath("/a/b"); ElementSelector ruleElementSelector = new ElementSelector("*"); assertEquals(0, ruleElementSelector.getTailMatchLength(p)); } { ElementPath p = new ElementPath("/a"); ElementSelector ruleElementSelector = new ElementSelector("*/a"); assertEquals(1, ruleElementSelector.getTailMatchLength(p)); } { ElementPath p = new ElementPath("/A"); ElementSelector ruleElementSelector = new ElementSelector("*/a"); assertEquals(1, ruleElementSelector.getTailMatchLength(p)); } { ElementPath p = new ElementPath("/a"); ElementSelector ruleElementSelector = new ElementSelector("*/A"); assertEquals(1, ruleElementSelector.getTailMatchLength(p)); } { ElementPath p = new ElementPath("/a/b"); ElementSelector ruleElementSelector = new ElementSelector("*/b"); assertEquals(1, ruleElementSelector.getTailMatchLength(p)); } { ElementPath p = new ElementPath("/a/B"); ElementSelector ruleElementSelector = new ElementSelector("*/b"); assertEquals(1, ruleElementSelector.getTailMatchLength(p)); } { ElementPath p = new ElementPath("/a/b/c"); ElementSelector ruleElementSelector = new ElementSelector("*/b/c"); assertEquals(2, ruleElementSelector.getTailMatchLength(p)); } }
public int getTailMatchLength(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 = 1; i <= minLen; i++) { String l = this.partList.get(lSize - i); String r = p.partList.get(rSize - i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; }
ElementSelector extends ElementPath { public int getTailMatchLength(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 = 1; i <= minLen; i++) { String l = this.partList.get(lSize - i); String r = p.partList.get(rSize - i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; } }
ElementSelector extends ElementPath { public int getTailMatchLength(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 = 1; i <= minLen; i++) { String l = this.partList.get(lSize - i); String r = p.partList.get(rSize - i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; } ElementSelector();  ElementSelector(List<String> list);  ElementSelector(String p); }
ElementSelector extends ElementPath { public int getTailMatchLength(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 = 1; i <= minLen; i++) { String l = this.partList.get(lSize - i); String r = p.partList.get(rSize - 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 getTailMatchLength(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 = 1; i <= minLen; i++) { String l = this.partList.get(lSize - i); String r = p.partList.get(rSize - 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();  }