From 07cee0b287e86101a1be64975f0949914f5531e9 Mon Sep 17 00:00:00 2001 From: Mark Harwood Date: Thu, 2 Jun 2005 20:27:06 +0000 Subject: [PATCH] git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@179637 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/search/highlight/TokenGroup.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/contrib/highlighter/src/java/org/apache/lucene/search/highlight/TokenGroup.java b/contrib/highlighter/src/java/org/apache/lucene/search/highlight/TokenGroup.java index bb48ced6a21..ececbafc2be 100644 --- a/contrib/highlighter/src/java/org/apache/lucene/search/highlight/TokenGroup.java +++ b/contrib/highlighter/src/java/org/apache/lucene/search/highlight/TokenGroup.java @@ -34,19 +34,22 @@ public class TokenGroup void addToken(Token token, float score) { - if(numTokens==0) - { - startOffset=token.startOffset(); - endOffset=token.endOffset(); - } - else - { - startOffset=Math.min(startOffset,token.startOffset()); - endOffset=Math.max(endOffset,token.endOffset()); - } - tokens[numTokens]=token; - scores[numTokens]=score; - numTokens++; + if(numTokens < MAX_NUM_TOKENS_PER_GROUP) + { + if(numTokens==0) + { + startOffset=token.startOffset(); + endOffset=token.endOffset(); + } + else + { + startOffset=Math.min(startOffset,token.startOffset()); + endOffset=Math.max(endOffset,token.endOffset()); + } + tokens[numTokens]=token; + scores[numTokens]=score; + numTokens++; + } } boolean isDistinct(Token token) @@ -116,5 +119,4 @@ public class TokenGroup } return total; } - }