org.gcube.resources.discovery.client.impl
Class DelegateClient<R>

java.lang.Object
  extended by org.gcube.resources.discovery.client.impl.DelegateClient<R>
Type Parameters:
R - the type of query results
All Implemented Interfaces:
DiscoveryClient<R>

public class DelegateClient<R>
extends Object
implements DiscoveryClient<R>

A DiscoveryClient that delegates the execution of queries to another DiscoveryClient that does not perform result parsing and the parsing itself to a dedicated ResultParser.

Author:
Fabio Simeoni

Constructor Summary
DelegateClient(ResultParser<R> parser, DiscoveryClient<String> inner)
          Creates an instance with a given ResultParser and a DiscoveryClient that produces untyped results
 
Method Summary
 List<R> submit(Query query)
          Submits a Query for remote execution and returns a list of typed results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegateClient

public DelegateClient(ResultParser<R> parser,
                      DiscoveryClient<String> inner)
Creates an instance with a given ResultParser and a DiscoveryClient that produces untyped results

Parameters:
parser - the parser
inner - the client
Method Detail

submit

public List<R> submit(Query query)
               throws DiscoveryException,
                      InvalidResultException
Submits a Query for remote execution and returns a list of typed results.

Result parsing errors are only logged as long as some results are successfully parsed. Otherwise, the client flags the parsing errors as likely due to the parser itself.

Specified by:
submit in interface DiscoveryClient<R>
Parameters:
query - the query
Returns:
the results
Throws:
DiscoveryException - if the query cannot be submitted
InvalidResultException - if the results cannot be parsed. Implementations may adopt different degrees of tolerance to parsing errors before raising this exception.


Copyright © 2013. All Rights Reserved.