public interface ResetHook extends JsonHandlerBase
JsonParser.reset() call.
JsonParser is designed to be reused, because it's allocation costs are pretty high,
but parser's handlers couldn't be updated after construction, ResetHook allows to reuse
the handlers implementation too.
Example usage:
class MapConstructor implements ObjectKeyHandler, StringValueHandler, ResetHook {
private Map<String, String> map = new HashMap<String, String>();
private String key;
public Map<String, String> getMap() {
return map;
}
@Override
public boolean onObjectKey(CharSequence key) {
key = key.toString();
return true;
}
@Override
public boolean onStringValue(CharSequence value) throws InvalidArgumentException {
if (key == null)
throw new InvalidArgumentException("Only objects are expected");
map.put(key, value.toString());
key = null;
return true;
}
@Override
public void onReset() {
map = new HashMap<String, String>();
}
}
| Modifier and Type | Method and Description |
|---|---|
void |
onReset()
Performs an action on
JsonParser.reset() call. |
void onReset()
JsonParser.reset() call.
Unchecked exceptions, that might be thrown in this method, are relayed to
the JsonParser.reset() caller.
Copyright © 2015. All rights reserved.