org.gcube.common.clients.queries
Class AbstractQuery<A,R>

java.lang.Object
  extended by org.gcube.common.clients.queries.AbstractQuery<A,R>
Type Parameters:
A - the type of service addresses
R - the type of query results
All Implemented Interfaces:
Query<A>

public abstract class AbstractQuery<A,R>
extends Object
implements Query<A>

Partial implementation of Querys.

Author:
Fabio Simeoni

Constructor Summary
protected AbstractQuery(ProxyPlugin<A,?,?> plugin)
          Creates an instance with a ISFacade, a PluginAdapter, and a type of IS queries
 
Method Summary
 void addCondition(String property, String value)
          Adds a condition to the query.
protected abstract  A address(R result)
          Returns an endpoint address from a query result.
 boolean equals(Object obj)
           
 List<A> fire()
          Executes the query.
protected abstract  List<R> fire(Map<String,String> conditions)
          Executes the query through implementation-specific means.
 int hashCode()
           
protected  ProxyPlugin<A,?,?> plugin()
          Returns the ProxyPlugin.
 void setMatcher(ResultMatcher<R> matcher)
          Sets an ResultMatcher for the query.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractQuery

protected AbstractQuery(ProxyPlugin<A,?,?> plugin)
Creates an instance with a ISFacade, a PluginAdapter, and a type of IS queries

Parameters:
facade - the facade
plugin - the plugin
queryClass - the query type
Method Detail

addCondition

public void addCondition(String property,
                         String value)
Adds a condition to the query.

Parameters:
property - an expression that identifies a property of service endpoints
value - the value of the property

setMatcher

public void setMatcher(ResultMatcher<R> matcher)
Sets an ResultMatcher for the query.

Parameters:
matcher - the matcher.

fire

public final List<A> fire()
                   throws DiscoveryException
Description copied from interface: Query
Executes the query.

Specified by:
fire in interface Query<A>
Returns:
the addresses of the discovered endpoints
Throws:
DiscoveryException - if query execution fails

fire

protected abstract List<R> fire(Map<String,String> conditions)
                         throws DiscoveryException
Executes the query through implementation-specific means.

Parameters:
conditions - the conditions to apply on the query prior to its execution
Returns:
the query results
Throws:
DiscoveryException - if the query could not be executed

address

protected abstract A address(R result)
                      throws IllegalArgumentException
Returns an endpoint address from a query result.

Parameters:
result - the result
Returns:
the address
Throws:
IllegalArgumentException - if an address cannot be derived from the result

plugin

protected ProxyPlugin<A,?,?> plugin()
Returns the ProxyPlugin.

Returns:
the plugin

equals

public final boolean equals(Object obj)
Specified by:
equals in interface Query<A>
Overrides:
equals in class Object

hashCode

public final int hashCode()
Specified by:
hashCode in interface Query<A>
Overrides:
hashCode in class Object

toString

public final String toString()
Specified by:
toString in interface Query<A>
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.