@@ -0,0 +1,2448 @@
+package org.apache.lucene.search.highlight;%0A/**%0A * Copyright 2002-2004 The Apache Software Foundation%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0A/**%0A * Formats text with different color intensity depending on the score of the%0A * term using the span tag.  GradientFormatter uses a bgcolor argument to the font tag which%0A * doesn't work in Mozilla, thus this class.%0A *%0A * @see GradientFormatter%0A * @author David Spencer dave@searchmorph.com%0A */%0A%0Aimport org.apache.lucene.search.highlight.*;%0A%0Apublic class SpanGradientFormatter%0A%09extends GradientFormatter%0A%7B%0A%09public SpanGradientFormatter(float maxScore, String minForegroundColor,%0A            String maxForegroundColor, String minBackgroundColor,%0A            String maxBackgroundColor)%0A    %7B%0A%09%09super( maxScore, minForegroundColor,%0A%09%09%09   maxForegroundColor, minBackgroundColor,%0A%09%09%09   maxBackgroundColor);%0A%09%7D%0A%09%0A%0A%09%0A%09public String highlightTerm(String originalText, TokenGroup tokenGroup)%0A    %7B%0A        if (tokenGroup.getTotalScore() == 0)%0A            return originalText;%0A        float score = tokenGroup.getTotalScore();%0A        if (score == 0)%0A        %7B%0A            return originalText;%0A        %7D%0A%0A%09%09// try to size sb correctly%0A        StringBuffer sb = new StringBuffer( originalText.length() + EXTRA);%0A%09%09%0A%09%09sb.append(%22%3Cspan style=%5C%22%22); %0A%09%09if (highlightForeground) %0A%09%09%7B%0A%09%09%09sb.append(%22color: %22); %0A%09%09%09sb.append(getForegroundColorString(score)); %0A%09%09%09sb.append(%22; %22); %0A%09%09%7D%0A%09%09if (highlightBackground)%0A%09%09%7B%0A%09%09%09sb.append(%22background: %22);%0A%09%09%09sb.append(getBackgroundColorString(score));%0A%09%09%09sb.append(%22; %22);%0A%09%09%7D%0A%09%09sb.append(%22%5C%22%3E%22);%0A%09%09sb.append(originalText);%0A%09%09sb.append(%22%3C/span%3E%22);%0A        return sb.toString();%0A    %7D%0A%0A%09// guess how much extra text we'll add to the text we're highlighting to try to avoid a  StringBuffer resize%0A%09private static final String TEMPLATE = %22%3Cspan style=%5C%22background: #EEEEEE; color: #000000;%5C%22%3E...%3C/span%3E%22;%0A%09private static final int EXTRA = TEMPLATE.length();%09%0A%7D%0A

Use <span> instead of <font> (as in GradientFormatter) to keep Mozilla happy.