共用方式為


TableOperation Class

  • java.lang.Object
    • com.microsoft.azure.storage.table.TableOperation

public class TableOperation

A class which represents a single table operation.

Use the static factory methods to construct TableOperation instances for operations on tables that insert, update, merge, delete, replace or retrieve table entities. To execute a TableOperation instance, call the method on a CloudTableClient instance. A TableOperation may be executed directly or as part of a TableBatchOperation. If a TableOperation returns an entity result, it is stored in the corresponding TableResult returned by the method.

Constructor Summary

Constructor Description
TableOperation()

Nullary Default Constructor.

TableOperation(final TableEntity entity, final TableOperationType opType)

Reserved for internal use. Constructs a TableOperation with the specified table entity and operation type.

TableOperation(final TableEntity entity, final TableOperationType opType, final boolean echoContent)

Reserved for internal use. Constructs a TableOperation with the specified table entity and operation type.

Method Summary

Modifier and Type Method and Description
TableOperation delete(final TableEntity entity)

A static factory method returning a TableOperation instance to delete the specified entity from Microsoft Azure storage. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

TableResult execute(final CloudTableClient client, final String tableName, TableRequestOptions options, OperationContext opContext)

Reserved for internal use. Execute this table operation on the specified table, using the specified TableRequestOptions and OperationContext.

This method will invoke the Storage Service REST API to execute this table operation, using the Table service endpoint and storage account credentials in the CloudTableClient object.

String generateRequestIdentity(boolean isSingleIndexEntry, final String entryName)

Reserved for internal use. Generates the request identity, consisting of the specified entry name, or the PartitionKey and RowKey pair from the operation, to identify the operation target.

String generateRequestIdentityWithTable(final String tableName)

Reserved for internal use. Generates the request identity string for the specified table. The request identity string combines the table name with the PartitionKey and RowKey from the operation to identify specific table entities. This request identity is already UrlEncoded.

boolean getEchoContent()

Gets the boolean representing whether the message payload should be returned in the response.

synchronized final TableEntity getEntity()

Reserved for internal use. Gets the table entity associated with this operation.

synchronized final TableOperationType getOperationType()

Reserved for internal use. Gets the operation type for this operation.

TableOperation insert(final TableEntity entity)

A static factory method returning a TableOperation instance to insert the specified entity into Microsoft Azure storage. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

TableOperation insert(final TableEntity entity, boolean echoContent)

A static factory method returning a TableOperation instance to insert the specified entity into Microsoft Azure storage. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

TableOperation insertOrMerge(final TableEntity entity)

A static factory method returning a TableOperation instance to merge the specified entity into Microsoft Azure storage, or insert it if it does not exist. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the table name and the TableOperation as arguments.

TableOperation insertOrReplace(final TableEntity entity)

A static factory method returning a TableOperation instance to replace the specified entity in Microsoft Azure storage, or insert it if it does not exist. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the table name and the TableOperation as arguments.

TableOperation merge(final TableEntity entity)

A static factory method returning a TableOperation instance to merge the specified table entity into Microsoft Azure storage. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

TableResult parseResponse(final InputStream inStream, final int httpStatusCode, String etagFromHeader, final OperationContext opContext, final TableRequestOptions options)

Reserved for internal use. Parses the table operation response into a TableResult to return.

TableOperation replace(final TableEntity entity)

A static factory method returning a TableOperation instance to replace the specified table entity. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method.

TableOperation retrieve(final String partitionKey, final String rowKey, final Class<? extends TableEntity> clazzType)

A static factory method returning a TableOperation instance to retrieve the specified table entity and return it as the specified type. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

TableOperation retrieve(final String partitionKey, final String rowKey, final EntityResolver<?> resolver)

A static factory method returning a TableOperation instance to retrieve the specified table entity and return a projection of it using the specified resolver. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the table name and the TableOperation as arguments.

void setEchoContent(boolean echoContent)

Sets the boolean representing whether the message payload should be returned in the response.

