Tatu Saloranta | 29552ca | 2013-05-17 20:36:07 -0700 | [diff] [blame] | 1 | package com.fasterxml.jackson.databind.node; |
| 2 | |
| 3 | import java.math.BigDecimal; |
| 4 | import java.math.BigInteger; |
| 5 | |
Tatu Saloranta | 04c9cf5 | 2015-04-01 20:37:16 -0700 | [diff] [blame] | 6 | import com.fasterxml.jackson.databind.util.RawValue; |
| 7 | |
Tatu Saloranta | 29552ca | 2013-05-17 20:36:07 -0700 | [diff] [blame] | 8 | /** |
| 9 | * Interface that defines common "creator" functionality implemented |
| 10 | * both by {@link JsonNodeFactory} and {@link ContainerNode} (that is, |
| 11 | * JSON Object and Array nodes). |
Matt Veitas | f81a3f9 | 2016-04-04 07:45:49 -0400 | [diff] [blame] | 12 | * |
Tatu Saloranta | 29552ca | 2013-05-17 20:36:07 -0700 | [diff] [blame] | 13 | * @since 2.3 |
| 14 | */ |
| 15 | public interface JsonNodeCreator |
| 16 | { |
| 17 | // Enumerated/singleton types |
Matt Veitas | f81a3f9 | 2016-04-04 07:45:49 -0400 | [diff] [blame] | 18 | |
Tatu Saloranta | 29552ca | 2013-05-17 20:36:07 -0700 | [diff] [blame] | 19 | public ValueNode booleanNode(boolean v); |
| 20 | public ValueNode nullNode(); |
| 21 | |
| 22 | // Numeric types |
| 23 | |
| 24 | public ValueNode numberNode(byte v); |
| 25 | public ValueNode numberNode(Byte value); |
| 26 | public ValueNode numberNode(short v); |
| 27 | public ValueNode numberNode(Short value); |
| 28 | public ValueNode numberNode(int v); |
| 29 | public ValueNode numberNode(Integer value); |
| 30 | public ValueNode numberNode(long v); |
| 31 | public ValueNode numberNode(Long value); |
| 32 | public ValueNode numberNode(BigInteger v); |
| 33 | public ValueNode numberNode(float v); |
| 34 | public ValueNode numberNode(Float value); |
| 35 | public ValueNode numberNode(double v); |
| 36 | public ValueNode numberNode(Double value); |
| 37 | public ValueNode numberNode(BigDecimal v); |
| 38 | |
Tatu Saloranta | 04c9cf5 | 2015-04-01 20:37:16 -0700 | [diff] [blame] | 39 | // Textual nodes |
Tatu Saloranta | 29552ca | 2013-05-17 20:36:07 -0700 | [diff] [blame] | 40 | |
| 41 | public ValueNode textNode(String text); |
Tatu Saloranta | 04c9cf5 | 2015-04-01 20:37:16 -0700 | [diff] [blame] | 42 | |
| 43 | // Other value (non-structured) nodes |
Matt Veitas | f81a3f9 | 2016-04-04 07:45:49 -0400 | [diff] [blame] | 44 | |
Tatu Saloranta | 29552ca | 2013-05-17 20:36:07 -0700 | [diff] [blame] | 45 | public ValueNode binaryNode(byte[] data); |
| 46 | public ValueNode binaryNode(byte[] data, int offset, int length); |
| 47 | public ValueNode pojoNode(Object pojo); |
| 48 | |
Tatu Saloranta | 04c9cf5 | 2015-04-01 20:37:16 -0700 | [diff] [blame] | 49 | /** |
| 50 | * Factory method to use for adding "raw values"; pre-encoded values |
| 51 | * that are included exactly as-is when node is serialized. |
| 52 | * This may be used, for example, to include fully serialized JSON |
| 53 | * sub-trees. |
| 54 | * Note that the concept may not work with all backends, and since |
| 55 | * no translation of any kinds is done it will not work when converting |
| 56 | * between data formats. |
Matt Veitas | f81a3f9 | 2016-04-04 07:45:49 -0400 | [diff] [blame] | 57 | * |
Tatu Saloranta | 04c9cf5 | 2015-04-01 20:37:16 -0700 | [diff] [blame] | 58 | * @since 2.6 |
| 59 | */ |
| 60 | public ValueNode rawValueNode(RawValue value); |
| 61 | |
Tatu Saloranta | 29552ca | 2013-05-17 20:36:07 -0700 | [diff] [blame] | 62 | // Structured nodes: |
| 63 | // (bit unkosher, due to forward references... but has to do for now) |
| 64 | |
| 65 | public ArrayNode arrayNode(); |
Tatu Saloranta | 5df9056 | 2016-04-21 11:10:49 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Factory method for constructing a JSON Array node with an initial capacity |
| 69 | * |
| 70 | * @since 2.8 |
| 71 | */ |
Matt Veitas | f81a3f9 | 2016-04-04 07:45:49 -0400 | [diff] [blame] | 72 | public ArrayNode arrayNode(int capacity); |
Tatu Saloranta | 5df9056 | 2016-04-21 11:10:49 -0700 | [diff] [blame] | 73 | |
Tatu Saloranta | 29552ca | 2013-05-17 20:36:07 -0700 | [diff] [blame] | 74 | public ObjectNode objectNode(); |
| 75 | } |