-
Notifications
You must be signed in to change notification settings - Fork 2
/
JsonGenerator.java
105 lines (94 loc) · 3.39 KB
/
JsonGenerator.java
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
/**
* Copyright (C) 2017 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jsonld.serialization;
import java.io.IOException;
/**
* Represents interface to the underlying JAXB implementation, which handles the actual value serialization.
*/
public interface JsonGenerator {
/**
* Writes a field name (JSON string surrounded by double quotes).
* <p>
* Can be used only in an object, when a field name is expected.
*
* @param name Field name to write
* @throws IOException When JSON writing error occurs
*/
void writeFieldName(String name) throws IOException;
/**
* Writes a starting marker of a JSON object value (the '{' character).
* <p>
* Can be used anywhere except when a field name is expected.
*
* @throws IOException When JSON writing error occurs
*/
void writeObjectStart() throws IOException;
/**
* Writes a closing marker of a JSON object value (the '}' character).
* <p>
* Can be used for closing objects either after a complete value or an object opening marker.
*
* @throws IOException When JSON writing error occurs
*/
void writeObjectEnd() throws IOException;
/**
* Writes an opening marker of a JSON array value (the '[' character).
* <p>
* Can be used anywhere except when a field name is expected.
*
* @throws IOException When JSON writing error occurs
*/
void writeArrayStart() throws IOException;
/**
* Writes a closing marker of a JSON array value(the ']' character).
* <p>
* Can be used when the innermost structured type is array.
*
* @throws IOException When JSON writing error occurs
*/
void writeArrayEnd() throws IOException;
/**
* Outputs the given numeric value as a JSON number.
*
* @param number Number to write
* @throws IOException When JSON writing error occurs
*/
void writeNumber(Number number) throws IOException;
/**
* Outputs the given boolean value as a JSON boolean.
*
* @param value Value to write
* @throws IOException When JSON writing error occurs
*/
void writeBoolean(boolean value) throws IOException;
/**
* Outputs JSON literal {@code null} value.
* <p>
* This is usually not used, because {@code null} values are by default omitted by the serialization. But this can
* be configurable.
*
* @throws IOException When JSON writing error occurs
*/
void writeNull() throws IOException;
/**
* Outputs a String value.
* <p>
* Escaping will be done by the underlying implementation.
*
* @param text Text to write
* @throws IOException When JSON writing error occurs
*/
void writeString(String text) throws IOException;
}