Class QueryParameter
- java.lang.Object
-
- com.supermap.data.QueryParameter
-
public class QueryParameter extends java.lang.Object
The query parameter class.The QueryParameter class is used to describe the conditions that the query is based, such as the SQL WHERE clause, cursor type, etc.
Select records based on certain conditions is called Query by condition, the result of this query is a Recordset. SQL query, or you may call it query by attribute. This manner selects records using SQL 'where' clause, which can contain fields, operators and values.
- Example:
- The following example demonstrates how to perform query operation. Suppose open a {
workspace
} object which contains a {workspace
} object. This object contains a vector dataset named "dataset_World" and take out the dataset.public void queryParameterTest(DatasetVector dataset_world) { // Sets the query parameters QueryParameter parameter = new QueryParameter(); parameter.setAttributeFilter("SmID<100"); parameter.setCursorType(CursorType.STATIC); // Querying Recordset recordset = dataset_world.query(parameter); //Closes all objects dataset_world.close(); recordset.dispose(); }
-
-
Constructor Summary
Constructors Constructor and Description QueryParameter()
Constructs a new QueryParameter object.QueryParameter(QueryParameter queryParameter)
Constructs a new object identical to the given QueryParameter object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static java.lang.String
dateToString(int year, int month, int day, int hours, int minutes, int seconds)
Static function to convert time to String, used in time query.void
dispose()
Release the resource occupy by this object.java.lang.String
getAttributeFilter()
Returns the SQL 'where' clause when querying by SQL.CursorType
getCursorType()
Returns the cursor type.java.lang.String[]
getGroupBy()
Returns the field used to group the result records of the SQL query.boolean
getHasGeometry()
Returns whether the result of query has geometry.java.lang.String[]
getOrderBy()
Returns the field used to sort the result records of the SQL query.java.lang.String[]
getResultFields()
Returns the result field collection of the query.SpatialQueryMode
getSpatialQueryMode()
Gets the operation mode of the spatial query.void
setAttributeFilter(java.lang.String value)
Sets the SQL 'where' clause when querying by SQL.void
setCursorType(CursorType value)
Sets the cursor type.void
setGroupBy(java.lang.String[] value)
Sets the field used to group the result records of the SQL query.void
setHasGeometry(boolean value)
Sets whether the result of query has geometry.void
setOrderBy(java.lang.String[] value)
Sets the field used to sort the result records of the SQL query.void
setResultFields(java.lang.String[] value)
Sets the result field collection of the query.void
setSpatialQueryMode(SpatialQueryMode value)
Sets the operation mode of the spatial query.void
setSpatialQueryObject(java.lang.Object value)
Sets the search object in spatial query, which can be type ofPoint2D
,Rectangle2D
,GeoPoint
,{@link GeoLine GeoLine},{@link GeoRegion GeoRegion},{@link DatasetVector DatasetVector},{@link Recordset Recordset}.java.lang.String
toString()
Outputs the parameter settings in this QueryParameter to a string.
-
-
-
Constructor Detail
-
QueryParameter
public QueryParameter()
Constructs a new QueryParameter object.
-
QueryParameter
public QueryParameter(QueryParameter queryParameter)
Constructs a new object identical to the given QueryParameter object.- Parameters:
queryParameter
- The specified prjParameter object.
-
-
Method Detail
-
getCursorType
public CursorType getCursorType()
Returns the cursor type. There are two types of cursor, dynamic and static. When querying with the dynamic cursor, the record set will refreshed dynamically to update the data if the data is modified by other users of the database, so it will occupy a lot of resources; when querying with static cursor, you are operating or querying a copy of the record set, so it will not record and reflect the modification made to data, and is very efficient. It is recommended that you use the static cursor when querying. The recordset obtained by the dynamic cursor isn't editable. For more information, see CursorType.- Returns:
- The type of the cursor used when querying.
- See Also:
CursorType
- Default:
- The default value is
DYNAMIC
type.
-
setCursorType
public void setCursorType(CursorType value)
Sets the cursor type. There are two types of cursor, dynamic and static. When querying with the dynamic cursor, the record set will refreshed dynamically to update the data if the data is modified by other users of the database, so it will occupy a lot of resources; when querying with static cursor, you are operating or querying a copy of the record set, so it will not record and reflect the modification made to data, and is very efficient. It is recommended that you use the static cursor when querying. The recordset obtained by the dynamic cursor isn't editable. For more information, see CursorType.- Parameters:
value
- Specifies the type of the cursor used when querying.- See Also:
CursorType
-
getAttributeFilter
public java.lang.String getAttributeFilter()
Returns the SQL 'where' clause when querying by SQL. Query by SQL is also called query by attribute, and it selects records according to one or more SQL 'where' clause. The SQL 'where' clause can contain fields, operators and values. For example, you want to query the clothing store whose sales last year is over RMB300,000, the SQL 'where' clause can be: Sales > 300,000 AND SellingType = 'Garment'.- Returns:
- The SQL 'where' clause when querying by SQL.
- Default:
- The default is a null string.
-
setAttributeFilter
public void setAttributeFilter(java.lang.String value)
Sets the SQL 'where' clause when querying by SQL. Query by SQL is also called query by attribute, and it selects records according to one or more SQL 'where' clause. The SQL 'where' clause can contain fields, operators and values. For example, you want to query the clothing store whose sales last year is over RMB300,000, the SQL 'where' clause can be: Sales > 300,000 AND SellingType = 'Garment'.- Parameters:
value
- The SQL 'where' clause when querying by SQL.
-
getHasGeometry
public boolean getHasGeometry()
Returns whether the result of query has geometry.- Returns:
- Returns true if the query result contains the field of the geometric objects; orherwise returns false.
- Default:
- The default value is true.
-
setHasGeometry
public void setHasGeometry(boolean value)
Sets whether the result of query has geometry.- Parameters:
value
- Specifies whether the result of query has geometry.
-
getOrderBy
public java.lang.String[] getOrderBy()
Returns the field used to sort the result records of the SQL query. For the records obtained from a SQL query, you can specify a field to sort them, either ascending or descending. Note: The field used for sorting must be numeric.- Returns:
- The field used to sort the result records of the SQL query.
- Default:
- The string array whose default is zero.
-
setOrderBy
public void setOrderBy(java.lang.String[] value)
Sets the field used to sort the result records of the SQL query. For the records obtained from a SQL query, you can specify a field to sort them, either ascending or descending. Note: The field used for sorting must be numeric.- Parameters:
value
- The field used to sort the result records of the SQL query.
-
getGroupBy
public java.lang.String[] getGroupBy()
Returns the field used to group the result records of the SQL query. For the records obtained from a SQL query, you can specify a field to group them, and the records with the same value in the specified field will be placed together.- Returns:
- The field used to group the result records of the SQL query.
- Default:
- The string array whose default is zero.
-
setGroupBy
public void setGroupBy(java.lang.String[] value)
Sets the field used to group the result records of the SQL query. For the records obtained from a SQL query, you can specify a field to group them, and the records with the same value in the specified field will be placed together.Note:
- When only
setCursorType(CursorType.STATIC)
, thesetGroupBy()
method is valid; - When the fields of
setHasGeometry(false)
andsetResultFields()
are the same with the fields of this method, thesetGroupBy()
method is valid. - If you use {
setGroupBy()
} method when the HasGeometry property is set to false (setHasGeometry(false)
), the result recordset is read-only.
- Parameters:
value
- The field used to group the result records of the SQL query.
- When only
-
getResultFields
public java.lang.String[] getResultFields()
Returns the result field collection of the query. In the result record set of the query, there can be all fields or you can specify some of the fields to return. If it is set to null, all the fields will be returned. The default value is null.- Returns:
- The result field collection of the query.
- Default:
- The string array whose default is zero.
-
setResultFields
public void setResultFields(java.lang.String[] value)
Sets the result field collection of the query. In the result record set of the query, there can be all fields or you can specify some of the fields to return. If it is set to null, all the fields will be returned. The default value is null.Note: only when
setHasGeometry(false)
,setHasGeometry(false)
, the setting for thesetHasGeometry(false)
method is valid, otherwise it will return all fields.- Parameters:
value
- The result field collection of the query.
-
toString
public java.lang.String toString()
Outputs the parameter settings in this QueryParameter to a string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The XML strings of the query parameters information.
-
dispose
public void dispose()
Release the resource occupy by this object.
-
setSpatialQueryObject
public void setSpatialQueryObject(java.lang.Object value)
Sets the search object in spatial query, which can be type ofPoint2D
,Rectangle2D
,GeoPoint
,{@link GeoLine GeoLine},{@link GeoRegion GeoRegion},{@link DatasetVector DatasetVector},{@link Recordset Recordset}.If the search object is of the dataset or recordset type, the coordinate system of the search object and the searched layer must be the same.
- Parameters:
value
- The search object in the spatial query.
-
setSpatialQueryMode
public void setSpatialQueryMode(SpatialQueryMode value)
Sets the operation mode of the spatial query.- Parameters:
value
- the operation mode of the spatial query.
-
getSpatialQueryMode
public SpatialQueryMode getSpatialQueryMode()
Gets the operation mode of the spatial query.- Returns:
- The operation mode of the spatial query, the default is
SpatialQueryMode.NONE
mode
-
dateToString
public static java.lang.String dateToString(int year, int month, int day, int hours, int minutes, int seconds)
Static function to convert time to String, used in time query.The dataset stored in the UDB datasource is to use double type to indicate the value of time which uses the unit of day, and hour, minute, minute is decimal. The to_date function in the database is for the level of ms. Users can use the returned value of the static interface in equal or ranges query.
Please do not use the to_date function in the database to perform time query.
- Parameters:
year
- Year.month
- Month.day
- Day.hours
- Hour.minutes
- Minutes.seconds
- Second.- Returns:
- Time string.
-
-