com.google.appengine.api.search
Class Document.Builder

java.lang.Object
  extended by com.google.appengine.api.search.Document.Builder
Enclosing class:
Document

public static final class Document.Builder
extends java.lang.Object

A builder of documents. This is not thread-safe.


Method Summary
 Document.Builder addField(Field.Builder builder)
          Adds the field builder to the document builder.
 Document.Builder addField(Field field)
          Adds the field to the builder.
 Document build()
          Builds a valid document.
 Document.Builder setId(java.lang.String documentId)
          Set the document id to a unique valid value.
 Document.Builder setLocale(java.util.Locale locale)
          Sets the Locale the document is written in.
 Document.Builder setOrderId(int orderId)
          Sets an order ID, which is used to return documents in a defined order in search results.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setId

public Document.Builder setId(java.lang.String documentId)
Set the document id to a unique valid value. A valid document id must be a printable ASCII string of between 1 and DocumentChecker#MAXIMUM_DOCUMENT_ID_LENGTH characters, and also not start with '!' which is reserved. If no document id is provided, then the search service will provide one when the document is indexed.

Parameters:
documentId - the unique id for the document to be built
Throws:
java.lang.IllegalArgumentException - if documentId is not valid

addField

public Document.Builder addField(Field.Builder builder)
Adds the field builder to the document builder. Allows multiple fields with the same name.

Parameters:
builder - the builder of the field to add
Returns:
this document builder

addField

public Document.Builder addField(Field field)
Adds the field to the builder. Allows multiple fields with the same name.

Parameters:
field - the field to add
Returns:
this builder
Throws:
java.lang.IllegalArgumentException - if the field is invalid

setLocale

public Document.Builder setLocale(java.util.Locale locale)
Sets the Locale the document is written in.

Parameters:
locale - the Locale the document is written in
Returns:
this document builder

setOrderId

public Document.Builder setOrderId(int orderId)
Sets an order ID, which is used to return documents in a defined order in search results. If it is not specified, then the number of seconds since 2011/1/1 will be used. Documents are returned in descending order of the order ID.

Parameters:
orderId - an id used to specify the order this document will be returned in search results
Returns:
this builder

build

public Document build()
Builds a valid document. The builder must have set a valid document id, and have a non-empty set of valid fields.

Returns:
the document built by this builder
Throws:
java.lang.IllegalArgumentException - if the document built is not valid