// ------------------------------------------------------------------------- @SuppressWarnings("unchecked") protected String formatValue(Object value, ReportOutputFormat format) { Object formatValue = value instanceof Optional ? ((Optional<?>) value).orElse(null) : value; if (formatValue == null) { return ""; } FormatSettings formatSettings = formatSettingsProvider.getSettings(formatValue.getClass(), fallbackSettings); ValueFormatter<Object> formatter = (ValueFormatter<Object>) formatSettings.getFormatter(); if (format == ReportOutputFormat.CSV) { return formatter.formatForCsv(formatValue); } else { return formatter.formatForDisplay(formatValue); } }
ColorChooserPanel(ColorModel model) { this.model = model; this.panel = new ColorPanel(this.model); this.slider = new DiagramComponent(this.panel, false); this.diagram = new DiagramComponent(this.panel, true); this.text = new JFormattedTextField(); this.label = new JLabel(null, null, SwingConstants.RIGHT); ValueFormatter.init(6, true, this.text); }
public static ValueFormatter read(StreamInput in) throws IOException { byte id = in.readByte(); ValueFormatter formatter = null; switch (id) { case ValueFormatter.Raw.ID: return ValueFormatter.RAW; case ValueFormatter.IPv4Formatter.ID: return ValueFormatter.IPv4; case ValueFormatter.DateTime.ID: formatter = new ValueFormatter.DateTime(); break; case ValueFormatter.Number.Pattern.ID: formatter = new ValueFormatter.Number.Pattern(); break; default: throw new ElasticsearchIllegalArgumentException( "Unknown value formatter with id [" + id + "]"); } formatter.readFrom(in); return formatter; }
public static void write(ValueFormatter formatter, StreamOutput out) throws IOException { out.writeByte(formatter.id()); formatter.writeTo(out); }