public final class

ServiceFeatureTable

extends ArcGISFeatureTable
implements RemoteResource
java.lang.Object
   ↳ com.esri.arcgisruntime.data.FeatureTable
     ↳ com.esri.arcgisruntime.data.ArcGISFeatureTable
       ↳ com.esri.arcgisruntime.data.ServiceFeatureTable

Class Overview

Represents a feature table created from a URL to an ArcGIS Feature service's layer or table. The service feature table has different ServiceFeatureTable.FeatureRequestModes which affects how data is populated, queried and cached.

When used to create a FeatureLayer in a MapView, features are requested from the services in the correct spatial reference to match the spatial reference of the map.

Here's an example to display features from a spatial feature service; a service which has geometry:

 ServiceFeatureTable table = new ServiceFeatureTable("http://sampleserver5.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/0");
 FeatureLayer layer = new FeatureLayer(table);
 map.getOperationalLayers().add(featureLayer);
 
Service feature tables can be used to access non-spatial tables from feature services where hasGeometry() is false. These tables are placed in MANUAL_CACHE and these need to be populated manually using populateFromServiceAsync(QueryParameters, boolean, Iterable).

The parent class definition allows ServiceFeatureTable to have editable attribute fields, FeatureTemplates, FeatureTypes and support editing capabilities defined in getCapabilities(). Also a ServiceFeatureTable can require Credentials to access the service.

When querying for ArcGIS features from a service feature table, you can ensure that all features are bulk loaded using the queryFeaturesAsync(QueryParameters, ServiceFeatureTable.QueryFeatureFields) method and specifying the queryFields parameter as LOAD_ALL. This means you do not need to load all features individually.

Summary

Nested Classes
enum ServiceFeatureTable.FeatureRequestMode The feature request mode for the feature table. 
enum ServiceFeatureTable.QueryFeatureFields The query feature fields for queries on the feature table. 
Public Constructors
ServiceFeatureTable(String url)
Creates an instance from the given feature service URL.
ServiceFeatureTable(ServiceFeatureTable table, RelationshipInfo relationshipInfo)
Creates a ServiceFeatureTable instance that relates to the given table based on the given relationship info.
ServiceFeatureTable(PortalItem portalItem, long layerId)
Creates a new service feature table instance from a feature service portal item.
Public Methods
ListenableFuture<List<FeatureEditResult>> applyEditsAsync()
Applies edits that have been added to this table including attachment edits in one call.
void clearCache(boolean keepLocalEdits)
Clears all the features in the local table.
double getBufferFactor()
Gets the buffer factor.
Credential getCredential()
Gets the credential used to authenticate the user with the service feature table.
String getDefinitionExpression()
Gets the definition expression for filtering the features queried in this table.
Envelope getExtent()
Returns the extent that the table represents, this can be used to determine the extent within which data can be edited.
ServiceFeatureTable.FeatureRequestMode getFeatureRequestMode()
Gets the Feature Request mode.
String getGeodatabaseVersion()
Gets the geodatabase version.
Item getItem()
Gets the item associated with this table.
RequestConfiguration getRequestConfiguration()
Gets the RequestConfiguration object in use by this table.
String getUri()
Returns the URL used to create the table.
ListenableFuture<Void> loadOrRefreshFeaturesAsync(Iterable<Feature> features)
Loads all attributes and geometries for unloaded features, and refetches attributes and geometry from already-loaded features.
ListenableFuture<FeatureQueryResult> populateFromServiceAsync(QueryParameters query, boolean clearCache, Iterable<String> outFields)
Executes an asynchronous method that populates the table with the results of a query.
ListenableFuture<FeatureQueryResult> queryFeaturesAsync(QueryParameters queryParameters, ServiceFeatureTable.QueryFeatureFields queryFields)
Queries features from this table's cache and/or from the service used to create this table.
ListenableFuture<FeatureQueryResult> queryFeaturesAsync(QueryParameters query)
Queries features from this table's cache and/or from the service used to create this table.
ListenableFuture<List<RelatedFeatureQueryResult>> queryRelatedFeaturesAsync(ArcGISFeature feature, RelatedQueryParameters relatedQueryParameters, ServiceFeatureTable.QueryFeatureFields queryFields)
Asynchronously queries for features related to the given ArcGISFeature and using the given RelatedQueryParameters.
void setBufferFactor(double bufferFactor)
Sets the factor used to calculate a buffered extent, within which features are automatically fetched and cached, if the FeatureRequestMode of the table is ON_INTERACTION_CACHE.
void setCredential(Credential credential)
Sets the credential used to authenticate the user with the service feature table.
void setDefinitionExpression(String definitionExpression)
Sets a definition expression which is a SQL statement where clause to filter out the features to be queried.
void setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode featureRequestMode)
Sets the Feature Request mode which affects how often data is retrieved from the service and how it is cached in the local table.
void setGeodatabaseVersion(String version)
Sets the geodatabase version.
void setRequestConfiguration(RequestConfiguration requestConfiguration)
Sets configuration parameters used for network requests sent using this table object.
ListenableFuture<Void> undoLocalEditsAsync()
Undoes all of the local edits since the last server acknowledgement.
[Expand]
Inherited Methods
From class com.esri.arcgisruntime.data.ArcGISFeatureTable
From class com.esri.arcgisruntime.data.FeatureTable
From class java.lang.Object
From interface com.esri.arcgisruntime.io.RemoteResource
From interface com.esri.arcgisruntime.loadable.Loadable
From interface com.esri.arcgisruntime.mapping.popup.PopupSource

