java.lang.Object
com.couchbase.columnar.client.java.Row

@ThreadSafe(caveat="Unless you modify the byte array returned by Row.bytes()") public final class Row extends Object
One row of a query result.

Convert the row's content to a Java object by calling as(java.lang.Class<T>) or asNullable(java.lang.Class<T>).

Conversion is done by the Deserializer specified in the query options, or by the cluster's default deserializer if none was specified for the query.

If you use JacksonDeserializer (the default) and enjoy working with Jackson's tree model, call row.as(JsonNode.class) to convert the row to a Jackson tree. Alternatively, pass a class whose fields match the structure of the row, and let Jackson bind the row data to a new instance of the class.

Convert to a parameterized type by calling the overload that takes a TypeRef instead of a Class. For example:

 row.as(new TypeRef<Map<String, MyCustomClass>>() {});
 

If you prefer to use the Couchbase Columnar SDK's simple JsonValue tree model, convert the row to JsonObject or JsonArray. These classes are not as full-featured as Jackson's tree model, but they are always supported regardless of which deserializer you use.

Call bytes() to get the raw bytes of the row content, exactly as it was received from the server. This may be useful for debugging, or if you want to handle deserialization yourself.

See Also:
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    <T> T
    as(TypeRef<T> type)
    Returns the content of the row deserialized as an instance of the specified type.
    <T> T
    as(Class<T> type)
    Returns the content of the row deserialized as an instance of the specified type.
    <T> @Nullable T
    Returns the content of the row deserialized as an instance of the specified type, or null if the row content is a literal null.
    <T> @Nullable T
    asNullable(Class<T> type)
    Returns the content of the row deserialized as an instance of the specified type, or null if the row's content is a literal null.
    byte[]
    Returns the raw content of the row, exactly as it was received from the server.
     

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details Link icon

    • bytes Link icon

      public byte[] bytes()
      Returns the raw content of the row, exactly as it was received from the server.

      This method returns the same array each time it is called.

    • as Link icon

      public <T> T as(Class<T> type)
      Returns the content of the row deserialized as an instance of the specified type.
      Throws:
      NullPointerException - if the row content is a literal null.
      DataConversionException - if the row could not be deserialized into an instance of the specified type.
    • asNullable Link icon

      public <T> @Nullable T asNullable(Class<T> type)
      Returns the content of the row deserialized as an instance of the specified type, or null if the row's content is a literal null.
      Throws:
      DataConversionException - if the row could not be deserialized into an instance of the specified type.
    • as Link icon

      public <T> T as(TypeRef<T> type)
      Returns the content of the row deserialized as an instance of the specified type.
      Throws:
      NullPointerException - if the row content is a literal null.
      DataConversionException - if the row could not be deserialized into an instance of the specified type.
    • asNullable Link icon

      public <T> @Nullable T asNullable(TypeRef<T> type)
      Returns the content of the row deserialized as an instance of the specified type, or null if the row content is a literal null.
      Throws:
      DataConversionException - if the row could not be deserialized into an instance of the specified type.
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object