/** Do the two terms overlap on any character indexes. */ public boolean hasOverlap(HighlightTerm otherTerm) { // note: if this.startOffset==otherTerm.endOffset, there's no overlap, // since the end offset is AFTER the term. return this.getDocId() == otherTerm.getDocId() && ((this.startOffset < otherTerm.getEndOffset() && this.endOffset > otherTerm.getStartOffset()) || (otherTerm.getStartOffset() < this.endOffset && otherTerm.getEndOffset() > this.startOffset)); }
@Override public int compareTo(HighlightTerm o) { if (this == o) return 0; if (this.getDocId() != o.getDocId()) return this.getDocId() - o.getDocId(); if (!this.getField().equals(o.getField())) return this.getField().compareTo(o.getField()); if (this.startOffset != o.getStartOffset()) return this.startOffset - o.getStartOffset(); if (this.endOffset != o.getEndOffset()) return this.endOffset - o.getEndOffset(); return 0; }