signature:
public class MimeHelper { /** * Reserved for internal use . A static factory method that constructs a { @ link MimeHeader } by parsing the MIME
 * header
 * data from a { @ link BufferedReader } .
 * @ param reader
 * The { @ link BufferedReader } containing the response stream to parse .
 * @ param opContext
 * An { @ link OperationContext } object for tracking the current operation . Specify < code > null < / code > to
 * safely ignore operation context .
 * @ return
 * A { @ link MimeHeader } constructed by parsing the MIME header data from the { @ link BufferedReader } .
 * @ throws IOException
 * if an error occurs accessing the input stream .
 * @ throws StorageException
 * if an error occurs parsing the input stream . */
private static MimeHeader readMimeHeader ( final BufferedReader reader , final OperationContext opContext ) throws IOException , StorageException { } }

implementation:
final MimeHeader retHeader = new MimeHeader ( ) ; reader . mark ( 1024 * 1024 ) ; // First thing is separator
retHeader . boundary = getNextLineSkippingBlankLines ( reader ) ; if ( retHeader . boundary . endsWith ( "--" ) ) { return null ; } if ( ! retHeader . boundary . startsWith ( "--" ) ) { reader . reset ( ) ; return null ; } for ( int m = 0 ; m < 2 ; m ++ ) { final String tempString = reader . readLine ( ) ; if ( tempString == null || tempString . length ( ) == 0 ) { break ; } if ( tempString . startsWith ( "Content-Type:" ) ) { final String [ ] headerVals = tempString . split ( "Content-Type: " ) ; if ( headerVals == null || headerVals . length != 2 ) { throw generateMimeParseException ( ) ; } retHeader . contentType = headerVals [ 1 ] ; } else if ( tempString . startsWith ( "Content-Transfer-Encoding:" ) ) { final String [ ] headerVals = tempString . split ( "Content-Transfer-Encoding: " ) ; if ( headerVals == null || headerVals . length != 2 ) { throw generateMimeParseException ( ) ; } retHeader . contentTransferEncoding = headerVals [ 1 ] ; } else { throw generateMimeParseException ( ) ; } } // Validate headers
if ( Utility . isNullOrEmpty ( retHeader . boundary ) || retHeader . contentType == null ) { throw generateMimeParseException ( ) ; } if ( retHeader . contentType . startsWith ( "multipart/mixed; boundary=" ) ) { final String [ ] headerVals = retHeader . contentType . split ( "multipart/mixed; boundary=" ) ; if ( headerVals == null || headerVals . length != 2 ) { throw generateMimeParseException ( ) ; } retHeader . subBoundary = "--" . concat ( headerVals [ 1 ] ) ; } else if ( ! retHeader . contentType . equals ( "application/http" ) ) { throw generateMimeParseException ( ) ; } if ( retHeader . contentTransferEncoding != null && ! retHeader . contentTransferEncoding . equals ( "binary" ) ) { throw generateMimeParseException ( ) ; } return retHeader ;


signature:
public class MimeHelper { /** * Reserved for internal use . A static factory method that generates a { @ link MimePart } containing the next MIME
 * part read from the { @ link BufferedReader } .
 * The { @ link BufferedReader } is left positioned at the start of the next MIME boundary header .
 * @ param reader
 * The { @ link BufferedReader } containing the response stream to parse .
 * @ param boundary
 * A < code > String < / code > containing the MIME part boundary string .
 * An { @ link OperationContext } object for tracking the current operation . Specify < code > null < / code > to
 * safely ignore operation context .
 * @ return
 * A { @ link MimePart } constructed by parsing the next MIME part data from the { @ link BufferedReader } .
 * @ throws IOException
 * if an error occured accessing the input stream .
 * @ throws StorageException
 * if an error occured parsing the input stream . */
private static MimePart readMimePart ( final BufferedReader reader , final String boundary , final OperationContext opContext ) throws IOException , StorageException { } }

implementation:
final MimePart retPart = new MimePart ( ) ; // Read HttpStatus code
String tempStr = getNextLineSkippingBlankLines ( reader ) ; if ( ! tempStr . startsWith ( "HTTP/1.1 " ) ) { throw generateMimeParseException ( ) ; } final String [ ] headerVals = tempStr . split ( " " ) ; if ( headerVals . length < 3 ) { throw generateMimeParseException ( ) ; } retPart . httpStatusCode = Integer . parseInt ( headerVals [ 1 ] ) ; // " HTTP / 1.1 XXX " . length ( ) = > 13
retPart . httpStatusMessage = tempStr . substring ( 13 ) ; // Read headers
tempStr = reader . readLine ( ) ; while ( tempStr != null && tempStr . length ( ) > 0 ) { final String [ ] headerParts = tempStr . split ( ": " ) ; if ( headerParts . length < 2 ) { throw generateMimeParseException ( ) ; } retPart . headers . put ( headerParts [ 0 ] , headerParts [ 1 ] ) ; tempStr = reader . readLine ( ) ; } // Store json payload
reader . mark ( 1024 * 1024 ) ; tempStr = getNextLineSkippingBlankLines ( reader ) ; if ( tempStr == null ) { throw generateMimeParseException ( ) ; } // empty body
if ( tempStr . startsWith ( boundary ) ) { reader . reset ( ) ; retPart . payload = Constants . EMPTY_STRING ; return retPart ; } final StringBuilder payloadBuilder = new StringBuilder ( ) ; // read until mime closure or end of file
while ( ! tempStr . startsWith ( boundary ) ) { payloadBuilder . append ( tempStr ) ; reader . mark ( 1024 * 1024 ) ; tempStr = getNextLineSkippingBlankLines ( reader ) ; if ( tempStr == null ) { throw generateMimeParseException ( ) ; } } // positions stream at start of next MIME Header
reader . reset ( ) ; retPart . payload = payloadBuilder . toString ( ) ; return retPart ;


signature:
public class MimeHelper { /** * Reserved for internal use . Writes a MIME part boundary to the output stream .
 * @ param outWriter
 * The { @ link OutputStreamWriter } to write the MIME part boundary to .
 * @ param boundaryID
 * The < code > String < / code > containing the MIME part boundary string .
 * @ throws IOException
 * if an error occurs writing to the output stream . */
private static void writeMIMEBoundary ( final OutputStreamWriter outWriter , final String boundaryID ) throws IOException { } }

implementation: outWriter . write ( String . format ( "--%s\r\n" , boundaryID ) ) ;


signature:
public class MimeHelper { /** * Reserved for internal use . Writes a MIME part boundary closure to the output stream .
 * @ param outWriter
 * The { @ link OutputStreamWriter } to write the MIME part boundary closure to .
 * @ param boundaryID
 * The < code > String < / code > containing the MIME part boundary string .
 * @ throws IOException
 * if an error occurs writing to the output stream . */
private static void writeMIMEBoundaryClosure ( final OutputStreamWriter outWriter , final String boundaryID ) throws IOException { } }

implementation: outWriter . write ( String . format ( "--%s--\r\n" , boundaryID ) ) ;


signature:
public class MimeHelper { /** * Reserved for internal use . Writes a MIME content type string to the output stream .
 * @ param outWriter
 * The { @ link OutputStreamWriter } to write the MIME content type string to .
 * @ param boundaryID
 * The < code > String < / code > containing the MIME part boundary string .
 * @ throws IOException
 * if an error occurs writing to the output stream . */
private static void writeMIMEContentType ( final OutputStreamWriter outWriter , final String boundaryName ) throws IOException { } }

implementation: outWriter . write ( String . format ( "Content-Type: multipart/mixed; boundary=%s\r\n" , boundaryName ) ) ;


signature:
public class MimeHelper { /** * Reserved for internal use . Generates a < code > String < / code > containing the entity associated with an operation in
 * Json format .
 * @ param operation
 * A { @ link TableOperation } containing the entity to write to the returned < code > String < / code > .
 * @ param opContext
 * An { @ link OperationContext } object for tracking the current operation . Specify < code > null < / code > to
 * safely ignore operation context .
 * @ return
 * A < code > String < / code > containing the entity associated with the operation in Json format
 * @ throws StorageException
 * if a Storage error occurs .
 * @ throws IOException */
private static String writeStringForOperation ( final TableOperation operation , TablePayloadFormat format , final OperationContext opContext ) throws StorageException , IOException { } }

implementation: Utility . assertNotNull ( "entity" , operation . getEntity ( ) ) ; final StringWriter outWriter = new StringWriter ( ) ; TableEntitySerializer . writeSingleEntity ( outWriter , operation . getEntity ( ) , false , opContext ) ; outWriter . write ( "\r\n" ) ; return outWriter . toString ( ) ;


signature:
public class MimeHelper { /** * Reserved for internal use . A static factory method that generates a { @ link StorageException } for invalid MIME
 * responses .
 * @ return
 * The { @ link StorageException } for the invalid MIME response . */
private static StorageException generateMimeParseException ( ) { } }

implementation: return new StorageException ( StorageErrorCodeStrings . OUT_OF_RANGE_INPUT , SR . INVALID_MIME_RESPONSE , Constants . HeaderConstants . HTTP_UNUSED_306 , null , null ) ;


signature:
public class MimeHelper { /** * Reserved for internal use . Returns the next non - blank line from the { @ link BufferedReader } .
 * @ param reader
 * The { @ link BufferedReader } to read lines from .
 * @ return
 * A < code > String < / code > containing the next non - blank line from the { @ link BufferedReader } , or
 * < code > null < / code > .
 * @ throws IOException
 * if an error occurs reading from the { @ link BufferedReader } . */
private static String getNextLineSkippingBlankLines ( final BufferedReader reader ) throws IOException { } }

implementation: String tString = null ; do { tString = reader . readLine ( ) ; } while ( tString != null && tString . length ( ) == 0 ) ; return tString ;


signature:
public class DynamicTableEntity { /** * Populates this { @ link DynamicTableEntity } instance using the specified map of property names to
 * { @ link EntityProperty } data typed values .
 * @ param properties
 * The < code > java . util . HashMap < / code > of < code > String < / code > property names to { @ link EntityProperty }
 * data typed values to store in this { @ link DynamicTableEntity } instance .
 * @ param opContext
 * An { @ link OperationContext } object used to track the execution of the operation . */
@ Override public void readEntity ( final HashMap < String , EntityProperty > properties , final OperationContext opContext ) { } }

implementation: this . setProperties ( properties ) ;


signature:
public class UriQueryBuilder { /** * Adds a value to the URI with escaping .
 * @ param name
 * the query key name .
 * @ param value
 * the query value .
 * @ throws StorageException */
public void add ( final String name , final String value ) throws StorageException { } }

implementation: if ( Utility . isNullOrEmpty ( name ) ) { throw new IllegalArgumentException ( SR . QUERY_PARAMETER_NULL_OR_EMPTY ) ; } this . insertKeyValue ( name , value ) ;


signature:
public class UriQueryBuilder { /** * Add query parameter to an existing Uri . This takes care of any existing query parameters in the Uri .
 * @ param uri
 * the original uri .
 * @ return the appended uri
 * @ throws URISyntaxException
 * if the resulting uri is invalid .
 * @ throws StorageException */
public URI addToURI ( final URI uri ) throws URISyntaxException , StorageException { } }

