org.gcube.common.core.informationsystem.client.impl
Class AbstractQuery<RESULT>

java.lang.Object
  extended by org.gcube.common.core.informationsystem.client.impl.AbstractQuery<RESULT>
All Implemented Interfaces:
ISQuery<RESULT>

public abstract class AbstractQuery<RESULT>
extends Object
implements ISQuery<RESULT>

Abstract implementation of ISQuery.

Author:
Andrea Manzi (CNR), Fabio Simeoni (University of Strathclyde)

Field Summary
protected  String expression
          The textual expression of the query.
protected  Map<String,String> parameters
          Query parameters .
 
Constructor Summary
AbstractQuery()
           
 
Method Summary
 void addParameters(QueryParameter... parameters)
          Add one or more parameters to the query.
 String getExpression()
          Returns the textual expression of the query.
 long getTTL()
          Returns the time-to-live of the results of the query.
protected  boolean isWellFormed()
          Override to indicate whether the query is well-formed.
protected abstract  RESULT parseResult(String unparsedResult)
          Override to return a query result from its textual serialisation.
 void setExpression(String exp)
          Sets the textual expression of the query.
 void setTTL(long ttl)
          Sets the time-to-live of the results of the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameters

protected Map<String,String> parameters
Query parameters .


expression

protected String expression
The textual expression of the query.

Constructor Detail

AbstractQuery

public AbstractQuery()
Method Detail

getTTL

public long getTTL()
Returns the time-to-live of the results of the query.

Specified by:
getTTL in interface ISQuery<RESULT>
Returns:
the time-to-live.

getExpression

public String getExpression()
Returns the textual expression of the query.

Specified by:
getExpression in interface ISQuery<RESULT>
Returns:
the expression.

setTTL

public void setTTL(long ttl)
Sets the time-to-live of the results of the query.

Specified by:
setTTL in interface ISQuery<RESULT>
Parameters:
ttl - the time-to-live.

setExpression

public void setExpression(String exp)
Sets the textual expression of the query.

Specified by:
setExpression in interface ISQuery<RESULT>
Parameters:
exp - the expression.

addParameters

public void addParameters(QueryParameter... parameters)
Add one or more parameters to the query.

Parameters:
parameters - the parameters.

isWellFormed

protected boolean isWellFormed()
Override to indicate whether the query is well-formed. By default, it simply checks that the query expression is non-null.

Returns:
true if the query is well-formed, false otherwise.

parseResult

protected abstract RESULT parseResult(String unparsedResult)
                               throws ISClient.ISMalformedResultException
Override to return a query result from its textual serialisation.

Parameters:
unparsedResult - the textual representation.
Returns:
the result.
Throws:
ISClient.ISMalformedResultException - if the result cannot be deserialised.


Copyright © 2013. All Rights Reserved.