List of usage examples for com.fasterxml.jackson.core JsonGenerator writeNumber
public abstract void writeNumber(String encodedValue) throws IOException, JsonGenerationException, UnsupportedOperationException;
From source file:io.swagger.inflector.processors.JsonNodeExampleSerializer.java
public void writeValue(JsonGenerator jgen, String field, Example o) throws IOException { if (o instanceof ArrayExample) { ArrayExample obj = (ArrayExample) o; jgen.writeArrayFieldStart(field); for (Example item : obj.getItems()) { if (item.getName() != null) { jgen.writeStartObject(); writeTo(jgen, item);/* www. ja v a 2 s. c o m*/ jgen.writeEndObject(); } else { writeTo(jgen, item); } } jgen.writeEndArray(); } else if (o instanceof BooleanExample) { BooleanExample obj = (BooleanExample) o; if (field != null) { jgen.writeBooleanField(field, obj.getValue()); } else { jgen.writeBoolean(obj.getValue()); } } else if (o instanceof DecimalExample) { DecimalExample obj = (DecimalExample) o; if (field != null) { jgen.writeNumberField(field, obj.getValue()); } else { jgen.writeNumber(obj.getValue()); } } else if (o instanceof DoubleExample) { DoubleExample obj = (DoubleExample) o; if (field != null) { jgen.writeNumberField(field, obj.getValue()); } else { jgen.writeNumber(obj.getValue()); } } else if (o instanceof FloatExample) { FloatExample obj = (FloatExample) o; if (field != null) { jgen.writeNumberField(field, obj.getValue()); } else { jgen.writeNumber(obj.getValue()); } } else if (o instanceof IntegerExample) { IntegerExample obj = (IntegerExample) o; if (field != null) { jgen.writeNumberField(field, obj.getValue()); } else { jgen.writeNumber(obj.getValue()); } } else if (o instanceof LongExample) { LongExample obj = (LongExample) o; if (field != null) { jgen.writeNumberField(field, obj.getValue()); } else { jgen.writeNumber(obj.getValue()); } } else if (o instanceof ObjectExample) { ObjectExample obj = (ObjectExample) o; if (field != null) { jgen.writeObjectField(field, obj); } } else if (o instanceof StringExample) { StringExample obj = (StringExample) o; if (field != null) { jgen.writeStringField(field, obj.getValue()); } else { jgen.writeString(obj.getValue()); } } }
From source file:ijfx.service.overlay.io.OverlaySerializer.java
private void saveRectangleOverlay(RectangleOverlay rectangleOverlay, JsonGenerator jg) throws IOException { jg.writeStartObject();/*from w ww .java 2s . co m*/ jg.writeStringField(JsonOverlayToken.OVERLAY_TYPE, JsonOverlayToken.RECTANGLE_OVERLAY); int dimensionCount = rectangleOverlay.numDimensions(); Double[] origin = Utils.extractArray(rectangleOverlay::getOrigin, dimensionCount); Double[] extent = Utils.extractArray(rectangleOverlay::getExtent, dimensionCount); ColorRGB fcolor = rectangleOverlay.getFillColor(); ColorRGB lcolor = rectangleOverlay.getLineColor(); Integer[] fill_color = { fcolor.getRed(), fcolor.getGreen(), fcolor.getBlue() }; Integer[] line_color = { lcolor.getRed(), lcolor.getGreen(), lcolor.getBlue() }; double width = rectangleOverlay.getLineWidth(); writeNumberArray(jg, JsonOverlayToken.ORIGIN, origin); writeNumberArray(jg, JsonOverlayToken.EXTENT, extent); writeNumberArray(jg, JsonOverlayToken.FILL_COLOR, fill_color); writeNumberArray(jg, JsonOverlayToken.LINE_COLOR, line_color); jg.writeFieldName(JsonOverlayToken.LINE_WIDTH); jg.writeNumber(width); jg.writeEndObject(); }
From source file:ijfx.service.overlay.io.OverlaySerializer.java
private void savePolytonOverlay(PolygonOverlay overlay, JsonGenerator jg) throws IOException { // {/*from w ww .ja v a 2 s. c o m*/ jg.writeStartObject(); int numDimension = overlay.numDimensions(); // "ovl_type":"polygon" jg.writeStringField(JsonOverlayToken.OVERLAY_TYPE, JsonOverlayToken.POLYGON_OVERLAY); // "points":[ int vertexCount = overlay.getRegionOfInterest().getVertexCount(); double[] xpoints = IntStream.range(0, vertexCount) .mapToDouble(i -> overlay.getRegionOfInterest().getVertex(i).getDoublePosition(0)).toArray(); double[] ypoints = IntStream.range(0, vertexCount) .mapToDouble(i -> overlay.getRegionOfInterest().getVertex(i).getDoublePosition(1)).toArray(); writeDoubleArray(jg, "xpoints", xpoints); writeDoubleArray(jg, "ypoints", ypoints); // } ColorRGB fcolor = overlay.getFillColor(); ColorRGB lcolor = overlay.getLineColor(); Integer[] fill_color = { fcolor.getRed(), fcolor.getGreen(), fcolor.getBlue() }; Integer[] line_color = { lcolor.getRed(), lcolor.getGreen(), lcolor.getBlue() }; double width = overlay.getLineWidth(); writeNumberArray(jg, JsonOverlayToken.FILL_COLOR, fill_color); writeNumberArray(jg, JsonOverlayToken.LINE_COLOR, line_color); jg.writeFieldName(JsonOverlayToken.LINE_WIDTH); jg.writeNumber(width); jg.writeEndObject(); }
From source file:net.opentsdb.contrib.tsquare.web.view.GraphiteJsonResponseWriter.java
@Override public void write(final AnnotatedDataPoints annotatedPoints, final ResponseContext context) throws IOException { final JsonGenerator jsonGenerator = getJsonGenerator(context); jsonGenerator.writeStartObject();/*from w w w. j av a 2 s. co m*/ jsonGenerator.writeStringField("target", annotatedPoints.getDataPoints().metricName()); if (includeAllTags) { jsonGenerator.writeArrayFieldStart("tags"); for (final Map.Entry<String, String> entry : annotatedPoints.getDataPoints().getTags().entrySet()) { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("key", entry.getKey()); jsonGenerator.writeStringField("value", entry.getValue()); jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); } if (includeAggregatedTags) { jsonGenerator.writeArrayFieldStart("aggregatedTags"); for (final String tag : annotatedPoints.getDataPoints().getAggregatedTags()) { jsonGenerator.writeString(tag); } jsonGenerator.writeEndArray(); } if (summarize) { final DataPointsAsDoubles doubles = new DataPointsAsDoubles(annotatedPoints.getDataPoints()); final double aggValue = Aggregators.SUM.runDouble(doubles); jsonGenerator.writeNumberField("summarizedValue", aggValue); } else { jsonGenerator.writeArrayFieldStart("datapoints"); for (final DataPoint p : annotatedPoints.getDataPoints()) { jsonGenerator.writeStartArray(); if (p.isInteger()) { jsonGenerator.writeNumber(p.longValue()); } else { jsonGenerator.writeNumber(p.doubleValue()); } if (isMillisecondResolution()) { jsonGenerator.writeNumber(p.timestamp()); } else { jsonGenerator.writeNumber(TimeUnit.MILLISECONDS.toSeconds(p.timestamp())); } jsonGenerator.writeEndArray(); } jsonGenerator.writeEndArray(); } jsonGenerator.writeEndObject(); }
From source file:net.solarnetwork.web.support.JSONView.java
private void writeJsonValue(JsonGenerator json, String key, Object val, PropertyEditorRegistrar registrar) throws JsonGenerationException, IOException { if (val instanceof Collection<?> || (val != null && val.getClass().isArray())) { Collection<?> col;//from w w w . ja va 2 s . c o m if (val instanceof Collection<?>) { col = (Collection<?>) val; } else if (!val.getClass().getComponentType().isPrimitive()) { col = Arrays.asList((Object[]) val); } else { // damn you, primitives col = getPrimitiveCollection(val); } if (key != null) { json.writeFieldName(key); } json.writeStartArray(); for (Object colObj : col) { writeJsonValue(json, null, colObj, registrar); } json.writeEndArray(); } else if (val instanceof Map<?, ?>) { if (key != null) { json.writeFieldName(key); } json.writeStartObject(); for (Map.Entry<?, ?> me : ((Map<?, ?>) val).entrySet()) { Object propName = me.getKey(); if (propName == null) { continue; } writeJsonValue(json, propName.toString(), me.getValue(), registrar); } json.writeEndObject(); } else if (val instanceof Double) { if (key == null) { json.writeNumber((Double) val); } else { json.writeNumberField(key, (Double) val); } } else if (val instanceof Integer) { if (key == null) { json.writeNumber((Integer) val); } else { json.writeNumberField(key, (Integer) val); } } else if (val instanceof Short) { if (key == null) { json.writeNumber(((Short) val).intValue()); } else { json.writeNumberField(key, ((Short) val).intValue()); } } else if (val instanceof Float) { if (key == null) { json.writeNumber((Float) val); } else { json.writeNumberField(key, (Float) val); } } else if (val instanceof Long) { if (key == null) { json.writeNumber((Long) val); } else { json.writeNumberField(key, (Long) val); } } else if (val instanceof Boolean) { if (key == null) { json.writeBoolean((Boolean) val); } else { json.writeBooleanField(key, (Boolean) val); } } else if (val instanceof String) { if (key == null) { json.writeString((String) val); } else { json.writeStringField(key, (String) val); } } else { // create a JSON object from bean properties if (getPropertySerializerRegistrar() != null && val != null) { // try whole-bean serialization first Object o = getPropertySerializerRegistrar().serializeProperty(key, val.getClass(), val, val); if (o != val) { if (o != null) { writeJsonValue(json, key, o, registrar); } return; } } generateJavaBeanObject(json, key, val, registrar); } }
From source file:data.DefaultExchanger.java
public void exportData(String dbName, String catalogName, final JsonGenerator generator, JdbcTemplate jdbcTemplate) throws IOException { generator.writeFieldName(getTable()); generator.writeStartArray();//from w w w .j a v a 2 s .c o m final int[] rowCount = { 0 }; jdbcTemplate.query(getSelectSql(), new RowCallbackHandler() { @Override public void processRow(ResultSet rs) throws SQLException { try { generator.writeStartObject(); setNode(generator, rs); generator.writeEndObject(); rowCount[0]++; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } } }); generator.writeEndArray(); play.Logger.info("exported {{}} {}", rowCount[0], getTable()); if (hasSequence()) { String sequenceName = sequenceName(); long sequenceValue = 0; if (dbName.equalsIgnoreCase("MySQL")) { String sql = String.format("SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES " + "WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'", catalogName, getTable()); sequenceValue = jdbcTemplate.queryForObject(sql, Long.class); } else if (dbName.equalsIgnoreCase("H2")) { sequenceValue = jdbcTemplate.queryForObject("CALL NEXT VALUE FOR " + sequenceName, Long.class); } generator.writeFieldName(sequenceName); generator.writeNumber(sequenceValue); play.Logger.info("exported sequence {{}}", sequenceName()); } }
From source file:net.opentsdb.tsd.HttpSampleSerializer.java
/** * Format the results from a timeseries data query * @param data_query The TSQuery object used to fetch the results * @param results The data fetched from storage * @param globals An optional list of global annotation objects * @return A ChannelBuffer object to pass on to the caller *//*from w w w .j a v a 2s . c o m*/ public ChannelBuffer formatQueryV1(final TSQuery data_query, final List<DataPoints[]> results, final List<Annotation> globals) { final boolean as_arrays = this.query.hasQueryStringParam("arrays"); final String jsonp = this.query.getQueryStringParam("jsonp"); // todo - this should be streamed at some point since it could be HUGE final ChannelBuffer response = ChannelBuffers.dynamicBuffer(); final OutputStream output = new ChannelBufferOutputStream(response); try { // don't forget jsonp if (jsonp != null && !jsonp.isEmpty()) { output.write((jsonp + "(").getBytes(query.getCharset())); } JsonGenerator json = JSON.getFactory().createGenerator(output); json.writeStartArray(); for (DataPoints[] separate_dps : results) { for (DataPoints dps : separate_dps) { json.writeStartObject(); json.writeStringField("metric", dps.metricName()); json.writeFieldName("tags"); json.writeStartObject(); if (dps.getTags() != null) { for (Map.Entry<String, String> tag : dps.getTags().entrySet()) { json.writeStringField(tag.getKey(), tag.getValue()); } } json.writeEndObject(); json.writeFieldName("aggregateTags"); json.writeStartArray(); if (dps.getAggregatedTags() != null) { for (String atag : dps.getAggregatedTags()) { json.writeString(atag); } } json.writeEndArray(); if (data_query.getShowTSUIDs()) { json.writeFieldName("tsuids"); json.writeStartArray(); final List<String> tsuids = dps.getTSUIDs(); Collections.sort(tsuids); for (String tsuid : tsuids) { json.writeString(tsuid); } json.writeEndArray(); } if (!data_query.getNoAnnotations()) { final List<Annotation> annotations = dps.getAnnotations(); if (annotations != null) { Collections.sort(annotations); json.writeArrayFieldStart("annotations"); for (Annotation note : annotations) { json.writeObject(note); } json.writeEndArray(); } if (globals != null && !globals.isEmpty()) { Collections.sort(globals); json.writeArrayFieldStart("globalAnnotations"); for (Annotation note : globals) { json.writeObject(note); } json.writeEndArray(); } } // now the fun stuff, dump the data json.writeFieldName("dps"); // default is to write a map, otherwise write arrays if (as_arrays) { json.writeStartArray(); for (final DataPoint dp : dps) { if (dp.timestamp() < data_query.startTime() || dp.timestamp() > data_query.endTime()) { continue; } final long timestamp = data_query.getMsResolution() ? dp.timestamp() : dp.timestamp() / 1000; json.writeStartArray(); json.writeNumber(timestamp); json.writeNumber(dp.isInteger() ? dp.longValue() : dp.doubleValue()); json.writeEndArray(); } json.writeEndArray(); } else { json.writeStartObject(); for (final DataPoint dp : dps) { if (dp.timestamp() < (data_query.startTime()) || dp.timestamp() > (data_query.endTime())) { continue; } final long timestamp = data_query.getMsResolution() ? dp.timestamp() : dp.timestamp() / 1000; json.writeNumberField(Long.toString(timestamp), dp.isInteger() ? dp.longValue() : dp.doubleValue()); } json.writeEndObject(); } // close the results for this particular query json.writeEndObject(); } } // close json.writeEndArray(); json.close(); if (jsonp != null && !jsonp.isEmpty()) { output.write(")".getBytes()); } return response; } catch (IOException e) { LOG.error("Unexpected exception", e); throw new RuntimeException(e); } }
From source file:net.opentsdb.tsd.HttpJsonSerializer.java
/** * Format the results from a timeseries data query * @param data_query The TSQuery object used to fetch the results * @param results The data fetched from storage * @param globals An optional list of global annotation objects * @return A ChannelBuffer object to pass on to the caller *//*from w w w . j av a 2s . co m*/ public ChannelBuffer formatQueryV1(final TSQuery data_query, final List<DataPoints[]> results, final List<Annotation> globals) { final boolean as_arrays = this.query.hasQueryStringParam("arrays"); final String jsonp = this.query.getQueryStringParam("jsonp"); // todo - this should be streamed at some point since it could be HUGE final ChannelBuffer response = ChannelBuffers.dynamicBuffer(); final OutputStream output = new ChannelBufferOutputStream(response); try { // don't forget jsonp if (jsonp != null && !jsonp.isEmpty()) { output.write((jsonp + "(").getBytes(query.getCharset())); } JsonGenerator json = JSON.getFactory().createGenerator(output); json.writeStartArray(); for (DataPoints[] separate_dps : results) { for (DataPoints dps : separate_dps) { json.writeStartObject(); json.writeStringField("metric", dps.metricName()); json.writeFieldName("tags"); json.writeStartObject(); if (dps.getTags() != null) { for (Map.Entry<String, String> tag : dps.getTags().entrySet()) { json.writeStringField(tag.getKey(), tag.getValue()); } } json.writeEndObject(); json.writeFieldName("aggregateTags"); json.writeStartArray(); if (dps.getAggregatedTags() != null) { for (String atag : dps.getAggregatedTags()) { json.writeString(atag); } } json.writeEndArray(); if (data_query.getShowTSUIDs()) { json.writeFieldName("tsuids"); json.writeStartArray(); final List<String> tsuids = dps.getTSUIDs(); Collections.sort(tsuids); for (String tsuid : tsuids) { json.writeString(tsuid); } json.writeEndArray(); } if (!data_query.getNoAnnotations()) { final List<Annotation> annotations = dps.getAnnotations(); if (annotations != null) { Collections.sort(annotations); json.writeArrayFieldStart("annotations"); for (Annotation note : annotations) { json.writeObject(note); } json.writeEndArray(); } if (globals != null && !globals.isEmpty()) { Collections.sort(globals); json.writeArrayFieldStart("globalAnnotations"); for (Annotation note : globals) { json.writeObject(note); } json.writeEndArray(); } } // now the fun stuff, dump the data json.writeFieldName("dps"); // default is to write a map, otherwise write arrays if (as_arrays) { json.writeStartArray(); for (final DataPoint dp : dps) { if (dp.timestamp() < data_query.startTime() || dp.timestamp() > data_query.endTime()) { continue; } final long timestamp = data_query.getMsResolution() ? dp.timestamp() : dp.timestamp() / 1000; json.writeStartArray(); json.writeNumber(timestamp); if (dp.isInteger()) { json.writeNumber(dp.longValue()); } else { json.writeNumber(dp.doubleValue()); } json.writeEndArray(); } json.writeEndArray(); } else { json.writeStartObject(); for (final DataPoint dp : dps) { if (dp.timestamp() < (data_query.startTime()) || dp.timestamp() > (data_query.endTime())) { continue; } final long timestamp = data_query.getMsResolution() ? dp.timestamp() : dp.timestamp() / 1000; if (dp.isInteger()) { json.writeNumberField(Long.toString(timestamp), dp.longValue()); } else { json.writeNumberField(Long.toString(timestamp), dp.doubleValue()); } } json.writeEndObject(); } // close the results for this particular query json.writeEndObject(); } } // close json.writeEndArray(); json.close(); if (jsonp != null && !jsonp.isEmpty()) { output.write(")".getBytes()); } return response; } catch (IOException e) { LOG.error("Unexpected exception", e); throw new RuntimeException(e); } }
From source file:de.escalon.hypermedia.spring.de.escalon.hypermedia.spring.jackson.LinkListSerializer.java
private void writePossiblePropertyValues(JsonGenerator jgen, String currentVocab, ActionInputParameter actionInputParameter, Object[] possiblePropertyValues) throws IOException { // Enable the following to list possible values. // Problem: how to express individuals only for certain hydra:options // not all hydra:options should be taken as uris, sometimes they might be just literals // how to make that clear to the client? // maybe we must write them out for options // if (possiblePropertyValues.length > 0) { // jgen.writeArrayFieldStart("hydra:option"); //// w w w .ja v a 2 s . co m // for (Object possibleValue : possiblePropertyValues) { // // TODO: apply "hydra:option" : { "@type": "@vocab"} to context for enums // writeScalarValue(jgen, possibleValue, actionInputParameter.getParameterType()); // } // jgen.writeEndArray(); // } if (actionInputParameter.isArrayOrCollection()) { jgen.writeBooleanField(getPropertyOrClassNameInVocab(currentVocab, "multipleValues", JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:"), true); } // valueRequired (hard to say, using @Access on Event is for all update requests - or make // specific request beans for different // purposes rather than always passing an instance of e.g. Event?) // -> update is a different use case than create - or maybe have an @Requires("eventStatus") // annotation alongside requestBody to tell which attributes are required or writable, and use Requires over // bean structure, where ctor with least length of args is required and setters are supported // but optional? The bean structure does say what is writable for updates, but not what is required for creation. Right now setters are supportedProperties. For creation we would have to add constructor arguments as supportedProperties. // (/) defaultValue (pre-filled value, e.g. list of selected items for option) // valueName (for iri templates only) // (/) readonlyValue (true for final public field or absence of setter, send fixed value like hidden field?) -> use hydra:readable, hydra:writable // (/) multipleValues // (/) valueMinLength // (/) valueMaxLength // (/) valuePattern // minValue (DateTime support) // maxValue (DateTime support) // (/) stepValue final Map<String, Object> inputConstraints = actionInputParameter.getInputConstraints(); if (actionInputParameter.hasCallValue()) { if (actionInputParameter.isArrayOrCollection()) { Object[] callValues = actionInputParameter.getCallValues(); Class<?> componentType = callValues.getClass().getComponentType(); // only write defaultValue for array of scalars if (DataType.isScalar(componentType)) { jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, "defaultValue", JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:")); jgen.writeStartArray(); for (Object callValue : callValues) { writeScalarValue(jgen, callValue, componentType); } jgen.writeEndArray(); } } else { jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, "defaultValue", JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:")); writeScalarValue(jgen, actionInputParameter.getCallValueFormatted(), actionInputParameter.getNestedParameterType()); } } if (!inputConstraints.isEmpty()) { final List<String> keysToAppendValue = Arrays.asList(ActionInputParameter.MAX, ActionInputParameter.MIN, ActionInputParameter.STEP); for (String keyToAppendValue : keysToAppendValue) { final Object constraint = inputConstraints.get(keyToAppendValue); if (constraint != null) { jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, keyToAppendValue + "Value", JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:")); jgen.writeNumber(constraint.toString()); } } final List<String> keysToPrependValue = Arrays.asList(ActionInputParameter.MAX_LENGTH, ActionInputParameter.MIN_LENGTH, ActionInputParameter.PATTERN); for (String keyToPrependValue : keysToPrependValue) { final Object constraint = inputConstraints.get(keyToPrependValue); if (constraint != null) { jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, "value" + StringUtils.capitalize(keyToPrependValue), JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:")); if (ActionInputParameter.PATTERN.equals(keyToPrependValue)) { jgen.writeString(constraint.toString()); } else { jgen.writeNumber(constraint.toString()); } } } } }
From source file:de.escalon.hypermedia.spring.hydra.LinkListSerializer.java
private void writePossiblePropertyValues(JsonGenerator jgen, String currentVocab, ActionInputParameter actionInputParameter, @SuppressWarnings("unused") Object[] possiblePropertyValues) throws IOException { // Enable the following to list possible values. // Problem: how to express individuals only for certain hydra:options // not all hydra:options should be taken as uris, sometimes they might be just literals // how to make that clear to the client? // maybe we must write them out for options // if (possiblePropertyValues.length > 0) { // jgen.writeArrayFieldStart("hydra:option"); ///*from w w w .j ava2 s. c o m*/ // for (Object possibleValue : possiblePropertyValues) { // // TODO: apply "hydra:option" : { "@type": "@vocab"} to context for enums // writeScalarValue(jgen, possibleValue, rootParameter.getParameterType()); // } // jgen.writeEndArray(); // } if (actionInputParameter.isArrayOrCollection()) { jgen.writeBooleanField(getPropertyOrClassNameInVocab(currentVocab, "multipleValues", LdContextFactory.HTTP_SCHEMA_ORG, "schema:"), true); } // valueRequired (hard to say, using @Access on Event is for all update requests - or make // specific request beans for different // purposes rather than always passing an instance of e.g. Event?) // -> update is a different use case than create - or maybe have an @Requires("eventStatus") // annotation alongside requestBody to tell which attributes are required or writable, and use // Requires over // bean structure, where ctor with least length of args is required and setters are supported // but optional? The bean structure does say what is writable for updates, but not what is required // for creation. Right now setters are supportedProperties. For creation we would have to add constructor // arguments as supportedProperties. // (/) defaultValue (pre-filled value, e.g. list of selected items for option) // valueName (for iri templates only) // (/) readonlyValue (true for final public field or absence of setter, send fixed value like hidden field?) // -> use hydra:readable, hydra:writable // (/) multipleValues // (/) valueMinLength // (/) valueMaxLength // (/) valuePattern // minValue (DateTime support) // maxValue (DateTime support) // (/) stepValue final Map<String, Object> inputConstraints = actionInputParameter.getInputConstraints(); if (actionInputParameter.hasValue()) { if (actionInputParameter.isArrayOrCollection()) { Object[] callValues = actionInputParameter.getValues(); Class<?> componentType = callValues.getClass().getComponentType(); // only write defaultValue for array of scalars if (DataType.isSingleValueType(componentType)) { jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, "defaultValue", LdContextFactory.HTTP_SCHEMA_ORG, "schema:")); jgen.writeStartArray(); for (Object callValue : callValues) { writeScalarValue(jgen, callValue, componentType); } jgen.writeEndArray(); } } else { jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, "defaultValue", LdContextFactory.HTTP_SCHEMA_ORG, "schema:")); writeScalarValue(jgen, actionInputParameter.getValue(), actionInputParameter.getParameterType()); } } if (!inputConstraints.isEmpty()) { final List<String> keysToAppendValue = Arrays.asList(Input.MAX, Input.MIN, Input.STEP); for (String keyToAppendValue : keysToAppendValue) { final Object constraint = inputConstraints.get(keyToAppendValue); if (constraint != null) { jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, keyToAppendValue + "Value", LdContextFactory.HTTP_SCHEMA_ORG, "schema:")); jgen.writeNumber(constraint.toString()); } } final List<String> keysToPrependValue = Arrays.asList(Input.MAX_LENGTH, Input.MIN_LENGTH, Input.PATTERN); for (String keyToPrependValue : keysToPrependValue) { final Object constraint = inputConstraints.get(keyToPrependValue); if (constraint != null) { jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, "value" + StringUtils.capitalize(keyToPrependValue), LdContextFactory.HTTP_SCHEMA_ORG, "schema:")); if (Input.PATTERN.equals(keyToPrependValue)) { jgen.writeString(constraint.toString()); } else { jgen.writeNumber(constraint.toString()); } } } } }