int (int offset, JoinLinesHandlerDelegate delegate, DocumentEx doc) { if (offset == CANNOT_JOIN) return offset; if (offset < 0) { LOG.error("Handler returned negative offset: handler class="+delegate.getClass()+"; offset="+offset); return 0; } else if (offset > doc.getTextLength()) { LOG.error("Handler returned an offset which exceeds the document length: handler class=" + delegate.getClass() + "; offset=" + offset + "; length=" + doc.getTextLength()); return doc.getTextLength(); } return offset; }