本文整理汇总了Java中com.koushikdutta.async.parser.AsyncParser类的典型用法代码示例。如果您正苦于以下问题:Java AsyncParser类的具体用法?Java AsyncParser怎么用?Java AsyncParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncParser类属于com.koushikdutta.async.parser包,在下文中一共展示了AsyncParser类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.koushikdutta.async.parser.AsyncParser; //导入依赖的package包/类
public <T> SimpleFuture<T> execute(AsyncHttpRequest req, final AsyncParser<T> parser, final RequestCallback<T> callback) {
final FutureAsyncHttpResponse cancel = new FutureAsyncHttpResponse();
final SimpleFuture<T> ret = new SimpleFuture<T>();
execute(req, 0, cancel, new HttpConnectCallback() {
@Override
public void onConnectCompleted(Exception ex, final AsyncHttpResponse response) {
if (ex != null) {
invoke(callback, ret, response, ex, null);
return;
}
invokeConnect(callback, response);
Future<T> parsed = parser.parse(response)
.setCallback(new FutureCallback<T>() {
@Override
public void onCompleted(Exception e, T result) {
invoke(callback, ret, response, e, result);
}
});
// reparent to the new parser future
ret.setParent(parsed);
}
});
ret.setParent(cancel);
return ret;
}
示例2: execute
import com.koushikdutta.async.parser.AsyncParser; //导入依赖的package包/类
private <T> SimpleFuture<T> execute(AsyncHttpRequest req, final AsyncParser<T> parser, final RequestCallback<T> callback) {
final FutureAsyncHttpResponse cancel = new FutureAsyncHttpResponse();
final SimpleFuture<T> ret = new SimpleFuture<T>();
final Handler handler = req.getHandler();
execute(req, 0, cancel, new HttpConnectCallback() {
@Override
public void onConnectCompleted(Exception ex, final AsyncHttpResponse response) {
if (ex != null) {
invoke(handler, callback, ret, response, ex, null);
return;
}
invokeConnect(callback, response);
final int contentLength = response.getHeaders().getContentLength();
Future<T> parsed = parser.parse(response)
.setCallback(new FutureCallback<T>() {
@Override
public void onCompleted(Exception e, T result) {
invoke(handler, callback, ret, response, e, result);
}
});
// reparent to the new parser future
ret.setParent(parsed);
}
});
ret.setParent(cancel);
return ret;
}