enterprises.orbital.impl.evexmlapi.crp.OutpostServiceDetailParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eve-xml-api Show documentation
Show all versions of eve-xml-api Show documentation
Library to interact with EVE XML API servers
package enterprises.orbital.impl.evexmlapi.crp;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import org.apache.commons.digester.Digester;
import enterprises.orbital.evexmlapi.crp.IOutpostServiceDetail;
import enterprises.orbital.impl.evexmlapi.AbstractAPIRequestAdapter;
import enterprises.orbital.impl.evexmlapi.AbstractApiParser;
import enterprises.orbital.impl.evexmlapi.ApiAuth;
import enterprises.orbital.impl.evexmlapi.ApiConnector;
import enterprises.orbital.impl.evexmlapi.ApiEndpoint;
public class OutpostServiceDetailParser extends AbstractApiParser> {
private Long itemID;
public OutpostServiceDetailParser(ApiConnector connector, Long itemID) {
super(connector, OutpostServiceDetailResponse.class, ApiEndpoint.CRP_OUTPOST_SERVICE_DETAIL_V2);
this.itemID = itemID;
}
@Override
protected Digester getDigester() {
Digester digester = super.getDigester();
digester.addObjectCreate("eveapi/result/rowset/row", ApiOutpostServiceDetail.class);
digester.addSetProperties("eveapi/result/rowset/row");
digester.addSetNext("eveapi/result/rowset/row", "addOutpost");
return digester;
}
private OutpostServiceDetailResponse getResponseWithItemID(ApiAuth auth) throws IOException {
if (itemID != null)
return getResponse(auth, "itemID", Long.toString(itemID));
else
return getResponse(auth);
}
@Override
public Collection retrieveResponse(AbstractAPIRequestAdapter adapter) throws IOException {
OutpostServiceDetailResponse response = getResponseWithItemID(adapter.getAuth());
adapter.setFromLastResponse(response);
if (adapter.isError()) return null;
Collection result = new HashSet();
result.addAll(response.getOutposts());
return result;
}
}