synchronized final void setEntity(final TableEntity entity)

Reserved for internal use. Sets the TableEntity instance for the table operation.

Constructor Details

TableOperation

protected TableOperation()

Nullary Default Constructor.

TableOperation

protected TableOperation(final TableEntity entity, final TableOperationType opType)

Reserved for internal use. Constructs a TableOperation with the specified table entity and operation type.

Parameters:

entity - The object instance implementing TableEntity to associate with the operation.
opType - The TableOperationType enumeration value for the operation type.

TableOperation

protected TableOperation(final TableEntity entity, final TableOperationType opType, final boolean echoContent)

Reserved for internal use. Constructs a TableOperation with the specified table entity and operation type.

Parameters:

entity - The object instance implementing TableEntity to associate with the operation.
opType - The TableOperationType enumeration value for the operation type.
echoContent - The boolean representing whether the message payload should be returned in the response.

Method Details

delete

public static TableOperation delete(final TableEntity entity)

A static factory method returning a TableOperation instance to delete the specified entity from Microsoft Azure storage. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

Parameters:

entity - The object instance implementing TableEntity to associate with the operation.

Returns:

A new TableOperation instance to insert the table entity.

execute

protected TableResult execute(final CloudTableClient client, final String tableName, TableRequestOptions options, OperationContext opContext)

Reserved for internal use. Execute this table operation on the specified table, using the specified TableRequestOptions and OperationContext.

This method will invoke the Storage Service REST API to execute this table operation, using the Table service endpoint and storage account credentials in the CloudTableClient object.

Parameters:

client - A CloudTableClient instance specifying the Table service endpoint, storage account credentials, and any additional query parameters.
tableName - A String which specifies the name of the table.
options - A TableRequestOptions object that specifies execution options such as retry policy and timeout settings for the operation.
opContext - An OperationContext object for tracking the current operation.

Returns:

A TableResult which represents the results of executing the operation.

Throws:

StorageException - if an error occurs in the storage operation.

generateRequestIdentity

protected String generateRequestIdentity(boolean isSingleIndexEntry, final String entryName)

Reserved for internal use. Generates the request identity, consisting of the specified entry name, or the PartitionKey and RowKey pair from the operation, to identify the operation target.

Parameters:

isSingleIndexEntry - Pass true to use the specified entryName parameter, or false to use PartitionKey and RowKey values from the operation as the request identity.
entryName - The entry name to use as the request identity if the isSingleIndexEntry parameter is true.

Returns:

A String which represents the formatted request identity string.

Throws:

StorageException - If a storage service error occurred.

generateRequestIdentityWithTable

protected String generateRequestIdentityWithTable(final String tableName)

Reserved for internal use. Generates the request identity string for the specified table. The request identity string combines the table name with the PartitionKey and RowKey from the operation to identify specific table entities. This request identity is already UrlEncoded.

Parameters:

tableName - A String which specifies the name of the table.

Returns:

A String which represents the formatted request identity string for the specified table.

Throws:

StorageException

getEchoContent

protected boolean getEchoContent()

Gets the boolean representing whether the message payload should be returned in the response.

Returns:

true if the message payload should be returned in the response; otherwise false

getEntity

protected synchronized final TableEntity getEntity()

Reserved for internal use. Gets the table entity associated with this operation.

Returns:

The TableEntity instance associated with this operation.

getOperationType

protected synchronized final TableOperationType getOperationType()

Reserved for internal use. Gets the operation type for this operation.

Returns:

the opType The TableOperationType instance associated with this operation.

insert

public static TableOperation insert(final TableEntity entity)

A static factory method returning a TableOperation instance to insert the specified entity into Microsoft Azure storage. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

Parameters:

entity - The object instance implementing TableEntity to associate with the operation.

Returns:

A new TableOperation instance to insert the table entity.

insert

public static TableOperation insert(final TableEntity entity, boolean echoContent)

A static factory method returning a TableOperation instance to insert the specified entity into Microsoft Azure storage. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

