public class

QueryParameters

extends Object
java.lang.Object
   ↳ com.esri.core.tasks.query.QueryParameters

Class Overview

Class holding the parameters of a query on a layer or table supporting queries, to be executed either locally or on the server.

In order to perform a query operation, an instance of QueryParameters must first be created and populated with the desired parameters. These parameters are then passed to either a QueryTask instance for execution or to the query methods on GeodatabaseFeatureTable.

In this class, you can define:

  • a where clause
  • whether the result set must include the geometry associated with each result
  • the list of fields to be included in the returned result set
  • the object IDs of this layer / table to be queried
  • whether the response should only include an array of object IDs or otherwise, a feature set
  • a literal search text
  • a geometry to apply as the spatial filter
  • a spatial relationship to be applied on the input geometry
  • the spatial reference of the input geometry
  • the spatial reference of the returned geometry
  • if the result set must include the geometry associated with each result

Summary

Public Constructors
QueryParameters()
Public Methods
String getGeodatabaseVersion()
Gets the geodatabase version, if any, to use for the data to query.
Geometry getGeometry()
Returns the geometry to apply as the spatial filter.
String[] getGroupByFieldsForStatistics()
Gets the field names on which to group statistics.
SpatialReference getInSpatialReference()
Returns the spatial reference of the input geometry.
double getMaxAllowableOffset()
Returns the maximum allowable offset.
int getMaxFeatures()
The maximum number of features to return from the query.
long[] getObjectIds()
Returns the object IDs of this layer/table to be queried.
String[] getOutFields()
Returns the array of fields to be included in the returned result set.
SpatialReference getOutSpatialReference()
Returns the spatial reference of the returned geometry.
OutStatistics[] getOutStatistics()
Gets the statistics to be output by the query.
SpatialRelationship getSpatialRelationship()
Returns the spatial relationship to be applied on the input geometry.
String getText()
Returns the literal search text.
String getWhere()
Returns the where clause for the query filter.
boolean isReturnGeometry()
Returns true if the result set is to include the geometry associated with each result.
boolean isReturnIdsOnly()
Returns true if the response only includes an array of object IDs.
boolean isReturnM()
Checks if M values are returned in geometries.
boolean isReturnZ()
Checks if Z values are returned in geometries.
void setGeodatabaseVersion(String geodatabaseVersion)
Sets the geodatabase version to use for the data to query.
void setGeometry(Geometry geometry)
Sets the geometry to apply as the spatial filter for the query.
void setGroupByFieldsForStatistics(String[] fieldNames)
Sets the groupByFieldsForStatistics property of the Query; this is one or more field names according to which the values need to be grouped for calculating the statistics.
void setInSpatialReference(SpatialReference inSR)
Sets the spatial reference of the input geometry.
void setMaxAllowableOffset(double maxAllowableOffset)
Sets the maximum allowable offset which is used for generalizing geometries returned by the query operation.
void setMaxFeatures(int maxFeatures)
Sets the maximum number of features/results to return from the query.
void setObjectIds(long[] objectIds)
Sets the object IDs of this layer/table to be queried.
void setOrderByFields(Map<String, Order> orderByFields)
Sets one or more field names that the features/records need to be ordered by.
void setOutFields(String[] outFields)
Sets the array of fields to be included in the returned result set.
void setOutSpatialReference(SpatialReference outSR)
Sets the spatial reference of the returned geometry.
void setOutStatistics(OutStatistics[] outStatistics)
The definitions for one or more field-based statistics to be calculated.
void setReturnGeometry(boolean returnGeometry)
Sets whether the result set should include the geometry associated with each result.
void setReturnIdsOnly(boolean returnIdsOnly)
Sets if the response should only include the object IDs.
void setReturnM(boolean returnM)
Sets whether M values are returned in geometries.
void setReturnZ(boolean returnZ)
Sets whether Z values are returned in geometries.
void setSpatialRelationship(SpatialRelationship spatialRelationship)
Sets the spatial relationship to be applied on the input geometry while performing the query.
void setText(String text)
Sets the literal search text: if the layer/table has a display field associated with it, the server searches for this text in this field.
void setWhere(String where)
Sets the where clause for the query filter.
String toJSON()
Returns JSON representing this object.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public QueryParameters ()

