org.hibernate.search.bridge.builtin.time.impl

## Class DurationBridge

- java.lang.Object
- - org.hibernate.search.bridge.builtin.time.impl.DurationBridge

- All Implemented Interfaces:
    FieldBridge, EncodingBridge, IgnoreAnalyzerBridge, StringBridge, TwoWayFieldBridge

      public class DurationBridge
      extends Object
      implements TwoWayFieldBridge, IgnoreAnalyzerBridge, EncodingBridge

  Converts a `Duration` to a `Long` expressing the duration in nanoseconds.

  If the duration cannot be expressed using a long, a `SearchException` get thrown.

  Author:
    Davide D'Alto

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static DurationBridge` | `INSTANCE`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `NullMarker` | `createNullMarker(String indexNullAs)`
    `Object` | `get(String name, Document document)` Build the element object from the `Document`
    `NumericFieldSettingsDescriptor.NumericEncodingType` | `getEncodingType()` Define the numeric encoding to use for the brdige.
    `String` | `objectToString(Object object)` Convert the object representation to a string.
    `void` | `set(String name, Object value, Document document, LuceneOptions luceneOptions)` Manipulate the document to index the given value.

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

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

- - ### Field Detail

    - #### INSTANCE

          public static final DurationBridge INSTANCE

  - ### Method Detail

    - #### objectToString

          public String objectToString(Object object)

      Description copied from interface: `TwoWayFieldBridge`
      Convert the object representation to a string.
      Specified by:
        `objectToString` in interface `StringBridge`
      Specified by:
        `objectToString` in interface `TwoWayFieldBridge`
      Parameters:
        `object` - The object to index.
      Returns:
        string (index) representation of the specified object. Must not be `null`, but can be empty.

    - #### set

          public void set(String name,
                          Object value,
                          Document document,
                          LuceneOptions luceneOptions)

      Description copied from interface: `FieldBridge`
      Manipulate the document to index the given value.

      A common implementation is to add a Field with the given `name` to `document` following the parameters `luceneOptions` if the `value` is not `null`.

           String fieldValue = convertToString(value);
           luceneOptions.addFieldToDocument(name, fieldValue, document);

      Specified by:
        `set` in interface `FieldBridge`
      Parameters:
        `name` - The field to add to the Lucene document
        `value` - The actual value to index
        `document` - The Lucene document into which we want to index the value.
        `luceneOptions` - Contains the parameters used for adding `value` to the Lucene document.

    - #### get

          public Object get(String name,
                            Document document)

      Description copied from interface: `TwoWayFieldBridge`
      Build the element object from the `Document`
      Specified by:
        `get` in interface `TwoWayFieldBridge`
      Parameters:
        `name` - field name
        `document` - document
      Returns:
        The return value is the entity property value.

    - #### getEncodingType

          public NumericFieldSettingsDescriptor.NumericEncodingType getEncodingType()

      Description copied from interface: `EncodingBridge`
      Define the numeric encoding to use for the brdige.
      Specified by:
        `getEncodingType` in interface `EncodingBridge`
      Returns:
        the encoding to use for this bridge, or `NumericFieldSettingsDescriptor.NumericEncodingType.UNKNOWN` if this bridge does not use numeric encoding.

    - #### createNullMarker

          public NullMarker createNullMarker(String indexNullAs)
                                      throws IllegalArgumentException

      Specified by:
        `createNullMarker` in interface `EncodingBridge`
      Parameters:
        `indexNullAs` - The value of `Field.indexNullAs()`.
      Returns:
        The marker to use when a value is missing.
      Throws:
        `IllegalArgumentException` - If `indexNullAs` cannot be encoded in the required format.

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved