com.microsoft.azure.storage.table

Classes

CloudTable

Represents a table in the Microsoft Azure Table service.

CloudTableClient

Provides a service client for accessing the Microsoft Azure Table service.

The CloudTableClient class encapsulates the base URI for the Table service endpoint and the credentials for accessing the storage account, and provides methods to create, delete, list, and query tables, as well as methods to execute operations and queries on table entities. These methods invoke Storage Service REST API operations to make the requests and obtain the results that are returned.

A Table service endpoint is the base URI for Table service resources, including the DNS name of the storage account:

For more information, see the MSDN topic Addressing Table Service Resources.

The credentials can be a combination of the storage account name and a key, or a shared access signature. For more information, see the MSDN topic Authenticating Access to Your Storage Account.

DynamicTableEntity

A TableEntity type which allows callers direct access to the property map of the entity. This class extends TableServiceEntity to eliminate the use of reflection for serialization and deserialization.

EntityProperty

A class which represents a single typed property value in a table entity. An EntityProperty stores the data type as an EdmType. The value, which may be for object types, but not for primitive types, is serialized and stored as a .

EntityProperty provides overloaded constructors and overloads of the method for supported value types. Each overloaded constructor or method sets the EdmType and serializes the value appropriately based on the parameter type.

Use one of the Type methods to deserialize an EntityProperty as the appropriate Java type. The method will throw a ParseException or IllegalArgumentException if the EntityProperty cannot be deserialized as the Java type.

QueryTableOperation

A class that extends TableOperation to implement a query to retrieve a single table entity. To execute a QueryTableOperation instance, call the method on a CloudTableClient instance. This operation can be executed directly or as part of a TableBatchOperation. If the QueryTableOperation returns an entity result, it is stored in the corresponding TableResult returned by the method.

SharedAccessTablePolicy

Represents a shared access policy, which specifies the start time, expiry time, and permissions for a shared access signature.

TableBatchOperation

A class which represents a batch operation. A batch operation is a collection of table operations which are executed by the Storage Service REST API as a single atomic operation, by invoking an Entity Group Transaction.

A batch operation may contain up to 100 individual table operations, with the requirement that each operation entity must have same partition key. A batch with a retrieve operation cannot contain any other operations. Note that the total payload of a batch operation is limited to 4MB.

TableEncryptionPolicy

Represents a table encryption policy that is used to perform envelope encryption/decryption of Azure table entities.

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.

TablePermissions

Represents the permissions for a table.

TableQuery<T>

A class which represents a query against a specified table. A TableQuery<T> instance aggregates the query parameters to use when the query is executed. One of the or methods of CloudTableClient must be called to execute the query. The parameters are encoded and passed to the server when the table query is executed.

To create a table query with fluent syntax, the from(final Class<T> clazzType) static factory method and the where(final String filter), select(final String[] columns), and take(final Integer take) mutator methods each return a reference to the object which can be chained into a single expression. Use the from(Class) static class factory method to create a instance that executes on the named table with entities of the specified TableEntity implementing type. Use the where(final String filter) method to specify a filter expression for the entities returned. Use the select(final String[] columns) method to specify the table entity properties to return. Use the take(final Integer take) method to limit the number of entities returned by the query. Note that nothing prevents calling these methods more than once on a , so the values saved in the will be the last encountered in order of execution.

As an example, you could construct a table query using fluent syntax:

This example creates a query on the "Products" table for all entities where the PartitionKey value is "ProductsMNO" and the RowKey value is greater than or equal to "Napkin" and requests the first 25 matching entities, selecting only the common properties and the property named "InventoryCount", and returns them as DynamicTableEntity objects.

Filter expressions for use with the where(final String filter) method or setFilterString(final String filterString) method can be created using fluent syntax with the overloaded generateFilterCondition(String propertyName, String operation, final boolean value) methods and combineFilters(String filterA, String operator, String filterB) method, using the comparison operators defined in QueryComparisons and the logical operators defined in Operators. Note that the first operand in a filter comparison must be a property name, and the second operand must evaluate to a constant. The PartitionKey and RowKey property values are types for comparison purposes.

The values that may be used in table queries are explained in more detail in the MSDN topic Querying Tables and Entities, but note that the space characters within values do not need to be URL-encoded, as this will be done when the query is executed.

The TableQuery#TableQuery(Class) constructor and TableQuery#from(Class) static factory methods require a class type which implements TableEntity and contains a nullary constructor. If the query will be executed using an EntityResolver<T>, the caller may specify TableServiceEntity as the class type.

TableRequestOptions

Represents a set of timeout, payload format, and retry policy options that may be specified for a table operation request.

TableResult

A class which represents the result of a table operation. The TableResult class encapsulates the HTTP response and any table entity results returned by the Storage Service REST API operation called for a particular TableOperation.

TableServiceEntity

The TableServiceEntity class represents the base object type for a table entity in the Storage service. TableServiceEntity provides a base implementation for the TableEntity interface that provides and methods that by default serialize and deserialize all properties via reflection. A table entity class may extend this class and override the and methods to provide customized or more performant serialization logic.

The use of reflection allows subclasses of TableServiceEntity to be serialized and deserialized without having to implement the serialization code themselves. When both a getter method and setter method are found for a given property name and data type, then the appropriate method is invoked automatically to serialize or deserialize the data. To take advantage of the automatic serialization code, your table entity classes should provide getter and setter methods for each property in the corresponding table entity in Microsoft Azure table storage. The reflection code looks for getter and setter methods in pairs of the form

and