implementation:
final String origRawQuery = uri . getRawQuery ( ) ; final String rawFragment = uri . getRawFragment ( ) ; final String uriString = uri . resolve ( uri ) . toASCIIString ( ) ; final HashMap < String , String [ ] > origQueryMap = PathUtility . parseQueryString ( origRawQuery ) ; // Try / Insert original queries to map
for ( final Entry < String , String [ ] > entry : origQueryMap . entrySet ( ) ) { for ( final String val : entry . getValue ( ) ) { this . insertKeyValue ( entry . getKey ( ) , val ) ; } } final StringBuilder retBuilder = new StringBuilder ( ) ; // has a fragment
if ( Utility . isNullOrEmpty ( origRawQuery ) && ! Utility . isNullOrEmpty ( rawFragment ) ) { final int bangDex = uriString . indexOf ( '#' ) ; retBuilder . append ( uriString . substring ( 0 , bangDex ) ) ; } else if ( ! Utility . isNullOrEmpty ( origRawQuery ) ) { // has a query
final int queryDex = uriString . indexOf ( '?' ) ; retBuilder . append ( uriString . substring ( 0 , queryDex ) ) ; } else { // no fragment or query
retBuilder . append ( uriString ) ; if ( uri . getRawPath ( ) . length ( ) <= 0 ) { retBuilder . append ( "/" ) ; } } final String finalQuery = this . toString ( ) ; if ( finalQuery . length ( ) > 0 ) { retBuilder . append ( "?" ) ; retBuilder . append ( finalQuery ) ; } if ( ! Utility . isNullOrEmpty ( rawFragment ) ) { retBuilder . append ( "#" ) ; retBuilder . append ( rawFragment ) ; } return new URI ( retBuilder . toString ( ) ) ;


signature:
public class UriQueryBuilder { /** * Inserts a key / value in the Hashmap , assumes the value is already utf - 8 encoded .
 * @ param key
 * the key to insert
 * @ param value
 * the value to insert
 * @ throws StorageException */
private void insertKeyValue ( String key , String value ) throws StorageException { } }

implementation: if ( value != null ) { value = Utility . safeEncode ( value ) ; } if ( ! key . startsWith ( "$" ) ) { key = Utility . safeEncode ( key ) ; } ArrayList < String > list = this . parameters . get ( key ) ; if ( list == null ) { list = new ArrayList < String > ( ) ; list . add ( value ) ; this . parameters . put ( key , list ) ; } else { if ( ! list . contains ( value ) ) { list . add ( value ) ; } }


signature:
public class PropertyPair { /** * Reserved for internal use . A static factory method to generate a map of property names to { @ link PropertyPair }
 * instances for the specified class type . Checks if the cache is enabled and if so tries to get the property pairs
 * from it . Otherwise , uses reflection to find pairs of getter and setter methods that are annotated with
 * { @ link StoreAs } with a common property name , or of the form < code > get < em > PropertyName < / em > < / code > and
 * < code > set < em > PropertyName < / em > < / code > , with a common type for the getter return value and the setter parameter ,
 * and stores the methods and the property name for each pair found in a map for use in serializing and
 * deserializing entity data . If the cache is enabled and the mapping was not present , adds it to the cache .
 * @ param clazzType
 * The class type to check for matching getter and setter methods with a common return and parameter
 * type , respectively . */
protected static HashMap < String , PropertyPair > generatePropertyPairs ( final Class < ? > clazzType ) { } }

implementation: if ( ! TableServiceEntity . isReflectedEntityCacheDisabled ( ) ) { HashMap < String , PropertyPair > props = new HashMap < String , PropertyPair > ( ) ; props = TableServiceEntity . getReflectedEntityCache ( ) . get ( clazzType ) ; if ( props == null ) { props = PropertyPair . generatePropertyPairsHelper ( clazzType ) ; TableServiceEntity . getReflectedEntityCache ( ) . put ( clazzType , props ) ; } return props ; } else { return PropertyPair . generatePropertyPairsHelper ( clazzType ) ; }


signature:
public class PropertyPair { /** * Reserved for internal use . A static factory method to generate a map of property names to { @ link PropertyPair }
 * instances for the specified class type . Uses reflection to find pairs of getter and setter methods that are
 * annotated with { @ link StoreAs } with a common property name , or of the form < code > get < em > PropertyName < / em > < / code >
 * and < code > set < em > PropertyName < / em > < / code > , with a common type for the getter return value and the
 * setter parameter , and stores the methods and the property name for each pair found in a map for use in
 * serializing and deserializing entity data .
 * @ param clazzType
 * The class type to check for matching getter and setter methods with a common return and parameter
 * type , respectively . */
private static HashMap < String , PropertyPair > generatePropertyPairsHelper ( final Class < ? > clazzType ) { } }

implementation:
final Method [ ] methods = clazzType . getMethods ( ) ; final HashMap < String , PropertyPair > propMap = new HashMap < String , PropertyPair > ( ) ; String propName = null ; PropertyPair currProperty = null ; for ( final Method m : methods ) { if ( m . getName ( ) . length ( ) < 4 || ( ! m . getName ( ) . startsWith ( "get" ) && ! m . getName ( ) . startsWith ( "set" ) ) ) { continue ; } propName = m . getName ( ) . substring ( 3 ) ; // Skip interface methods , these will be called explicitly
if ( propName . equals ( TableConstants . PARTITION_KEY ) || propName . equals ( TableConstants . ROW_KEY ) || propName . equals ( TableConstants . TIMESTAMP ) || propName . equals ( "Etag" ) || propName . equals ( "LastModified" ) ) { continue ; } if ( propMap . containsKey ( propName ) ) { currProperty = propMap . get ( propName ) ; } else { currProperty = new PropertyPair ( ) ; currProperty . name = propName ; propMap . put ( propName , currProperty ) ; } if ( m . getName ( ) . startsWith ( "get" ) && m . getParameterTypes ( ) . length == 0 ) { currProperty . type = m . getReturnType ( ) ; currProperty . getter = m ; } else if ( m . getName ( ) . startsWith ( "set" ) && m . getParameterTypes ( ) . length == 1 && void . class . equals ( m . getReturnType ( ) ) ) { currProperty . setter = m ; } // Check for StoreAs Annotation
final StoreAs storeAsInstance = m . getAnnotation ( StoreAs . class ) ; if ( storeAsInstance != null ) { if ( Utility . isNullOrEmpty ( storeAsInstance . name ( ) ) ) { throw new IllegalArgumentException ( String . format ( SR . STOREAS_USED_ON_EMPTY_PROPERTY , currProperty . name ) ) ; } if ( currProperty . effectiveName != null && ! currProperty . effectiveName . equals ( currProperty . name ) && ! currProperty . effectiveName . equals ( storeAsInstance . name ( ) ) ) { throw new IllegalArgumentException ( String . format ( SR . STOREAS_DIFFERENT_FOR_GETTER_AND_SETTER , currProperty . name ) ) ; } if ( ! currProperty . name . equals ( storeAsInstance . name ( ) ) ) { currProperty . effectiveName = storeAsInstance . name ( ) ; } } } // Return only processable pairs
final ArrayList < String > keysToRemove = new ArrayList < String > ( ) ; final ArrayList < String > keysToAlter = new ArrayList < String > ( ) ; for ( final Entry < String , PropertyPair > e : propMap . entrySet ( ) ) { if ( ! e . getValue ( ) . shouldProcess ( ) ) { keysToRemove . add ( e . getKey ( ) ) ; continue ; } if ( ! Utility . isNullOrEmpty ( e . getValue ( ) . effectiveName ) ) { keysToAlter . add ( e . getKey ( ) ) ; } else { e . getValue ( ) . effectiveName = e . getValue ( ) . name ; } } // remove all entries for keys that should not process
for ( final String key : keysToRemove ) { propMap . remove ( key ) ; } // Any store as properties should be re - stored into the hash under the efective name .
for ( final String key : keysToAlter ) { final PropertyPair p = propMap . get ( key ) ; propMap . remove ( key ) ; propMap . put ( p . effectiveName , p ) ; } return propMap ;


signature:
public class PropertyPair { /** * Reserved for internal use . Invokes the setter method on the specified instance parameter with the value of the
 * { @ link EntityProperty } deserialized as the appropriate type .
 * @ param prop
 * The { @ link EntityProperty } containing the value to pass to the setter on the instance .
 * @ param instance
 * An instance of a class supporting this property with getter and setter methods of the
 * appropriate name and parameter or return type .
 * @ throws IllegalArgumentException
 * if the specified instance parameter is not an instance of the class
 * or interface declaring the setter method ( or of a subclass or implementor thereof ) .
 * @ throws IllegalAccessException
 * if the setter method is inaccessible .
 * @ throws InvocationTargetException
 * if the setter method throws an exception . */
protected void consumeEntityProperty ( final EntityProperty prop , final Object instance ) throws IllegalArgumentException , IllegalAccessException , InvocationTargetException { } }

implementation: Class < ? > paramType = this . setter . getParameterTypes ( ) [ 0 ] ; if ( prop . getIsNull ( ) ) { if ( ! paramType . isPrimitive ( ) ) { this . setter . invoke ( instance , ( Object ) null ) ; } } else { if ( prop . getEdmType ( ) == EdmType . STRING ) { if ( paramType . equals ( String . class ) ) { this . setter . invoke ( instance , prop . getValueAsString ( ) ) ; } } else if ( prop . getEdmType ( ) == EdmType . BINARY ) { if ( paramType . equals ( Byte [ ] . class ) ) { this . setter . invoke ( instance , ( Object ) prop . getValueAsByteObjectArray ( ) ) ; } else if ( paramType . equals ( byte [ ] . class ) ) { this . setter . invoke ( instance , prop . getValueAsByteArray ( ) ) ; } } else if ( prop . getEdmType ( ) == EdmType . BOOLEAN ) { if ( paramType . equals ( Boolean . class ) ) { this . setter . invoke ( instance , prop . getValueAsBooleanObject ( ) ) ; } else if ( paramType . equals ( boolean . class ) ) { this . setter . invoke ( instance , prop . getValueAsBoolean ( ) ) ; } } else if ( prop . getEdmType ( ) == EdmType . DOUBLE ) { if ( paramType . equals ( Double . class ) ) { this . setter . invoke ( instance , prop . getValueAsDoubleObject ( ) ) ; } else if ( paramType . equals ( double . class ) ) { this . setter . invoke ( instance , prop . getValueAsDouble ( ) ) ; } } else if ( prop . getEdmType ( ) == EdmType . GUID ) { if ( paramType . equals ( UUID . class ) ) { this . setter . invoke ( instance , prop . getValueAsUUID ( ) ) ; } } else if ( prop . getEdmType ( ) == EdmType . INT32 ) { if ( paramType . equals ( Integer . class ) ) { this . setter . invoke ( instance , prop . getValueAsIntegerObject ( ) ) ; } else if ( paramType . equals ( int . class ) ) { this . setter . invoke ( instance , prop . getValueAsInteger ( ) ) ; } } else if ( prop . getEdmType ( ) == EdmType . INT64 ) { if ( paramType . equals ( Long . class ) ) { this . setter . invoke ( instance , prop . getValueAsLongObject ( ) ) ; } else if ( paramType . equals ( long . class ) ) { this . setter . invoke ( instance , prop . getValueAsLong ( ) ) ; } } else if ( prop . getEdmType ( ) == EdmType . DATE_TIME ) { if ( paramType . equals ( Date . class ) ) { this . setter . invoke ( instance , prop . getValueAsDate ( ) ) ; } } else { throw new IllegalArgumentException ( String . format ( SR . PROPERTY_CANNOT_BE_SERIALIZED_AS_GIVEN_EDMTYPE , this . name , prop . getEdmType ( ) . toString ( ) ) ) ; } }


signature:
public class PropertyPair { /** * Reserved for internal use . Generates an { @ link EntityProperty } from the result of invoking the getter method for
 * this property on the specified instance parameter .
 * @ param instance
 * An instance of a class supporting this property with getter and setter methods of the
 * appropriate name and parameter or return type .
 * @ return
 * An { @ link EntityProperty } with the data type and value returned by the invoked getter on the instance .
 * @ throws IllegalArgumentException
 * if the specified instance parameter is not an instance of the class
 * or interface declaring the getter method ( or of a subclass or implementor thereof ) .
 * @ throws IllegalAccessException
 * if the getter method is inaccessible .
 * @ throws InvocationTargetException
 * if the getter method throws an exception . */
protected EntityProperty generateEntityProperty ( final Object instance ) throws IllegalArgumentException , IllegalAccessException , InvocationTargetException { } }