Public Methods

public String getGeodatabaseVersion ()

Gets the geodatabase version, if any, to use for the data to query.

Returns
String the geodatabase version, or null if none is set

public Geometry getGeometry ()

Returns the geometry to apply as the spatial filter.

Returns
Geometry the geometry to apply as the spatial filter

public String[] getGroupByFieldsForStatistics ()

Gets the field names on which to group statistics.

Note: groupByFieldsForStatistics is valid only when the outStatistics parameter is used.

Returns
String[] field names

public SpatialReference getInSpatialReference ()

Returns the spatial reference of the input geometry.

Returns
SpatialReference the spatial reference of the input geometry

public double getMaxAllowableOffset ()

Returns the maximum allowable offset.

Returns
double the maximum allowable offset value

public int getMaxFeatures ()

The maximum number of features to return from the query. The parameter has no effect on an ArcGISServer service.

Returns
int the maxFeatures

public long[] getObjectIds ()

Returns the object IDs of this layer/table to be queried.

Returns
long[] the array of ObjectIDs

public String[] getOutFields ()

Returns the array of fields to be included in the returned result set.

Returns
String[] an array of field names

public SpatialReference getOutSpatialReference ()

Returns the spatial reference of the returned geometry.

Returns
SpatialReference the spatial reference of the returned geometry.

public OutStatistics[] getOutStatistics ()

Gets the statistics to be output by the query.

Returns
OutStatistics[] An array of statistic definitions. A statistic definition specifies the type of statistic, the field on which it is to be calculated, and the resulting output field name.

public SpatialRelationship getSpatialRelationship ()

Returns the spatial relationship to be applied on the input geometry.

Returns
SpatialRelationship the spatial relationship

public String getText ()

Returns the literal search text.

Returns
String the literal search text

See also:

public String getWhere ()

Returns the where clause for the query filter.

Returns
String the where clause

public boolean isReturnGeometry ()

Returns true if the result set is to include the geometry associated with each result. The default is true.

Returns
boolean true if the result set is to include the geometry associated with each result, false otherwise

public boolean isReturnIdsOnly ()

Returns true if the response only includes an array of object IDs.

Returns
boolean true if the response only includes an array of object IDs, false otherwise

public boolean isReturnM ()

Checks if M values are returned in geometries.

Returns
boolean true, if M values are included.

public boolean isReturnZ ()

Checks if Z values are returned in geometries.

Returns
boolean true, if Z values are included.

public void setGeodatabaseVersion (String geodatabaseVersion)

Sets the geodatabase version to use for the data to query. Only has an effect if the data is versioned. This parameter has no effect on a local geodatabase.

Parameters
geodatabaseVersion String: the geodatabase version

public void setGeometry (Geometry geometry)

Sets the geometry to apply as the spatial filter for the query.

Parameters
geometry Geometry: the geometry to apply as the spatial filter

public void setGroupByFieldsForStatistics (String[] fieldNames)

Sets the groupByFieldsForStatistics property of the Query; this is one or more field names according to which the values need to be grouped for calculating the statistics.

Note: groupByFieldsForStatistics is valid only when the outStatistics parameter is used.

Parameters
fieldNames String: The groupByFieldsForStatistics to set.

public void setInSpatialReference (SpatialReference inSR)

Sets the spatial reference of the input geometry.

Parameters
inSR SpatialReference: the spatial reference of the input geometry

public void setMaxAllowableOffset (double maxAllowableOffset)

Sets the maximum allowable offset which is used for generalizing geometries returned by the query operation. This parameter has no effect on a local geodatabase.

