/** * 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. * * @param isSingleIndexEntry Pass <code>true</code> to use the specified <code>entryName</code> * parameter, or <code>false</code> to use PartitionKey and RowKey values from the operation * as the request identity. * @param entryName The entry name to use as the request identity if the <code>isSingleIndexEntry * </code> parameter is <code>true</code>. * @param encodeKeys Pass <code>true</code> to url encode the partition & row keys * @return A <code>String</code> containing the formatted request identity string. * @throws StorageException If a storage service error occurred. */ protected String generateRequestIdentity( boolean isSingleIndexEntry, final String entryName, boolean encodeKeys) throws StorageException { if (isSingleIndexEntry) { return String.format("'%s'", entryName); } if (this.opType == TableOperationType.INSERT) { return Constants.EMPTY_STRING; } else { String pk = null; String rk = null; if (this.opType == TableOperationType.RETRIEVE) { final QueryTableOperation qOp = (QueryTableOperation) this; pk = qOp.getPartitionKey(); rk = qOp.getRowKey(); } else { pk = this.getEntity().getPartitionKey(); rk = this.getEntity().getRowKey(); } return String.format( "%s='%s',%s='%s'", TableConstants.PARTITION_KEY, encodeKeys ? Utility.safeEncode(pk) : pk, TableConstants.ROW_KEY, encodeKeys ? Utility.safeEncode(rk) : rk); } }
/** * A static factory method returning a {@link TableOperation} instance to retrieve the specified * table entity and return it as the specified type. To execute this {@link TableOperation} on a * given table, call the {@link CloudTableClient#execute(String, TableOperation)} method on a * {@link CloudTableClient} instance with the table name and the {@link TableOperation} as * arguments. * * @param partitionKey A <code>String</code> containing the PartitionKey value for the entity to * retrieve. * @param rowKey A <code>String</code> containing the RowKey value for the entity to retrieve. * @param clazzType The class type of the table entity object to retrieve. * @return A new {@link TableOperation} instance for retrieving the table entity. */ public static TableOperation retrieve( final String partitionKey, final String rowKey, final Class<? extends TableEntity> clazzType) { final QueryTableOperation retOp = new QueryTableOperation(partitionKey, rowKey); retOp.setClazzType(clazzType); return retOp; }
/** * A static factory method returning a {@link TableOperation} instance to retrieve the specified * table entity and return a projection of it using the specified resolver. To execute this {@link * TableOperation} on a given table, call the {@link CloudTableClient#execute(String, * TableOperation)} method on a {@link CloudTableClient} instance with the table name and the * {@link TableOperation} as arguments. * * @param partitionKey A <code>String</code> containing the PartitionKey value for the entity to * retrieve. * @param rowKey A <code>String</code> containing the RowKey value for the entity to retrieve. * @param resolver The implementation of {@link EntityResolver} to use to project the result * entity as type T. * @return A new {@link TableOperation} instance for retrieving the table entity. */ public static TableOperation retrieve( final String partitionKey, final String rowKey, final EntityResolver<?> resolver) { final QueryTableOperation retOp = new QueryTableOperation(partitionKey, rowKey); retOp.setResolver(resolver); return retOp; }