001/*
002 * File   : $Source$
003 * Date   : $Date$
004 * Version: $Revision$
005 *
006 * This library is part of OpenCms -
007 * the Open Source Content Management System
008 *
009 * Copyright (C) 2002 - 2009 Alkacon Software (http://www.alkacon.com)
010 *
011 * This library is free software; you can redistribute it and/or
012 * modify it under the terms of the GNU Lesser General Public
013 * License as published by the Free Software Foundation; either
014 * version 2.1 of the License, or (at your option) any later version.
015 *
016 * This library is distributed in the hope that it will be useful,
017 * but WITHOUT ANY WARRANTY; without even the implied warranty of
018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019 * Lesser General Public License for more details.
020 *
021 * For further information about Alkacon Software, please see the
022 * company website: http://www.alkacon.com
023 *
024 * For further information about OpenCms, please see the
025 * project website: http://www.opencms.org
026 *
027 * You should have received a copy of the GNU Lesser General Public
028 * License along with this library; if not, write to the Free Software
029 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030 */
031
032package org.opencms.search.fields;
033
034import org.opencms.file.CmsObject;
035import org.opencms.file.CmsProperty;
036import org.opencms.file.CmsResource;
037import org.opencms.search.extractors.I_CmsExtractionResult;
038
039import java.io.Serializable;
040import java.util.List;
041
042/**
043 * Describes a mapping of a piece of content from an OpenCms VFS
044 * resource to a field of a search index.<p>
045 *
046 * @since 8.5.0
047 */
048public interface I_CmsSearchFieldMapping extends Serializable {
049
050    /**
051     * Returns the default value used for this field mapping in case no content is available.<p>
052     *
053     * @return the default value used for this field mapping in case no content is available
054     */
055    String getDefaultValue();
056
057    /**
058     * Returns the mapping parameter.<p>
059     *
060     * The parameter is used depending on the implementation of the rules of
061     * the selected {@link CmsSearchFieldMappingType}.<p>
062     *
063     * @return the mapping parameter
064     */
065    String getParam();
066
067    /**
068     * Returns the String value extracted form the provided data according to the rules of this mapping type.<p>
069     *
070     * @param cms the OpenCms context used for building the search index
071     * @param res the resource that is indexed
072     * @param extractionResult the plain text extraction result from the resource
073     * @param properties the list of all properties directly attached to the resource (not searched)
074     * @param propertiesSearched the list of all searched properties of the resource
075     *
076     * @return the String value extracted form the provided data according to the rules of this mapping type
077     */
078    String getStringValue(
079        CmsObject cms,
080        CmsResource res,
081        I_CmsExtractionResult extractionResult,
082        List<CmsProperty> properties,
083        List<CmsProperty> propertiesSearched);
084
085    /**
086     * Returns the mapping type.<p>
087     *
088     * @return the mapping type
089     */
090    CmsSearchFieldMappingType getType();
091
092    /**
093     * Sets the default value for this field mapping in case no content is available.<p>
094     *
095     * @param defaultValue the default value to set
096     */
097    void setDefaultValue(String defaultValue);
098
099    /**
100     * Sets the mapping parameter.<p>
101     *
102     * The parameter is used depending on the implementation of the rules of
103     * the selected {@link CmsSearchFieldMappingType}.<p>
104     *
105     * @param param the parameter to set
106     */
107    void setParam(String param);
108
109    /**
110     * Sets the mapping type.<p>
111     *
112     * @param type the type to set
113     */
114    void setType(CmsSearchFieldMappingType type);
115
116    /**
117     * Sets the mapping type as a String.<p>
118     *
119     * @param type the name of the type to set
120     */
121    void setType(String type);
122}