Parameters
maxAllowableOffset double: the maximum allowable offset value

public void setMaxFeatures (int maxFeatures)

Sets the maximum number of features/results to return from the query.

Parameters
maxFeatures int: the maxFeatures to set

public void setObjectIds (long[] objectIds)

Sets the object IDs of this layer/table to be queried.

Parameters
objectIds long: an array of ObjectIds

public void setOrderByFields (Map<String, Order> orderByFields)

Sets one or more field names that the features/records need to be ordered by. Use ASC or DESC from the Order enum, for ascending or descending order respectively, for each field to control the ordering.

Note:

  • this property is supported on only those layers / tables that indicate supportsAdvancedQueries is true.
  • orderByFields defaults to ASC (ascending order) if "ORDER" is unspecified.
To use the default order you can set it to null:
 
    Map<String, Order> orderFields = new LinkedHashMap<String, Order>();
    orderFields.put("pop2007", Order.ASC);
    orderFields.put("AVE_FAM_SZ", null); // defaults to ascending
 
 

Parameters
orderByFields Map: the map of field names to OrderByFields options

public void setOutFields (String[] outFields)

Sets the array of fields to be included in the returned result set. For the query results to include all the field values, specify the wildcard '*' character as the value of this parameter.

Parameters
outFields String: an array of field names

public void setOutSpatialReference (SpatialReference outSR)

Sets the spatial reference of the returned geometry.

Parameters
outSR SpatialReference: the spatial reference of the returned geometry.

public void setOutStatistics (OutStatistics[] outStatistics)

The definitions for one or more field-based statistics to be calculated.

Note:

  • outStatistics is supported on only those layers / tables that indicate suppportsStatistics is true.
  • A valid field name can only contain alpha-numeric characters and an underscore.
  • When using outStatistics the only other parameters that will be used are groupByFieldsForStatistics, orderByFields, text, time, and where.
  • Specifying geometry, objectIds, or geodatabaseVersion parameters will return an error.

Parameters
outStatistics OutStatistics: The array of OutStatistics to set.

public void setReturnGeometry (boolean returnGeometry)

Sets whether the result set should include the geometry associated with each result. The default is true. This parameter has no effect on a local geodatabase.

Parameters
returnGeometry boolean: true for the result set to include the geometry associated with each result

public void setReturnIdsOnly (boolean returnIdsOnly)

Sets if the response should only include the object IDs. The default is false. This parameter has no effect on a local geodatabase, instead use the queryIds(QueryParameters, CallbackListener) method.

Parameters
returnIdsOnly boolean: true for the response only to include the object IDs

public void setReturnM (boolean returnM)

Sets whether M values are returned in geometries. The default is false. This parameter has no effect on a local geodatabase.

Parameters
returnM boolean: true to have M values returned.

public void setReturnZ (boolean returnZ)

Sets whether Z values are returned in geometries. The default is false. This parameter has no effect on a local geodatabase.

Parameters
returnZ boolean: true to have Z values returned.

public void setSpatialRelationship (SpatialRelationship spatialRelationship)

Sets the spatial relationship to be applied on the input geometry while performing the query. The supported spatial relationships include intersects, contains, envelope intersects, within, etc. The default spatial relationship is intersects (INTERSECTS).

Parameters
spatialRelationship SpatialRelationship: the spatial relationship

public void setText (String text)

Sets the literal search text: if the layer/table has a display field associated with it, the server searches for this text in this field. This parameter is a short hand for a where clause of:

 where  like '%%'
 
. The text is case sensitive. This parameter is ignored if the where parameter is specified.

Parameters
text String: the literal search text

public void setWhere (String where)

Sets the where clause for the query filter. Any legal SQL where clause operating on the fields in the layer/table is allowed, for example 'POP2000 > 500000'.

Parameters
where String: the where clause to set

public String toJSON ()

Returns JSON representing this object.

Returns
String JSON string