use of io.crate.types.Regclass in project crate by crate.
the class ServerXContentExtension method getXContentWriters.
@Override
public Map<Class<?>, XContentBuilder.Writer> getXContentWriters() {
Map<Class<?>, XContentBuilder.Writer> writers = new HashMap<>();
// Fully-qualified here to reduce ambiguity around our (ES') Version class
writers.put(org.apache.lucene.util.Version.class, (b, v) -> b.value(Objects.toString(v)));
writers.put(DateTimeZone.class, (b, v) -> b.value(Objects.toString(v)));
writers.put(CachedDateTimeZone.class, (b, v) -> b.value(Objects.toString(v)));
writers.put(FixedDateTimeZone.class, (b, v) -> b.value(Objects.toString(v)));
writers.put(MutableDateTime.class, XContentBuilder::timeValue);
writers.put(DateTime.class, XContentBuilder::timeValue);
writers.put(TimeValue.class, (b, v) -> b.value(v.toString()));
writers.put(ZonedDateTime.class, XContentBuilder::timeValue);
writers.put(OffsetDateTime.class, XContentBuilder::timeValue);
writers.put(OffsetTime.class, XContentBuilder::timeValue);
writers.put(java.time.Instant.class, XContentBuilder::timeValue);
writers.put(LocalDateTime.class, XContentBuilder::timeValue);
writers.put(LocalDate.class, XContentBuilder::timeValue);
writers.put(LocalTime.class, XContentBuilder::timeValue);
writers.put(DayOfWeek.class, (b, v) -> b.value(v.toString()));
writers.put(Month.class, (b, v) -> b.value(v.toString()));
writers.put(MonthDay.class, (b, v) -> b.value(v.toString()));
writers.put(Year.class, (b, v) -> b.value(v.toString()));
writers.put(Duration.class, (b, v) -> b.value(v.toString()));
writers.put(Period.class, (b, v) -> b.value(v.toString()));
writers.put(org.joda.time.Period.class, (b, v) -> {
org.joda.time.Period period = (org.joda.time.Period) v;
b.value(IntervalType.PERIOD_FORMATTER.print(period));
});
writers.put(BytesReference.class, (b, v) -> {
if (v == null) {
b.nullValue();
} else {
BytesRef bytes = ((BytesReference) v).toBytesRef();
b.value(bytes.bytes, bytes.offset, bytes.length);
}
});
writers.put(BytesRef.class, (b, v) -> {
if (v == null) {
b.nullValue();
} else {
BytesRef bytes = (BytesRef) v;
b.value(bytes.bytes, bytes.offset, bytes.length);
}
});
writers.put(Regproc.class, (b, v) -> b.value(((Regproc) v).name()));
writers.put(Regclass.class, (b, v) -> b.value(((Regclass) v).oid()));
writers.put(PointImpl.class, (b, v) -> {
Point point = (Point) v;
b.startArray();
b.value(point.getX());
b.value(point.getY());
b.endArray();
});
writers.put(JtsPoint.class, (b, v) -> {
Point point = (Point) v;
b.startArray();
b.value(point.getX());
b.value(point.getY());
b.endArray();
});
writers.put(RowN.class, (b, v) -> {
RowN row = (RowN) v;
b.startArray();
for (int i = 0; i < row.numColumns(); i++) {
b.value(row.get(i));
}
b.endArray();
});
writers.put(TimeTZ.class, (b, v) -> {
TimeTZ timetz = (TimeTZ) v;
b.startArray();
b.value(timetz.getMicrosFromMidnight());
b.value(timetz.getSecondsFromUTC());
b.endArray();
});
writers.put(BitString.class, (b, v) -> {
BitString bitString = (BitString) v;
b.value(bitString.asBitString());
});
return writers;
}
Aggregations