public class

Query

extends Object
java.lang.Object
   ↳ com.esri.core.tasks.ags.query.Query

Class Overview

Class holding the parameters of a query to be executed on the server.

In this class, you can define:

  • a where clause
  • 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
  • the list of fields to be included in the returned result set
  • the object IDs of this layer / table to be queried
  • if the response should only include an array of object IDs or otherwise, a feature set
  • Summary

    Public Constructors
    Query()
    Default constructor.
    Public Methods
    boolean equals(Object obj)
    Geometry getGeometry()
    Returns the geometry to apply as the spatial filter.
    String[] getGroupByFieldsForStatistics()
    Gets the groupByFieldsForStatistics for Query.
    SpatialReference getInSpatialReference()
    Returns the spatial reference of the input geometry.
    double getMaxAllowableOffset()
    Returns the maximum allowable offset.
    int getMaxFeatures()
    Gets the max features.
    int[] getObjectIds()
    This method is deprecated. since 10.2 use getObjectIdsInLong()
    long[] getObjectIdsInLong()
    Returns the object IDs of this layer/table to be queried.
    Map<String, OrderByFields> getOrderByFields()
    Gets the orderByFields of the Query.
    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()
    The definitions for one or more field-based statistic to be calculated Note:
    • outStatistics is supported on only those layers / tables that indicate suppportsStatistics is true.
    SpatialRelationship getSpatialRelationship()
    Returns the spatial relationship to be applied on the input geometry.
    String getText()
    Returns the literal search text.
    TimeExtent getTimeExtent()
    Gets the time extent.
    String getWhere()
    Returns the where clause for the query.
    int hashCode()
    boolean isReturnGeometry()
    Returns true if the result set includes the geometry associated with each result.
    boolean isReturnIdsOnly()
    Returns true if the response only includes an array of object IDs.
    void setGeometry(Geometry geometry)
    Sets the geometry to apply as the spatial filter.
    void setGroupByFieldsForStatistics(String[] groupByFieldsForStatistics)
    Sets the groupByFieldsForStatistics for Query.
    void setInSpatialReference(SpatialReference inSR)
    Sets the spatial reference of the input geometry.
    void setMaxAllowableOffset(double maxAllowableOffset)
    Sets the maximum allowable offset.
    void setMaxFeatures(int maxFeatures)
    Sets the max features.
    void setObjectIds(int[] objectIds)
    This method is deprecated. since 10.2 use setObjectIds(long[])
    void setObjectIds(long[] objectIds)
    Sets the object IDs of this layer/table to be queried.
    void setOrderByFields(Map<String, OrderByFields> orderByFields)
    Sets the orderByFields for Query.
    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 statistic to be calculated Note:
    • outStatistics is supported on only those layers / tables that indicate suppportsStatistics is true.
    void setReturnGeometry(boolean returnGeometry)
    Sets if 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 setSpatialRelationship(SpatialRelationship spatialRelationship)
    Sets the spatial relationship to be applied on the input geometry.
    void setText(String text)
    Sets the literal search text.
    void setTimeExtent(TimeExtent timeExtent)
    Sets the time extent.
    void setWhere(String where)
    Sets the where clause for the query.
    Object toInternalFormat()
    Returns the Query in an internal format.
    [Expand]
    Inherited Methods
    From class java.lang.Object

    Public Constructors

    public Query ()

    Default constructor.

    Public Methods

    public boolean equals (Object obj)

    Parameters
    obj Object
    Returns
    boolean

    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 groupByFieldsForStatistics for Query. One or more field names using which the values need to be grouped for calculating the statistics.

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

    Returns
    String[] Returns the groupByFieldsForStatistics.

    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

    public int getMaxFeatures ()

    Gets the max features.

    Returns
    int the maxFeatures

    public int[] getObjectIds ()

    This method is deprecated.
    since 10.2 use getObjectIdsInLong()

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

    Returns
    int[] the array of ObjectIDs

    public long[] getObjectIdsInLong ()

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

    Returns
    long[] the array of ObjectIDs

    public Map<String, OrderByFields> getOrderByFields ()

    Gets the orderByFields of the Query. One or more field names using which the features/records need to be ordered. Use ASC or DESC, for ascending or descending order respectively, following every field to control the ordering.

    Note:

    • orderByFields is supported on only those layers / tables that indicate supportsAdvancedQueries is true.
    • orderByFields defaults to ASC (ascending order) if "ORDER" is unspecified.

    Returns
    Map<String, OrderByFields> Returns the orderByFields.

    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 ()

    The definitions for one or more field-based statistic to be calculated Note:

    • outStatistics is supported on only those layers / tables that indicate suppportsStatistics is true.
    • If outStatisticFieldName is empty or missing, then map server would assign a field name to the returned statistic field. A valid field name can only contain alpha-numberic 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 gdbVersion parameters would return an error.

    Values: 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.

    Returns
    OutStatistics[] Returns the outStatistics.

    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

    public TimeExtent getTimeExtent ()

    Gets the time extent.

    Returns
    TimeExtent the time extent

    public String getWhere ()

    Returns the where clause for the query.

    Returns
    String the where clause

    public int hashCode ()

    Returns
    int

    public boolean isReturnGeometry ()

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

    Returns
    boolean true if the result set includes 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 void setGeometry (Geometry geometry)

    Sets the geometry to apply as the spatial filter.

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

    public void setGroupByFieldsForStatistics (String[] groupByFieldsForStatistics)

    Sets the groupByFieldsForStatistics for Query. One or more field names using which the values need to be grouped for calculating the statistics.

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

    Parameters
    groupByFieldsForStatistics 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.

    Parameters
    maxAllowableOffset double: the max allowable offset

    public void setMaxFeatures (int maxFeatures)

    Sets the max features.

    Parameters
    maxFeatures int: the maxFeatures to set

    public void setObjectIds (int[] objectIds)

    This method is deprecated.
    since 10.2 use setObjectIds(long[])

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

    Parameters
    objectIds int: an array of ObjectIds

    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, OrderByFields> orderByFields)

    Sets the orderByFields for Query. One or more field names using which the features/records need to be ordered. Use ASC or DESC, for ascending or descending order respectively, following every field to control the ordering.

    Note:

    • orderByFields 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 order = new LinkedHashMap();
     order.put("pop2007",FieldOrder.ASC);
     order.put("AVE_FAM_SZ",null);
     
     

    Parameters
    orderByFields Map: The orderByFields to set.

    public void setOutFields (String[] outFields)

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

    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 statistic to be calculated Note:

    • outStatistics is supported on only those layers / tables that indicate suppportsStatistics is true.
    • If outStatisticFieldName is empty or missing, then map server would assign a field name to the returned statistic field. A valid field name can only contain alpha-numberic 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 gdbVersion parameters would return an error.

    Values: 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.

    Parameters
    outStatistics OutStatistics: The outStatistics to set.

    public void setReturnGeometry (boolean returnGeometry)

    Sets if the result set should include the geometry associated with each result.

    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.

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

    public void setSpatialRelationship (SpatialRelationship spatialRelationship)

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

    Parameters
    spatialRelationship SpatialRelationship: the spatial relationship

    public void setText (String text)

    Sets the literal search text.

    Parameters
    text String: the literal search text

    public void setTimeExtent (TimeExtent timeExtent)

    Sets the time extent.

    Parameters
    timeExtent TimeExtent: the time extent to set

    public void setWhere (String where)

    Sets the where clause for the query.

    Parameters
    where String: the where clause to set

    public Object toInternalFormat ()

    Returns the Query in an internal format.

    Returns
    Object the object