Public Constructors

public ServiceFeatureTable (String url)

Creates an instance from the given feature service URL. To use a request configuration, call setRequestConfiguration(RequestConfiguration) after this constructor and before loading this table. To use a credential, call setCredential(Credential) after this constructor and before loading this table.

Parameters
url the URL of an ArcGIS Feature Service.
Throws
IllegalArgumentException if input is null or empty

public ServiceFeatureTable (ServiceFeatureTable table, RelationshipInfo relationshipInfo)

Creates a ServiceFeatureTable instance that relates to the given table based on the given relationship info.

Parameters
table the related table
relationshipInfo the relationship info defining the relationship between this new table and the given table
Throws
IllegalArgumentException if table or relationshipInfo are null

public ServiceFeatureTable (PortalItem portalItem, long layerId)

Creates a new service feature table instance from a feature service portal item.

Parameters
portalItem a feature service portal item
layerId the layer ID to use
Throws
IllegalArgumentException if portalItem is null

Public Methods

public ListenableFuture<List<FeatureEditResult>> applyEditsAsync ()

Applies edits that have been added to this table including attachment edits in one call. This returns edit results for each features, each result includes attachment results for that feature.

Returns
  • a ListenableFuture representing the resulting list of edit results and indicating if the operation isDone(); also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to IOException if a network request fails

public void clearCache (boolean keepLocalEdits)

Clears all the features in the local table. Caches will only exist in certain modes.

Parameters
keepLocalEdits true, if edited rows in the table should not be cleared, otherwise false

public double getBufferFactor ()

Gets the buffer factor.

Returns
  • the buffer factor

public Credential getCredential ()

Gets the credential used to authenticate the user with the service feature table.

Returns
  • the credential used to authenticate the user with the service feature table

public String getDefinitionExpression ()

Gets the definition expression for filtering the features queried in this table.

Returns
  • the definition expression for filtering the features queried in this table; or empty if it is set to null

public Envelope getExtent ()

