TableEntity Interface

public interface 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.

Method Summary

Modifier and Type Method and Description
String getEtag()

Gets the ETag value to verify for the entity. This value is used to determine if the table entity has changed since it was last read from Microsoft Azure storage. The client cannot update this value on the service.

String getPartitionKey()

Gets the PartitionKey value for the entity.

String getRowKey()

Gets the RowKey value for the entity.

Date getTimestamp()

Gets the Timestamp for the entity. The server manages the value of Timestamp, which cannot be modified.

void readEntity(HashMap<String, EntityProperty> properties, OperationContext opContext)

Populates an instance of the object implementing TableEntity using the specified properties parameter, which represents a map of property names to EntityProperty data typed values.

void setEtag(String etag)

Sets the ETag value to verify for the entity. This value is used to determine if the table entity has changed since it was last read from Microsoft Azure storage. The client cannot update this value on the service.

void setPartitionKey(String partitionKey)

Sets the PartitionKey value for the entity.

void setRowKey(String rowKey)

Sets the RowKey value for the entity.

void setTimestamp(Date timeStamp)

Sets the Timestamp value for the entity. Note that timestamp is a read-only property on the service and should not be set by the user.

HashMap<String, EntityProperty> writeEntity(OperationContext opContext)

Returns a map of property names to EntityProperty data typed values that represents the serialized content of the table entity instance.

Method Details

getEtag

public String getEtag()

Gets the ETag value to verify for the entity. This value is used to determine if the table entity has changed since it was last read from Microsoft Azure storage. The client cannot update this value on the service.

Returns:

A String which represents the ETag for the entity.

getPartitionKey

public String getPartitionKey()

Gets the PartitionKey value for the entity.

Returns:

A String which represents the PartitionKey value for the entity.

getRowKey

public String getRowKey()

Gets the RowKey value for the entity.

Returns:

A String which represents the RowKey value for the entity.

getTimestamp

public Date getTimestamp()

Gets the Timestamp for the entity. The server manages the value of Timestamp, which cannot be modified.

Returns:

A java.util.Date object which represents the Timestamp value for the entity.

readEntity

public void readEntity(HashMap properties, OperationContext opContext)

Populates an instance of the object implementing TableEntity using the specified properties parameter, which represents a map of property names to EntityProperty data typed values.

Parameters:

properties - The java.util.HashMap of String to EntityProperty data typed values to use to populate the table entity instance.
opContext - An OperationContext object used to track the execution of the operation.

Throws:

StorageException - If an error occurs during the operation.

setEtag

public void setEtag(String etag)

Sets the ETag value to verify for the entity. This value is used to determine if the table entity has changed since it was last read from Microsoft Azure storage. The client cannot update this value on the service.

Parameters:

etag - A String which specifies the ETag to set for the entity.

setPartitionKey

public void setPartitionKey(String partitionKey)

Sets the PartitionKey value for the entity.

Parameters:

partitionKey - A String which specifies the PartitionKey value to set for the entity.

setRowKey

public void setRowKey(String rowKey)

Sets the RowKey value for the entity.

Parameters:

rowKey - A String which specifies the RowKey value to set for the entity.

setTimestamp

public void setTimestamp(Date timeStamp)

Sets the Timestamp value for the entity. Note that timestamp is a read-only property on the service and should not be set by the user.

Parameters:

timeStamp - A java.util.Date which specifies the Timestamp value to set for the entity.

writeEntity

public HashMap writeEntity(OperationContext opContext)

Returns a map of property names to EntityProperty data typed values that represents the serialized content of the table entity instance.

Parameters:

opContext - An OperationContext object used to track the execution of the operation.

Returns:

A java.util.HashMap of String property names to EntityProperty data typed values representing the properties of the table entity.

Throws:

StorageException - If an error occurs during the operation.

Applies to