implementation: final Class < ? > getType = this . getter . getReturnType ( ) ; Object val = this . getter . invoke ( instance , ( Object [ ] ) null ) ; return new EntityProperty ( val , getType ) ;


signature:
public class PropertyPair { /** * Reserved for internal use . A utility function that returns < code > true < / code > if this property is accessible
 * through reflection .
 * @ return */
protected boolean shouldProcess ( ) { } }

implementation: if ( Utility . isNullOrEmpty ( this . name ) || this . getter == null || this . getter . isAnnotationPresent ( Ignore . class ) || this . setter == null || this . setter . isAnnotationPresent ( Ignore . class ) || ( ! this . getter . getReturnType ( ) . equals ( this . setter . getParameterTypes ( ) [ 0 ] ) ) ) { return false ; } return true ;


signature:
public class BaseRequest { /** * Adds the metadata .
 * @ param request
 * The request .
 * @ param metadata
 * The metadata . */
public static void addMetadata ( final HttpURLConnection request , final Map < String , String > metadata , final OperationContext opContext ) { } }

implementation: if ( metadata != null ) { for ( final Entry < String , String > entry : metadata . entrySet ( ) ) { addMetadata ( request , entry . getKey ( ) , entry . getValue ( ) , opContext ) ; } }


signature:
public class BaseRequest { /** * Adds the metadata .
 * @ param opContext
 * an object used to track the execution of the operation
 * @ param request
 * The request .
 * @ param name
 * The metadata name .
 * @ param value
 * The metadata value . */
private static void addMetadata ( final HttpURLConnection request , final String name , final String value , final OperationContext opContext ) { } }

implementation: if ( Utility . isNullOrEmptyOrWhitespace ( name ) ) { throw new IllegalArgumentException ( SR . METADATA_KEY_INVALID ) ; } else if ( Utility . isNullOrEmptyOrWhitespace ( value ) ) { throw new IllegalArgumentException ( SR . METADATA_VALUE_INVALID ) ; } request . setRequestProperty ( Constants . HeaderConstants . PREFIX_FOR_STORAGE_METADATA + name , value ) ;


signature:
public class BaseRequest { /** * Adds the optional header .
 * @ param request
 * a HttpURLConnection for the operation .
 * @ param name
 * the metadata name .
 * @ param value
 * the metadata value . */
public static void addOptionalHeader ( final HttpURLConnection request , final String name , final String value ) { } }

implementation: if ( value != null && ! value . equals ( Constants . EMPTY_STRING ) ) { request . setRequestProperty ( name , value ) ; }


