cmssearchfield.java
来自「找了很久才找到到源代码」· Java 代码 · 共 700 行 · 第 1/2 页
JAVA
700 行
}
}
/**
* Returns the mappings for this field.<p>
*
* @return the mappings for this field
*/
public List getMappings() {
return m_mappings;
}
/**
* Returns the name of this field in the Lucene search index.<p>
*
* @return the name of this field in the Lucene search index
*/
public String getName() {
return m_name;
}
/**
* The hash code for a field is based only on the field name.<p>
*
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return (m_name == null) ? 41 : m_name.hashCode();
}
/**
* Returns true if the field should be displayed.<p>
*
* @return returns true if the field should be displayed otherwise false
*/
public boolean isDisplayed() {
return m_displayed;
}
/**
* Returns the indexed.<p>
*
* @return the indexed
*/
public boolean isIndexed() {
return m_indexed;
}
/**
* Returns <code>true</code> if this fields content is used in the search result excerpt.<p>
*
* @return <code>true</code> if this fields content is used in the search result excerpt
*
* @see #isStored()
*/
public boolean isInExcerpt() {
return m_excerpt;
}
/**
* Returns <code>true</code> if this fields content is used in the search result excerpt.<p>
*
* A field can only be used in the excerpt if it is stored, see {@link #isStored()}.<p>
*
* @return <code>true</code> if this fields content is used in the search result excerpt
*
* @see #isStored()
*/
public boolean isInExcerptAndStored() {
return m_excerpt && m_stored;
}
/**
* Returns <code>true</code> if the content of this field is stored in the Lucene index.<p>
*
* Please refer to the Lucene documentation about {@link org.apache.lucene.document.Field.Store}
* for the concept behind stored and unstored fields.<p>
*
* @return <code>true</code> if the content of this field is stored in the Lucene index
*
* @see #isTokenizedAndIndexed()
*/
public boolean isStored() {
return m_stored;
}
/**
* Returns <code>true</code> if the content of this field is tokenized in the Lucene index.<p>
*
* Please refer to the Lucene documentation about {@link org.apache.lucene.document.Field.Index}
* for the concept behind tokenized and untokenized fields.<p>
*
* @return <code>true</code> if the content of this field is tokenized in the Lucene index
*/
public boolean isTokenized() {
return m_tokenized;
}
/**
* Returns <code>true</code> if the content of this field is tokenized in the Lucene index.<p>
*
* A field can only be tokenized if it is also indexed, see {@link #isIndexed()}.<p>
*
* Please refer to the Lucene documentation about {@link org.apache.lucene.document.Field.Index}
* for the concept behind tokenized and untokenized fields.<p>
*
* @return <code>true</code> if the content of this field is tokenized in the Lucene index
*
* @see #isStored()
* @see #isIndexed()
*/
public boolean isTokenizedAndIndexed() {
return m_tokenized && m_indexed;
}
/**
* Sets the boost factor for this field.<p>
*
* The boost factor is a Lucene function that controls the "importance" of a field in the
* search result ranking. The default is <code>1.0</code>. A lower boost factor will make the field
* less important for the result ranking, a higher value will make it more important.<p>
*
* <b>Use with caution:</b> You should only use this if you fully understand the concept behind
* Lucene boost factors. Otherwise it is likley that your result rankings will be worse then with
* the default values.<p>
*
* @param boost the boost factor to set
*/
public void setBoost(float boost) {
if (boost < 0.0f) {
boost = 0.0f;
}
m_boost = boost;
}
/**
* Sets the boost factor for this field from a String value.<p>
*
* @param boost the boost factor to set
*
* @see #setBoost(float)
*/
public void setBoost(String boost) {
try {
setBoost(Float.valueOf(boost).floatValue());
} catch (NumberFormatException e) {
// invalid number format, use default boost factor
setBoost(BOOST_DEFAULT);
}
}
/**
* Sets the boost factor of this field (only for display use).<p>
*
* @param boost the boost factor to set
*
* @see #setBoost(String)
*/
public void setBoostDisplay(String boost) {
setBoost(boost);
}
/**
* Sets the default value to use if no content for this field was collected.<p>
*
* @param defaultValue the default value to set
*/
public void setDefaultValue(String defaultValue) {
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(defaultValue)) {
m_defaultValue = defaultValue.trim();
} else {
m_defaultValue = null;
}
}
/**
* Controls if the field is displayed or not.<p>
*
* @param displayed if true the field is displayed
*/
public void setDisplayed(boolean displayed) {
m_displayed = displayed;
}
/**
* Sets the display name. If the given name equals IGNORE_DISPLAY_NAME the field is not displayed.<p>
*
* @param displayName the display name to set
*/
public void setDisplayName(String displayName) {
if (CmsStringUtil.isEmpty(displayName) || (IGNORE_DISPLAY_NAME.equals(displayName))) {
m_displayName = null;
setDisplayed(false);
} else {
m_displayName = displayName;
m_displayNameForConfiguration = displayName;
setDisplayed(true);
}
}
/**
* Sets the displayNameForConfiguration.<p>
*
* @param displayNameForConfiguration the displayNameForConfiguration to set
*/
public void setDisplayNameForConfiguration(String displayNameForConfiguration) {
m_displayNameForConfiguration = displayNameForConfiguration;
setDisplayName(displayNameForConfiguration);
}
/**
* Controls if the content of this field is indexed (and possibly tokenized) in the Lucene index.<p>
*
* @param indexed the indexed to set
*
* @see #setTokenized(boolean)
*/
public void setIndexed(boolean indexed) {
m_indexed = indexed;
}
/**
* Controls if the content of this field is indexed (and possibly tokenized) in the Lucene index from a String parameter.<p>
*
* This sets the values for {@link #isIndexed()} as well as {@link #isTokenizedAndIndexed()}.<p>
*
* The parameter can have the following values:
* <ul>
* <li><b>"true"</b> or <b>"tokenized"</b>: The field is indexed and tokenized.
* <li><b>"false"</b>: The field is not indexed and not tokenized.
* <li><b>"untokenized"</b>: The field is indexed but not tokenized.
* </ul>
*
* @param indexed the index setting to use
*
* @see #setIndexed(boolean)
* @see #setTokenized(boolean)
*/
public void setIndexed(String indexed) {
boolean isIndexed = false;
boolean isTokenized = false;
if (indexed != null) {
indexed = indexed.trim().toLowerCase();
if (STR_TOKENIZED.equals(indexed)) {
isIndexed = true;
isTokenized = true;
} else if (STR_UN_TOKENIZED.equals(indexed)) {
isIndexed = true;
} else {
isIndexed = Boolean.valueOf(indexed).booleanValue();
isTokenized = isIndexed;
}
}
setIndexed(isIndexed);
setTokenized(isTokenized);
}
/**
* Controls if this fields content is used in the search result excerpt.<p>
*
* @param excerpt if <code>true</code>, then this fields content is used in the search excerpt
*/
public void setInExcerpt(boolean excerpt) {
m_excerpt = excerpt;
}
/**
* Controls if this fields content is used in the search result excerpt.<p>
*
* @param excerpt if <code>"true"</code>, then this fields content is used in the search excerpt
*
* @see #setInExcerpt(boolean)
*/
public void setInExcerpt(String excerpt) {
setInExcerpt(Boolean.valueOf(String.valueOf(excerpt)).booleanValue());
}
/**
* Sets the name of this field in the Lucene search index.<p>
*
* @param name the name to set
*/
public void setName(String name) {
m_name = name;
}
/**
* Controls if the content of this field is stored in the Lucene index.<p>
*
* Please refer to the Lucene documentation about {@link org.apache.lucene.document.Field.Store}
* for the concept behind stored and unstored fields.<p>
*
* @param stored if <code>true</code>, then the field content is stored
*
* @see #setTokenized(boolean)
*/
public void setStored(boolean stored) {
m_stored = stored;
}
/**
* Controls if the content of this field is stored in the Lucene index from a String parameter.<p>
*
* @param stored if <code>"true"</code>, then the field content is stored
*
* @see #setStored(boolean)
*/
public void setStored(String stored) {
setStored(Boolean.valueOf(String.valueOf(stored)).booleanValue());
}
/**
* Controls if the content of this field is tokenized in the Lucene index.<p>
*
* Please refer to the Lucene documentation about {@link org.apache.lucene.document.Field.Index}
* for the concept behind tokenized and untokenized fields.<p>
*
* @param tokenized if <code>true</code>, then the field content is tokenized
*
* @see #setStored(boolean)
*/
public void setTokenized(boolean tokenized) {
m_tokenized = tokenized;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?