net.conquiris.lucene.document
Class BaseDocumentBuilder<B extends BaseDocumentBuilder<B>>

java.lang.Object
  extended by net.derquinse.common.reflect.This<B>
      extended by net.conquiris.lucene.document.BaseDocumentBuilder<B>
All Implemented Interfaces:
net.derquinse.common.base.Builder<org.apache.lucene.document.Document>
Direct Known Subclasses:
DocumentBuilder

public abstract class BaseDocumentBuilder<B extends BaseDocumentBuilder<B>>
extends net.derquinse.common.reflect.This<B>
implements net.derquinse.common.base.Builder<org.apache.lucene.document.Document>

Base class for document builders. Document builders can only be used once and are NOT THREAD SAFE.

Author:
Andres Rodriguez

Nested Class Summary
 class BaseDocumentBuilder.DocFieldBuilder
          Numeric field builder that adds to the current document builder.
 class BaseDocumentBuilder.DocNumericFieldBuilder
          Numeric field builder that adds to the current document builder.
 
Constructor Summary
protected BaseDocumentBuilder()
          Constructor.
 
Method Summary
 B add(org.apache.lucene.document.Fieldable fieldable)
          Adds a fieldable to the document.
 B add(Iterable<? extends org.apache.lucene.document.Fieldable> fieldables)
          Adds several fieldables to the document.
 org.apache.lucene.document.Document build()
          Builds the document.
protected  void complete(com.google.common.collect.Multiset<String> fields)
          Completes the document before building.
 BaseDocumentBuilder.DocFieldBuilder field(String name)
          Creates a new field builder that adds to the current document.
 BaseDocumentBuilder.DocNumericFieldBuilder numeric(String name)
          Creates a new numeric field builder that adds to the current document.
 
Methods inherited from class net.derquinse.common.reflect.This
thisValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseDocumentBuilder

protected BaseDocumentBuilder()
Constructor.

Method Detail

complete

protected void complete(com.google.common.collect.Multiset<String> fields)
Completes the document before building.

Parameters:
fields - A live but unmodifiable view of the fields added to the document.
Throws:
IllegalStateException - if the document must not be built.

build

public final org.apache.lucene.document.Document build()
Builds the document.

Specified by:
build in interface net.derquinse.common.base.Builder<org.apache.lucene.document.Document>
Throws:
IllegalStateException - if the document can't be built or was already built.

add

public final B add(org.apache.lucene.document.Fieldable fieldable)
Adds a fieldable to the document.

Parameters:
fieldable - Fieldable to add.
Returns:
This builder.
Throws:
IllegalStateException - if the document was already built.

add

public final B add(Iterable<? extends org.apache.lucene.document.Fieldable> fieldables)
Adds several fieldables to the document.

Parameters:
fieldables - Fieldables to add.
Returns:
This builder.
Throws:
IllegalStateException - if the document was already built.

numeric

public final BaseDocumentBuilder.DocNumericFieldBuilder numeric(String name)
Creates a new numeric field builder that adds to the current document.

Parameters:
name - Field name.

field

public final BaseDocumentBuilder.DocFieldBuilder field(String name)
Creates a new field builder that adds to the current document.

Parameters:
name - Field name.


Copyright © 2012 Derquinse Projects.. All Rights Reserved.