org.opencms.search.fields
Class CmsSearchFieldMapping

java.lang.Object
  extended by org.opencms.search.fields.CmsSearchFieldMapping
All Implemented Interfaces:
java.io.Serializable, I_CmsSearchFieldMapping
Direct Known Subclasses:
CmsGallerySearchFieldMapping

public class CmsSearchFieldMapping
extends java.lang.Object
implements I_CmsSearchFieldMapping

Describes a mapping of a piece of content from an OpenCms VFS resource to a field of a search index.

Since:
7.0.0
See Also:
Serialized Form

Constructor Summary
CmsSearchFieldMapping()
          Public constructor for a new search field mapping.
CmsSearchFieldMapping(CmsSearchFieldMappingType type, java.lang.String param)
          Public constructor for a new search field mapping.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Two mappings are equal if the type and the parameter is equal.
static java.util.Date getDefaultDateExpired()
          Returns the default expiration date, meaning the resource never expires.
 java.lang.String getDefaultValue()
          Returns the default value used for this field mapping in case no content is available.
 java.lang.String getParam()
          Returns the mapping parameter.
 java.lang.String getStringValue(CmsObject cms, CmsResource res, I_CmsExtractionResult extractionResult, java.util.List<CmsProperty> properties, java.util.List<CmsProperty> propertiesSearched)
          Returns the String value extracted form the provided data according to the rules of this mapping type.
 CmsSearchFieldMappingType getType()
          Returns the mapping type.
 int hashCode()
          The hash code depends on the type and the parameter.
 void setDefaultValue(java.lang.String defaultValue)
          Sets the default value for this field mapping in case no content is available.
 void setParam(java.lang.String param)
          Sets the mapping parameter.
 void setType(CmsSearchFieldMappingType type)
          Sets the mapping type.
 void setType(java.lang.String type)
          Sets the mapping type as a String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsSearchFieldMapping

public CmsSearchFieldMapping()
Public constructor for a new search field mapping.


CmsSearchFieldMapping

public CmsSearchFieldMapping(CmsSearchFieldMappingType type,
                             java.lang.String param)
Public constructor for a new search field mapping.

Parameters:
type - the type to use, see setType(CmsSearchFieldMappingType)
param - the mapping parameter, see setParam(String)
Method Detail

getDefaultDateExpired

public static java.util.Date getDefaultDateExpired()
                                            throws java.text.ParseException
Returns the default expiration date, meaning the resource never expires.

Returns:
the default expiration date
Throws:
java.text.ParseException - if something goes wrong parsing the default date string

equals

public boolean equals(java.lang.Object obj)
Two mappings are equal if the type and the parameter is equal.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

getDefaultValue

public java.lang.String getDefaultValue()
Description copied from interface: I_CmsSearchFieldMapping
Returns the default value used for this field mapping in case no content is available.

Specified by:
getDefaultValue in interface I_CmsSearchFieldMapping
Returns:
the default value used for this field mapping in case no content is available
See Also:
I_CmsSearchFieldMapping.getDefaultValue()

getParam

public java.lang.String getParam()
Description copied from interface: I_CmsSearchFieldMapping
Returns the mapping parameter.

The parameter is used depending on the implementation of the rules of the selected CmsSearchFieldMappingType.

Specified by:
getParam in interface I_CmsSearchFieldMapping
Returns:
the mapping parameter
See Also:
I_CmsSearchFieldMapping.getParam()

getStringValue

public java.lang.String getStringValue(CmsObject cms,
                                       CmsResource res,
                                       I_CmsExtractionResult extractionResult,
                                       java.util.List<CmsProperty> properties,
                                       java.util.List<CmsProperty> propertiesSearched)
Description copied from interface: I_CmsSearchFieldMapping
Returns the String value extracted form the provided data according to the rules of this mapping type.

Specified by:
getStringValue in interface I_CmsSearchFieldMapping
Parameters:
cms - the OpenCms context used for building the search index
res - the resource that is indexed
extractionResult - the plain text extraction result from the resource
properties - the list of all properties directly attached to the resource (not searched)
propertiesSearched - the list of all searched properties of the resource
Returns:
the String value extracted form the provided data according to the rules of this mapping type
See Also:
I_CmsSearchFieldMapping.getStringValue(org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.extractors.I_CmsExtractionResult, java.util.List, java.util.List)

getType

public CmsSearchFieldMappingType getType()
Description copied from interface: I_CmsSearchFieldMapping
Returns the mapping type.

Specified by:
getType in interface I_CmsSearchFieldMapping
Returns:
the mapping type
See Also:
I_CmsSearchFieldMapping.getType()

hashCode

public int hashCode()
The hash code depends on the type and the parameter.

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

setDefaultValue

public void setDefaultValue(java.lang.String defaultValue)
Description copied from interface: I_CmsSearchFieldMapping
Sets the default value for this field mapping in case no content is available.

Specified by:
setDefaultValue in interface I_CmsSearchFieldMapping
Parameters:
defaultValue - the default value to set
See Also:
I_CmsSearchFieldMapping.setDefaultValue(java.lang.String)

setParam

public void setParam(java.lang.String param)
Description copied from interface: I_CmsSearchFieldMapping
Sets the mapping parameter.

The parameter is used depending on the implementation of the rules of the selected CmsSearchFieldMappingType.

Specified by:
setParam in interface I_CmsSearchFieldMapping
Parameters:
param - the parameter to set
See Also:
I_CmsSearchFieldMapping.setParam(java.lang.String)

setType

public void setType(CmsSearchFieldMappingType type)
Description copied from interface: I_CmsSearchFieldMapping
Sets the mapping type.

Specified by:
setType in interface I_CmsSearchFieldMapping
Parameters:
type - the type to set
See Also:
I_CmsSearchFieldMapping.setType(org.opencms.search.fields.CmsSearchFieldMappingType)

setType

public void setType(java.lang.String type)
Description copied from interface: I_CmsSearchFieldMapping
Sets the mapping type as a String.

Specified by:
setType in interface I_CmsSearchFieldMapping
Parameters:
type - the name of the type to set
See Also:
I_CmsSearchFieldMapping.setType(java.lang.String)