where PropertyName is a property name for the table entity, and type is a Java type compatible with the EDM data type of the property. See the table below for a map of property types to their Java equivalents. The StoreAs annotation may be applied with a attribute to specify a property name for reflection on getter and setter methods that do not follow the property name convention. Method names and the attribute of StoreAs annotations are case sensitive for matching property names with reflection. Use the Ignore annotation to prevent methods from being used by reflection for automatic serialization and deserialization. Note that the names "PartitionKey", "RowKey", "Timestamp", and "Etag" are reserved and will be ignored if set with the StoreAs annotation in a subclass.

The following table shows the supported property data types in Microsoft Azure storage and the corresponding Java types when deserialized.

Supported property data types in Microsoft Azure storage

See the MSDN topic Understanding the Table Service Data Model for an overview of tables, entities, and properties as used in the Microsoft Azure Storage service.

For an overview of the available EDM primitive data types and names, see the

Primitive Data Types section of the OData Protocol Overview.

TableServiceException

An exception that results when a table storage service operation fails to complete successfully.

TableQuery.Operators

A static class that maps identifiers to filter expression operators.

TableQuery.QueryComparisons

A static class that maps identifiers to filter property comparison operators.

Interfaces

Encrypt

Represents a custom attribute that can be used to indicate whether an entity property should be encrypted. Use this annotation to specify whether to encrypt the data stored by a setter method or decrypt the data retrieved by a getter method in a class implementing TableEntity.

EntityResolver<T>

An interface to perform client side projection on a retrieved entity. An EntityResolver<T> instance must implement a method projecting the entity data represented by the parameters passed in as a new instance of the type specified by the type parameter.

This interface is useful for converting directly from table entity data to a client object type without requiring a separate table entity class type that deserializes every property individually. For example, a client can perform a client side projection of a Customer entity by simply returning the for the CustomerName property of each entity. The result of this projection will be a collection of s containing each customer name.

Ignore

An annotation set on a method to prevent its use in serializing or deserializing a property by reflection. Apply the annotation to methods in a class implementing TableEntity to force them to be ignored during reflection-based serialization and deserialization. See the documentation for TableServiceEntity for more information on using reflection-based serialization and deserialization.

StoreAs

An annotation used to override the name a property is serialized and deserialized with using reflection. Use this annotation to specify the property name to associate with the data stored by a setter method or retrieved by a getter method in a class implementing TableEntity that uses reflection-based serialization and deserialization. Note that the names "PartitionKey", "RowKey", "Timestamp", and "Etag" are reserved and will be ignored if set with the annotation.

Example:

This example shows how the methods that would get and set an entity property named ObjectPropertyName in the default case can be annotated to get and set an entity property named EntityPropertyName. See the documentation for TableServiceEntity for more information on using reflection-based serialization and deserialization.

TableEntity

An interface required for table entity types. The TableEntity interface declares getter and setter methods for the common entity properties, and and methods for serialization and deserialization of all entity properties using a property map. Create classes implementing TableEntity to customize property storage, retrieval, serialization and deserialization, and to provide additional custom logic for a table entity.

The Storage client library includes two implementations of TableEntity that provide for simple property access and serialization:

DynamicTableEntity implements TableEntity and provides a simple property map to store and retrieve properties. Use a DynamicTableEntity for simple access to entity properties when only a subset of properties are returned (for example, by a select clause in a query), or for when your query can return multiple entity types with different properties. You can also use this type to perform bulk table updates of heterogeneous entities without losing property information.

TableServiceEntity is an implementation of TableEntity that uses reflection-based serialization and deserialization behavior in its and methods. TableServiceEntity-derived classes with methods that follow a convention for types and naming are serialized and deserialized automatically.

Any class that implements TableEntity can take advantage of the automatic reflection-based serialization and deserialization behavior in TableServiceEntity by invoking the static methods in and in . The class must provide methods that follow the type and naming convention to be serialized and deserialized automatically. When both a getter method and setter method are found for a given property name and data type, then the appropriate method is invoked automatically to serialize or deserialize the data. The reflection code looks for getter and setter methods in pairs of the form

and

where PropertyName is a property name for the table entity, and type is a Java type compatible with the EDM data type of the property. See the table in the class description for TableServiceEntity for a map of property types to their Java equivalents. The StoreAs annotation may be applied with a attribute to specify a property name for reflection on getter and setter methods that do not follow the property name convention. Method names and the attribute of StoreAs annotations are case sensitive for matching property names with reflection. Use the Ignore annotation to prevent methods from being used by reflection for automatic serialization and deserialization. Note that the names "PartitionKey", "RowKey", "Timestamp", and "Etag" are reserved and will be ignored if set with the StoreAs annotation in a subclass that uses the reflection methods.

TableRequestOptions.EncryptionResolver

The interface whose function is used to get the value indicating whether a property should be encrypted or not given the partition key, row key, and the property name.

TableRequestOptions.PropertyResolver

The interface whose function is used to get the EdmType for an entity property given the partition key, row, key, and the property name, if the interface is implemented

Enums

EdmType

A enumeration used to represent the primitive types of the Entity Data Model (EDM) in the Open Data Protocol (OData). The EDM is the underlying abstract data model used by OData services. The EdmType enumeration includes a parse(final String value) method to convert EDM data type names to the enumeration type, and overrides the toString() method to produce an EDM data type name.

For more information about OData, see the Open Data Protocol website.

For an overview of the available EDM primitive data types and names, see the Primitive Data Types section of the OData Protocol Overview.

The Abstract Type System used to define the primitive types supported by OData is defined in detail in [MC-CSDL] (section 2.2.1).

SharedAccessTablePermissions

Specifies the set of possible permissions for a shared access table policy.

TablePayloadFormat

Describes the payload formats supported for Tables.