|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.appengine.api.search.Document
public final class Document
Represents a user generated document. The following example shows how to create a document consisting of a set of fields, some with plain text and some in HTML.
Document document = Document.newBuilder().setId("document id") .setLocale(Locale.UK) .addField(Field.newBuilder() .setName("subject") .setText("going for dinner")) .addField(Field.newBuilder() .setName("body") .setHTML("<html>I found a restaurant.</html>") .addField(Field.newBuilder() .setName("signature") .setText("ten post jest przeznaczony dla odbiorcy"), .setLocale(new Locale("pl"))) .addField(Field.newBuilder() .setName("tag") .setText("food")) .addField(Field.newBuilder() .setName("tag") .setText("friend")) .build();The following example shows how to access the fields within a document:
Document document = ... for (Field field : document.getFields()) { switch (field.getType()) { case TEXT: use(field.getText()); break; case HTML: use(field.getHtml()); break; case ATOM: use(field.getAtom()); break; case DATE: use(field.getDate()); break; } }
Nested Class Summary | |
---|---|
static class |
Document.Builder
A builder of documents. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object object)
|
java.lang.Iterable<Field> |
getField(java.lang.String name)
|
java.util.Set<java.lang.String> |
getFieldNames()
|
java.lang.Iterable<Field> |
getFields()
|
java.lang.String |
getId()
|
java.util.Locale |
getLocale()
|
Field |
getOnlyField(java.lang.String name)
Returns the single field with the given name. |
int |
getOrderId()
|
int |
hashCode()
|
static Document.Builder |
newBuilder()
Creates a new document builder. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public java.lang.Iterable<Field> getFields()
Field
in the documentpublic java.util.Set<java.lang.String> getFieldNames()
Set
of the field names in the documentpublic java.lang.Iterable<Field> getField(java.lang.String name)
Field
with the given name,
or null
public Field getOnlyField(java.lang.String name)
name
- the name of the field to return
java.lang.IllegalArgumentException
- if the document does not have exactly
one field with the namepublic java.lang.String getId()
public java.util.Locale getLocale()
Locale
the document is written in. Can be nullpublic int getOrderId()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public static Document.Builder newBuilder()
Document.Builder.build()
method on the returned builder.
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |