propane 3.4.1-java → 3.7.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -1
- data/.mvn/wrapper/MavenWrapperDownloader.java +2 -2
- data/.mvn/wrapper/maven-wrapper.properties +2 -2
- data/.travis.yml +1 -1
- data/CHANGELOG.md +9 -1
- data/Gemfile +2 -0
- data/README.md +9 -5
- data/Rakefile +10 -11
- data/bin/propane +3 -1
- data/lib/propane.rb +4 -2
- data/lib/propane/app.rb +2 -1
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +22 -23
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +10 -9
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +20 -14
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +2 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +2 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +2 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +2 -0
- data/pom.rb +37 -36
- data/pom.xml +6 -6
- data/propane.gemspec +12 -10
- data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
- data/src/main/java/monkstone/ColorUtil.java +1 -3
- data/src/main/java/monkstone/MathToolModule.java +10 -9
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -2
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +781 -285
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +56 -52
- data/src/main/java/processing/awt/PSurfaceAWT.java +308 -208
- data/src/main/java/processing/awt/ShimAWT.java +581 -0
- data/src/main/java/processing/core/PApplet.java +4225 -4855
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +914 -880
- data/src/main/java/processing/core/PGraphics.java +150 -134
- data/src/main/java/processing/core/PImage.java +275 -372
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +478 -415
- data/src/main/java/processing/core/PMatrix3D.java +762 -735
- data/src/main/java/processing/core/PShape.java +2887 -2651
- data/src/main/java/processing/core/PShapeOBJ.java +97 -92
- data/src/main/java/processing/core/PShapeSVG.java +1705 -1490
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +139 -97
- data/src/main/java/processing/core/PSurfaceNone.java +296 -218
- data/src/main/java/processing/core/PVector.java +995 -963
- data/src/main/java/processing/core/ThinkDifferent.java +12 -8
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3690 -3510
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +957 -883
- data/src/main/java/processing/event/Event.java +87 -67
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +88 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
- data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
- data/src/main/java/processing/net/Client.java +20 -20
- data/src/main/java/processing/net/Server.java +9 -9
- data/src/main/java/processing/opengl/FontTexture.java +286 -266
- data/src/main/java/processing/opengl/FrameBuffer.java +389 -377
- data/src/main/java/processing/opengl/LinePath.java +132 -89
- data/src/main/java/processing/opengl/LineStroker.java +588 -581
- data/src/main/java/processing/opengl/PGL.java +660 -567
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
- data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
- data/src/main/java/processing/opengl/PShader.java +369 -461
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
- data/src/main/java/processing/opengl/Texture.java +1492 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +35 -22
- data/vendors/Rakefile +35 -40
- metadata +42 -22
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -30,396 +30,406 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
30
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
31
31
|
SOFTWARE.
|
32
32
|
*/
|
33
|
+
|
33
34
|
/**
|
34
35
|
* A JSONTokener takes a source string and extracts characters and tokens from
|
35
|
-
* it. It is used by the JSONObject and JSONArray constructors to parse
|
36
|
-
* source strings.
|
37
|
-
*
|
36
|
+
* it. It is used by the JSONObject and JSONArray constructors to parse
|
37
|
+
* JSON source strings.
|
38
38
|
* @author JSON.org
|
39
39
|
* @version 2012-02-16
|
40
40
|
*/
|
41
41
|
class JSONTokener {
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
private long character;
|
44
|
+
private boolean eof;
|
45
|
+
private long index;
|
46
|
+
private long line;
|
47
|
+
private char previous;
|
48
|
+
private Reader reader;
|
49
|
+
private boolean usePrevious;
|
50
50
|
|
51
|
-
/**
|
52
|
-
* Construct a JSONTokener from a Reader.
|
53
|
-
*
|
54
|
-
* @param reader A reader.
|
55
|
-
*/
|
56
|
-
public JSONTokener(Reader reader) {
|
57
|
-
this.reader = reader.markSupported()
|
58
|
-
? reader
|
59
|
-
: new BufferedReader(reader);
|
60
|
-
this.eof = false;
|
61
|
-
this.usePrevious = false;
|
62
|
-
this.previous = 0;
|
63
|
-
this.index = 0;
|
64
|
-
this.character = 1;
|
65
|
-
this.line = 1;
|
66
|
-
}
|
67
51
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
52
|
+
/**
|
53
|
+
* Construct a JSONTokener from a Reader.
|
54
|
+
*
|
55
|
+
* @param reader A reader.
|
56
|
+
*/
|
57
|
+
public JSONTokener(Reader reader) {
|
58
|
+
this.reader = reader.markSupported()
|
59
|
+
? reader
|
60
|
+
: new BufferedReader(reader);
|
61
|
+
this.eof = false;
|
62
|
+
this.usePrevious = false;
|
63
|
+
this.previous = 0;
|
64
|
+
this.index = 0;
|
65
|
+
this.character = 1;
|
66
|
+
this.line = 1;
|
67
|
+
}
|
74
68
|
|
75
|
-
/**
|
76
|
-
* Construct a JSONTokener from a string.
|
77
|
-
*
|
78
|
-
* @param s A source string.
|
79
|
-
*/
|
80
|
-
public JSONTokener(String s) {
|
81
|
-
this(new StringReader(s));
|
82
|
-
}
|
83
69
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
if (this.usePrevious || this.index <= 0) {
|
91
|
-
throw new RuntimeException("Stepping back two steps is not supported");
|
92
|
-
}
|
93
|
-
this.index -= 1;
|
94
|
-
this.character -= 1;
|
95
|
-
this.usePrevious = true;
|
96
|
-
this.eof = false;
|
97
|
-
}
|
70
|
+
/**
|
71
|
+
* Construct a JSONTokener from an InputStream.
|
72
|
+
*/
|
73
|
+
public JSONTokener(InputStream inputStream) {
|
74
|
+
this(new InputStreamReader(inputStream));
|
75
|
+
}
|
98
76
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Construct a JSONTokener from a string.
|
80
|
+
*
|
81
|
+
* @param s A source string.
|
82
|
+
*/
|
83
|
+
public JSONTokener(String s) {
|
84
|
+
this(new StringReader(s));
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Back up one character. This provides a sort of lookahead capability,
|
90
|
+
* so that you can test for a digit or letter before attempting to parse
|
91
|
+
* the next number or identifier.
|
92
|
+
*/
|
93
|
+
public void back() {
|
94
|
+
if (this.usePrevious || this.index <= 0) {
|
95
|
+
throw new RuntimeException("Stepping back two steps is not supported");
|
117
96
|
}
|
97
|
+
this.index -= 1;
|
98
|
+
this.character -= 1;
|
99
|
+
this.usePrevious = true;
|
100
|
+
this.eof = false;
|
101
|
+
}
|
102
|
+
|
118
103
|
|
119
|
-
|
120
|
-
|
104
|
+
/**
|
105
|
+
* Get the hex value of a character (base16).
|
106
|
+
* @param c A character between '0' and '9' or between 'A' and 'F' or
|
107
|
+
* between 'a' and 'f'.
|
108
|
+
* @return An int between 0 and 15, or -1 if c was not a hex digit.
|
109
|
+
*/
|
110
|
+
public static int dehexchar(char c) {
|
111
|
+
if (c >= '0' && c <= '9') {
|
112
|
+
return c - '0';
|
121
113
|
}
|
114
|
+
if (c >= 'A' && c <= 'F') {
|
115
|
+
return c - ('A' - 10);
|
116
|
+
}
|
117
|
+
if (c >= 'a' && c <= 'f') {
|
118
|
+
return c - ('a' - 10);
|
119
|
+
}
|
120
|
+
return -1;
|
121
|
+
}
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
123
|
+
public boolean end() {
|
124
|
+
return this.eof && !this.usePrevious;
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Determine if the source string still contains characters that next()
|
130
|
+
* can consume.
|
131
|
+
* @return true if not yet at the end of the source.
|
132
|
+
*/
|
133
|
+
public boolean more() {
|
134
|
+
this.next();
|
135
|
+
if (this.end()) {
|
136
|
+
return false;
|
136
137
|
}
|
138
|
+
this.back();
|
139
|
+
return true;
|
140
|
+
}
|
137
141
|
|
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
|
-
this.previous = (char) c;
|
171
|
-
return this.previous;
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Get the next character in the source string.
|
145
|
+
*
|
146
|
+
* @return The next character, or 0 if past the end of the source string.
|
147
|
+
*/
|
148
|
+
public char next() {
|
149
|
+
int c;
|
150
|
+
if (this.usePrevious) {
|
151
|
+
this.usePrevious = false;
|
152
|
+
c = this.previous;
|
153
|
+
} else {
|
154
|
+
try {
|
155
|
+
c = this.reader.read();
|
156
|
+
} catch (IOException exception) {
|
157
|
+
throw new RuntimeException(exception);
|
158
|
+
}
|
159
|
+
|
160
|
+
if (c <= 0) { // End of stream
|
161
|
+
this.eof = true;
|
162
|
+
c = 0;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
this.index += 1;
|
166
|
+
if (this.previous == '\r') {
|
167
|
+
this.line += 1;
|
168
|
+
this.character = c == '\n' ? 0 : 1;
|
169
|
+
} else if (c == '\n') {
|
170
|
+
this.line += 1;
|
171
|
+
this.character = 0;
|
172
|
+
} else {
|
173
|
+
this.character += 1;
|
172
174
|
}
|
175
|
+
this.previous = (char) c;
|
176
|
+
return this.previous;
|
177
|
+
}
|
173
178
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
}
|
187
|
-
return n;
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Consume the next character, and check that it matches a specified
|
182
|
+
* character.
|
183
|
+
* @param c The character to match.
|
184
|
+
* @return The character.
|
185
|
+
* @throws JSONException if the character does not match.
|
186
|
+
*/
|
187
|
+
public char next(char c) {
|
188
|
+
char n = this.next();
|
189
|
+
if (n != c) {
|
190
|
+
throw new RuntimeException("Expected '" + c + "' and instead saw '" + n + "'");
|
188
191
|
}
|
192
|
+
return n;
|
193
|
+
}
|
189
194
|
|
190
|
-
/**
|
191
|
-
* Get the next n characters.
|
192
|
-
*
|
193
|
-
* @param n The number of characters to take.
|
194
|
-
* @return A string of n characters.
|
195
|
-
* @throws JSONException Substring bounds error if there are not n
|
196
|
-
* characters remaining in the source string.
|
197
|
-
*/
|
198
|
-
public String next(int n) {
|
199
|
-
if (n == 0) {
|
200
|
-
return "";
|
201
|
-
}
|
202
195
|
|
203
|
-
|
204
|
-
|
196
|
+
/**
|
197
|
+
* Get the next n characters.
|
198
|
+
*
|
199
|
+
* @param n The number of characters to take.
|
200
|
+
* @return A string of n characters.
|
201
|
+
* @throws JSONException
|
202
|
+
* Substring bounds error if there are not
|
203
|
+
* n characters remaining in the source string.
|
204
|
+
*/
|
205
|
+
public String next(int n) {
|
206
|
+
if (n == 0) {
|
207
|
+
return "";
|
208
|
+
}
|
205
209
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
210
|
+
char[] chars = new char[n];
|
211
|
+
int pos = 0;
|
212
|
+
|
213
|
+
while (pos < n) {
|
214
|
+
chars[pos] = this.next();
|
215
|
+
if (this.end()) {
|
216
|
+
throw new RuntimeException("Substring bounds error");
|
217
|
+
}
|
218
|
+
pos += 1;
|
214
219
|
}
|
220
|
+
return new String(chars);
|
221
|
+
}
|
215
222
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
}
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Get the next char in the string, skipping whitespace.
|
226
|
+
* @throws JSONException
|
227
|
+
* @return A character, or 0 if there are no more characters.
|
228
|
+
*/
|
229
|
+
public char nextClean() {
|
230
|
+
for (;;) {
|
231
|
+
char c = this.next();
|
232
|
+
if (c == 0 || c > ' ') {
|
233
|
+
return c;
|
234
|
+
}
|
229
235
|
}
|
236
|
+
}
|
230
237
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
sb.append(c);
|
288
|
-
}
|
238
|
+
|
239
|
+
/**
|
240
|
+
* Return the characters up to the next close quote character.
|
241
|
+
* Backslash processing is done. The formal JSON format does not
|
242
|
+
* allow strings in single quotes, but an implementation is allowed to
|
243
|
+
* accept them.
|
244
|
+
* @param quote The quoting character, either
|
245
|
+
* <code>"</code> <small>(double quote)</small> or
|
246
|
+
* <code>'</code> <small>(single quote)</small>.
|
247
|
+
* @return A String.
|
248
|
+
* @throws JSONException Unterminated string.
|
249
|
+
*/
|
250
|
+
public String nextString(char quote) {
|
251
|
+
char c;
|
252
|
+
StringBuilder sb = new StringBuilder();
|
253
|
+
for (;;) {
|
254
|
+
c = this.next();
|
255
|
+
switch (c) {
|
256
|
+
case 0:
|
257
|
+
case '\n':
|
258
|
+
case '\r':
|
259
|
+
throw new RuntimeException("Unterminated string");
|
260
|
+
case '\\':
|
261
|
+
c = this.next();
|
262
|
+
switch (c) {
|
263
|
+
case 'b':
|
264
|
+
sb.append('\b');
|
265
|
+
break;
|
266
|
+
case 't':
|
267
|
+
sb.append('\t');
|
268
|
+
break;
|
269
|
+
case 'n':
|
270
|
+
sb.append('\n');
|
271
|
+
break;
|
272
|
+
case 'f':
|
273
|
+
sb.append('\f');
|
274
|
+
break;
|
275
|
+
case 'r':
|
276
|
+
sb.append('\r');
|
277
|
+
break;
|
278
|
+
case 'u':
|
279
|
+
sb.append((char)Integer.parseInt(this.next(4), 16));
|
280
|
+
break;
|
281
|
+
case '"':
|
282
|
+
case '\'':
|
283
|
+
case '\\':
|
284
|
+
case '/':
|
285
|
+
sb.append(c);
|
286
|
+
break;
|
287
|
+
default:
|
288
|
+
throw new RuntimeException("Illegal escape.");
|
289
|
+
}
|
290
|
+
break;
|
291
|
+
default:
|
292
|
+
if (c == quote) {
|
293
|
+
return sb.toString();
|
289
294
|
}
|
295
|
+
sb.append(c);
|
296
|
+
}
|
290
297
|
}
|
298
|
+
}
|
291
299
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
}
|
307
|
-
return sb.toString().trim();
|
308
|
-
}
|
309
|
-
sb.append(c);
|
300
|
+
|
301
|
+
/**
|
302
|
+
* Get the text up but not including the specified character or the
|
303
|
+
* end of line, whichever comes first.
|
304
|
+
* @param delimiter A delimiter character.
|
305
|
+
* @return A string.
|
306
|
+
*/
|
307
|
+
public String nextTo(char delimiter) {
|
308
|
+
StringBuilder sb = new StringBuilder();
|
309
|
+
for (;;) {
|
310
|
+
char c = this.next();
|
311
|
+
if (c == delimiter || c == 0 || c == '\n' || c == '\r') {
|
312
|
+
if (c != 0) {
|
313
|
+
this.back();
|
310
314
|
}
|
315
|
+
return sb.toString().trim();
|
316
|
+
}
|
317
|
+
sb.append(c);
|
311
318
|
}
|
319
|
+
}
|
312
320
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
}
|
330
|
-
return sb.toString().trim();
|
331
|
-
}
|
332
|
-
sb.append(c);
|
321
|
+
|
322
|
+
/**
|
323
|
+
* Get the text up but not including one of the specified delimiter
|
324
|
+
* characters or the end of line, whichever comes first.
|
325
|
+
* @param delimiters A set of delimiter characters.
|
326
|
+
* @return A string, trimmed.
|
327
|
+
*/
|
328
|
+
public String nextTo(String delimiters) {
|
329
|
+
char c;
|
330
|
+
StringBuilder sb = new StringBuilder();
|
331
|
+
for (;;) {
|
332
|
+
c = this.next();
|
333
|
+
if (delimiters.indexOf(c) >= 0 || c == 0 ||
|
334
|
+
c == '\n' || c == '\r') {
|
335
|
+
if (c != 0) {
|
336
|
+
this.back();
|
333
337
|
}
|
338
|
+
return sb.toString().trim();
|
339
|
+
}
|
340
|
+
sb.append(c);
|
334
341
|
}
|
342
|
+
}
|
335
343
|
|
336
|
-
/**
|
337
|
-
* Get the next value. The value can be a Boolean, Double, Integer,
|
338
|
-
* JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
|
339
|
-
*
|
340
|
-
* @throws JSONException If syntax error.
|
341
|
-
*
|
342
|
-
* @return An object.
|
343
|
-
*/
|
344
|
-
public Object nextValue() {
|
345
|
-
char c = this.nextClean();
|
346
|
-
String string;
|
347
344
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
345
|
+
/**
|
346
|
+
* Get the next value. The value can be a Boolean, Double, Integer,
|
347
|
+
* JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
|
348
|
+
* @throws JSONException If syntax error.
|
349
|
+
*
|
350
|
+
* @return An object.
|
351
|
+
*/
|
352
|
+
public Object nextValue() {
|
353
|
+
char c = this.nextClean();
|
354
|
+
String string;
|
355
|
+
|
356
|
+
switch (c) {
|
357
|
+
case '"':
|
358
|
+
case '\'':
|
359
|
+
return this.nextString(c);
|
360
|
+
case '{':
|
361
|
+
this.back();
|
362
|
+
return new JSONObject(this);
|
363
|
+
case '[':
|
364
|
+
this.back();
|
365
|
+
return new JSONArray(this);
|
366
|
+
}
|
359
367
|
|
360
|
-
|
368
|
+
/*
|
361
369
|
* Handle unquoted text. This could be the values true, false, or
|
362
370
|
* null, or it can be a number. An implementation (such as this one)
|
363
371
|
* is allowed to also accept non-standard forms.
|
364
372
|
*
|
365
373
|
* Accumulate characters until we reach the end of the text or a
|
366
374
|
* formatting character.
|
367
|
-
|
368
|
-
StringBuilder sb = new StringBuilder();
|
369
|
-
while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
|
370
|
-
sb.append(c);
|
371
|
-
c = this.next();
|
372
|
-
}
|
373
|
-
this.back();
|
375
|
+
*/
|
374
376
|
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
return JSONObject.stringToValue(string);
|
377
|
+
StringBuilder sb = new StringBuilder();
|
378
|
+
while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
|
379
|
+
sb.append(c);
|
380
|
+
c = this.next();
|
380
381
|
}
|
382
|
+
this.back();
|
381
383
|
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
*
|
386
|
-
* @param to A character to skip to.
|
387
|
-
* @return The requested character, or zero if the requested character is
|
388
|
-
* not found.
|
389
|
-
*/
|
390
|
-
public char skipTo(char to) {
|
391
|
-
char c;
|
392
|
-
try {
|
393
|
-
long startIndex = this.index;
|
394
|
-
long startCharacter = this.character;
|
395
|
-
long startLine = this.line;
|
396
|
-
this.reader.mark(1000000);
|
397
|
-
do {
|
398
|
-
c = this.next();
|
399
|
-
if (c == 0) {
|
400
|
-
this.reader.reset();
|
401
|
-
this.index = startIndex;
|
402
|
-
this.character = startCharacter;
|
403
|
-
this.line = startLine;
|
404
|
-
return c;
|
405
|
-
}
|
406
|
-
} while (c != to);
|
407
|
-
} catch (IOException exc) {
|
408
|
-
throw new RuntimeException(exc);
|
409
|
-
}
|
410
|
-
|
411
|
-
this.back();
|
412
|
-
return c;
|
384
|
+
string = sb.toString().trim();
|
385
|
+
if ("".equals(string)) {
|
386
|
+
throw new RuntimeException("Missing value");
|
413
387
|
}
|
388
|
+
return JSONObject.stringToValue(string);
|
389
|
+
}
|
414
390
|
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
391
|
+
|
392
|
+
/**
|
393
|
+
* Skip characters until the next character is the requested character.
|
394
|
+
* If the requested character is not found, no characters are skipped.
|
395
|
+
* @param to A character to skip to.
|
396
|
+
* @return The requested character, or zero if the requested character
|
397
|
+
* is not found.
|
398
|
+
*/
|
399
|
+
public char skipTo(char to) {
|
400
|
+
char c;
|
401
|
+
try {
|
402
|
+
long startIndex = this.index;
|
403
|
+
long startCharacter = this.character;
|
404
|
+
long startLine = this.line;
|
405
|
+
this.reader.mark(1000000);
|
406
|
+
do {
|
407
|
+
c = this.next();
|
408
|
+
if (c == 0) {
|
409
|
+
this.reader.reset();
|
410
|
+
this.index = startIndex;
|
411
|
+
this.character = startCharacter;
|
412
|
+
this.line = startLine;
|
413
|
+
return c;
|
414
|
+
}
|
415
|
+
} while (c != to);
|
416
|
+
} catch (IOException exc) {
|
417
|
+
throw new RuntimeException(exc);
|
424
418
|
}
|
419
|
+
|
420
|
+
this.back();
|
421
|
+
return c;
|
422
|
+
}
|
423
|
+
|
424
|
+
|
425
|
+
/**
|
426
|
+
* Make a printable string of this JSONTokener.
|
427
|
+
*
|
428
|
+
* @return " at {index} [character {character} line {line}]"
|
429
|
+
*/
|
430
|
+
@Override
|
431
|
+
public String toString() {
|
432
|
+
return " at " + this.index + " [character " + this.character + " line " +
|
433
|
+
this.line + "]";
|
434
|
+
}
|
425
435
|
}
|