secondaryindex

## Class Binding

- java.lang.Object
- - secondaryindex.Binding

-     public class Binding
      extends Object

  Implements a generic conversion between Value and Avro schema instances.

  The class is used by IndexViewService to parse the Value part of KV pairs. It also supplies some general conversion methods for user records with different schemas. The example defines a BillInfo as its primary DB record schema which is defined in the resource file "billinfo-schema.avsc".

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Binding(AvroCatalog avroCatalog)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Schema` | `getSchema(String schemaName)` Returns the Schema object for the given schema name.
    `String` | `getSchemaName(Value value)` Returns the schema name of value.
    `List<Object>` | `toFields(Value value, List<String> fieldNames)` Given a list of Avro field names, extracts the field values from the `value` parameter.
    `GenericRecord` | `toObject(Value value)` Returns the deserialized `GenericRecord` instance.
    `Value` | `toValue(GenericRecord record)` Returns the Value that conforms to the schema of the given `GenericRecord`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Binding

          public Binding(AvroCatalog avroCatalog)

  - ### Method Detail

    - #### toValue

          public Value toValue(GenericRecord record)

      Returns the Value that conforms to the schema of the given `GenericRecord`.
      Parameters:
        `record` -
      Returns:
        Value

    - #### toObject

          public GenericRecord toObject(Value value)

      Returns the deserialized `GenericRecord` instance. If the given Value is not in Avro format then null will be returned.
      Parameters:
        `value` -
      Returns:
        a GenericRecord or null if the given Value is not an Avro data.

    - #### toFields

          public List<Object> toFields(Value value,
                              List<String> fieldNames)

      Given a list of Avro field names, extracts the field values from the `value` parameter. null is returned if the given Value is not valid Avro data.
      Parameters:
        `value` -
        `fieldNames` - the Avro field names to extract from value. The fields must be contained in the value's schema definition.
      Returns:
        a list holding field values in the same order as the input field name list. null is return if the given Value is not valid Avro data.

    - #### getSchemaName

          public String getSchemaName(Value value)

      Returns the schema name of value. If the value is not an Avro data then null is returned.
      Parameters:
        `value` -
      Returns:
        null if the given Value is not valid Avro data.

    - #### getSchema

          public Schema getSchema(String schemaName)

      Returns the Schema object for the given schema name.
      Parameters:
        `schemaName` -
      Returns:
        Schema

Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.