throw exception;
}
}
private static void replace(FacesContext context, UIComponent effect, StringBuffer s) throws Exception {
JSONTokener x = new JSONTokener(s.toString());
char c;
String key;
if (x.nextClean() != '{') {
throw x.syntaxError("A JSONObject text must begin with '{'");
}
for (;;) {
int idx;
c = x.nextClean();
switch (c) {
case 0:
throw x.syntaxError("A JSONObject text must end with '}'");
case '}':
return;
default:
x.back();
idx = x.getMyIndex();
//System.out.println(s.substring(x.getMyIndex()));
key = x.nextValue().toString();
}
/*
* The key is followed by ':'. We will also tolerate '=' or '=>'.
*/
c = x.nextClean();
if (c == '=') {
if (x.next() != '>') {
x.back();
}
} else if (c != ':') {
throw x.syntaxError("Expected a ':' after a key");
}
if ("id".equals(key)) {
Object value = x.nextValue();
UIComponent component = RendererUtils.getInstance().findComponentFor(effect, value.toString());
if (component != null) {
value = component.getClientId(context);
}
s.replace(idx, x.getMyIndex(), "'id': '" + value + "'");
return ;
} else {
x.nextValue();
}
/*
* Pairs are separated by ','. We will also tolerate ';'.
*/
switch (x.nextClean()) {
case ';':
case ',':
if (x.nextClean() == '}') {
return;
}
x.back();
break;
case '}':
return;
default:
throw x.syntaxError("Expected a ',' or '}'");
}
}
}