ContentStrategypublic abstract class ContentStrategy extends Object Creating Indexable document requires processing of incoming entities as
GData Entries. Entries in the GData protocol might have very different
structures and content. They all have on thing in common as they are atom xml
format. To retrieve the configured elements of the atom format and process the
actual content might differ from element to element.
Each predefined ContentStrategy can be used to retrieve certain content from
the defined element. Which element to process is defined using a XPath
expression in the gdata-config.xml file.
ContentStrategy implementation should not be accessed directly. To
get a ContentStrategy for a specific
{@link org.apache.lucene.gdata.search.config.IndexSchemaField.ContentType}
use the {@link ContentStrategy#getFieldStrategy} factory method. This method
expects a IndexSchemaField instance with a set ContentType. The
return value is a new ContentStrategy instance for the defined
ContentType.
|
Fields Summary |
---|
protected final org.apache.lucene.document.Field.Store | store | protected final org.apache.lucene.document.Field.Index | index | protected final org.apache.lucene.gdata.search.config.IndexSchemaField | config | protected String | content | protected String | fieldName |
Methods Summary |
---|
public org.apache.lucene.document.Field[] | createLuceneField()This method creates a lucene field from the retrieved content of the
entity. Values for Field.Index, Field.Store, the field name and the boost
factor are configured in the IndexSchemaField passed by the
constructor e.g the factory method. This method might be overwritten by
subclasses.
/*
* should I test the content for being empty?!
* does that make any difference if empty fields are indexed?!
*/
if(this.fieldName==null|| this.content == null)
throw new GdataIndexerException("Required field not set fieldName: "+this.fieldName+" content: "+this.content);
if(this.content.length()==0){
return new Field[0];
}
Field retValue = new Field(this.fieldName, this.content, this.store,
this.index);
float boost = this.config.getBoost();
if (boost != 1.0f)
retValue.setBoost(boost);
return new Field[]{retValue};
| public static org.apache.lucene.gdata.search.analysis.ContentStrategy | getFieldStrategy(org.apache.lucene.gdata.search.config.IndexSchemaField fieldConfig)This factory method creates the ContentStrategy corresponding
to the set ContentType value in the IndexSchemaField
passed to the method as the single parameter.
The ContentType must not be null
if (fieldConfig == null)
throw new IllegalArgumentException(
"field configuration must not be null");
ContentType type = fieldConfig.getContentType();
if (type == null)
throw new IllegalArgumentException(
"ContentType in IndexSchemaField must not be null");
fieldConfig.getAnalyzerClass();
switch (type) {
case CATEGORY:
return new GdataCategoryStrategy(fieldConfig);
case HTML:
return new HTMLStrategy(fieldConfig);
case XHTML:
return new XHtmlStrategy(fieldConfig);
case GDATADATE:
return new GdataDateStrategy(fieldConfig);
case TEXT:
return new PlainTextStrategy(fieldConfig);
case KEYWORD:
return new KeywordStrategy(fieldConfig);
case CUSTOM:
/*
* check if this class can be created with default constructor is checked
* in IndexSchemaField#setFieldClass and throws RuntimeEx if not. So
* server can not start up.
*/
return ReflectionUtils.getDefaultInstance(fieldConfig
.getFieldClass());
case MIXED:
return new MixedContentStrategy(fieldConfig);
default:
throw new RuntimeException("No content strategy found for " + type);
}
| public abstract void | processIndexable(Indexable indexable)
|
|