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:
Builder<Document>
Direct Known Subclasses:
DocumentBuilder

public abstract class BaseDocumentBuilder<B extends BaseDocumentBuilder<B>>
extends This<B>
implements Builder<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.DocBinaryFieldBuilder
          Binary field builder that adds to the current document builder.
 class BaseDocumentBuilder.DocNumericFieldBuilder
          Numeric field builder that adds to the current document builder.
 class BaseDocumentBuilder.DocTextFieldBuilder
          Text field builder that adds to the current document builder.
 
Constructor Summary
protected BaseDocumentBuilder()
          Constructor.
 
Method Summary
 B add(BinarySchemaItem item, byte[] value)
          Adds a binary field based on a schema item.
 B add(BinarySchemaItem item, ByteString value)
          Adds a binary field based on a schema item.
 B add(BooleanSchemaItem item, boolean value)
          Adds a boolean field based on a schema item.
 B add(DoubleSchemaItem item, double value)
          Adds a double field based on a schema item.
 B add(Fieldable fieldable)
          Adds a fieldable to the document.
 B add(FloatSchemaItem item, float value)
          Adds a float field based on a schema item.
 B add(InstantSchemaItem item, ReadableInstant value)
          Adds an instant field based on a schema item.
 B add(IntegerSchemaItem item, int value)
          Adds an integer field based on a schema item.
 B add(Iterable<? extends Fieldable> fieldables)
          Adds several fieldables to the document.
 B add(LongSchemaItem item, long value)
          Adds a long field based on a schema item.
 B add(StreamSchemaItem item, Reader reader)
          Adds a streamed textual field based on a schema item.
 B add(StreamSchemaItem item, TokenStream tokenStream)
          Adds a streamed textual field based on a schema item.
 B add(TextSchemaItem item, String value)
          Adds a textual field based on a schema item.
 B add(UUIDSchemaItem item, UUID value)
          Adds an UUID field based on a schema item.
 BaseDocumentBuilder.DocBinaryFieldBuilder binary(String name)
          Creates a new binary field builder that adds to the current document.
 Document build()
          Builds the document.
protected  void complete(Multiset<String> fields)
          Completes the document before building.
 BaseDocumentBuilder.DocNumericFieldBuilder numeric(String name)
          Creates a new numeric field builder that adds to the current document.
 BaseDocumentBuilder.DocTextFieldBuilder text(String name)
          Creates a new text 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(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 Document build()
Builds the document.

Specified by:
build in interface Builder<Document>
Throws:
IllegalStateException - if the document can't be built or was already built.

add

public final B add(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 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.

text

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

Parameters:
name - Field name.

binary

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

Parameters:
name - Field name.

add

public final B add(IntegerSchemaItem item,
                   int value)
Adds an integer field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(LongSchemaItem item,
                   long value)
Adds a long field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(FloatSchemaItem item,
                   float value)
Adds a float field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(DoubleSchemaItem item,
                   double value)
Adds a double field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(TextSchemaItem item,
                   String value)
Adds a textual field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(StreamSchemaItem item,
                   Reader reader)
Adds a streamed textual field based on a schema item.

Parameters:
item - Schema item.
reader - Field value reader.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(StreamSchemaItem item,
                   TokenStream tokenStream)
Adds a streamed textual field based on a schema item.

Parameters:
item - Schema item.
tokenStream - Field value token stream.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(UUIDSchemaItem item,
                   UUID value)
Adds an UUID field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(BinarySchemaItem item,
                   byte[] value)
Adds a binary field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(BinarySchemaItem item,
                   ByteString value)
Adds a binary field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(InstantSchemaItem item,
                   ReadableInstant value)
Adds an instant field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.

add

public final B add(BooleanSchemaItem item,
                   boolean value)
Adds a boolean field based on a schema item.

Parameters:
item - Schema item.
value - Field value.
Returns:
This builder.
Throws:
IllegalStateException - if the maximum number of occurrences for this field has been reached.


Copyright © 2013 Derquinse Projects. All Rights Reserved.