FileDocCategorySizeDatePackage
SetBasedFieldSelector.javaAPI DocApache Lucene 2.1.02361Wed Feb 14 10:46:42 GMT 2007org.apache.lucene.document

SetBasedFieldSelector

public class SetBasedFieldSelector extends Object implements FieldSelector
Declare what fields to load normally and what fields to load lazily

Fields Summary
private Set
fieldsToLoad
private Set
lazyFieldsToLoad
Constructors Summary
public SetBasedFieldSelector(Set fieldsToLoad, Set lazyFieldsToLoad)
Pass in the Set of {@link Field} names to load and the Set of {@link Field} names to load lazily. If both are null, the Document will not have any {@link Field} on it.

param
fieldsToLoad A Set of {@link String} field names to load. May be empty, but not null
param
lazyFieldsToLoad A Set of {@link String} field names to load lazily. May be empty, but not null

    this.fieldsToLoad = fieldsToLoad;
    this.lazyFieldsToLoad = lazyFieldsToLoad;
  
Methods Summary
public org.apache.lucene.document.FieldSelectorResultaccept(java.lang.String fieldName)
Indicate whether to load the field with the given name or not. If the {@link Field#name()} is not in either of the initializing Sets, then {@link org.apache.lucene.document.FieldSelectorResult#NO_LOAD} is returned. If a Field name is in both fieldsToLoad and lazyFieldsToLoad, lazy has precedence.

param
fieldName The {@link Field} name to check
return
The {@link FieldSelectorResult}

    FieldSelectorResult result = FieldSelectorResult.NO_LOAD;
    if (fieldsToLoad.contains(fieldName) == true){
      result = FieldSelectorResult.LOAD;
    }
    if (lazyFieldsToLoad.contains(fieldName) == true){
      result = FieldSelectorResult.LAZY_LOAD;
    }                                           
    return result;