signature:
public class BaseRequest { /** * Creates the specified resource . Note request is set to setFixedLengthStreamingMode ( 0 ) ; Sign with 0 length .
 * @ param uri
 * the request Uri .
 * @ param options
 * A { @ link RequestOptions } object that specifies execution options such as retry policy and timeout
 * settings for the operation .
 * @ param builder
 * the UriQueryBuilder for the request
 * @ param opContext
 * an object used to track the execution of the operation
 * @ return a HttpURLConnection to perform the operation .
 * @ throws IOException
 * if there is an error opening the connection
 * @ throws URISyntaxException
 * if there is an improperly formated URI
 * @ throws StorageException
 * @ throws IllegalArgumentException */
public static HttpURLConnection create ( final URI uri , final RequestOptions options , UriQueryBuilder builder , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { } }

implementation: if ( builder == null ) { builder = new UriQueryBuilder ( ) ; } final HttpURLConnection retConnection = createURLConnection ( uri , options , builder , opContext ) ; retConnection . setFixedLengthStreamingMode ( 0 ) ; retConnection . setDoOutput ( true ) ; retConnection . setRequestMethod ( Constants . HTTP_PUT ) ; return retConnection ;


signature:
public class BaseRequest { /** * Creates the web request .
 * @ param uri
 * the request Uri .
 * @ param options
 * A { @ link RequestOptions } object that specifies execution options such as retry policy and timeout
 * settings for the operation . This parameter is unused .
 * @ param builder
 * the UriQueryBuilder for the request
 * @ param opContext
 * an object used to track the execution of the operation
 * @ return a HttpURLConnection to perform the operation .
 * @ throws IOException
 * if there is an error opening the connection
 * @ throws URISyntaxException
 * if there is an improperly formated URI
 * @ throws StorageException */
public static HttpURLConnection createURLConnection ( final URI uri , final RequestOptions options , UriQueryBuilder builder , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { } }

implementation:
if ( builder == null ) { builder = new UriQueryBuilder ( ) ; } if ( options . getTimeoutIntervalInMs ( ) != null && options . getTimeoutIntervalInMs ( ) != 0 ) { builder . add ( TIMEOUT , String . valueOf ( options . getTimeoutIntervalInMs ( ) / 1000 ) ) ; } final URL resourceUrl = builder . addToURI ( uri ) . toURL ( ) ; // Get the proxy settings
Proxy proxy = OperationContext . getDefaultProxy ( ) ; if ( opContext != null && opContext . getProxy ( ) != null ) { proxy = opContext . getProxy ( ) ; } // Set up connection , optionally with proxy settings
final HttpURLConnection retConnection ; if ( proxy != null ) { retConnection = ( HttpURLConnection ) resourceUrl . openConnection ( proxy ) ; } else { retConnection = ( HttpURLConnection ) resourceUrl . openConnection ( ) ; } /* * ReadTimeout must be explicitly set to avoid a bug in JDK 6 . In certain cases , this bug causes an immediate
 * read timeout exception to be thrown even if ReadTimeout is not set .
 * Both connect and read timeout are set to the same value as we have no way of knowing how to partition
 * the remaining time between these operations . The user can override these timeouts using the SendingRequest
 * event handler if more control is desired . */
int timeout = Utility . getRemainingTimeout ( options . getOperationExpiryTimeInMs ( ) , options . getTimeoutIntervalInMs ( ) ) ; retConnection . setReadTimeout ( timeout ) ; retConnection . setConnectTimeout ( timeout ) ; // Note : by default sends Accept behavior as text / html , image / gif , image / jpeg , * ; q = . 2 , * / * ; q = . 2
retConnection . setRequestProperty ( Constants . HeaderConstants . ACCEPT , Constants . HeaderConstants . XML_TYPE ) ; retConnection . setRequestProperty ( Constants . HeaderConstants . ACCEPT_CHARSET , Constants . UTF8_CHARSET ) ; // Note : by default sends Accept - Encoding as gzip
retConnection . setRequestProperty ( Constants . HeaderConstants . ACCEPT_ENCODING , Constants . EMPTY_STRING ) ; // Note : by default sends Content - type behavior as application / x - www - form - urlencoded for posts .
retConnection . setRequestProperty ( Constants . HeaderConstants . CONTENT_TYPE , Constants . EMPTY_STRING ) ; retConnection . setRequestProperty ( Constants . HeaderConstants . STORAGE_VERSION_HEADER , Constants . HeaderConstants . TARGET_STORAGE_VERSION ) ; retConnection . setRequestProperty ( Constants . HeaderConstants . USER_AGENT , getUserAgent ( ) ) ; retConnection . setRequestProperty ( Constants . HeaderConstants . CLIENT_REQUEST_ID_HEADER , opContext . getClientRequestID ( ) ) ; return retConnection ;


signature:
public class BaseRequest { /** * Deletes the specified resource . Sign with no length specified .
 * @ param uri
 * the request Uri .
 * @ param timeout
 * the timeout for the request
 * @ param builder
 * the UriQueryBuilder for the request
 * @ param opContext
 * an object used to track the execution of the operation
 * @ return a HttpURLConnection to perform the operation .
 * @ throws IOException
 * if there is an error opening the connection
 * @ throws URISyntaxException
 * if there is an improperly formated URI
 * @ throws StorageException */
public static HttpURLConnection delete ( final URI uri , final RequestOptions options , UriQueryBuilder builder , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { } }

implementation: if ( builder == null ) { builder = new UriQueryBuilder ( ) ; } final HttpURLConnection retConnection = createURLConnection ( uri , options , builder , opContext ) ; retConnection . setRequestMethod ( Constants . HTTP_DELETE ) ; return retConnection ;


signature:
public class BaseRequest { /** * Gets a { @ link UriQueryBuilder } for listing .
 * @ param listingContext
 * A { @ link ListingContext } object that specifies parameters for
 * the listing operation , if any . May be < code > null < / code > .
 * @ throws StorageException
 * If a storage service error occurred during the operation . */
public static UriQueryBuilder getListUriQueryBuilder ( final ListingContext listingContext ) throws StorageException { } }

implementation: final UriQueryBuilder builder = new UriQueryBuilder ( ) ; builder . add ( Constants . QueryConstants . COMPONENT , Constants . QueryConstants . LIST ) ; if ( listingContext != null ) { if ( ! Utility . isNullOrEmpty ( listingContext . getPrefix ( ) ) ) { builder . add ( Constants . QueryConstants . PREFIX , listingContext . getPrefix ( ) ) ; } if ( ! Utility . isNullOrEmpty ( listingContext . getMarker ( ) ) ) { builder . add ( Constants . QueryConstants . MARKER , listingContext . getMarker ( ) ) ; } if ( listingContext . getMaxResults ( ) != null && listingContext . getMaxResults ( ) > 0 ) { builder . add ( Constants . QueryConstants . MAX_RESULTS , listingContext . getMaxResults ( ) . toString ( ) ) ; } } return builder ;


signature:
public class BaseRequest { /** * Creates a HttpURLConnection used to retrieve the Analytics service properties from the storage service .
 * @ param uri
 * The service endpoint .
 * @ param timeout
 * The timeout .
 * @ param builder
 * The builder .
 * @ param opContext
 * an object used to track the execution of the operation
 * @ return a web request for performing the operation .
 * @ throws IOException
 * @ throws URISyntaxException
 * @ throws StorageException */
public static HttpURLConnection getServiceProperties ( final URI uri , final RequestOptions options , UriQueryBuilder builder , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { } }

implementation: if ( builder == null ) { builder = new UriQueryBuilder ( ) ; } builder . add ( Constants . QueryConstants . COMPONENT , Constants . QueryConstants . PROPERTIES ) ; builder . add ( Constants . QueryConstants . RESOURCETYPE , SERVICE ) ; final HttpURLConnection retConnection = createURLConnection ( uri , options , builder , opContext ) ; retConnection . setRequestMethod ( Constants . HTTP_GET ) ; return retConnection ;


signature:
public class BaseRequest { /** * Gets the user agent to send over the wire to identify the client .
 * @ return the user agent to send over the wire to identify the client . */
public static String getUserAgent ( ) { } }

implementation: if ( userAgent == null ) { String userAgentComment = String . format ( Utility . LOCALE_US , "(Android %s; %s; %s)" , android . os . Build . VERSION . RELEASE , android . os . Build . BRAND , android . os . Build . MODEL ) ; userAgent = String . format ( "%s/%s %s" , Constants . HeaderConstants . USER_AGENT_PREFIX , Constants . HeaderConstants . USER_AGENT_VERSION , userAgentComment ) ; } return userAgent ;


signature:
public class BaseRequest { /** * Sets the metadata . Sign with 0 length .
 * @ param uri
 * The blob Uri .
 * @ param timeout
 * The timeout .
 * @ param builder
 * The builder .
 * @ param opContext
 * an object used to track the execution of the operation
 * @ return a web request for performing the operation .
 * @ throws StorageException
 * @ throws URISyntaxException
 * @ throws IOException */
public static HttpURLConnection setMetadata ( final URI uri , final RequestOptions options , UriQueryBuilder builder , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { } }

implementation: if ( builder == null ) { builder = new UriQueryBuilder ( ) ; } builder . add ( Constants . QueryConstants . COMPONENT , METADATA ) ; final HttpURLConnection retConnection = createURLConnection ( uri , options , builder , opContext ) ; retConnection . setFixedLengthStreamingMode ( 0 ) ; retConnection . setDoOutput ( true ) ; retConnection . setRequestMethod ( Constants . HTTP_PUT ) ; return retConnection ;


signature:
public class BaseRequest { /** * Creates a HttpURLConnection used to set the Analytics service properties on the storage service .
 * @ param uri
 * The service endpoint .
 * @ param timeout
 * The timeout .
 * @ param builder
 * The builder .
 * @ param opContext
 * an object used to track the execution of the operation
 * @ return a web request for performing the operation .
 * @ throws IOException
 * @ throws URISyntaxException
 * @ throws StorageException */
public static HttpURLConnection setServiceProperties ( final URI uri , final RequestOptions options , UriQueryBuilder builder , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { } }

implementation: if ( builder == null ) { builder = new UriQueryBuilder ( ) ; } builder . add ( Constants . QueryConstants . COMPONENT , Constants . QueryConstants . PROPERTIES ) ; builder . add ( Constants . QueryConstants . RESOURCETYPE , SERVICE ) ; final HttpURLConnection retConnection = createURLConnection ( uri , options , builder , opContext ) ; retConnection . setDoOutput ( true ) ; retConnection . setRequestMethod ( Constants . HTTP_PUT ) ; return retConnection ;


signature:
public class FileOutputStream { /** * Closes this output stream and releases any system resources associated with this stream . If any data remains in
 * the buffer it is committed to the service .
 * @ throws IOException
 * If an I / O error occurs . */
@ Override @ DoesServiceRequest public void close ( ) throws IOException { } }

implementation:
try { // if the user has already closed the stream , this will throw a STREAM _ CLOSED exception
// if an exception was thrown by any thread in the threadExecutor , realize it now
this . checkStreamState ( ) ; // flush any remaining data
this . flush ( ) ; // shut down the ExecutorService .
this . threadExecutor . shutdown ( ) ; // try to commit the file
try { this . commit ( ) ; } catch ( final StorageException e ) { throw Utility . initIOException ( e ) ; } catch ( URISyntaxException e ) { throw Utility . initIOException ( e ) ; } } finally { // if close ( ) is called again , an exception will be thrown
synchronized ( this . lastErrorLock ) { this . streamFaulted = true ; this . lastError = new IOException ( SR . STREAM_CLOSED ) ; } // if an exception was thrown and the executor was not yet closed , call shutDownNow ( ) to cancel all tasks
// and shutdown the ExecutorService
if ( ! this . threadExecutor . isShutdown ( ) ) { this . threadExecutor . shutdownNow ( ) ; } }


signature:
public class FileOutputStream { /** * Commits the file .
 * @ throws StorageException
 * An exception representing any error which occurred during the operation .
 * @ throws URISyntaxException */
@ DoesServiceRequest private void commit ( ) throws StorageException , URISyntaxException { } }

implementation: if ( this . options . getStoreFileContentMD5 ( ) ) { this . parentFileRef . getProperties ( ) . setContentMD5 ( Base64 . encode ( this . md5Digest . digest ( ) ) ) ; } this . parentFileRef . uploadProperties ( this . accessCondition , this . options , this . opContext ) ;


signature:
public class FileOutputStream { /** * Dispatches a write operation for a given length .
 * @ param writeLength
 * An < code > int < / code > which represents the length of the data to write , this is the write threshold that
 * triggered the write .
 * @ throws IOException
 * If an I / O error occurs . In particular , an IOException may be thrown if the output stream has been
 * closed . */
@ DoesServiceRequest private synchronized void dispatchWrite ( final int writeLength ) throws IOException { } }

implementation:
if ( writeLength == 0 ) { return ; } Callable < Void > worker = null ; if ( this . outstandingRequests > this . options . getConcurrentRequestCount ( ) * 2 ) { this . waitForTaskToComplete ( ) ; } final ByteArrayInputStream bufferRef = new ByteArrayInputStream ( this . outBuffer . toByteArray ( ) ) ; final CloudFile fileRef = this . parentFileRef ; long tempOffset = this . currentOffset ; long tempLength = writeLength ; final long opWriteLength = tempLength ; final long opOffset = tempOffset ; this . currentOffset += writeLength ; worker = new Callable < Void > ( ) { @ Override public Void call ( ) { try { fileRef . uploadRange ( bufferRef , opOffset , opWriteLength , FileOutputStream . this . accessCondition , FileOutputStream . this . options , FileOutputStream . this . opContext ) ; } catch ( final IOException e ) { synchronized ( FileOutputStream . this . lastErrorLock ) { FileOutputStream . this . streamFaulted = true ; FileOutputStream . this . lastError = e ; } } catch ( final StorageException e ) { synchronized ( FileOutputStream . this . lastErrorLock ) { FileOutputStream . this . streamFaulted = true ; FileOutputStream . this . lastError = Utility . initIOException ( e ) ; } } catch ( URISyntaxException e ) { synchronized ( FileOutputStream . this . lastErrorLock ) { FileOutputStream . this . streamFaulted = true ; FileOutputStream . this . lastError = Utility . initIOException ( e ) ; } } return null ; } } ; // Do work and reset buffer .
this . completionService . submit ( worker ) ; this . outstandingRequests ++ ; this . currentBufferedBytes = 0 ; this . outBuffer = new ByteArrayOutputStream ( ) ;


signature:
public class FileOutputStream { /** * Flushes this output stream and forces any buffered output bytes to be written out . If any data remains in the
 * buffer it is committed to the service .
 * @ throws IOException
 * If an I / O error occurs . */
@ Override @ DoesServiceRequest public synchronized void flush ( ) throws IOException { } }

implementation:
this . checkStreamState ( ) ; // Dispatch a write for the current bytes in the buffer
this . dispatchWrite ( this . currentBufferedBytes ) ; // Waits for all submitted tasks to complete
while ( this . outstandingRequests > 0 ) { // Wait for a task to complete
this . waitForTaskToComplete ( ) ; // If that task threw an error , fail fast
this . checkStreamState ( ) ; }


signature:
public class FileOutputStream { /** * Waits for one task to complete
 * @ throws IOException
 * If an I / O error occurs . In particular , an IOException may be thrown if the output stream has been
 * closed . */
private void waitForTaskToComplete ( ) throws IOException { } }

implementation: try { final Future < Void > future = this . completionService . take ( ) ; future . get ( ) ; } catch ( final InterruptedException e ) { throw Utility . initIOException ( e ) ; } catch ( final ExecutionException e ) { throw Utility . initIOException ( e ) ; } this . outstandingRequests -- ;


signature:
public class FileOutputStream { /** * Writes length bytes from the specified byte array starting at offset to this output stream .
 * @ param data
 * A < code > byte < / code > array which represents the data to write .
 * @ param offset
 * An < code > int < / code > which represents the start offset in the data .
 * @ param length
 * An < code > int < / code > which represents the number of bytes to write .
 * @ throws IOException
 * If an I / O error occurs . In particular , an IOException may be thrown if the output stream has been
 * closed . */
@ Override @ DoesServiceRequest public void write ( final byte [ ] data , final int offset , final int length ) throws IOException { } }

implementation: if ( offset < 0 || length < 0 || length > data . length - offset ) { throw new IndexOutOfBoundsException ( ) ; } this . writeInternal ( data , offset , length ) ;


signature:
public class FileOutputStream { /** * Writes all data from the InputStream to the File .
 * @ param sourceStream
 * An { @ link InputStream } object which species the data to write to the File .
 * @ throws IOException
 * If an I / O error occurs . In particular , an IOException may be thrown if the output stream has been
 * closed .
 * @ throws StorageException
 * An exception representing any error which occurred during the operation . */
@ DoesServiceRequest public void write ( final InputStream sourceStream , final long writeLength ) throws IOException , StorageException { } }

implementation: Utility . writeToOutputStream ( sourceStream , this , writeLength , false , false , this . opContext , this . options , false ) ;


signature:
public class FileOutputStream { /** * Writes the data to the buffer and triggers writes to the service as needed .
 * @ param data
 * A < code > byte < / code > array which represents the data to write .
 * @ param offset
 * An < code > int < / code > which represents the start offset in the data .
 * @ param length
 * An < code > int < / code > which represents the number of bytes to write .
 * @ throws IOException
 * If an I / O error occurs . In particular , an IOException may be thrown if the output stream has been
 * closed . */
@ DoesServiceRequest private synchronized void writeInternal ( final byte [ ] data , int offset , int length ) throws IOException { } }

implementation:
while ( length > 0 ) { this . checkStreamState ( ) ; final int availableBufferBytes = this . internalWriteThreshold - this . currentBufferedBytes ; final int nextWrite = Math . min ( availableBufferBytes , length ) ; // If we need to set MD5 then update the digest accordingly
if ( this . options . getStoreFileContentMD5 ( ) ) { this . md5Digest . update ( data , offset , nextWrite ) ; } this . outBuffer . write ( data , offset , nextWrite ) ; this . currentBufferedBytes += nextWrite ; offset += nextWrite ; length -= nextWrite ; if ( this . currentBufferedBytes == this . internalWriteThreshold ) { this . dispatchWrite ( this . internalWriteThreshold ) ; } }


signature:
public class SharedAccessFilePolicy { /** * Converts this policy ' s permissions to a string .
 * @ return A < code > String < / code > that represents the shared access permissions in the " rcwdl " format ,
 * which is described at { @ link # setPermissionsFromString ( String ) } . */
@ Override public String permissionsToString ( ) { } }

implementation:
if ( this . permissions == null ) { return Constants . EMPTY_STRING ; } // The service supports a fixed order = > rcwdl
final StringBuilder builder = new StringBuilder ( ) ; if ( this . permissions . contains ( SharedAccessFilePermissions . READ ) ) { builder . append ( "r" ) ; } if ( this . permissions . contains ( SharedAccessFilePermissions . CREATE ) ) { builder . append ( "c" ) ; } if ( this . permissions . contains ( SharedAccessFilePermissions . WRITE ) ) { builder . append ( "w" ) ; } if ( this . permissions . contains ( SharedAccessFilePermissions . DELETE ) ) { builder . append ( "d" ) ; } if ( this . permissions . contains ( SharedAccessFilePermissions . LIST ) ) { builder . append ( "l" ) ; } return builder . toString ( ) ;


signature:
public class SharedAccessFilePolicy { /** * Sets shared access permissions using the specified permissions string .
 * @ param value
 * A < code > String < / code > that represents the shared access permissions . The string must contain one or
 * more of the following values . Note they must all be lowercase .
 * < ul >
 * < li > < code > r < / code > : Read access . < / li >
 * < li > < code > c < / code > : Create access . < / li >
 * < li > < code > w < / code > : Write access . < / li >
 * < li > < code > d < / code > : Delete access . < / li >
 * < li > < code > l < / code > : List access . < / li >
 * < / ul > */
public void setPermissionsFromString ( final String value ) { } }

implementation: EnumSet < SharedAccessFilePermissions > initial = EnumSet . noneOf ( SharedAccessFilePermissions . class ) ; for ( final char c : value . toCharArray ( ) ) { switch ( c ) { case 'r' : initial . add ( SharedAccessFilePermissions . READ ) ; break ; case 'c' : initial . add ( SharedAccessFilePermissions . CREATE ) ; break ; case 'w' : initial . add ( SharedAccessFilePermissions . WRITE ) ; break ; case 'd' : initial . add ( SharedAccessFilePermissions . DELETE ) ; break ; case 'l' : initial . add ( SharedAccessFilePermissions . LIST ) ; break ; default : throw new IllegalArgumentException ( "value" ) ; } } this . permissions = initial ;


signature:
public class CloudStorageAccount { /** * Returns a { @ link CloudStorageAccount } object that represents the development storage credentials , using the
 * specified proxy URI . Secondary endpoints are enabled by default .
 * @ param proxyUri
 * A < code > java . net . URI < / code > object that represents the proxy endpoint to use . Specifying
 * < code > null < / code > will use the default < code > http : / / 127.0.0.1 < / code > .
 * @ return A { @ link CloudStorageAccount } object for the development storage credentials .
 * @ throws URISyntaxException
 * If the resource URI is invalid . */
public static CloudStorageAccount getDevelopmentStorageAccount ( final URI proxyUri ) throws URISyntaxException { } }

implementation:
String scheme ; String host ; if ( proxyUri == null ) { scheme = "http" ; host = "127.0.0.1" ; } else { scheme = proxyUri . getScheme ( ) ; host = proxyUri . getHost ( ) ; } StorageCredentials credentials = new StorageCredentialsAccountAndKey ( DEVSTORE_ACCOUNT_NAME , DEVSTORE_ACCOUNT_KEY ) ; URI blobPrimaryEndpoint = new URI ( String . format ( DEVELOPMENT_STORAGE_PRIMARY_ENDPOINT_FORMAT , scheme , host , "10000" , DEVSTORE_ACCOUNT_NAME ) ) ; URI queuePrimaryEndpoint = new URI ( String . format ( DEVELOPMENT_STORAGE_PRIMARY_ENDPOINT_FORMAT , scheme , host , "10001" , DEVSTORE_ACCOUNT_NAME ) ) ; URI tablePrimaryEndpoint = new URI ( String . format ( DEVELOPMENT_STORAGE_PRIMARY_ENDPOINT_FORMAT , scheme , host , "10002" , DEVSTORE_ACCOUNT_NAME ) ) ; URI blobSecondaryEndpoint = new URI ( String . format ( DEVELOPMENT_STORAGE_SECONDARY_ENDPOINT_FORMAT , scheme , host , "10000" , DEVSTORE_ACCOUNT_NAME ) ) ; URI queueSecondaryEndpoint = new URI ( String . format ( DEVELOPMENT_STORAGE_SECONDARY_ENDPOINT_FORMAT , scheme , host , "10001" , DEVSTORE_ACCOUNT_NAME ) ) ; URI tableSecondaryEndpoint = new URI ( String . format ( DEVELOPMENT_STORAGE_SECONDARY_ENDPOINT_FORMAT , scheme , host , "10002" , DEVSTORE_ACCOUNT_NAME ) ) ; CloudStorageAccount account = new CloudStorageAccount ( credentials , new StorageUri ( blobPrimaryEndpoint , blobSecondaryEndpoint ) , new StorageUri ( queuePrimaryEndpoint , queueSecondaryEndpoint ) , new StorageUri ( tablePrimaryEndpoint , tableSecondaryEndpoint ) , null /* fileStorageUri */
) ; account . isDevStoreAccount = true ; return account ;


signature:
public class CloudStorageAccount { /** * Parses a connection string and returns a cloud storage account created from the connection string .
 * The connection string should be in the < a href = " http : / / msdn . microsoft . com / library / azure / ee758697 . aspx " > Azure
 * connection string < / a > format .
 * Note that while a connection string may include a SAS token , it is often easier to use the
 * { @ link CloudBlobContainer # CloudBlobContainer ( URI ) } , { @ link CloudQueue # CloudQueue ( URI ) } ,
 * { @ link CloudTable # CloudTable ( URI ) } constructors directly . To do this , create a
 * { @ link StorageCredentialsSharedAccessSignature # StorageCredentialsSharedAccessSignature ( String ) } object with your
 * SAS token , use the { @ link StorageCredentialsSharedAccessSignature # transformUri ( URI ) } method on the container ,
 * queue , or table URI , and then use that URI to construct the object .
 * @ param connectionString
 * A < code > String < / code > that represents the connection string to parse .
 * @ return A { @ link CloudStorageAccount } object that represents the cloud storage account constructed from the
 * values provided in the connection string .
 * @ throws InvalidKeyException
 * If credentials in the connection string contain an invalid key .
 * @ throws URISyntaxException
 * If the connection string specifies an invalid URI . */
public static CloudStorageAccount parse ( final String connectionString ) throws URISyntaxException , InvalidKeyException { } }

implementation:
if ( connectionString == null || connectionString . length ( ) == 0 ) { throw new IllegalArgumentException ( SR . INVALID_CONNECTION_STRING ) ; } // 1 . Parse connection string in to key / value pairs
final Map < String , String > settings = Utility . parseAccountString ( connectionString ) ; // 2 Validate General Settings rules ,
// - only setting value per key
// - setting must have value .
for ( final Entry < String , String > entry : settings . entrySet ( ) ) { if ( entry . getValue ( ) == null || entry . getValue ( ) . equals ( Constants . EMPTY_STRING ) ) { throw new IllegalArgumentException ( SR . INVALID_CONNECTION_STRING ) ; } } // 3 . Validate scenario specific constraints
CloudStorageAccount account = tryConfigureDevStore ( settings ) ; if ( account != null ) { return account ; } account = tryConfigureServiceAccount ( settings ) ; if ( account != null ) { return account ; } throw new IllegalArgumentException ( SR . INVALID_CONNECTION_STRING ) ;


signature:
public class CloudStorageAccount { /** * Gets the { @ link StorageUri } using specified service , settings , and endpoint .
 * @ param settings
 * A < code > java . util . Map < / code > of key / value pairs which represents
 * the connection settings .
 * @ param service
 * A String that represents the service ' s base DNS name .
 * @ param serviceEndpointName
 * The service endpoint name to check in settings .
 * @ param serviceSecondaryEndpointName
 * The service secondary endpoint name to check in settings .
 * @ param matchesAutomaticEndpointsSpec
 * Whether the settings match the automatic endpoints specification .
 * @ return The { @ link StorageUri } .
 * @ throws URISyntaxException */
private static StorageUri getStorageUri ( final Map < String , String > settings , final String service , final String serviceEndpointName , final String serviceSecondaryEndpointName , final Boolean matchesAutomaticEndpointsSpec ) throws URISyntaxException { } }

implementation: String serviceEndpoint = settingOrDefault ( settings , serviceEndpointName ) ; String serviceSecondaryEndpoint = settingOrDefault ( settings , serviceSecondaryEndpointName ) ; if ( serviceSecondaryEndpoint != null && serviceEndpoint != null ) { return new StorageUri ( new URI ( serviceEndpoint ) , new URI ( serviceSecondaryEndpoint ) ) ; } else if ( serviceEndpoint != null ) { return new StorageUri ( new URI ( serviceEndpoint ) ) ; } else if ( matchesAutomaticEndpointsSpec ) { final String scheme = settings . get ( CloudStorageAccount . DEFAULT_ENDPOINTS_PROTOCOL_NAME ) ; final String accountName = settings . get ( CloudStorageAccount . ACCOUNT_NAME_NAME ) ; final String endpointSuffix = settings . get ( CloudStorageAccount . ENDPOINT_SUFFIX_NAME ) ; return getDefaultStorageUri ( scheme , accountName , getDNS ( service , endpointSuffix ) ) ; } else { return null ; }


signature:
public class CloudStorageAccount { /** * Gets the default { @ link StorageUri } using the specified service , protocol and account name .
 * @ param scheme
 * The protocol to use .
 * @ param accountName
 * The name of the storage account .
 * @ param service
 * A String that represents the service ' s base DNS name .
 * @ return The default { @ link StorageUri } . */
private static StorageUri getDefaultStorageUri ( final String scheme , final String accountName , final String service ) throws URISyntaxException { } }

implementation: if ( Utility . isNullOrEmpty ( scheme ) ) { throw new IllegalArgumentException ( SR . SCHEME_NULL_OR_EMPTY ) ; } if ( Utility . isNullOrEmpty ( accountName ) ) { throw new IllegalArgumentException ( SR . ACCOUNT_NAME_NULL_OR_EMPTY ) ; } URI primaryUri = new URI ( String . format ( PRIMARY_ENDPOINT_FORMAT , scheme , accountName , service ) ) ; URI secondaryUri = new URI ( String . format ( SECONDARY_ENDPOINT_FORMAT , scheme , accountName , SECONDARY_LOCATION_ACCOUNT_SUFFIX , service ) ) ; return new StorageUri ( primaryUri , secondaryUri ) ;


signature:
public class CloudStorageAccount { /** * This generates a domain name for the given service .
 * @ param service
 * the service to connect to
 * @ param base
 * the suffix to use
 * @ return the domain name */
private static String getDNS ( String service , String base ) { } }

implementation: if ( base == null ) { base = DEFAULT_DNS ; } return String . format ( DNS_NAME_FORMAT , service , base ) ;


signature:
public class CloudStorageAccount { /** * Evaluates connection settings and returns a CloudStorageAccount representing Development Storage .
 * @ param settings
 * A < code > java . util . Map < / code > of key / value pairs which represents the connection settings .
 * @ return A { @ link CloudStorageAccount } object constructed from the values provided in the connection settings , or
 * null if
 * one cannot be constructed .
 * @ throws URISyntaxException
 * if the connection settings contains an invalid URI */
private static CloudStorageAccount tryConfigureDevStore ( final Map < String , String > settings ) throws URISyntaxException { } }

implementation: if ( matchesSpecification ( settings , allRequired ( USE_DEVELOPMENT_STORAGE_NAME ) , optional ( DEVELOPMENT_STORAGE_PROXY_URI_NAME ) ) ) { if ( ! Boolean . parseBoolean ( settings . get ( USE_DEVELOPMENT_STORAGE_NAME ) ) ) { throw new IllegalArgumentException ( SR . INVALID_CONNECTION_STRING_DEV_STORE_NOT_TRUE ) ; } URI devStoreProxyUri = null ; if ( settings . containsKey ( DEVELOPMENT_STORAGE_PROXY_URI_NAME ) ) { devStoreProxyUri = new URI ( settings . get ( DEVELOPMENT_STORAGE_PROXY_URI_NAME ) ) ; } return getDevelopmentStorageAccount ( devStoreProxyUri ) ; } else { return null ; }


signature:
public class CloudStorageAccount { /** * Evaluates connection settings and configures a CloudStorageAccount accordingly .
 * @ param settings
 * A < code > java . util . Map < / code > of key / value pairs which represents
 * the connection settings .
 * @ return A { @ link CloudStorageAccount } represented by the settings .
 * @ throws URISyntaxException
 * if the connectionString specifies an invalid URI .
 * @ throws InvalidKeyException
 * if credentials in the connection settings contain an invalid key . */
private static CloudStorageAccount tryConfigureServiceAccount ( final Map < String , String > settings ) throws URISyntaxException , InvalidKeyException { } }

implementation:
ConnectionStringFilter endpointsOptional = optional ( BLOB_ENDPOINT_NAME , BLOB_SECONDARY_ENDPOINT_NAME , QUEUE_ENDPOINT_NAME , QUEUE_SECONDARY_ENDPOINT_NAME , TABLE_ENDPOINT_NAME , TABLE_SECONDARY_ENDPOINT_NAME , FILE_ENDPOINT_NAME , FILE_SECONDARY_ENDPOINT_NAME ) ; ConnectionStringFilter primaryEndpointRequired = atLeastOne ( BLOB_ENDPOINT_NAME , QUEUE_ENDPOINT_NAME , TABLE_ENDPOINT_NAME , FILE_ENDPOINT_NAME ) ; ConnectionStringFilter secondaryEndpointsOptional = optional ( BLOB_SECONDARY_ENDPOINT_NAME , QUEUE_SECONDARY_ENDPOINT_NAME , TABLE_SECONDARY_ENDPOINT_NAME , FILE_SECONDARY_ENDPOINT_NAME ) ; ConnectionStringFilter automaticEndpointsMatchSpec = matchesExactly ( matchesAll ( matchesOne ( matchesAll ( allRequired ( ACCOUNT_KEY_NAME ) ) , // Key + Name , Endpoints optional
allRequired ( SHARED_ACCESS_SIGNATURE_NAME ) // SAS + Name , Endpoints optional
) , allRequired ( ACCOUNT_NAME_NAME ) , // Name required to automatically create URIs
endpointsOptional , optional ( DEFAULT_ENDPOINTS_PROTOCOL_NAME , ENDPOINT_SUFFIX_NAME ) ) ) ; ConnectionStringFilter explicitEndpointsMatchSpec = matchesExactly ( matchesAll ( // Any Credentials , Endpoints must be explicitly declared
validCredentials , primaryEndpointRequired , secondaryEndpointsOptional ) ) ; Boolean matchesAutomaticEndpointsSpec = matchesSpecification ( settings , automaticEndpointsMatchSpec ) ; Boolean matchesExplicitEndpointsSpec = matchesSpecification ( settings , explicitEndpointsMatchSpec ) ; if ( matchesAutomaticEndpointsSpec || matchesExplicitEndpointsSpec ) { if ( matchesAutomaticEndpointsSpec && ! settings . containsKey ( DEFAULT_ENDPOINTS_PROTOCOL_NAME ) ) { settings . put ( DEFAULT_ENDPOINTS_PROTOCOL_NAME , "https" ) ; } String blobEndpoint = settingOrDefault ( settings , BLOB_ENDPOINT_NAME ) ; String queueEndpoint = settingOrDefault ( settings , QUEUE_ENDPOINT_NAME ) ; String tableEndpoint = settingOrDefault ( settings , TABLE_ENDPOINT_NAME ) ; String fileEndpoint = settingOrDefault ( settings , FILE_ENDPOINT_NAME ) ; String blobSecondaryEndpoint = settingOrDefault ( settings , BLOB_SECONDARY_ENDPOINT_NAME ) ; String queueSecondaryEndpoint = settingOrDefault ( settings , QUEUE_SECONDARY_ENDPOINT_NAME ) ; String tableSecondaryEndpoint = settingOrDefault ( settings , TABLE_SECONDARY_ENDPOINT_NAME ) ; String fileSecondaryEndpoint = settingOrDefault ( settings , FILE_SECONDARY_ENDPOINT_NAME ) ; // if secondary is specified , primary must also be specified
if ( isValidEndpointPair ( blobEndpoint , blobSecondaryEndpoint ) && isValidEndpointPair ( queueEndpoint , queueSecondaryEndpoint ) && isValidEndpointPair ( tableEndpoint , tableSecondaryEndpoint ) && isValidEndpointPair ( fileEndpoint , fileSecondaryEndpoint ) ) { CloudStorageAccount accountInformation = new CloudStorageAccount ( StorageCredentials . tryParseCredentials ( settings ) , getStorageUri ( settings , SR . BLOB , BLOB_ENDPOINT_NAME , BLOB_SECONDARY_ENDPOINT_NAME , matchesAutomaticEndpointsSpec ) , getStorageUri ( settings , SR . QUEUE , QUEUE_ENDPOINT_NAME , QUEUE_SECONDARY_ENDPOINT_NAME , matchesAutomaticEndpointsSpec ) , getStorageUri ( settings , SR . TABLE , TABLE_ENDPOINT_NAME , TABLE_SECONDARY_ENDPOINT_NAME , matchesAutomaticEndpointsSpec ) , getStorageUri ( settings , SR . FILE , FILE_ENDPOINT_NAME , FILE_SECONDARY_ENDPOINT_NAME , matchesAutomaticEndpointsSpec ) ) ; accountInformation . isBlobEndpointDefault = blobEndpoint == null ; accountInformation . isFileEndpointDefault = fileEndpoint == null ; accountInformation . isQueueEndpointDefault = queueEndpoint == null ; accountInformation . isTableEndpointDefault = tableEndpoint == null ; accountInformation . endpointSuffix = settingOrDefault ( settings , ENDPOINT_SUFFIX_NAME ) ; accountInformation . accountName = settingOrDefault ( settings , ACCOUNT_NAME_NAME ) ; return accountInformation ; } } return null ;


signature:
public class CloudStorageAccount { /** * Creates a new Analytics service client .
 * @ return An analytics client object that uses the Blob and Table service endpoints . */
public CloudAnalyticsClient createCloudAnalyticsClient ( ) { } }

implementation: if ( this . getBlobStorageUri ( ) == null ) { throw new IllegalArgumentException ( SR . BLOB_ENDPOINT_NOT_CONFIGURED ) ; } if ( this . getTableStorageUri ( ) == null ) { throw new IllegalArgumentException ( SR . TABLE_ENDPOINT_NOT_CONFIGURED ) ; } if ( this . credentials == null ) { throw new IllegalArgumentException ( SR . MISSING_CREDENTIALS ) ; } return new CloudAnalyticsClient ( this . getBlobStorageUri ( ) , this . getTableStorageUri ( ) , this . getCredentials ( ) ) ;


signature:
public class CloudStorageAccount { /** * Creates a new Blob service client .
 * @ return A { @ link CloudBlobClient } that represents the cloud Blob client . */
public CloudBlobClient createCloudBlobClient ( ) { } }

implementation: if ( this . getBlobStorageUri ( ) == null ) { throw new IllegalArgumentException ( SR . BLOB_ENDPOINT_NOT_CONFIGURED ) ; } if ( this . credentials == null ) { throw new IllegalArgumentException ( SR . MISSING_CREDENTIALS ) ; } return new CloudBlobClient ( this . getBlobStorageUri ( ) , this . getCredentials ( ) ) ;


signature:
public class CloudStorageAccount { /** * Creates a new File service client .
 * @ return A { @ link CloudFileClient } that represents the cloud File client . */
public CloudFileClient createCloudFileClient ( ) { } }

implementation: if ( this . getFileStorageUri ( ) == null ) { throw new IllegalArgumentException ( SR . FILE_ENDPOINT_NOT_CONFIGURED ) ; } if ( this . credentials == null ) { throw new IllegalArgumentException ( SR . MISSING_CREDENTIALS ) ; } if ( ! StorageCredentialsHelper . canCredentialsGenerateClient ( this . credentials ) ) { throw new IllegalArgumentException ( SR . CREDENTIALS_CANNOT_SIGN_REQUEST ) ; } return new CloudFileClient ( this . getFileStorageUri ( ) , this . getCredentials ( ) ) ;


signature:
public class CloudStorageAccount { /** * Creates a new Queue service client .
 * @ return A client object that uses the Queue service endpoint . */
public CloudQueueClient createCloudQueueClient ( ) { } }

implementation: if ( this . getQueueStorageUri ( ) == null ) { throw new IllegalArgumentException ( SR . QUEUE_ENDPOINT_NOT_CONFIGURED ) ; } if ( this . credentials == null ) { throw new IllegalArgumentException ( SR . MISSING_CREDENTIALS ) ; } if ( ! StorageCredentialsHelper . canCredentialsGenerateClient ( this . credentials ) ) { throw new IllegalArgumentException ( SR . CREDENTIALS_CANNOT_SIGN_REQUEST ) ; } return new CloudQueueClient ( this . getQueueStorageUri ( ) , this . getCredentials ( ) ) ;


signature:
public class CloudStorageAccount { /** * Creates a new Table service client .
 * @ return A client object that uses the Table service endpoint . */
public CloudTableClient createCloudTableClient ( ) { } }

implementation: if ( this . getTableStorageUri ( ) == null ) { throw new IllegalArgumentException ( SR . TABLE_ENDPOINT_NOT_CONFIGURED ) ; } if ( this . credentials == null ) { throw new IllegalArgumentException ( SR . MISSING_CREDENTIALS ) ; } if ( ! StorageCredentialsHelper . canCredentialsGenerateClient ( this . credentials ) ) { throw new IllegalArgumentException ( SR . CREDENTIALS_CANNOT_SIGN_REQUEST ) ; } return new CloudTableClient ( this . getTableStorageUri ( ) , this . getCredentials ( ) ) ;


signature:
public class CloudStorageAccount { /** * Returns a shared access signature for the account .
 * @ param policy
 * A { @ link SharedAccessAccountPolicy } specifying the access policy for the shared access signature .
 * @ return The query string returned includes the leading question mark .
 * @ throws StorageException
 * If a storage service error occurred .
 * @ throws InvalidKeyException
 * If the key is invalid . */
public String generateSharedAccessSignature ( SharedAccessAccountPolicy policy ) throws InvalidKeyException , StorageException { } }

implementation: if ( ! StorageCredentialsHelper . canCredentialsSignRequest ( this . getCredentials ( ) ) ) { throw new IllegalArgumentException ( SR . CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY ) ; } final String sig = SharedAccessSignatureHelper . generateSharedAccessSignatureHashForAccount ( this . credentials . getAccountName ( ) , policy , this . getCredentials ( ) ) ; final UriQueryBuilder sasBuilder = SharedAccessSignatureHelper . generateSharedAccessSignatureForAccount ( policy , sig ) ; return sasBuilder . toString ( ) ;


signature:
public class TableOperation { /** * A static factory method returning a { @ link TableOperation } instance to delete the specified entity from Microsoft
 * Azure storage . To execute this { @ link TableOperation } on a given table , call the
 * { @ link CloudTable # execute ( TableOperation ) } method on a { @ link CloudTableClient } instance with the
 * @ param entity
 * The object instance implementing { @ link TableEntity } to associate with the operation .
 * @ return
 * A new { @ link TableOperation } instance to insert the table entity . */
public static TableOperation delete ( final TableEntity entity ) { } }

implementation: Utility . assertNotNull ( "entity" , entity ) ; Utility . assertNotNullOrEmpty ( "entity etag" , entity . getEtag ( ) ) ; return new TableOperation ( entity , TableOperationType . DELETE ) ;


signature:
public class TableOperation { /** * A static factory method returning a { @ link TableOperation } instance to insert the specified entity into
 * Microsoft Azure storage . To execute this { @ link TableOperation } on a given table , call the
 * { @ link CloudTable # execute ( TableOperation ) } method on a { @ link CloudTableClient } instance with the
 * @ param entity
 * The object instance implementing { @ link TableEntity } to associate with the operation .
 * @ param echoContent
 * The boolean representing whether the message payload should be returned in the response .
 * @ return
 * A new { @ link TableOperation } instance to insert the table entity . */
public static TableOperation insert ( final TableEntity entity , boolean echoContent ) { } }

implementation: Utility . assertNotNull ( "entity" , entity ) ; return new TableOperation ( entity , TableOperationType . INSERT , echoContent ) ;


signature:
public class TableOperation { /** * A static factory method returning a { @ link TableOperation } instance to merge the specified entity into
 * Microsoft Azure storage , or insert it if it does not exist . To execute this { @ link TableOperation } on a given
 * table , call
 * the { @ link CloudTable # execute ( TableOperation ) } method on a { @ link CloudTableClient } instance with
 * the table name and the { @ link TableOperation } as arguments .
 * @ param entity
 * The object instance implementing { @ link TableEntity } to associate with the operation .
 * @ return
 * A new { @ link TableOperation } instance for inserting or merging the table entity . */
public static TableOperation insertOrMerge ( final TableEntity entity ) { } }

implementation: Utility . assertNotNull ( "entity" , entity ) ; return new TableOperation ( entity , TableOperationType . INSERT_OR_MERGE ) ;


signature:
public class TableOperation { /** * A static factory method returning a { @ link TableOperation } instance to replace the specified entity in
 * Microsoft Azure storage , or insert it if it does not exist . To execute this { @ link TableOperation } on a given
 * table , call
 * the { @ link CloudTable # execute ( TableOperation ) } method on a { @ link CloudTableClient } instance with
 * the table name and the { @ link TableOperation } as arguments .
 * @ param entity
 * The object instance implementing { @ link TableEntity } to associate with the operation .
 * @ return
 * A new { @ link TableOperation } instance for inserting or replacing the table entity . */
public static TableOperation insertOrReplace ( final TableEntity entity ) { } }

implementation: Utility . assertNotNull ( "entity" , entity ) ; return new TableOperation ( entity , TableOperationType . INSERT_OR_REPLACE ) ;


signature:
public class TableOperation { /** * A static factory method returning a { @ link TableOperation } instance to merge the specified table entity into
 * Microsoft Azure storage . To execute this { @ link TableOperation } on a given table , call the
 * { @ link CloudTable # execute ( TableOperation ) } method on a { @ link CloudTableClient } instance with the
 * @ param entity
 * The object instance implementing { @ link TableEntity } to associate with the operation .
 * @ return
 * A new { @ link TableOperation } instance for merging the table entity . */
public static TableOperation merge ( final TableEntity entity ) { } }

implementation: Utility . assertNotNull ( "entity" , entity ) ; Utility . assertNotNullOrEmpty ( "entity etag" , entity . getEtag ( ) ) ; return new TableOperation ( entity , TableOperationType . MERGE ) ;


signature:
public class TableOperation { /** * 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 CloudTable # execute ( TableOperation ) } method on a { @ link CloudTableClient } instance with the
 * @ param partitionKey
 * A < code > String < / code > which specifies the PartitionKey value for the entity to retrieve .
 * @ param rowKey
 * A < code > String < / code > which specifies 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 ) { } }

implementation: final QueryTableOperation retOp = new QueryTableOperation ( partitionKey , rowKey ) ; retOp . setClazzType ( clazzType ) ; return retOp ;


signature:
public class TableOperation { /** * 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 CloudTable # execute ( TableOperation ) } method on a { @ link CloudTableClient } instance
 * with the table name and the { @ link TableOperation } as arguments .
 * @ param partitionKey
 * A < code > String < / code > which specifies the PartitionKey value for the entity to retrieve .
 * @ param rowKey
 * A < code > String < / code > which specifies 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 ) { } }

implementation: final QueryTableOperation retOp = new QueryTableOperation ( partitionKey , rowKey ) ; retOp . setResolver ( resolver ) ; return retOp ;


signature:
public class TableOperation { /** * A static factory method returning a { @ link TableOperation } instance to replace the specified table entity . To
 * execute this { @ link TableOperation } on a given table , call the
 * { @ link CloudTable # execute ( TableOperation ) } method .
 * @ param entity
 * The object instance implementing { @ link TableEntity } to associate with the operation .
 * @ return
 * A new { @ link TableOperation } instance for replacing the table entity . */
public static TableOperation replace ( final TableEntity entity ) { } }

implementation: Utility . assertNotNullOrEmpty ( "entity etag" , entity . getEtag ( ) ) ; return new TableOperation ( entity , TableOperationType . REPLACE ) ;


signature:
public class TableOperation { /** * Reserved for internal use . Performs a delete operation on the specified table , using the specified
 * { @ link TableRequestOptions } and { @ link OperationContext } .
 * This method will invoke the < a href = " http : / / msdn . microsoft . com / en - us / library / azure / dd135727 . aspx " > Delete
 * Entity < / a > REST API to execute this table operation , using the Table service endpoint and storage account
 * credentials in the { @ link CloudTableClient } object .
 * @ param client
 * A { @ link CloudTableClient } instance specifying the Table service endpoint , storage account
 * credentials , and any additional query parameters .
 * @ param tableName
 * A < code > String < / code > which specifies the name of the table .
 * @ param options
 * A { @ link TableRequestOptions } object that specifies execution options such as retry policy and timeout
 * settings for the operation .
 * @ param opContext
 * An { @ link OperationContext } object for tracking the current operation .
 * @ return
 * A { @ link TableResult } which represents the results of executing the operation .
 * @ throws StorageException
 * if an error occurs in the storage operation . */
private TableResult performDelete ( final CloudTableClient client , final String tableName , final TableRequestOptions options , final OperationContext opContext ) throws StorageException { } }

implementation: return ExecutionEngine . executeWithRetry ( client , this , this . deleteImpl ( client , tableName , options , opContext ) , options . getRetryPolicyFactory ( ) , opContext ) ;


signature:
public class TableOperation { /** * Reserved for internal use . Performs an insert operation on the specified table , using the specified
 * { @ link TableRequestOptions } and { @ link OperationContext } .
 * This method will invoke the Insert Entity REST API to execute this table operation , using the Table service
 * endpoint and storage account credentials in the { @ link CloudTableClient } object .
 * @ param client
 * A { @ link CloudTableClient } instance specifying the Table service endpoint , storage account
 * credentials , and any additional query parameters .
 * @ param tableName
 * A < code > String < / code > which specifies the name of the table .
 * @ param options
 * A { @ link TableRequestOptions } object that specifies execution options such as retry policy and timeout
 * settings for the operation .
 * @ param opContext
 * An { @ link OperationContext } object for tracking the current operation .
 * @ return
 * A { @ link TableResult } which represents the results of executing the operation .
 * @ throws StorageException
 * if an error occurs in the storage operation . */
private TableResult performInsert ( final CloudTableClient client , final String tableName , final TableRequestOptions options , final OperationContext opContext ) throws StorageException { } }

implementation: return ExecutionEngine . executeWithRetry ( client , this , this . insertImpl ( client , tableName , options , opContext ) , options . getRetryPolicyFactory ( ) , opContext ) ;


signature:
public class TableOperation { /** * Reserved for internal use . Perform a merge operation on the specified table , using the specified
 * { @ link TableRequestOptions } and { @ link OperationContext } .
 * This method will invoke the Merge Entity REST API to execute this table operation , using the Table service
 * endpoint and storage account credentials in the { @ link CloudTableClient } object .
 * @ param client
 * A { @ link CloudTableClient } instance specifying the Table service endpoint , storage account
 * credentials , and any additional query parameters .
 * @ param tableName
 * A < code > String < / code > which specifies the name of the table .
 * @ param options
 * A { @ link TableRequestOptions } object that specifies execution options such as retry policy and timeout
 * settings for the operation .
 * @ param opContext
 * An { @ link OperationContext } object for tracking the current operation .
 * @ return
 * A { @ link TableResult } which represents the results of executing the operation .
 * @ throws StorageException
 * if an error occurs in the storage operation .
 * @ throws IOException */
private TableResult performMerge ( final CloudTableClient client , final String tableName , final TableRequestOptions options , final OperationContext opContext ) throws StorageException { } }

implementation: return ExecutionEngine . executeWithRetry ( client , this , this . mergeImpl ( client , tableName , options , opContext ) , options . getRetryPolicyFactory ( ) , opContext ) ;


signature:
public class TableOperation { /** * Reserved for internal use . Perform an update operation on the specified table , using the specified
 * { @ link TableRequestOptions } and { @ link 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 { @ link CloudTableClient } object .
 * @ param client
 * A { @ link CloudTableClient } instance specifying the Table service endpoint , storage account
 * credentials , and any additional query parameters .
 * @ param tableName
 * A < code > String < / code > which specifies the name of the table .
 * @ param options
 * A { @ link TableRequestOptions } object that specifies execution options such as retry policy and timeout
 * settings for the operation .
 * @ param opContext
 * An { @ link OperationContext } object for tracking the current operation .
 * @ return
 * A { @ link TableResult } which represents the results of executing the operation .
 * @ throws StorageException
 * if an error occurs in the storage operation . */
private TableResult performUpdate ( final CloudTableClient client , final String tableName , final TableRequestOptions options , final OperationContext opContext ) throws StorageException { } }

implementation: return ExecutionEngine . executeWithRetry ( client , this , this . updateImpl ( client , tableName , options , opContext ) , options . getRetryPolicyFactory ( ) , opContext ) ;


signature:
public class TableOperation { /** * Reserved for internal use . Execute this table operation on the specified table , using the specified
 * { @ link TableRequestOptions } and { @ link 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 { @ link CloudTableClient } object .
 * @ param client
 * A { @ link CloudTableClient } instance specifying the Table service endpoint , storage account
 * credentials , and any additional query parameters .
 * @ param tableName
 * A < code > String < / code > which specifies the name of the table .
 * @ param options
 * A { @ link TableRequestOptions } object that specifies execution options such as retry policy and timeout
 * settings for the operation .
 * @ param opContext
 * An { @ link OperationContext } object for tracking the current operation .
 * @ return
 * A { @ link TableResult } which represents the results of executing the operation .
 * @ throws StorageException
 * if an error occurs in the storage operation . */
protected TableResult execute ( final CloudTableClient client , final String tableName , TableRequestOptions options , OperationContext opContext ) throws StorageException { } }

implementation: if ( opContext == null ) { opContext = new OperationContext ( ) ; } opContext . initialize ( ) ; options = TableRequestOptions . populateAndApplyDefaults ( options , client ) ; Utility . assertNotNullOrEmpty ( TableConstants . TABLE_NAME , tableName ) ; if ( this . getOperationType ( ) == TableOperationType . INSERT || this . getOperationType ( ) == TableOperationType . INSERT_OR_MERGE || this . getOperationType ( ) == TableOperationType . INSERT_OR_REPLACE ) { return this . performInsert ( client , tableName , options , opContext ) ; } else if ( this . getOperationType ( ) == TableOperationType . DELETE ) { return this . performDelete ( client , tableName , options , opContext ) ; } else if ( this . getOperationType ( ) == TableOperationType . MERGE ) { return this . performMerge ( client , tableName , options , opContext ) ; } else if ( this . getOperationType ( ) == TableOperationType . REPLACE ) { return this . performUpdate ( client , tableName , options , opContext ) ; } else if ( this . getOperationType ( ) == TableOperationType . RETRIEVE ) { return ( ( QueryTableOperation ) this ) . performRetrieve ( client , tableName , options , opContext ) ; } else { throw new IllegalArgumentException ( SR . UNKNOWN_TABLE_OPERATION ) ; }


signature:
public class TableOperation { /** * 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 > .
 * @ return
 * A < code > String < / code > which represents the formatted request identity string .
 * @ throws StorageException
 * If a storage service error occurred . */
protected String generateRequestIdentity ( boolean isSingleIndexEntry , final String entryName ) throws StorageException { } }

implementation: if ( isSingleIndexEntry ) { return String . format ( "'%s'" , entryName . replace ( "'" , "''" ) ) ; } 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 , pk . replace ( "'" , "''" ) , TableConstants . ROW_KEY , rk . replace ( "'" , "''" ) ) ; }


signature:
public class TableOperation { /** * 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 .
 * @ param tableName
 * A < code > String < / code > which specifies the name of the table .
 * @ return
 * A < code > String < / code > which represents the formatted request identity string for the specified table .
 * @ throws StorageException */
protected String generateRequestIdentityWithTable ( final String tableName ) throws StorageException { } }

implementation: return String . format ( "%s(%s)" , tableName , generateRequestIdentity ( false , null ) ) ;


signature:
public class TableOperation { /** * Reserved for internal use . Parses the table operation response into a { @ link TableResult } to return .
 * @ param inStream
 * An < code > InputStream < / code > which specifies the response to an insert operation .
 * @ param httpStatusCode
 * An < code > int < / code > which represents the HTTP status code returned from the operation request .
 * @ param etagFromHeader
 * The < code > String < / code > which specifies the Etag returned with the operation response .
 * @ param opContext
 * An { @ link OperationContext } object that represents the context for the current operation .
 * @ return
 * The { @ link TableResult } representing the result of the operation .
 * @ throws InstantiationException
 * if an error occurs in object construction .
 * @ throws IllegalAccessException
 * if an error occurs in reflection on an object type .
 * @ throws StorageException
 * if an error occurs in the storage operation .
 * @ throws IOException
 * if an error occurs while accessing the { @ link InputStream } with Json .
 * @ throws JsonParseException
 * if an error occurs while parsing the Json , if Json is used . */
protected TableResult parseResponse ( final InputStream inStream , final int httpStatusCode , String etagFromHeader , final OperationContext opContext , final TableRequestOptions options ) throws InstantiationException , IllegalAccessException , StorageException , JsonParseException , IOException { } }

implementation:
TableResult resObj ; if ( this . opType == TableOperationType . INSERT && this . echoContent ) { // Sending null for class type and resolver will ignore parsing the return payload .
resObj = TableDeserializer . parseSingleOpResponse ( inStream , options , httpStatusCode , null /* clazzType */
, null /* resolver */
, opContext ) ; resObj . setEtag ( etagFromHeader ) ; resObj . updateResultObject ( this . getEntity ( ) ) ; } else { resObj = new TableResult ( httpStatusCode ) ; resObj . setResult ( this . getEntity ( ) ) ; if ( this . opType != TableOperationType . DELETE && etagFromHeader != null ) { resObj . setEtag ( etagFromHeader ) ; resObj . updateResultObject ( this . getEntity ( ) ) ; } } return resObj ;


signature:
public class StorageRequest { /** * Resets the operation status flags between operations . */
protected final void initialize ( OperationContext opContext ) { } }

implementation: RequestResult currResult = new RequestResult ( ) ; this . setResult ( currResult ) ; opContext . appendRequestResult ( currResult ) ; this . setException ( null ) ; this . setNonExceptionedRetryableFailure ( false ) ; this . setIsSent ( false ) ;


signature:
public class StorageRequest { /** * Returns either the held exception from the operation if it is set , otherwise the translated exception .
 * @ param request
 * the reference to the HttpURLConnection for the operation .
 * @ param opContext
 * an object used to track the execution of the operation
 * @ return the exception to throw . */
protected final StorageException materializeException ( final OperationContext opContext ) { } }

implementation: if ( this . getException ( ) != null ) { return this . getException ( ) ; } return StorageException . translateException ( this , null , opContext ) ;


signature:
public class StorageRequest { /** * Post - Stream Retrieval function .
 * @ param connection
 * HttpURLConnection configured for the operation .
 * @ param storageObject
 * An object of the expected result ' s type .
 * @ return the expected result of the operation .
 * @ throws Exception */
public R postProcessResponse ( HttpURLConnection connection , P parentObject , C client , OperationContext context , R storageObject ) throws Exception { } }

implementation: return storageObject ;


signature:
public class StorageRequest { /** * Returns extended error information for this request .
 * @ return A { @ link StorageExtendedErrorInformation } object that represents the error details for the specified
 * request . */
public StorageExtendedErrorInformation parseErrorDetails ( ) { } }

implementation: try { if ( this . getConnection ( ) == null || this . getConnection ( ) . getErrorStream ( ) == null ) { return null ; } return StorageErrorHandler . getExtendedErrorInformation ( this . getConnection ( ) . getErrorStream ( ) ) ; } catch ( final Exception e ) { return null ; }


signature:
public class TableBatchOperation { /** * Adds the table operation at the specified index in the batch operation < code > ArrayList < / code > .
 * @ param index
 * An < code > int < / code > which represents the index in the batch operation < code > ArrayList < / code > to add
 * the table operation at .
 * @ param element
 * The { @ link TableOperation } to add to the batch operation . */
@ Override public void add ( final int index , final TableOperation element ) { } }

implementation: Utility . assertNotNull ( "element" , element ) ; this . checkSingleQueryPerBatch ( element , this . size ( ) ) ; if ( element . getOperationType ( ) == TableOperationType . RETRIEVE ) { this . lockToPartitionKey ( ( ( QueryTableOperation ) element ) . getPartitionKey ( ) ) ; } else { this . lockToPartitionKey ( element . getEntity ( ) . getPartitionKey ( ) ) ; } super . add ( index , element ) ;


signature:
public class TableBatchOperation { /** * Adds the collection of table operations to the batch operation < code > ArrayList < / code > starting at the specified
 * index .
 * @ param index
 * An < code > int < / code > which represents the index in the batch operation < code > ArrayList < / code > to add
 * the table operation at .
 * @ param c
 * A < code > java . util . Collection < / code > of { @ link TableOperation } objects to add to the batch operation .
 * @ return
 * < code > true < / code > if the operations were added successfully . */
@ Override public boolean addAll ( final int index , final java . util . Collection < ? extends TableOperation > c ) { } }

implementation:
int size = this . size ( ) ; for ( final TableOperation operation : c ) { Utility . assertNotNull ( "operation" , operation ) ; this . checkSingleQueryPerBatch ( operation , size ) ; if ( operation . getEntity ( ) == null ) { // Query operation
this . lockToPartitionKey ( ( ( QueryTableOperation ) operation ) . getPartitionKey ( ) ) ; } else { this . lockToPartitionKey ( operation . getEntity ( ) . getPartitionKey ( ) ) ; } size ++ ; } return super . addAll ( index , c ) ;


signature:
public class TableBatchOperation { /** * Adds a table operation to delete the specified entity to the batch operation .
 * @ param entity
 * The { @ link TableEntity } to delete . */
public void delete ( final TableEntity entity ) { } }

implementation: this . lockToPartitionKey ( entity . getPartitionKey ( ) ) ; this . add ( TableOperation . delete ( entity ) ) ;


signature:
public class TableBatchOperation { /** * Adds a table operation to insert the specified entity to the batch operation .
 * @ param entity
 * The { @ link TableEntity } to insert .
 * @ param echoContent
 * The boolean representing whether the message payload should be returned in the response . */
public void insert ( final TableEntity entity , boolean echoContent ) { } }

implementation: this . lockToPartitionKey ( entity . getPartitionKey ( ) ) ; this . add ( TableOperation . insert ( entity , echoContent ) ) ;


signature:
public class TableBatchOperation { /** * Adds a table operation to insert or merge the specified entity to the batch operation .
 * @ param entity
 * The { @ link TableEntity } to insert if not found or to merge if it exists . */
public void insertOrMerge ( final TableEntity entity ) { } }

implementation: this . lockToPartitionKey ( entity . getPartitionKey ( ) ) ; this . add ( TableOperation . insertOrMerge ( entity ) ) ;


signature:
public class TableBatchOperation { /** * Adds a table operation to insert or replace the specified entity to the batch operation .
 * @ param entity
 * The { @ link TableEntity } to insert if not found or to replace if it exists . */
public void insertOrReplace ( final TableEntity entity ) { } }

implementation: this . lockToPartitionKey ( entity . getPartitionKey ( ) ) ; this . add ( TableOperation . insertOrReplace ( entity ) ) ;


signature:
public class TableBatchOperation { /** * Adds a table operation to merge the specified entity to the batch operation .
 * @ param entity
 * The { @ link TableEntity } to merge . */
public void merge ( final TableEntity entity ) { } }

implementation: this . lockToPartitionKey ( entity . getPartitionKey ( ) ) ; this . add ( TableOperation . merge ( entity ) ) ;


signature:
public class TableBatchOperation { /** * Adds a table operation to retrieve an entity of the specified class type with the specified PartitionKey and
 * RowKey to the batch operation .
 * @ param partitionKey
 * A < code > String < / code > containing the PartitionKey of the entity to retrieve .
 * @ param rowKey
 * A < code > String < / code > containing the RowKey of the entity to retrieve .
 * @ param clazzType
 * The class of the { @ link TableEntity } type for the entity to retrieve . */
public void retrieve ( final String partitionKey , final String rowKey , final Class < ? extends TableEntity > clazzType ) { } }

implementation: this . lockToPartitionKey ( partitionKey ) ; this . add ( TableOperation . retrieve ( partitionKey , rowKey , clazzType ) ) ;


signature:
public class TableBatchOperation { /** * Adds a table operation to retrieve an entity of the specified class type with the specified PartitionKey and
 * RowKey to the batch operation .
 * @ param partitionKey
 * A < code > String < / code > containing the PartitionKey of the entity to retrieve .
 * @ param rowKey
 * A < code > String < / code > containing the RowKey of the entity to retrieve .
 * @ param resolver
 * The { @ link EntityResolver } implementation to project the entity to retrieve as a particular type in
 * the result . */
public void retrieve ( final String partitionKey , final String rowKey , final EntityResolver < ? > resolver ) { } }

implementation: this . lockToPartitionKey ( partitionKey ) ; this . add ( TableOperation . retrieve ( partitionKey , rowKey , resolver ) ) ;


signature:
public class TableBatchOperation { /** * Removes the table operation at the specified index from the batch operation .
 * @ param index
 * An < code > int < / code > which represents the index in the < code > ArrayList < / code > of the table operation to
 * remove from the batch operation . */
@ Override public TableOperation remove ( int index ) { } }

implementation: TableOperation op = super . remove ( index ) ; checkResetEntityLocks ( ) ; return op ;


signature:
public class TableBatchOperation { /** * Removes all elements of the specified collection from the batch operation .
 * @ param c
 * The collection of elements to remove from the batch operation .
 * @ return
 * < code > true < / code > if the objects in the collection were removed successfully . */
@ Override public boolean removeAll ( java . util . Collection < ? > c ) { } }

implementation: boolean ret = super . removeAll ( c ) ; checkResetEntityLocks ( ) ; return ret ;


signature:
public class TableBatchOperation { /** * Adds a table operation to replace the specified entity to the batch operation .
 * @ param entity
 * The { @ link TableEntity } to replace . */
public void replace ( final TableEntity entity ) { } }

implementation: this . lockToPartitionKey ( entity . getPartitionKey ( ) ) ; this . add ( TableOperation . replace ( entity ) ) ;


signature:
public class TableBatchOperation { /** * Reserved for internal use . Verifies that the batch operation either contains no retrieve operations , or contains
 * only a single retrieve operation .
 * @ param op
 * The { @ link TableOperation } to be added if the verification succeeds . */
private void checkSingleQueryPerBatch ( final TableOperation op , final int size ) { } }

implementation:
// if this has a query then no other operations can be added .
if ( this . hasQuery ) { throw new IllegalArgumentException ( SR . RETRIEVE_MUST_BE_ONLY_OPERATION_IN_BATCH ) ; } if ( op . getOperationType ( ) == TableOperationType . RETRIEVE ) { if ( size > 0 ) { throw new IllegalArgumentException ( SR . RETRIEVE_MUST_BE_ONLY_OPERATION_IN_BATCH ) ; } else { this . hasQuery = true ; } } this . containsWrites = op . getOperationType ( ) != TableOperationType . RETRIEVE ;


signature:
public class TableBatchOperation { /** * Reserved for internal use . Verifies that the specified PartitionKey value matches the value in the batch
 * operation .
 * @ param partitionKey
 * The < code > String < / code > containing the PartitionKey value to check . */
private void lockToPartitionKey ( final String partitionKey ) { } }

implementation: if ( this . partitionKey == null ) { this . partitionKey = partitionKey ; } else { if ( partitionKey . length ( ) != partitionKey . length ( ) || ! this . partitionKey . equals ( partitionKey ) ) { throw new IllegalArgumentException ( SR . OPS_IN_BATCH_MUST_HAVE_SAME_PARTITION_KEY ) ; } }