public Parsed<State> parse(Reader r, Parsed<State> parsed) throws ParseException {
// First things first, if there's a "leftover" event, process that immediately
State state = (State)parsed.state;
- if(state.unsent > 0) {
+ if (state.unsent > 0) {
parsed.event = state.unsent;
state.unsent = 0;
return parsed;
boolean go = true;
try {
// Gather data from Reader, looking for special characters when not in Quotes
- while(go && (ch=r.read())>=0) {
- if(state.braces>=0 || ch==Parse.START_OBJ) { // ignore garbage/whitespace before content
+ while (go && (ch=r.read())>=0) {
+ if (state.braces>=0 || ch==Parse.START_OBJ) { // ignore garbage/whitespace before content
c=(char)ch;
// Character is a quote.
- if(c=='"') {
- if(inQuotes) {
- if(escaped) { // if escaped Quote, add to data.
+ if (c=='"') {
+ if (inQuotes) {
+ if (escaped) { // if escaped Quote, add to data.
sb.append(c);
escaped = false;
} else {
inQuotes = true;
}
} else { // Not a Quote
- if(inQuotes) {
- if(c=='\\') {
- if(escaped) {
+ if (inQuotes) {
+ if (c=='\\') {
+ if (escaped) {
sb.append("\\\\");
escaped = false;
} else {
parsed.isString = false;
break;
case Parse.START_OBJ:
- if(state.braces++ == 0) {
+ if (state.braces++ == 0) {
parsed.event = START_DOC;
state.unsent = c;
} else {
go = false;
break;
case Parse.END_OBJ:
- if(--state.braces == 0) {
+ if (--state.braces == 0) {
parsed.event = c;
state.unsent = END_DOC;
} else {
break;
// These three end the data gathering, and send it along with the event that is ending the data gathering
case Parse.NEXT:
- if(parsed.name.startsWith("__")) {
+ if (parsed.name.startsWith("__")) {
parsed.event = Parse.ATTRIB;
parsed.name = parsed.name.substring(2);
} else {