/** * Returns the number of "prefix" components that this pattern has in common * with the pattern p passed as parameter. By "prefix" components we mean the * components at the beginning of the pattern. */ public int getPrefixMatchLength(Pattern p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); // no match possible for empty sets 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 = (String) this.partList.get(i); String r = (String) p.partList.get(i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; }
/** * Returns the number of "tail" components that this pattern has in common * with the pattern p passed as parameter. By "tail" components we mean the * components at the end of the pattern. */ public int getTailMatchLength(Pattern p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); // no match possible for empty sets if ((lSize == 0) || (rSize == 0)) { return 0; } int minLen = (lSize <= rSize) ? lSize : rSize; int match = 0; // loop from the end to the front for (int i = 1; i <= minLen; i++) { String l = (String) this.partList.get(lSize - i); String r = (String) p.partList.get(rSize - i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; }
/** * Returns the number of "prefix" components that this pattern has in common * with the pattern p passed as parameter. By "prefix" components we mean the * components at the beginning of the pattern. */ public int getPrefixMatchLength(Pattern p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); // no match possible for empty sets 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 = (String) this.partList.get(i); String r = (String) p.partList.get(i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; }
/** * Returns the number of "tail" components that this pattern has in common * with the pattern p passed as parameter. By "tail" components we mean the * components at the end of the pattern. */ public int getTailMatchLength(Pattern p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); // no match possible for empty sets if ((lSize == 0) || (rSize == 0)) { return 0; } int minLen = (lSize <= rSize) ? lSize : rSize; int match = 0; // loop from the end to the front for (int i = 1; i <= minLen; i++) { String l = (String) this.partList.get(lSize - i); String r = (String) p.partList.get(rSize - i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; }
/** * Returns the number of "prefix" components that this pattern has in common * with the pattern p passed as parameter. By "prefix" components we mean the * components at the beginning of the pattern. */ public int getPrefixMatchLength(Pattern p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); // no match possible for empty sets 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 = (String) this.partList.get(i); String r = (String) p.partList.get(i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; }
/** * Returns the number of "tail" components that this pattern has in common * with the pattern p passed as parameter. By "tail" components we mean the * components at the end of the pattern. */ public int getTailMatchLength(Pattern p) { if (p == null) { return 0; } int lSize = this.partList.size(); int rSize = p.partList.size(); // no match possible for empty sets if ((lSize == 0) || (rSize == 0)) { return 0; } int minLen = (lSize <= rSize) ? lSize : rSize; int match = 0; // loop from the end to the front for (int i = 1; i <= minLen; i++) { String l = (String) this.partList.get(lSize - i); String r = (String) p.partList.get(rSize - i); if (equalityCheck(l, r)) { match++; } else { break; } } return match; }
@Override public boolean equals(Object o) { if ((o == null) || !(o instanceof Pattern)) { return false; } Pattern r = (Pattern) o; if (r.size() != size()) { return false; } int len = size(); for (int i = 0; i < len; i++) { if (!equalityCheck(get(i), r.get(i))) { return false; } } // if everything matches, then the two patterns are equal return true; }
@Override public boolean equals(Object o) { if ((o == null) || !(o instanceof Pattern)) { return false; } Pattern r = (Pattern) o; if (r.size() != size()) { return false; } int len = size(); for (int i = 0; i < len; i++) { if (!equalityCheck(get(i), r.get(i))) { return false; } } // if everything matches, then the two patterns are equal return true; }
@Override public boolean equals(Object o) { if ((o == null) || !(o instanceof Pattern)) { return false; } Pattern r = (Pattern) o; if (r.size() != size()) { return false; } int len = size(); for (int i = 0; i < len; i++) { if (!equalityCheck(get(i), r.get(i))) { return false; } } // if everything matches, then the two patterns are equal return true; }