forked from NASAWorldWind/WorldWindJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectCodec.java
More file actions
177 lines (160 loc) · 6.19 KB
/
ObjectCodec.java
File metadata and controls
177 lines (160 loc) · 6.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package org.codehaus.jackson;
import java.io.IOException;
import org.codehaus.jackson.type.JavaType;
import org.codehaus.jackson.type.TypeReference;
/**
* Abstract class that defines the interface that {@link JsonParser} and
* {@link JsonGenerator} use to serialize and deserialize regular
* Java objects (POJOs aka Beans).
*/
public abstract class ObjectCodec
{
protected ObjectCodec() { }
/*
/////////////////////////////////////////////////
// API for serialization (Object-to-JSON)
/////////////////////////////////////////////////
*/
/**
* Method to deserialize JSON content into a non-container
* type (it can be an array type, however): typically a bean, array
* or a wrapper type (like {@link java.lang.Boolean}).
*<p>
* Note: this method should NOT be used if the result type is a
* container ({@link java.util.Collection} or {@link java.util.Map}.
* The reason is that due to type erasure, key and value types
* can not be introspected when using this method.
* @param <T> Undocumented.
* @param jp Undocumented.
* @param valueType Undocumented.
* @return Undocumented.
* @throws java.io.IOException Undocumented.
* @throws org.codehaus.jackson.JsonProcessingException Undocumented.
*/
public abstract <T> T readValue(JsonParser jp, Class<T> valueType)
throws IOException, JsonProcessingException;
/**
* Method to deserialize JSON content into a Java type, reference to which is passed as argument.Type is passed
* using so-called "super type token" (see ) and specifically needs to be used if the root type is a parameterized
* (generic) container type.
*
* @param <T> Undocumented.
* @param jp Undocumented.
* @param valueTypeRef Undocumented.
* @return Undocumented.
* @throws java.io.IOException Undocumented.
* @throws org.codehaus.jackson.JsonProcessingException Undocumented.
*/
public abstract <T> T readValue(JsonParser jp, TypeReference<?> valueTypeRef)
throws IOException, JsonProcessingException;
/**
* Method to deserialize JSON content as tree expressed
* using set of {@link JsonNode} instances.Returns
root of the resulting tree (where root can consist
of just a single node if the current event is a
value event, not container).
* @param <T> Undocumented.
* @param jp Undocumented.
* @param valueType Undocumented.
* @return Undocumented.
* @throws java.io.IOException Undocumented.
* @throws org.codehaus.jackson.JsonProcessingException Undocumented.
*/
public abstract <T> T readValue(JsonParser jp, JavaType valueType)
throws IOException, JsonProcessingException;
/**
* Method to deserialize JSON content as tree expressed
* using set of {@link JsonNode} instances.Returns
root of the resulting tree (where root can consist
of just a single node if the current event is a
value event, not container).
* @param jp Undocumented.
* @return Undocumented.
* @throws java.io.IOException Undocumented.
* @throws org.codehaus.jackson.JsonProcessingException Undocumented.
*/
public abstract JsonNode readTree(JsonParser jp)
throws IOException, JsonProcessingException;
/*
/////////////////////////////////////////////////
// API for de-serialization (Json-to-Object)
/////////////////////////////////////////////////
*/
/**
* Method to serialize given Java Object, using generator
* provided.
* @param jgen Undocumented.
* @param value Undocumented.
* @throws java.io.IOException Undocumented.
* @throws org.codehaus.jackson.JsonProcessingException Undocumented.
*/
public abstract void writeValue(JsonGenerator jgen, Object value)
throws IOException, JsonProcessingException;
/**
* Method to serialize given Json Tree, using generator
* provided.
* @param jgen Undocumented.
* @param rootNode Undocumented.
* @throws java.io.IOException Undocumented.
* @throws org.codehaus.jackson.JsonProcessingException Undocumented.
*/
public abstract void writeTree(JsonGenerator jgen, JsonNode rootNode)
throws IOException, JsonProcessingException;
/*
/////////////////////////////////////////////////
// API for Tree Model handling
/////////////////////////////////////////////////
*/
/**
* Method for construct root level Object nodes
* for Tree Model instances.
*
* @return Undocumented.
* @since 1.2
*/
public abstract JsonNode createObjectNode();
/**
* Method for construct root level Array nodes
* for Tree Model instances.
*
* @return Undocumented.
* @since 1.2
*/
public abstract JsonNode createArrayNode();
/**
* Method for constructing a {@link JsonParser} for reading
* contents of a JSON tree, as if it was external serialized
* JSON content.
*
* @param n Undocumented.
* @return Undocumented.
* @since 1.3
*/
public abstract JsonParser treeAsTokens(JsonNode n);
/*
* Method for constructing a {@link JsonGenerator} that can
* be used to add content to a JSON tree.
*
* @param containerNode Container node to add contents to via created generator.
* If node is not a container node (as per {@link JsonNode#isContainerNode}),
* {@link IllegalArgumentException} will be thrown
*
c public abstract JsonGenerator treeFromTokens(JsonNode containerNode)
throws IllegalArgumentException;
*/
/**
* Convenience method for converting given JSON tree into instance of specified value type.This is equivalent to
* first constructing a {@link JsonParser} to iterate over contents of the tree, and using that parser for data
* binding.
*
* @param <T> Undocumented.
* @param n Undocumented.
* @param valueType Undocumented.
* @return Undocumented.
* @throws java.io.IOException Undocumented.
* @throws org.codehaus.jackson.JsonProcessingException Undocumented.
* @since 1.3
*/
public abstract <T> T treeToValue(JsonNode n, Class<T> valueType)
throws IOException, JsonProcessingException;
}