Class XContentElasticsearchExtension
- java.lang.Object
-
- org.elasticsearch.common.xcontent.XContentElasticsearchExtension
-
- All Implemented Interfaces:
XContentBuilderExtension
public class XContentElasticsearchExtension extends Object implements XContentBuilderExtension
SPI extensions for Elasticsearch-specific classes (like the Lucene or Joda dependency classes) that need to be encoded byXContentBuilderin a specific way.
-
-
Field Summary
Fields Modifier and Type Field Description static org.joda.time.format.DateTimeFormatterDEFAULT_DATE_PRINTERstatic DateFormatterDEFAULT_FORMATTERstatic DateFormatterLOCAL_TIME_FORMATTERstatic DateFormatterOFFSET_TIME_FORMATTER
-
Constructor Summary
Constructors Constructor Description XContentElasticsearchExtension()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Class<?>,Function<Object,Object>>getDateTransformers()Used for plugging a transformer for a date or time type object into a String (or other encodable object).Map<Class<?>,XContentBuilder.HumanReadableTransformer>getXContentHumanReadableTransformers()Used for plugging in a human readable version of a class's encoding.Map<Class<?>,XContentBuilder.Writer>getXContentWriters()Used for plugging in a generic writer for a class, for example, an example implementation:
-
-
-
Field Detail
-
DEFAULT_DATE_PRINTER
public static final org.joda.time.format.DateTimeFormatter DEFAULT_DATE_PRINTER
-
DEFAULT_FORMATTER
public static final DateFormatter DEFAULT_FORMATTER
-
LOCAL_TIME_FORMATTER
public static final DateFormatter LOCAL_TIME_FORMATTER
-
OFFSET_TIME_FORMATTER
public static final DateFormatter OFFSET_TIME_FORMATTER
-
-
Method Detail
-
getXContentWriters
public Map<Class<?>,XContentBuilder.Writer> getXContentWriters()
Description copied from interface:XContentBuilderExtensionUsed for plugging in a generic writer for a class, for example, an example implementation:Map<Class<?>, XContentBuilder.Writer> addlWriters = new HashMap<>(); addlWriters.put(BytesRef.class, (builder, value) -> b.value(((BytesRef) value).utf8String())); return addlWriters;- Specified by:
getXContentWritersin interfaceXContentBuilderExtension- Returns:
- a map of class name to writer
-
getXContentHumanReadableTransformers
public Map<Class<?>,XContentBuilder.HumanReadableTransformer> getXContentHumanReadableTransformers()
Description copied from interface:XContentBuilderExtensionUsed for plugging in a human readable version of a class's encoding. It is assumed that the human readable equivalent is always behind thetoString()method, so this transformer returns the raw value to be used. An example implementation:Map<Class<?>, XContentBuilder.HumanReadableTransformer> transformers = new HashMap<>(); transformers.put(ByteSizeValue.class, (value) -> ((ByteSizeValue) value).bytes());- Specified by:
getXContentHumanReadableTransformersin interfaceXContentBuilderExtension- Returns:
- a map of class name to transformer used to retrieve raw value
-
getDateTransformers
public Map<Class<?>,Function<Object,Object>> getDateTransformers()
Description copied from interface:XContentBuilderExtensionUsed for plugging a transformer for a date or time type object into a String (or other encodable object). For example:final DateTimeFormatter datePrinter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); Map<Class<?>, Function<Object, Object>> transformers = new HashMap<>(); transformers.put(Date.class, d -> datePrinter.print(((Date) d).getTime()));- Specified by:
getDateTransformersin interfaceXContentBuilderExtension
-
-