Returns the extent that the table represents, this can be used to determine the extent within which data can be edited. ServiceFeatureTables in manual cache mode will return the extent of the features which have been cached, all other modes will return the extent of the layer/table defined by the service (from getExtent().

Returns
  • the extent

public ServiceFeatureTable.FeatureRequestMode getFeatureRequestMode ()

Gets the Feature Request mode.

Returns
  • the feature request mode

public String getGeodatabaseVersion ()

Gets the geodatabase version.

Returns
  • the geodatabase version, or an empty string if there is no version

public Item getItem ()

Gets the item associated with this table.

Returns
  • the associated item or null if there is no associated item

public RequestConfiguration getRequestConfiguration ()

Gets the RequestConfiguration object in use by this table. If null is returned, then that indicates that the global RequestConfiguration is used instead.

Returns
  • the RequestConfiguration object or null if none has been set

public String getUri ()

Returns the URL used to create the table.

Returns
  • the URL used to create the table.

public ListenableFuture<Void> loadOrRefreshFeaturesAsync (Iterable<Feature> features)

Loads all attributes and geometries for unloaded features, and refetches attributes and geometry from already-loaded features. In the latter case, Geometries previously retrieved from features may be out of date and getGeometry() needs to be called again to get the correct Geometry.

This method will not refresh feature attachments. Use fetchAttachmentsAsync() to retrieve attachments.

This method makes network requests in order to fetch the data from the remote service.

Parameters
features the features to be reloaded or refetched
Returns
  • a ListenableFuture to reload or refetch the features asynchronously. Add a listener to the Future to know when the task is done.
Throws
IllegalArgumentException if features is null

public ListenableFuture<FeatureQueryResult> populateFromServiceAsync (QueryParameters query, boolean clearCache, Iterable<String> outFields)

Executes an asynchronous method that populates the table with the results of a query. The table must be in MANUAL_CACHE mode.

Parameters
query the query to execute
clearCache true if this table should be cleared when this method is called, false if the result of the query should be appended to this table
outFields the names of the fields to be populated or "*" for all fields
Returns
  • a ListenableFuture represents the result of the query; the results will replace or be appended to this table. The ListenableFuture indicates if the query isDone(); also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to IOException if a network request fails
Throws
IllegalArgumentException if the input is null
ArcGISRuntimeException if the query execution failed
IllegalStateException if the feature request mode is not MANUAL_CACHE

public ListenableFuture<FeatureQueryResult> queryFeaturesAsync (QueryParameters queryParameters, ServiceFeatureTable.QueryFeatureFields queryFields)

Queries features from this table's cache and/or from the service used to create this table.

  • This method does not need to be used if the table is in MANUAL_CACHE mode as the query will be performed locally and features will be returned fully loaded.
  • If the FeatureRequestMode is ON_INTERACTION_CACHE queries that only contain geometries which are within an extent that has been cached will be performed locally, otherwise they will be requested from the server.
  • If the FeatureRequestMode is ON_INTERACTION_NOCACHE the query will always be requested from the server. If the feature is to be edited or the attributes are shown in a UI (e.g. Popup) they should be loaded first.
Note: for MINIMUM and IDS_ONLY only the minimum set of fields are queried, additional information is returned when features are loaded.

Parameters
queryParameters query parameters to be used
queryFields specifies what fields will be populated on returned Features
Returns
  • a ListenableFuture representing the result of the query. The ListenableFuture indicates if the query operation isDone(); also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to IOException if a network request fails
Throws
IllegalArgumentException if the queryParameters or queryFields are null

public ListenableFuture<FeatureQueryResult> queryFeaturesAsync (QueryParameters query)

Queries features from this table's cache and/or from the service used to create this table. If the FeatureRequestMode is MANUAL_CACHE then the query will always be performed locally. If the FeatureRequestMode is ON_INTERACTION_CACHE then queries that contain geometries which are within an extent that has been cached will be performed locally, otherwise they will be performed on the server. If the FeatureRequestMode is ON_INTERACTION_NOCACHE the query will always be performed on the server.

Parameters
query query parameters to be used
Returns
  • a ListenableFuture represents the result of the query. The ListenableFuture indicates if the query isDone(); also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to IOException if a network request fails
Throws
ArcGISRuntimeException if the query execution failed

public ListenableFuture<List<RelatedFeatureQueryResult>> queryRelatedFeaturesAsync (ArcGISFeature feature, RelatedQueryParameters relatedQueryParameters, ServiceFeatureTable.QueryFeatureFields queryFields)

Asynchronously queries for features related to the given ArcGISFeature and using the given RelatedQueryParameters. Only returns results from tables that have been added to same ArcGISMap as this table. As there can be more than one instance of the same table or layer on the map with different scale level visibility, definition expression, and so on, a list of results are returned. In such cases, results from all instances are returned, one per related table containing features related to the queried feature, and getRelatedTable() is used to distinguish between them.

  • This method does not need to be used if the table is in MANUAL_CACHE mode as the query will be performed locally and features will be returned fully loaded.
  • If the FeatureRequestMode is ON_INTERACTION_CACHE queries that only contain geometries which are within an extent that has been cached will be performed locally, otherwise they will be requested from the server.
  • If the FeatureRequestMode is ON_INTERACTION_NOCACHE the query will always be requested from the server. If the feature is to be edited or the attributes are shown in a UI (e.g. Popup) they should be loaded first.
Note: for MINIMUM and IDS_ONLY only the minimum set of fields are queried, additional information is returned when features are loaded.

Parameters
feature feature for which to query related features
relatedQueryParameters related query parameters to be used
queryFields specifies what fields will be populated on returned Features
Returns
  • a ListenableFuture representing the resulting list of RelatedFeatureQueryResults and indicating if the query operation isDone(); also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to IOException if a network request fails
Throws
IllegalArgumentException if the feature, relatedQueryParameters, or queryFields are null

public void setBufferFactor (double bufferFactor)

Sets the factor used to calculate a buffered extent, within which features are automatically fetched and cached, if the FeatureRequestMode of the table is ON_INTERACTION_CACHE. By default it is 2.0 (two times the visible extent) The buffered extent is calculated as:

 width = bufferFactor : extent.width; 
 height = bufferFactor : extent.height;
 
 

public void setCredential (Credential credential)

Sets the credential used to authenticate the user with the service feature table.

Parameters
credential the credential used to authenticate the user with the service feature table

public void setDefinitionExpression (String definitionExpression)

Sets a definition expression which is a SQL statement where clause to filter out the features to be queried. Once a valid definition expression is set, it will be applied in the all subsequent queries. The FeatureLayer being created from the service table will inherit the same definition expression. Any changes applied on the definition expression of the feature layer is immediately applied to the table and vice versa. In the MANUAL_CACHE mode, the definition expression will be appended to the QueryParameters' where clause when populateFromServiceAsync(QueryParameters, boolean, Iterable) is called.

Parameters
definitionExpression an expression which is a SQL statement where clause to filter out the features to be queried, it can be null

public void setFeatureRequestMode (ServiceFeatureTable.FeatureRequestMode featureRequestMode)

Sets the Feature Request mode which affects how often data is retrieved from the service and how it is cached in the local table.

Parameters
featureRequestMode the feature request mode
Throws
IllegalArgumentException if the input is null

public void setGeodatabaseVersion (String version)

Sets the geodatabase version.

Parameters
version the version, can be null or empty

public void setRequestConfiguration (RequestConfiguration requestConfiguration)

Sets configuration parameters used for network requests sent using this table object. The global RequestConfiguration is used if no RequestConfiguration is set or null is set

Parameters
requestConfiguration object containing the parameters to use

public ListenableFuture<Void> undoLocalEditsAsync ()

Undoes all of the local edits since the last server acknowledgement.

Returns
  • a ListenableFuture to undo all of the local edits asynchronously. Add a listener to the Future to know when the task is done.