001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.jsp.search.config;
029
030/**
031 * Search configuration for highlighting options.
032 */
033public class CmsSearchConfigurationHighlighting implements I_CmsSearchConfigurationHighlighting {
034
035    /** The fields that should be used for highlighting. */
036    private final String m_highlightField;
037    /** The number of snippets to return. */
038    private final Integer m_snippetCount;
039    /** The size of a snippet (in letters). */
040    private final Integer m_fragSize;
041    /** A field that should be displayed if no highlighting snippet is found. */
042    private final String m_alternateField;
043    /** The maximal length of the snippet shown from the alternative field (in letters). */
044    private final Integer m_maxAlternateFieldLength;
045    /** The String added in front of the highlighted part. */
046    private final String m_pre;
047    /** The String added behind the highlighted part. */
048    private final String m_post;
049    /** The formatter used for highlighting. */
050    private final String m_formatter;
051    /** The fragmenter used for highlighting. */
052    private final String m_fragmenter;
053    /** Flag, indicating if fast vector highlighting should be used. */
054    private final Boolean m_fastVectorHighlighting;
055
056    /** The constructor setting all configuration values.
057     * @param field The fields that should be used for highlighting. (Solr: hl.fl)
058     * @param snippetCount The number of snippets to return. (Solr: hl.snippets)
059     * @param fragSize The size of a snippet (in letters). (Solr: hl.fragsize)
060     * @param alternateField A field that should be displayed if no highlighting snippet is found. (Solr: hl.alternateField)
061     * @param maxAlternateFieldLength The maximal length of the snippet shown from the alternative field (in letters). (Solr: hl.maxAlternateFieldLength)
062     * @param pre The String added in front of the highlighted part. (Solr: hl.simple.pre)
063     * @param post The String added behind the highlighted part. (Solr: hl.simple.post)
064     * @param formatter The formatter used for highlighting. (Solr: hl.formatter)
065     * @param fragmenter The fragmenter used for highlighting. (Solr: hl.fragmenter)
066     * @param useFastVectorHighlighting Flag, indicating if fast vector highlighting should be used. (Solr: hl.useFastVectorHighlighting)
067     */
068    public CmsSearchConfigurationHighlighting(
069        final String field,
070        final Integer snippetCount,
071        final Integer fragSize,
072        final String alternateField,
073        final Integer maxAlternateFieldLength,
074        final String pre,
075        final String post,
076        final String formatter,
077        final String fragmenter,
078        final Boolean useFastVectorHighlighting) {
079
080        m_highlightField = field;
081        m_snippetCount = snippetCount;
082        m_fragSize = fragSize;
083        m_alternateField = alternateField;
084        m_maxAlternateFieldLength = maxAlternateFieldLength;
085        m_pre = pre;
086        m_post = post;
087        m_formatter = formatter;
088        m_fragmenter = fragmenter;
089        m_fastVectorHighlighting = useFastVectorHighlighting;
090    }
091
092    /**
093     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getAlternateHighlightField()
094     */
095    @Override
096    public String getAlternateHighlightField() {
097
098        return m_alternateField;
099    }
100
101    /**
102     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getFormatter()
103     */
104    @Override
105    public String getFormatter() {
106
107        return m_formatter;
108    }
109
110    /**
111     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getFragmenter()
112     */
113    @Override
114    public String getFragmenter() {
115
116        return m_fragmenter;
117    }
118
119    /**
120     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getFragSize()
121     */
122    @Override
123    public Integer getFragSize() {
124
125        return m_fragSize;
126    }
127
128    /**
129     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getHightlightField()
130     */
131    @Override
132    public String getHightlightField() {
133
134        return m_highlightField;
135    }
136
137    /**
138     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getMaxAlternateHighlightFieldLength()
139     */
140    @Override
141    public Integer getMaxAlternateHighlightFieldLength() {
142
143        return m_maxAlternateFieldLength;
144    }
145
146    /**
147     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getSimplePost()
148     */
149    @Override
150    public String getSimplePost() {
151
152        return m_post;
153    }
154
155    /**
156     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getSimplePre()
157     */
158    @Override
159    public String getSimplePre() {
160
161        return m_pre;
162    }
163
164    /**
165     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getSnippetsCount()
166     */
167    @Override
168    public Integer getSnippetsCount() {
169
170        return m_snippetCount;
171    }
172
173    /**
174     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationHighlighting#getUseFastVectorHighlighting()
175     */
176    @Override
177    public Boolean getUseFastVectorHighlighting() {
178
179        return m_fastVectorHighlighting;
180    }
181
182}