use of com.codename1.util.AsyncResource in project CodeRAD by shannah.
the class ParsingService method parseXML.
public AsyncResource<Element> parseXML(InputStream content, XMLParser parser) {
AsyncResource<Element> out = new AsyncResource<Element>();
start();
thread.run(() -> {
try {
Element el = parser.parse(new InputStreamReader(content, "UTF-8"));
if (autoCloseStreams)
content.close();
out.complete(el);
} catch (Throwable ex) {
out.error(ex);
}
});
return out;
}
use of com.codename1.util.AsyncResource in project CodeRAD by shannah.
the class ParsingService method parseJSON.
public AsyncResource<Map> parseJSON(String content, JSONParser parser) {
AsyncResource<Map> out = new AsyncResource<Map>();
start();
thread.run(() -> {
try {
Map m = parser.parseJSON(new StringReader(content));
out.complete(m);
} catch (Throwable ex) {
out.error(ex);
}
});
return out;
}
Aggregations