propane 3.1.0.pre-java → 3.2.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.mvn/wrapper/maven-wrapper.properties +1 -0
- data/CHANGELOG.md +1 -5
- data/README.md +23 -12
- data/Rakefile +23 -12
- data/lib/propane/helpers/version_error.rb +6 -0
- data/lib/propane/runner.rb +12 -0
- data/lib/propane/version.rb +1 -1
- data/library/slider/slider.rb +1 -1
- data/mvnw +234 -0
- data/mvnw.cmd +145 -0
- data/pom.xml +28 -27
- data/propane.gemspec +2 -2
- data/src/main/java/japplemenubar/JAppleMenuBar.java +41 -47
- data/src/main/java/monkstone/ColorUtil.java +1 -1
- data/src/main/java/monkstone/MathToolModule.java +12 -11
- data/src/main/java/monkstone/PropaneLibrary.java +9 -10
- data/src/main/java/monkstone/core/LibraryProxy.java +124 -113
- data/src/main/java/monkstone/fastmath/Deglut.java +86 -89
- data/src/main/java/monkstone/filechooser/Chooser.java +7 -13
- data/src/main/java/monkstone/noise/SimplexNoise.java +0 -1
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +4 -4
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +9 -9
- data/src/main/java/monkstone/slider/SimpleSlider.java +0 -9
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +11 -13
- data/src/main/java/monkstone/slider/Slider.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 +8 -9
- data/src/main/java/monkstone/vecmath/AppRender.java +2 -2
- data/src/main/java/monkstone/vecmath/ShapeRender.java +2 -2
- data/src/main/java/monkstone/vecmath/package-info.java +2 -2
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +2 -2
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/VideoInterface.java +11 -5
- data/src/main/java/monkstone/videoevent/package-info.java +2 -2
- data/src/main/java/processing/awt/PGraphicsJava2D.java +1742 -2243
- data/src/main/java/processing/awt/PShapeJava2D.java +268 -270
- data/src/main/java/processing/awt/PSurfaceAWT.java +821 -920
- data/src/main/java/processing/core/DesktopHandler.java +94 -0
- data/src/main/java/processing/core/PApplet.java +14170 -14082
- data/src/main/java/processing/core/PConstants.java +447 -473
- data/src/main/java/processing/core/PFont.java +867 -873
- data/src/main/java/processing/core/PGraphics.java +7193 -7428
- data/src/main/java/processing/core/PImage.java +3051 -3117
- data/src/main/java/processing/core/PMatrix.java +159 -172
- data/src/main/java/processing/core/PMatrix2D.java +403 -444
- data/src/main/java/processing/core/PMatrix3D.java +735 -749
- data/src/main/java/processing/core/PShape.java +2651 -2793
- data/src/main/java/processing/core/PShapeOBJ.java +415 -422
- data/src/main/java/processing/core/PShapeSVG.java +1466 -1475
- data/src/main/java/processing/core/PStyle.java +37 -40
- data/src/main/java/processing/core/PSurface.java +98 -103
- data/src/main/java/processing/core/PSurfaceNone.java +208 -236
- data/src/main/java/processing/core/PVector.java +961 -990
- data/src/main/java/processing/data/DoubleDict.java +709 -753
- data/src/main/java/processing/data/DoubleList.java +695 -748
- data/src/main/java/processing/data/FloatDict.java +702 -746
- data/src/main/java/processing/data/FloatList.java +697 -751
- data/src/main/java/processing/data/IntDict.java +673 -718
- data/src/main/java/processing/data/IntList.java +633 -699
- data/src/main/java/processing/data/JSONArray.java +873 -931
- data/src/main/java/processing/data/JSONObject.java +1165 -1262
- data/src/main/java/processing/data/JSONTokener.java +341 -351
- data/src/main/java/processing/data/LongDict.java +662 -707
- data/src/main/java/processing/data/LongList.java +634 -700
- data/src/main/java/processing/data/Sort.java +41 -37
- data/src/main/java/processing/data/StringDict.java +486 -522
- data/src/main/java/processing/data/StringList.java +580 -624
- data/src/main/java/processing/data/Table.java +3508 -3686
- data/src/main/java/processing/data/TableRow.java +183 -182
- data/src/main/java/processing/data/XML.java +883 -957
- data/src/main/java/processing/event/Event.java +66 -87
- data/src/main/java/processing/event/KeyEvent.java +41 -48
- data/src/main/java/processing/event/MouseEvent.java +93 -103
- data/src/main/java/processing/event/TouchEvent.java +6 -10
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +5 -69
- data/src/main/java/processing/javafx/PSurfaceFX.java +2 -7
- data/src/main/java/processing/opengl/FontTexture.java +270 -290
- data/src/main/java/processing/opengl/FrameBuffer.java +363 -375
- data/src/main/java/processing/opengl/LinePath.java +500 -543
- data/src/main/java/processing/opengl/LineStroker.java +582 -593
- data/src/main/java/processing/opengl/PGL.java +2881 -2904
- data/src/main/java/processing/opengl/PGraphics2D.java +315 -408
- data/src/main/java/processing/opengl/PGraphics3D.java +72 -107
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12043 -12230
- data/src/main/java/processing/opengl/PJOGL.java +1681 -1745
- data/src/main/java/processing/opengl/PShader.java +1257 -1260
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4599 -4662
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1030 -1047
- data/src/main/java/processing/opengl/Texture.java +1397 -1462
- data/src/main/java/processing/opengl/VertexBuffer.java +55 -57
- data/src/main/resources/icon/icon-1024.png +0 -0
- data/src/main/resources/icon/icon-128.png +0 -0
- data/src/main/resources/icon/icon-16.png +0 -0
- data/src/main/resources/icon/icon-256.png +0 -0
- data/src/main/resources/icon/icon-32.png +0 -0
- data/src/main/resources/icon/icon-48.png +0 -0
- data/src/main/resources/icon/icon-512.png +0 -0
- data/src/main/resources/icon/icon-64.png +0 -0
- data/vendors/Rakefile +1 -1
- metadata +12 -8
- data/src/main/java/processing/core/ThinkDifferent.java +0 -70
|
@@ -30,406 +30,396 @@ 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
|
-
|
|
34
33
|
/**
|
|
35
34
|
* A JSONTokener takes a source string and extracts characters and tokens from
|
|
36
|
-
* it. It is used by the JSONObject and JSONArray constructors to parse
|
|
37
|
-
*
|
|
35
|
+
* it. It is used by the JSONObject and JSONArray constructors to parse JSON
|
|
36
|
+
* source strings.
|
|
37
|
+
*
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Construct a JSONTokener from an InputStream.
|
|
72
|
-
*/
|
|
73
|
-
public JSONTokener(InputStream inputStream) {
|
|
74
|
-
this(new InputStreamReader(inputStream));
|
|
75
|
-
}
|
|
76
|
-
|
|
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;
|
|
77
50
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
public void back() {
|
|
94
|
-
if (this.usePrevious || this.index <= 0) {
|
|
95
|
-
throw new RuntimeException("Stepping back two steps is not supported");
|
|
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;
|
|
96
66
|
}
|
|
97
|
-
this.index -= 1;
|
|
98
|
-
this.character -= 1;
|
|
99
|
-
this.usePrevious = true;
|
|
100
|
-
this.eof = false;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
67
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*/
|
|
110
|
-
public static int dehexchar(char c) {
|
|
111
|
-
if (c >= '0' && c <= '9') {
|
|
112
|
-
return c - '0';
|
|
113
|
-
}
|
|
114
|
-
if (c >= 'A' && c <= 'F') {
|
|
115
|
-
return c - ('A' - 10);
|
|
116
|
-
}
|
|
117
|
-
if (c >= 'a' && c <= 'f') {
|
|
118
|
-
return c - ('a' - 10);
|
|
68
|
+
/**
|
|
69
|
+
* Construct a JSONTokener from an InputStream.
|
|
70
|
+
*/
|
|
71
|
+
public JSONTokener(InputStream inputStream) {
|
|
72
|
+
this(new InputStreamReader(inputStream));
|
|
119
73
|
}
|
|
120
|
-
return -1;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
public boolean end() {
|
|
124
|
-
return this.eof && !this.usePrevious;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
74
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (this.end()) {
|
|
136
|
-
return false;
|
|
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));
|
|
137
82
|
}
|
|
138
|
-
this.back();
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
83
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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;
|
|
84
|
+
/**
|
|
85
|
+
* Back up one character. This provides a sort of lookahead capability, so
|
|
86
|
+
* that you can test for a digit or letter before attempting to parse the
|
|
87
|
+
* next number or identifier.
|
|
88
|
+
*/
|
|
89
|
+
public void back() {
|
|
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;
|
|
174
97
|
}
|
|
175
|
-
this.previous = (char) c;
|
|
176
|
-
return this.previous;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
98
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Get the hex value of a character (base16).
|
|
101
|
+
*
|
|
102
|
+
* @param c A character between '0' and '9' or between 'A' and 'F' or
|
|
103
|
+
* between 'a' and 'f'.
|
|
104
|
+
* @return An int between 0 and 15, or -1 if c was not a hex digit.
|
|
105
|
+
*/
|
|
106
|
+
public static int dehexchar(char c) {
|
|
107
|
+
if (c >= '0' && c <= '9') {
|
|
108
|
+
return c - '0';
|
|
109
|
+
}
|
|
110
|
+
if (c >= 'A' && c <= 'F') {
|
|
111
|
+
return c - ('A' - 10);
|
|
112
|
+
}
|
|
113
|
+
if (c >= 'a' && c <= 'f') {
|
|
114
|
+
return c - ('a' - 10);
|
|
115
|
+
}
|
|
116
|
+
return -1;
|
|
191
117
|
}
|
|
192
|
-
return n;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
118
|
|
|
196
|
-
|
|
197
|
-
|
|
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 "";
|
|
119
|
+
public boolean end() {
|
|
120
|
+
return this.eof && !this.usePrevious;
|
|
208
121
|
}
|
|
209
122
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Determine if the source string still contains characters that next() can
|
|
125
|
+
* consume.
|
|
126
|
+
*
|
|
127
|
+
* @return true if not yet at the end of the source.
|
|
128
|
+
*/
|
|
129
|
+
public boolean more() {
|
|
130
|
+
this.next();
|
|
131
|
+
if (this.end()) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
this.back();
|
|
135
|
+
return true;
|
|
219
136
|
}
|
|
220
|
-
return new String(chars);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
137
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Get the next character in the source string.
|
|
140
|
+
*
|
|
141
|
+
* @return The next character, or 0 if past the end of the source string.
|
|
142
|
+
*/
|
|
143
|
+
public char next() {
|
|
144
|
+
int c;
|
|
145
|
+
if (this.usePrevious) {
|
|
146
|
+
this.usePrevious = false;
|
|
147
|
+
c = this.previous;
|
|
148
|
+
} else {
|
|
149
|
+
try {
|
|
150
|
+
c = this.reader.read();
|
|
151
|
+
} catch (IOException exception) {
|
|
152
|
+
throw new RuntimeException(exception);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (c <= 0) { // End of stream
|
|
156
|
+
this.eof = true;
|
|
157
|
+
c = 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
this.index += 1;
|
|
161
|
+
if (this.previous == '\r') {
|
|
162
|
+
this.line += 1;
|
|
163
|
+
this.character = c == '\n' ? 0 : 1;
|
|
164
|
+
} else if (c == '\n') {
|
|
165
|
+
this.line += 1;
|
|
166
|
+
this.character = 0;
|
|
167
|
+
} else {
|
|
168
|
+
this.character += 1;
|
|
169
|
+
}
|
|
170
|
+
this.previous = (char) c;
|
|
171
|
+
return this.previous;
|
|
235
172
|
}
|
|
236
|
-
}
|
|
237
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Consume the next character, and check that it matches a specified
|
|
176
|
+
* character.
|
|
177
|
+
*
|
|
178
|
+
* @param c The character to match.
|
|
179
|
+
* @return The character.
|
|
180
|
+
* @throws JSONException if the character does not match.
|
|
181
|
+
*/
|
|
182
|
+
public char next(char c) {
|
|
183
|
+
char n = this.next();
|
|
184
|
+
if (n != c) {
|
|
185
|
+
throw new RuntimeException("Expected '" + c + "' and instead saw '" + n + "'");
|
|
186
|
+
}
|
|
187
|
+
return n;
|
|
188
|
+
}
|
|
238
189
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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.");
|
|
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 "";
|
|
289
201
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
202
|
+
|
|
203
|
+
char[] chars = new char[n];
|
|
204
|
+
int pos = 0;
|
|
205
|
+
|
|
206
|
+
while (pos < n) {
|
|
207
|
+
chars[pos] = this.next();
|
|
208
|
+
if (this.end()) {
|
|
209
|
+
throw new RuntimeException("Substring bounds error");
|
|
210
|
+
}
|
|
211
|
+
pos += 1;
|
|
294
212
|
}
|
|
295
|
-
|
|
296
|
-
}
|
|
213
|
+
return new String(chars);
|
|
297
214
|
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
215
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
this.back();
|
|
216
|
+
/**
|
|
217
|
+
* Get the next char in the string, skipping whitespace.
|
|
218
|
+
*
|
|
219
|
+
* @throws JSONException
|
|
220
|
+
* @return A character, or 0 if there are no more characters.
|
|
221
|
+
*/
|
|
222
|
+
public char nextClean() {
|
|
223
|
+
for (;;) {
|
|
224
|
+
char c = this.next();
|
|
225
|
+
if (c == 0 || c > ' ') {
|
|
226
|
+
return c;
|
|
227
|
+
}
|
|
314
228
|
}
|
|
315
|
-
return sb.toString().trim();
|
|
316
|
-
}
|
|
317
|
-
sb.append(c);
|
|
318
229
|
}
|
|
319
|
-
}
|
|
320
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Return the characters up to the next close quote character. Backslash
|
|
233
|
+
* processing is done. The formal JSON format does not allow strings in
|
|
234
|
+
* single quotes, but an implementation is allowed to accept them.
|
|
235
|
+
*
|
|
236
|
+
* @param quote The quoting character, either
|
|
237
|
+
* <code>"</code> <small>(double quote)</small> or
|
|
238
|
+
* <code>'</code> <small>(single quote)</small>.
|
|
239
|
+
* @return A String.
|
|
240
|
+
* @throws JSONException Unterminated string.
|
|
241
|
+
*/
|
|
242
|
+
public String nextString(char quote) {
|
|
243
|
+
char c;
|
|
244
|
+
StringBuilder sb = new StringBuilder();
|
|
245
|
+
for (;;) {
|
|
246
|
+
c = this.next();
|
|
247
|
+
switch (c) {
|
|
248
|
+
case 0:
|
|
249
|
+
case '\n':
|
|
250
|
+
case '\r':
|
|
251
|
+
throw new RuntimeException("Unterminated string");
|
|
252
|
+
case '\\':
|
|
253
|
+
c = this.next();
|
|
254
|
+
switch (c) {
|
|
255
|
+
case 'b':
|
|
256
|
+
sb.append('\b');
|
|
257
|
+
break;
|
|
258
|
+
case 't':
|
|
259
|
+
sb.append('\t');
|
|
260
|
+
break;
|
|
261
|
+
case 'n':
|
|
262
|
+
sb.append('\n');
|
|
263
|
+
break;
|
|
264
|
+
case 'f':
|
|
265
|
+
sb.append('\f');
|
|
266
|
+
break;
|
|
267
|
+
case 'r':
|
|
268
|
+
sb.append('\r');
|
|
269
|
+
break;
|
|
270
|
+
case 'u':
|
|
271
|
+
sb.append((char) Integer.parseInt(this.next(4), 16));
|
|
272
|
+
break;
|
|
273
|
+
case '"':
|
|
274
|
+
case '\'':
|
|
275
|
+
case '\\':
|
|
276
|
+
case '/':
|
|
277
|
+
sb.append(c);
|
|
278
|
+
break;
|
|
279
|
+
default:
|
|
280
|
+
throw new RuntimeException("Illegal escape.");
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
default:
|
|
284
|
+
if (c == quote) {
|
|
285
|
+
return sb.toString();
|
|
286
|
+
}
|
|
287
|
+
sb.append(c);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
321
291
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
char
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Get the text up but not including the specified character or the end of
|
|
294
|
+
* line, whichever comes first.
|
|
295
|
+
*
|
|
296
|
+
* @param delimiter A delimiter character.
|
|
297
|
+
* @return A string.
|
|
298
|
+
*/
|
|
299
|
+
public String nextTo(char delimiter) {
|
|
300
|
+
StringBuilder sb = new StringBuilder();
|
|
301
|
+
for (;;) {
|
|
302
|
+
char c = this.next();
|
|
303
|
+
if (c == delimiter || c == 0 || c == '\n' || c == '\r') {
|
|
304
|
+
if (c != 0) {
|
|
305
|
+
this.back();
|
|
306
|
+
}
|
|
307
|
+
return sb.toString().trim();
|
|
308
|
+
}
|
|
309
|
+
sb.append(c);
|
|
337
310
|
}
|
|
338
|
-
return sb.toString().trim();
|
|
339
|
-
}
|
|
340
|
-
sb.append(c);
|
|
341
311
|
}
|
|
342
|
-
}
|
|
343
312
|
|
|
313
|
+
/**
|
|
314
|
+
* Get the text up but not including one of the specified delimiter
|
|
315
|
+
* characters or the end of line, whichever comes first.
|
|
316
|
+
*
|
|
317
|
+
* @param delimiters A set of delimiter characters.
|
|
318
|
+
* @return A string, trimmed.
|
|
319
|
+
*/
|
|
320
|
+
public String nextTo(String delimiters) {
|
|
321
|
+
char c;
|
|
322
|
+
StringBuilder sb = new StringBuilder();
|
|
323
|
+
for (;;) {
|
|
324
|
+
c = this.next();
|
|
325
|
+
if (delimiters.indexOf(c) >= 0 || c == 0
|
|
326
|
+
|| c == '\n' || c == '\r') {
|
|
327
|
+
if (c != 0) {
|
|
328
|
+
this.back();
|
|
329
|
+
}
|
|
330
|
+
return sb.toString().trim();
|
|
331
|
+
}
|
|
332
|
+
sb.append(c);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
344
335
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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;
|
|
355
347
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
348
|
+
switch (c) {
|
|
349
|
+
case '"':
|
|
350
|
+
case '\'':
|
|
351
|
+
return this.nextString(c);
|
|
352
|
+
case '{':
|
|
353
|
+
this.back();
|
|
354
|
+
return new JSONObject(this);
|
|
355
|
+
case '[':
|
|
356
|
+
this.back();
|
|
357
|
+
return new JSONArray(this);
|
|
358
|
+
}
|
|
367
359
|
|
|
368
|
-
|
|
360
|
+
/*
|
|
369
361
|
* Handle unquoted text. This could be the values true, false, or
|
|
370
362
|
* null, or it can be a number. An implementation (such as this one)
|
|
371
363
|
* is allowed to also accept non-standard forms.
|
|
372
364
|
*
|
|
373
365
|
* Accumulate characters until we reach the end of the text or a
|
|
374
366
|
* formatting character.
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
this.back();
|
|
383
|
-
|
|
384
|
-
string = sb.toString().trim();
|
|
385
|
-
if ("".equals(string)) {
|
|
386
|
-
throw new RuntimeException("Missing value");
|
|
387
|
-
}
|
|
388
|
-
return JSONObject.stringToValue(string);
|
|
389
|
-
}
|
|
390
|
-
|
|
367
|
+
*/
|
|
368
|
+
StringBuilder sb = new StringBuilder();
|
|
369
|
+
while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
|
|
370
|
+
sb.append(c);
|
|
371
|
+
c = this.next();
|
|
372
|
+
}
|
|
373
|
+
this.back();
|
|
391
374
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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;
|
|
375
|
+
string = sb.toString().trim();
|
|
376
|
+
if ("".equals(string)) {
|
|
377
|
+
throw new RuntimeException("Missing value");
|
|
414
378
|
}
|
|
415
|
-
|
|
416
|
-
} catch (IOException exc) {
|
|
417
|
-
throw new RuntimeException(exc);
|
|
379
|
+
return JSONObject.stringToValue(string);
|
|
418
380
|
}
|
|
419
381
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
382
|
+
/**
|
|
383
|
+
* Skip characters until the next character is the requested character. If
|
|
384
|
+
* the requested character is not found, no characters are skipped.
|
|
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
|
+
}
|
|
423
410
|
|
|
411
|
+
this.back();
|
|
412
|
+
return c;
|
|
413
|
+
}
|
|
424
414
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
415
|
+
/**
|
|
416
|
+
* Make a printable string of this JSONTokener.
|
|
417
|
+
*
|
|
418
|
+
* @return " at {index} [character {character} line {line}]"
|
|
419
|
+
*/
|
|
420
|
+
@Override
|
|
421
|
+
public String toString() {
|
|
422
|
+
return " at " + this.index + " [character " + this.character + " line "
|
|
423
|
+
+ this.line + "]";
|
|
424
|
+
}
|
|
435
425
|
}
|