|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.couchbase.client.protocol.views.ComplexKey
public final class ComplexKey
Allows simple definition of complex JSON keys for query inputs. If you use the ComplexKex class, the stored objects ultimately get converted into a JSON string. As a result, make sure your custom objects implement the "toString" method accordingly (unless you work with trivial types like Strings or numbers). Instead of using a constructor, use the static "of" method to generate your objects. You can also use a special empty object or array. Here are some simple examples: // generated JSON: [2012,9,7] ComplexKey.of(2012, 9, 7); // generated JSON: ["Hello","World",5.12] ComplexKey.of("Hello", "World", 5.12); // generated JSON: {} ComplexKey.of(ComplexKey.emptyObject()); // generated JSON: [] ComplexKey.of(ComplexKey.emptyArray()); This was inspired by the Ektorp project, which queries Apache CouchDB.
Method Summary | |
---|---|
static java.lang.Object[] |
emptyArray()
Returns an empty array of objects. |
static java.lang.Object |
emptyObject()
Returns a single empty object. |
ComplexKey |
forceArray(boolean force)
Force the cast to a JSON array even when there is only one element. |
static ComplexKey |
of(java.lang.Object... components)
Generate a ComplexKey based on the input Object arguments (varargs). |
java.lang.String |
toJson()
Generate a JSON string of the ComplexKey. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ComplexKey of(java.lang.Object... components)
components
- List of objects that should be converted
public static java.lang.Object emptyObject()
public static java.lang.Object[] emptyArray()
public ComplexKey forceArray(boolean force)
force
- whether the ComplexKey should be forced to be an array or not.
public java.lang.String toJson()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |