Returns the next event encountered in the JSON stream, one of #STRING #LONG #NUMBER #BIGNUMBER #BOOLEAN #NULL #OBJECT_START #OBJECT_END #OBJECT_END {@link #ARRAY_
()
| 1042 | * </ul> |
| 1043 | */ |
| 1044 | public int nextEvent() throws IOException { |
| 1045 | if (valstate != 0) { |
| 1046 | if (valstate == STRING) { |
| 1047 | readStringChars2(devNull, start); |
| 1048 | } else if (valstate == BIGNUMBER) { |
| 1049 | continueNumber(devNull); |
| 1050 | } |
| 1051 | valstate = 0; |
| 1052 | } |
| 1053 | |
| 1054 | int ch; |
| 1055 | outer: |
| 1056 | for (; ; ) { |
| 1057 | switch (state) { |
| 1058 | case 0: |
| 1059 | event = next(getChar()); |
| 1060 | if (event == STRING && (flags & OPTIONAL_OUTER_BRACES) != 0) { |
| 1061 | if (start > 0) start--; |
| 1062 | missingOpeningBrace = true; |
| 1063 | stringTerm = 0; |
| 1064 | valstate = 0; |
| 1065 | event = next('{'); |
| 1066 | } |
| 1067 | return event; |
| 1068 | case DID_OBJSTART: |
| 1069 | ch = getCharExpected('"'); |
| 1070 | if (ch == '}') { |
| 1071 | pop(); |
| 1072 | return event = OBJECT_END; |
| 1073 | } |
| 1074 | if (ch == '"') { |
| 1075 | stringTerm = ch; |
| 1076 | } else if (ch == ',' && (flags & ALLOW_EXTRA_COMMAS) != 0) { |
| 1077 | continue outer; |
| 1078 | } else { |
| 1079 | handleNonDoubleQuoteString(ch, true); |
| 1080 | } |
| 1081 | state = DID_MEMNAME; |
| 1082 | valstate = STRING; |
| 1083 | return event = STRING; |
| 1084 | case DID_MEMNAME: |
| 1085 | ch = getCharExpected(':'); |
| 1086 | if (ch != ':') { |
| 1087 | if ((ch == '{' || ch == '[') |
| 1088 | && (flags & ALLOW_MISSING_COLON_COMMA_BEFORE_OBJECT) != 0) { |
| 1089 | start--; |
| 1090 | } else { |
| 1091 | throw err("Expected key,value separator ':'"); |
| 1092 | } |
| 1093 | } |
| 1094 | state = DID_MEMVAL; // set state first because it might be pushed... |
| 1095 | return event = next(getChar()); |
| 1096 | case DID_MEMVAL: |
| 1097 | ch = getCharExpected(','); |
| 1098 | if (ch == '}') { |
| 1099 | pop(); |
| 1100 | return event = OBJECT_END; |
| 1101 | } else if (ch != ',') { |