Parameters:

entity - The object instance implementing TableEntity to associate with the operation.
echoContent - The boolean representing whether the message payload should be returned in the response.

Returns:

A new TableOperation instance to insert the table entity.

insertOrMerge

public static TableOperation insertOrMerge(final TableEntity entity)

A static factory method returning a TableOperation instance to merge the specified entity into Microsoft Azure storage, or insert it if it does not exist. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the table name and the TableOperation as arguments.

Parameters:

entity - The object instance implementing TableEntity to associate with the operation.

Returns:

A new TableOperation instance for inserting or merging the table entity.

insertOrReplace

public static TableOperation insertOrReplace(final TableEntity entity)

A static factory method returning a TableOperation instance to replace the specified entity in Microsoft Azure storage, or insert it if it does not exist. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the table name and the TableOperation as arguments.

Parameters:

entity - The object instance implementing TableEntity to associate with the operation.

Returns:

A new TableOperation instance for inserting or replacing the table entity.

merge

public static TableOperation merge(final TableEntity entity)

A static factory method returning a TableOperation instance to merge the specified table entity into Microsoft Azure storage. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

Parameters:

entity - The object instance implementing TableEntity to associate with the operation.

Returns:

A new TableOperation instance for merging the table entity.

parseResponse

protected TableResult parseResponse(final InputStream inStream, final int httpStatusCode, String etagFromHeader, final OperationContext opContext, final TableRequestOptions options)

Reserved for internal use. Parses the table operation response into a TableResult to return.

Parameters:

inStream - An InputStream which specifies the response to an insert operation.
httpStatusCode - An int which represents the HTTP status code returned from the operation request.
etagFromHeader - The String which specifies the Etag returned with the operation response.
opContext - An OperationContext object that represents the context for the current operation.
options

Returns:

The TableResult representing the result of the operation.

Throws:

InstantiationException - if an error occurs in object construction.
IllegalAccessException - if an error occurs in reflection on an object type.
StorageException - if an error occurs in the storage operation.
IOException - if an error occurs while accessing the InputStream with Json.
JsonParseException - if an error occurs while parsing the Json, if Json is used.

replace

public static TableOperation replace(final TableEntity entity)

A static factory method returning a TableOperation instance to replace the specified table entity. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method.

Parameters:

entity - The object instance implementing TableEntity to associate with the operation.

Returns:

A new TableOperation instance for replacing the table entity.

retrieve

public static TableOperation retrieve(final String partitionKey, final String rowKey, final Class clazzType)

A static factory method returning a TableOperation instance to retrieve the specified table entity and return it as the specified type. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the

Parameters:

partitionKey - A String which specifies the PartitionKey value for the entity to retrieve.
rowKey - A String which specifies the RowKey value for the entity to retrieve.
clazzType - The class type of the table entity object to retrieve.

Returns:

A new TableOperation instance for retrieving the table entity.

retrieve

public static TableOperation retrieve(final String partitionKey, final String rowKey, final EntityResolver resolver)

A static factory method returning a TableOperation instance to retrieve the specified table entity and return a projection of it using the specified resolver. To execute this TableOperation on a given table, call the execute(final TableOperation operation) method on a CloudTableClient instance with the table name and the TableOperation as arguments.

Parameters:

partitionKey - A String which specifies the PartitionKey value for the entity to retrieve.
rowKey - A String which specifies the RowKey value for the entity to retrieve.
resolver - The implementation of EntityResolver<T> to use to project the result entity as type T.

Returns:

A new TableOperation instance for retrieving the table entity.

setEchoContent

protected void setEchoContent(boolean echoContent)

Sets the boolean representing whether the message payload should be returned in the response.

Parameters:

echoContent -

true if the message payload should be returned in the response; otherwise false.

setEntity

protected synchronized final void setEntity(final TableEntity entity)

Reserved for internal use. Sets the TableEntity instance for the table operation.

Parameters:

entity - The TableEntity instance to set.

Applies to