org.hibernate.search.elasticsearch.bridge.builtin.impl

## Class ElasticsearchCalendarBridge

- java.lang.Object
- - org.hibernate.search.bridge.util.impl.EncodingStringBridge<Calendar>
  - - org.hibernate.search.elasticsearch.bridge.builtin.impl.ElasticsearchCalendarBridge

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

      public class ElasticsearchCalendarBridge
      extends EncodingStringBridge<Calendar>
      implements TwoWayFieldBridge, ParameterizedBridge, IgnoreAnalyzerBridge

  Bridge a `java.util.Calendar` to a `String` using the ISO 8601 standard which is the default date format of Elasticsearch. The time zone of the calendar is stored in the index. Typically, a `java.util.Calendar` will be converted to "2016-04-28T15:24:25+01:00".
  Author:
    Guillaume Smet

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ElasticsearchCalendarBridge` | `DATE_DAY`
    `static ElasticsearchCalendarBridge` | `DATE_HOUR`
    `static ElasticsearchCalendarBridge` | `DATE_MILLISECOND`
    `static ElasticsearchCalendarBridge` | `DATE_MINUTE`
    `static ElasticsearchCalendarBridge` | `DATE_MONTH`
    `static ElasticsearchCalendarBridge` | `DATE_SECOND`
    `static ElasticsearchCalendarBridge` | `DATE_YEAR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ElasticsearchCalendarBridge()`
    `ElasticsearchCalendarBridge(Resolution resolution)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `get(String name, Document document)` Build the element object from the `Document`
    `String` | `objectToString(Object object)` Convert the object representation to a string.
    `protected Calendar` | `parseIndexNullAs(String indexNullAs)` Parse the 'indexNullAs' string to an indexable value.
    `void` | `set(String name, Object value, Document document, LuceneOptions luceneOptions)` Manipulate the document to index the given value.
    `void` | `setParameterValues(Map<String,String> parameters)` Called on the bridge implementation to pass the parameters.

    - ### Methods inherited from class org.hibernate.search.bridge.util.impl.EncodingStringBridge

      `createNullMarker, getEncodingType`

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

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

- - ### Field Detail

    - #### DATE_YEAR

          public static final ElasticsearchCalendarBridge DATE_YEAR

    - #### DATE_MONTH

          public static final ElasticsearchCalendarBridge DATE_MONTH

    - #### DATE_DAY

          public static final ElasticsearchCalendarBridge DATE_DAY

    - #### DATE_HOUR

          public static final ElasticsearchCalendarBridge DATE_HOUR

    - #### DATE_MINUTE

          public static final ElasticsearchCalendarBridge DATE_MINUTE

    - #### DATE_SECOND

          public static final ElasticsearchCalendarBridge DATE_SECOND

    - #### DATE_MILLISECOND

          public static final ElasticsearchCalendarBridge DATE_MILLISECOND

  - ### Constructor Detail

    - #### ElasticsearchCalendarBridge

          public ElasticsearchCalendarBridge()

    - #### ElasticsearchCalendarBridge

          public ElasticsearchCalendarBridge(Resolution resolution)

  - ### Method Detail

    - #### 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.

    - #### 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.

    - #### setParameterValues

          public void setParameterValues(Map<String,String> parameters)

      Description copied from interface: `ParameterizedBridge`
      Called on the bridge implementation to pass the parameters.
      Specified by:
        `setParameterValues` in interface `ParameterizedBridge`
      Parameters:
        `parameters` - map containing string based parameters to be passed to the parameterized bridge. The map is never `null`.

    - #### parseIndexNullAs

          protected Calendar parseIndexNullAs(String indexNullAs)
                                       throws IllegalArgumentException

      Description copied from class: `EncodingStringBridge`
      Parse the 'indexNullAs' string to an indexable value.

      The required format does not have to be the same as the encoded format.

      Specified by:
        `parseIndexNullAs` in class `EncodingStringBridge<Calendar>`
      Parameters:
        `indexNullAs` - The string to parse.
      Returns:
        The encoded value for the given string.
      Throws:
        `IllegalArgumentException` - If the given string does not match the required format.

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