org.ektorp.util
Class Documents
java.lang.Object
org.ektorp.util.Documents
public final class Documents
- extends java.lang.Object
Class for handling id and revision for persistent classes.
A persistent class must either declare setters and getters for the properties id and revision or
annotate equivalent methods with org.codehaus.jackson.annotate.JsonProperty("_id") and JsonProperty("_rev")
Map can be used as a document class, the map must contain the id field with key "_id" and revision with the key "_rev".
org.codehaus.jackson.node.ObjectNode can olso be used as a document class.
For special needs, a custom document accessor can be registered through the method registerAccessor(Class> documentType, DocumentAccessor accessor)
- Author:
- henrik lundgren, bjohnson.professional
|
Method Summary |
static java.lang.String |
getId(java.lang.Object document)
|
static java.lang.String |
getRevision(java.lang.Object document)
|
static boolean |
isNew(java.lang.Object document)
|
static void |
registerAccessor(java.lang.Class<?> documentType,
DocumentAccessor accessor)
Used to register a custom DocumentAccessor for a particular class. |
static void |
setId(java.lang.Object document,
java.lang.String id)
Will set the id property on the document IF a mutator exists. |
static void |
setRevision(java.lang.Object document,
java.lang.String rev)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Documents
public Documents()
registerAccessor
public static void registerAccessor(java.lang.Class<?> documentType,
DocumentAccessor accessor)
- Used to register a custom DocumentAccessor for a particular class.
Any existing accessor for the class will be overridden.
- Parameters:
documentType - accessor -
getId
public static java.lang.String getId(java.lang.Object document)
setId
public static void setId(java.lang.Object document,
java.lang.String id)
- Will set the id property on the document IF a mutator exists. Otherwise
nothing happens.
- Parameters:
document - id -
getRevision
public static java.lang.String getRevision(java.lang.Object document)
setRevision
public static void setRevision(java.lang.Object document,
java.lang.String rev)
isNew
public static boolean isNew(java.lang.Object document)
Copyright © 2011. All Rights Reserved.