FileDocCategorySizeDatePackage
MixedContentStrategy.javaAPI DocApache Lucene 2.1.03166Wed Feb 14 10:46:04 GMT 2007org.apache.lucene.gdata.search.analysis

MixedContentStrategy

public class MixedContentStrategy extends ContentStrategy
author
Simon Willnauer

Fields Summary
protected ContentStrategy
strategy
Constructors Summary
protected MixedContentStrategy(org.apache.lucene.gdata.search.config.IndexSchemaField fieldConfiguration)

        super(fieldConfiguration);

    
Methods Summary
private static ContentStrategychooseStrategy(java.lang.String contentType, org.apache.lucene.gdata.search.config.IndexSchemaField config)

        ContentType type = null;
        try {
            type = ContentType.valueOf(contentType==null?"TEXT":contentType.toUpperCase());
        } catch (Throwable e) {
            type = ContentType.TEXT;
        }

        switch (type) {
        case HTML:
            return new HTMLStrategy(config);

        case XHTML:
            return new XHtmlStrategy(config);

        default:
            return new PlainTextStrategy(config);

        }
    
public org.apache.lucene.document.Field[]createLuceneField()

see
org.apache.lucene.gdata.search.analysis.ContentStrategy#createLuceneField()

        
        return this.strategy.createLuceneField();
    
public voidprocessIndexable(Indexable indexable)

throws
NotIndexableException
see
org.apache.lucene.gdata.search.analysis.ContentStrategy#processIndexable(org.apache.lucene.gdata.search.analysis.Indexable)

        String path = this.config.getTypePath();

        try {
            Node node = indexable.applyPath(path);
            if (node == null)
                this.strategy = new PlainTextStrategy(this.config);
            else {
                String contentType = node.getTextContent();

                this.strategy = chooseStrategy(contentType, this.config);
            }
            this.strategy.processIndexable(indexable);
        } catch (XPathExpressionException e) {
            throw new NotIndexableException("Can not apply path -- " + path);

        }