|
1 /** |
|
2 * Copyright 2002-2004 The Apache Software Foundation |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 #ifndef _lucene_search_highlight_simplehtmlformatter_ |
|
18 #define _lucene_search_highlight_simplehtmlformatter_ |
|
19 |
|
20 #if defined(_LUCENE_PRAGMA_ONCE) |
|
21 # pragma once |
|
22 #endif |
|
23 |
|
24 #include "CLucene/util/StringBuffer.h" |
|
25 #include "CLucene/highlighter/Formatter.h" |
|
26 |
|
27 CL_NS_DEF2(search,highlight) |
|
28 |
|
29 /** |
|
30 * Simple {@link Formatter} implementation to highlight terms with a pre and post tag |
|
31 * |
|
32 */ |
|
33 class SimpleHTMLFormatter :public Formatter |
|
34 { |
|
35 private: |
|
36 const TCHAR* _preTag; |
|
37 const TCHAR* _postTag; |
|
38 |
|
39 public: |
|
40 ~SimpleHTMLFormatter(); |
|
41 |
|
42 |
|
43 SimpleHTMLFormatter(const TCHAR* preTag, const TCHAR* postTag); |
|
44 |
|
45 /** |
|
46 * Default constructor uses HTML: <B> tags to markup terms |
|
47 * |
|
48 **/ |
|
49 SimpleHTMLFormatter(); |
|
50 |
|
51 |
|
52 /** |
|
53 * Returns the original text enclosed in _preTag and _postTag, if the score is greater |
|
54 * than 0. Otherwise, it returns the original text. |
|
55 * It doesn't use the stemmed text nor the startOffset. |
|
56 * It allocates memory for the returned text, and it has to be freed by the caller. |
|
57 */ |
|
58 TCHAR* highlightTerm(const TCHAR* originalText, const TokenGroup* tokenGroup); |
|
59 }; |
|
60 |
|
61 CL_NS_END2 |
|
62 |
|
63 #endif |