org.apache.stanbol.entityhub.servicesapi.query
Interface FieldQuery

All Superinterfaces:
Cloneable, Iterable<Map.Entry<String,Constraint>>, Query

public interface FieldQuery
extends Query, Iterable<Map.Entry<String,Constraint>>, Cloneable

Simple query interface that allows to search for representations based on fields and there values.

Currently it is only possible to set a single constraint per field. Therefore it is not possible to combine an range constraint with an language constraint. e.g. searching for all labels form a-f in a list of given languages. TODO: This shortcoming needs to be reevaluated. The intension was to ease the implementation and the usage of this interface. TODO: Implementation need to be able to throw UnsupportedConstraintExceptions for specific combinations of Constraints e.g. Regex or case insensitive ... TODO: Would be nice if an Implementation could also announce the list of supported constraints (e.g. via Capability levels ...)

Author:
Rupert Westenthaler

Field Summary
static String TYPE
          The value used as result for Query.getQueryType() of this query type.
 
Method Summary
 void addSelectedField(String field)
          Adds Fields to be selected by this Query
 void addSelectedFields(Collection<String> fields)
          Adds Fields to be selected by this Query
 FieldQuery clone()
          Clones the FieldQuery
<T extends FieldQuery>
T
copyTo(T copyTo)
          Copies the state of this instance to the parsed one
 Constraint getConstraint(String field)
          Getter for the Constraint of a field
 Set<Map.Entry<String,Constraint>> getConstraints()
          Getter for the unmodifiable list of query elements for the given Path.
 Set<String> getSelectedFields()
          Unmodifiable set with all the fields to be selected by this query
 boolean isConstrained(String field)
          Checks if there is a constraint for the given field
 void removeAllConstraints()
          Removes all constraints form the query
 void removeAllSelectedFields()
          Removes all selected fields
 void removeConstraint(String field)
          Removes the constraint for the parse field
 void removeSelectedField(String fields)
          Removes Fields to be selected by this Query
 void removeSelectedFields(Collection<String> fields)
          Removes Fields to be selected by this Query
 void setConstraint(String field, Constraint constraint)
          Sets/replaces the constraint for a field of the representation.
 
Methods inherited from interface org.apache.stanbol.entityhub.servicesapi.query.Query
getLimit, getOffset, getQueryType, setLimit, setOffset
 
Methods inherited from interface java.lang.Iterable
iterator
 

Field Detail

TYPE

static final String TYPE
The value used as result for Query.getQueryType() of this query type.

See Also:
Constant Field Values
Method Detail

addSelectedField

void addSelectedField(String field)
Adds Fields to be selected by this Query

Parameters:
fields - the fields to be selected by this query

addSelectedFields

void addSelectedFields(Collection<String> fields)
Adds Fields to be selected by this Query

Parameters:
fields - the fields to be selected by this query

removeSelectedField

void removeSelectedField(String fields)
Removes Fields to be selected by this Query

Parameters:
fields - the fields to be selected by this query

removeSelectedFields

void removeSelectedFields(Collection<String> fields)
Removes Fields to be selected by this Query

Parameters:
fields - the fields to be selected by this query

getSelectedFields

Set<String> getSelectedFields()
Unmodifiable set with all the fields to be selected by this query

Returns:
the fields to be selected by this query

setConstraint

void setConstraint(String field,
                   Constraint constraint)
Sets/replaces the constraint for a field of the representation. If null is parsed as constraint this method removes any existing constraint for the field

Parameters:
field - the field
constraint - the Constraint

removeConstraint

void removeConstraint(String field)
Removes the constraint for the parse field

Parameters:
field -

isConstrained

boolean isConstrained(String field)
Checks if there is a constraint for the given field

Parameters:
field - the field
Returns:
the state

getConstraint

Constraint getConstraint(String field)
Getter for the Constraint of a field

Parameters:
field - the field
Returns:
the constraint or null if none is defined.

getConstraints

Set<Map.Entry<String,Constraint>> getConstraints()
Getter for the unmodifiable list of query elements for the given Path. Use the add/remove constraint methods to change query elements for an path

Parameters:
path - the path
Returns:
the list of query elements for a path

removeAllConstraints

void removeAllConstraints()
Removes all constraints form the query


removeAllSelectedFields

void removeAllSelectedFields()
Removes all selected fields


copyTo

<T extends FieldQuery> T copyTo(T copyTo)
Copies the state of this instance to the parsed one

Type Parameters:
T - the FieldQuery implementation
Parameters:
copyTo - the instance to copy the state
Returns:
the parsed instance with the exact same state as this one

clone

FieldQuery clone()
Clones the FieldQuery

Specified by:
clone in interface Query
Returns:
the clone


Copyright © 2010-2013 The Apache Software Foundation. All Rights Reserved.