blob: 55c880f62470431897fe8cda9af2d754f2a0bcb7 [file] [log] [blame]
Tatu Saloranta29552ca2013-05-17 20:36:07 -07001package com.fasterxml.jackson.databind.node;
2
3import java.math.BigDecimal;
4import java.math.BigInteger;
5
Tatu Saloranta04c9cf52015-04-01 20:37:16 -07006import com.fasterxml.jackson.databind.util.RawValue;
7
Tatu Saloranta29552ca2013-05-17 20:36:07 -07008/**
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 Veitasf81a3f92016-04-04 07:45:49 -040012 *
Tatu Saloranta29552ca2013-05-17 20:36:07 -070013 * @since 2.3
14 */
15public interface JsonNodeCreator
16{
17 // Enumerated/singleton types
Matt Veitasf81a3f92016-04-04 07:45:49 -040018
Tatu Saloranta29552ca2013-05-17 20:36:07 -070019 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 Saloranta04c9cf52015-04-01 20:37:16 -070039 // Textual nodes
Tatu Saloranta29552ca2013-05-17 20:36:07 -070040
41 public ValueNode textNode(String text);
Tatu Saloranta04c9cf52015-04-01 20:37:16 -070042
43 // Other value (non-structured) nodes
Matt Veitasf81a3f92016-04-04 07:45:49 -040044
Tatu Saloranta29552ca2013-05-17 20:36:07 -070045 public ValueNode binaryNode(byte[] data);
46 public ValueNode binaryNode(byte[] data, int offset, int length);
47 public ValueNode pojoNode(Object pojo);
48
Tatu Saloranta04c9cf52015-04-01 20:37:16 -070049 /**
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 Veitasf81a3f92016-04-04 07:45:49 -040057 *
Tatu Saloranta04c9cf52015-04-01 20:37:16 -070058 * @since 2.6
59 */
60 public ValueNode rawValueNode(RawValue value);
61
Tatu Saloranta29552ca2013-05-17 20:36:07 -070062 // Structured nodes:
63 // (bit unkosher, due to forward references... but has to do for now)
64
65 public ArrayNode arrayNode();
Tatu Saloranta5df90562016-04-21 11:10:49 -070066
67 /**
68 * Factory method for constructing a JSON Array node with an initial capacity
69 *
70 * @since 2.8
71 */
Matt Veitasf81a3f92016-04-04 07:45:49 -040072 public ArrayNode arrayNode(int capacity);
Tatu Saloranta5df90562016-04-21 11:10:49 -070073
Tatu Saloranta29552ca2013-05-17 20:36:07 -070074 public ObjectNode objectNode();
75}