signature:
public class FileRequestOptions { /** * Uses the concurrent request count from the specified client if < code > null < / code > , sets a default value for
 * everything else , and sets defaults as defined in the parent class .
 * @ param options
 * The input options to copy from when applying defaults
 * @ param client
 * A { @ link CloudFileClient } object that represents the service client used to set the default timeout
 * interval and retry policy , if they are < code > null < / code > . Additionally , if the
 * { @ link # concurrentRequestCount } field ' s value is null , it will be set to the value specified by the
 * cloud blob client ' s { @ link CloudFileClient # getConcurrentRequestCount } method .
 * @ param setStartTime
 * whether to initialize the startTimeInMs field , or not */
protected static final FileRequestOptions populateAndApplyDefaults ( final FileRequestOptions options , final CloudFileClient client , final boolean setStartTime ) { } }

implementation: FileRequestOptions modifiedOptions = new FileRequestOptions ( options ) ; FileRequestOptions . populateRequestOptions ( modifiedOptions , client . getDefaultRequestOptions ( ) , setStartTime ) ; FileRequestOptions . applyDefaults ( modifiedOptions ) ; return modifiedOptions ;


signature:
public class FileRequestOptions { /** * Applies defaults to the options passed in .
 * @ param modifiedOptions
 * The options to apply defaults to . */
protected static void applyDefaults ( final FileRequestOptions modifiedOptions ) { } }

implementation: Utility . assertNotNull ( "modifiedOptions" , modifiedOptions ) ; RequestOptions . applyBaseDefaultsInternal ( modifiedOptions ) ; if ( modifiedOptions . getConcurrentRequestCount ( ) == null ) { modifiedOptions . setConcurrentRequestCount ( FileConstants . DEFAULT_CONCURRENT_REQUEST_COUNT ) ; } if ( modifiedOptions . getUseTransactionalContentMD5 ( ) == null ) { modifiedOptions . setUseTransactionalContentMD5 ( false ) ; } if ( modifiedOptions . getStoreFileContentMD5 ( ) == null ) { modifiedOptions . setStoreFileContentMD5 ( false ) ; } if ( modifiedOptions . getDisableContentMD5Validation ( ) == null ) { modifiedOptions . setDisableContentMD5Validation ( false ) ; }


signature:
public class FileRequestOptions { /** * Populates any null fields in the first requestOptions object with values from the second requestOptions object . */
private static void populateRequestOptions ( FileRequestOptions modifiedOptions , final FileRequestOptions clientOptions , boolean setStartTime ) { } }

implementation: RequestOptions . populateRequestOptions ( modifiedOptions , clientOptions , setStartTime ) ; if ( modifiedOptions . getConcurrentRequestCount ( ) == null ) { modifiedOptions . setConcurrentRequestCount ( clientOptions . getConcurrentRequestCount ( ) ) ; }


signature:
public class FileRequestOptions { /** * Sets the { @ link LocationMode } for this request .
 * The default { @ link LocationMode } is set in the client and is by default { @ link LocationMode # PRIMARY _ ONLY } . You
 * can change the { @ link LocationMode } on this request by setting this property . You can also change the value on
 * the { @ link ServiceClient # getDefaultRequestOptions ( ) } object so that all subsequent requests made via the service
 * client will use that { @ link LocationMode } .
 * @ param locationMode
 * the locationMode to set */
@ Override public final void setLocationMode ( final LocationMode locationMode ) { } }

implementation: if ( locationMode != null && ! locationMode . equals ( LocationMode . PRIMARY_ONLY ) ) { throw new UnsupportedOperationException ( SR . PRIMARY_ONLY_COMMAND ) ; } super . setLocationMode ( locationMode ) ;


signature:
public class EntityProperty { /** * Gets the value of this { @ link EntityProperty } as a < code > double < / code > .
 * @ return
 * A < code > double < / code > representation of the { @ link EntityProperty } value .
 * @ throws IllegalArgumentException
 * If the value is < code > null < / code > or cannot be parsed as a < code > double < / code > . */
public double getValueAsDouble ( ) { } }

implementation: if ( this . getIsNull ( ) ) { throw new IllegalArgumentException ( SR . ENTITY_PROPERTY_CANNOT_BE_NULL_FOR_PRIMITIVES ) ; } else if ( this . value . equals ( "Infinity" ) || this . value . equals ( "INF" ) ) { return Double . POSITIVE_INFINITY ; } else if ( this . value . equals ( "-Infinity" ) || this . value . equals ( "-INF" ) ) { return Double . NEGATIVE_INFINITY ; } else if ( this . value . equals ( "NaN" ) ) { return Double . NaN ; } else { return Double . parseDouble ( this . value ) ; }


signature:
public class EntityProperty { /** * Gets the value of this { @ link EntityProperty } as a < code > double < / code > .
 * @ return
 * A < code > double < / code > representation of the { @ link EntityProperty } value .
 * @ throws IllegalArgumentException
 * If the value is < code > null < / code > or cannot be parsed as a < code > double < / code > . */
public Double getValueAsDoubleObject ( ) { } }

implementation: if ( this . getIsNull ( ) ) { return null ; } else if ( this . value . equals ( "Infinity" ) || this . value . equals ( "INF" ) ) { return Double . POSITIVE_INFINITY ; } else if ( this . value . equals ( "-Infinity" ) || this . value . equals ( "-INF" ) ) { return Double . NEGATIVE_INFINITY ; } else if ( this . value . equals ( "NaN" ) ) { return Double . NaN ; } else { return Double . parseDouble ( this . value ) ; }


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > boolean < / code > value .
 * @ param value
 * The < code > boolean < / code > value to set as the { @ link EntityProperty } value . */
public synchronized final void setValue ( final boolean value ) { } }

implementation: this . edmType = EdmType . BOOLEAN ; this . type = boolean . class ; this . value = value ? Constants . TRUE : Constants . FALSE ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > Boolean < / code > value .
 * @ param value
 * The < code > Boolean < / code > value to set as the { @ link EntityProperty } value . */
public synchronized final void setValue ( final Boolean value ) { } }

implementation: this . edmType = EdmType . BOOLEAN ; this . type = Boolean . class ; if ( value == null ) { this . value = null ; } else { this . value = value ? Constants . TRUE : Constants . FALSE ; }


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > byte [ ] < / code > value .
 * @ param value
 * The < code > byte [ ] < / code > value to set as the { @ link EntityProperty } value . This value may be
 * < code > null < / code > . */
public synchronized final void setValue ( final byte [ ] value ) { } }

implementation: this . edmType = EdmType . BINARY ; this . type = byte [ ] . class ; this . value = value == null ? null : Base64 . encode ( value ) ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > java . util . Date < / code > value .
 * @ param value
 * The < code > java . util . Date < / code > value to set as the { @ link EntityProperty } value . This value may be
 * < code > null < / code > . */
public synchronized final void setValue ( final Date value ) { } }

implementation: this . edmType = EdmType . DATE_TIME ; this . type = Date . class ; this . value = value == null ? null : Utility . getJavaISO8601Time ( value ) ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > double < / code > value .
 * @ param value
 * The < code > double < / code > value to set as the { @ link EntityProperty } value . */
public synchronized final void setValue ( final double value ) { } }

implementation: this . edmType = EdmType . DOUBLE ; this . type = double . class ; this . value = Double . toString ( value ) ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > Double < / code > value .
 * @ param value
 * The < code > Double < / code > value to set as the { @ link EntityProperty } value . */
public synchronized final void setValue ( final Double value ) { } }

implementation: this . edmType = EdmType . DOUBLE ; this . type = Double . class ; this . value = value == null ? null : Double . toString ( value ) ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > int < / code > value .
 * @ param value
 * The < code > int < / code > value to set as the { @ link EntityProperty } value . */
public synchronized final void setValue ( final int value ) { } }

implementation: this . edmType = EdmType . INT32 ; this . type = int . class ; this . value = Integer . toString ( value ) ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > Integer < / code > value .
 * @ param value
 * The < code > Integer < / code > value to set as the { @ link EntityProperty } value . */
public synchronized final void setValue ( final Integer value ) { } }

implementation: this . edmType = EdmType . INT32 ; this . type = Integer . class ; this . value = value == null ? null : Integer . toString ( value ) ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > long < / code > value .
 * @ param value
 * The < code > long < / code > value to set as the { @ link EntityProperty } value . */
public synchronized final void setValue ( final long value ) { } }

implementation: this . edmType = EdmType . INT64 ; this . type = long . class ; this . value = Long . toString ( value ) ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > Long < / code > value .
 * @ param value
 * The < code > Long < / code > value to set as the { @ link EntityProperty } value . */
public synchronized final void setValue ( final Long value ) { } }

implementation: this . edmType = EdmType . INT64 ; this . type = Long . class ; this . value = value == null ? null : Long . toString ( value ) ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the < code > String < / code > value .
 * @ param value
 * The < code > String < / code > value to set as the { @ link EntityProperty } value . This value may be
 * < code > null < / code > . */
public synchronized final void setValue ( final String value ) { } }

implementation: this . edmType = EdmType . STRING ; this . type = String . class ; this . value = value ;


signature:
public class EntityProperty { /** * Sets this { @ link EntityProperty } using the serialized < code > java . util . UUID < / code > value .
 * @ param value
 * The < code > java . util . UUID < / code > value to set as the { @ link EntityProperty } value .
 * This value may be < code > null < / code > . */
public synchronized final void setValue ( final UUID value ) { } }

implementation: this . edmType = EdmType . GUID ; this . type = UUID . class ; this . value = value == null ? null : value . toString ( ) ;


signature:
public class StorageEventMultiCaster { /** * Fires the event to all subscribed event listeners .
 * @ param event
 * An < code > EVENTTYPE < / code > object that represents the event being multi - casted . */
public void fireEvent ( final EVENT_TYPE event ) { } }

implementation: for ( final StorageEvent < EVENT_TYPE > listener : this . listeners ) { listener . eventOccurred ( event ) ; }


signature:
public class ExecutionEngine { /** * Executes an operation and enforces a retrypolicy to handle any potential errors
 * @ param < CLIENT _ TYPE >
 * The type of the service client
 * @ param < PARENT _ TYPE >
 * The type of the parent object , i . e . CloudBlobContainer for downloadAttributes etc .
 * @ param < RESULT _ TYPE >
 * The type of the expected result
 * @ param client
 * the service client associated with the request
 * @ param parentObject
 * the parent object
 * @ param task
 * the StorageRequest to execute
 * @ param policyFactory
 * the factory used to generate a new retry policy instance
 * @ param opContext
 * an object used to track the execution of the operation
 * @ return the result of the operation
 * @ throws StorageException
 * an exception representing any error which occurred during the operation . */
public static < CLIENT_TYPE , PARENT_TYPE , RESULT_TYPE > RESULT_TYPE executeWithRetry ( final CLIENT_TYPE client , final PARENT_TYPE parentObject , final StorageRequest < CLIENT_TYPE , PARENT_TYPE , RESULT_TYPE > task , final RetryPolicyFactory policyFactory , final OperationContext opContext ) throws StorageException { } }

implementation:
RetryPolicy policy = null ; if ( policyFactory == null ) { policy = new RetryNoRetry ( ) ; } else { policy = policyFactory . createInstance ( opContext ) ; // if the returned policy is null , set to not retry
if ( policy == null ) { policy = new RetryNoRetry ( ) ; } } int currentRetryCount = 0 ; StorageException translatedException = null ; HttpURLConnection request = null ; final long startTime = new Date ( ) . getTime ( ) ; while ( true ) { try { // 1-4 : setup the request
request = setupStorageRequest ( client , parentObject , task , currentRetryCount , opContext ) ; Logger . info ( opContext , LogConstants . START_REQUEST , request . getURL ( ) , request . getRequestProperty ( Constants . HeaderConstants . DATE ) ) ; // 5 . Potentially upload data
boolean responseReceivedEventTriggered = false ; try { if ( task . getSendStream ( ) != null ) { Logger . info ( opContext , LogConstants . UPLOAD ) ; final StreamMd5AndLength descriptor = Utility . writeToOutputStream ( task . getSendStream ( ) , request . getOutputStream ( ) , task . getLength ( ) , false /* rewindStream */
, false /* calculate MD5 */
, opContext , task . getRequestOptions ( ) ) ; task . validateStreamWrite ( descriptor ) ; Logger . info ( opContext , LogConstants . UPLOADDONE ) ; } Utility . logHttpRequest ( request , opContext ) ; // 6 . Process the request - Get response
RequestResult currResult = task . getResult ( ) ; currResult . setStartDate ( new Date ( ) ) ; Logger . info ( opContext , LogConstants . GET_RESPONSE ) ; currResult . setStatusCode ( request . getResponseCode ( ) ) ; currResult . setStatusMessage ( request . getResponseMessage ( ) ) ; currResult . setStopDate ( new Date ( ) ) ; currResult . setServiceRequestID ( BaseResponse . getRequestId ( request ) ) ; currResult . setEtag ( BaseResponse . getEtag ( request ) ) ; currResult . setRequestDate ( BaseResponse . getDate ( request ) ) ; currResult . setContentMD5 ( BaseResponse . getContentMD5 ( request ) ) ; // 7 . Fire ResponseReceived Event
responseReceivedEventTriggered = true ; ExecutionEngine . fireResponseReceivedEvent ( opContext , request , task . getResult ( ) ) ; Logger . info ( opContext , LogConstants . RESPONSE_RECEIVED , currResult . getStatusCode ( ) , currResult . getServiceRequestID ( ) , currResult . getContentMD5 ( ) , currResult . getEtag ( ) , currResult . getRequestDate ( ) ) ; Utility . logHttpResponse ( request , opContext ) ; } finally { Logger . info ( opContext , LogConstants . ERROR_RECEIVING_RESPONSE ) ; if ( ! responseReceivedEventTriggered ) { if ( task . getResult ( ) . getStartDate ( ) == null ) { task . getResult ( ) . setStartDate ( new Date ( ) ) ; } ExecutionEngine . fireErrorReceivingResponseEvent ( opContext , request , task . getResult ( ) ) ; } } // 8 . Pre - process response to check if there was an exception . Do Response parsing ( headers etc ) .
Logger . info ( opContext , LogConstants . PRE_PROCESS ) ; RESULT_TYPE result = task . preProcessResponse ( parentObject , client , opContext ) ; Logger . info ( opContext , LogConstants . PRE_PROCESS_DONE ) ; if ( ! task . isNonExceptionedRetryableFailure ( ) ) { // 9 . Post - process response . Read stream from server .
Logger . info ( opContext , LogConstants . POST_PROCESS ) ; result = task . postProcessResponse ( request , parentObject , client , opContext , result ) ; Logger . info ( opContext , LogConstants . POST_PROCESS_DONE ) ; // Success return result and drain the input stream .
if ( ( task . getResult ( ) . getStatusCode ( ) >= 200 ) && ( task . getResult ( ) . getStatusCode ( ) < 300 ) ) { if ( request != null ) { InputStream inStream = request . getInputStream ( ) ; // At this point , we already have a result / exception to return to the user .
// This is just an optimization to improve socket reuse .
try { Utility . writeToOutputStream ( inStream , null , - 1 , false , false , null , task . getRequestOptions ( ) ) ; } catch ( final IOException ex ) { } catch ( StorageException e ) { } finally { inStream . close ( ) ; } } } Logger . info ( opContext , LogConstants . COMPLETE ) ; return result ; } else { Logger . warn ( opContext , LogConstants . UNEXPECTED_RESULT_OR_EXCEPTION ) ; // The task may have already parsed an exception .
translatedException = task . materializeException ( opContext ) ; task . getResult ( ) . setException ( translatedException ) ; // throw on non retryable status codes : 501 , 505 , blob type mismatch
if ( task . getResult ( ) . getStatusCode ( ) == HttpURLConnection . HTTP_NOT_IMPLEMENTED || task . getResult ( ) . getStatusCode ( ) == HttpURLConnection . HTTP_VERSION || translatedException . getErrorCode ( ) . equals ( StorageErrorCodeStrings . INVALID_BLOB_TYPE ) ) { throw translatedException ; } } } catch ( final NetworkOnMainThreadException e ) { // Non Retryable , just throw
translatedException = new StorageException ( "NetworkOnMainThreadException" , SR . NETWORK_ON_MAIN_THREAD_EXCEPTION , - 1 , null , e ) ; task . getResult ( ) . setException ( translatedException ) ; Logger . error ( opContext , LogConstants . UNRETRYABLE_EXCEPTION , e . getClass ( ) . getName ( ) , e . getMessage ( ) ) ; throw translatedException ; } catch ( final StorageException e ) { // In case of table batch error or internal error , the exception will contain a different
// status code and message than the original HTTP response . Reset based on error values .
task . getResult ( ) . setStatusCode ( e . getHttpStatusCode ( ) ) ; task . getResult ( ) . setStatusMessage ( e . getMessage ( ) ) ; task . getResult ( ) . setException ( e ) ; Logger . warn ( opContext , LogConstants . RETRYABLE_EXCEPTION , e . getClass ( ) . getName ( ) , e . getMessage ( ) ) ; translatedException = e ; } catch ( final Exception e ) { // Retryable , wrap
Logger . warn ( opContext , LogConstants . RETRYABLE_EXCEPTION , e . getClass ( ) . getName ( ) , e . getMessage ( ) ) ; translatedException = StorageException . translateException ( task , e , opContext ) ; task . getResult ( ) . setException ( translatedException ) ; } finally { opContext . setClientTimeInMs ( new Date ( ) . getTime ( ) - startTime ) ; // 10 . Fire RequestCompleted Event
if ( task . isSent ( ) ) { ExecutionEngine . fireRequestCompletedEvent ( opContext , request , task . getResult ( ) ) ; } } // Evaluate Retry Policy
Logger . info ( opContext , LogConstants . RETRY_CHECK , currentRetryCount , task . getResult ( ) . getStatusCode ( ) , translatedException == null ? null : translatedException . getMessage ( ) ) ; task . setCurrentLocation ( getNextLocation ( task . getCurrentLocation ( ) , task . getLocationMode ( ) ) ) ; Logger . info ( opContext , LogConstants . NEXT_LOCATION , task . getCurrentLocation ( ) , task . getLocationMode ( ) ) ; RetryContext retryContext = new RetryContext ( currentRetryCount ++ , task . getResult ( ) , task . getCurrentLocation ( ) , task . getLocationMode ( ) ) ; RetryInfo retryInfo = policy . evaluate ( retryContext , opContext ) ; if ( retryInfo == null ) { // policy does not allow for retry
Logger . error ( opContext , LogConstants . DO_NOT_RETRY_POLICY , translatedException == null ? null : translatedException . getMessage ( ) ) ; throw translatedException ; } else if ( Utility . validateMaxExecutionTimeout ( task . getRequestOptions ( ) . getOperationExpiryTimeInMs ( ) , retryInfo . getRetryInterval ( ) ) ) { // maximum execution time would be exceeded by current time plus retry interval delay
TimeoutException timeoutException = new TimeoutException ( SR . MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION ) ; translatedException = new StorageException ( StorageErrorCodeStrings . OPERATION_TIMED_OUT , SR . MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION , Constants . HeaderConstants . HTTP_UNUSED_306 , null , timeoutException ) ; task . initialize ( opContext ) ; task . getResult ( ) . setException ( translatedException ) ; Logger . error ( opContext , LogConstants . DO_NOT_RETRY_TIMEOUT , translatedException == null ? null : translatedException . getMessage ( ) ) ; throw translatedException ; } else { // attempt to retry
task . setCurrentLocation ( retryInfo . getTargetLocation ( ) ) ; task . setLocationMode ( retryInfo . getUpdatedLocationMode ( ) ) ; Logger . info ( opContext , LogConstants . RETRY_INFO , task . getCurrentLocation ( ) , task . getLocationMode ( ) ) ; try { ExecutionEngine . fireRetryingEvent ( opContext , task . getConnection ( ) , task . getResult ( ) , retryContext ) ; Logger . info ( opContext , LogConstants . RETRY_DELAY , retryInfo . getRetryInterval ( ) ) ; Thread . sleep ( retryInfo . getRetryInterval ( ) ) ; } catch ( final InterruptedException e ) { // Restore the interrupted status
Thread . currentThread ( ) . interrupt ( ) ; } } }


signature:
public class ExecutionEngine { /** * Fires events representing that a request will be sent . */
private static void fireSendingRequestEvent ( OperationContext opContext , HttpURLConnection request , RequestResult result ) { } }

implementation: if ( opContext . getSendingRequestEventHandler ( ) . hasListeners ( ) || OperationContext . getGlobalSendingRequestEventHandler ( ) . hasListeners ( ) ) { SendingRequestEvent event = new SendingRequestEvent ( opContext , request , result ) ; opContext . getSendingRequestEventHandler ( ) . fireEvent ( event ) ; OperationContext . getGlobalSendingRequestEventHandler ( ) . fireEvent ( event ) ; }


signature:
public class ExecutionEngine { /** * Fires events representing that a response has been received . */
private static void fireResponseReceivedEvent ( OperationContext opContext , HttpURLConnection request , RequestResult result ) { } }

implementation: if ( opContext . getResponseReceivedEventHandler ( ) . hasListeners ( ) || OperationContext . getGlobalResponseReceivedEventHandler ( ) . hasListeners ( ) ) { ResponseReceivedEvent event = new ResponseReceivedEvent ( opContext , request , result ) ; opContext . getResponseReceivedEventHandler ( ) . fireEvent ( event ) ; OperationContext . getGlobalResponseReceivedEventHandler ( ) . fireEvent ( event ) ; }


signature:
public class ExecutionEngine { /** * Fires events representing that an error occurred when receiving the response . */
private static void fireErrorReceivingResponseEvent ( OperationContext opContext , HttpURLConnection request , RequestResult result ) { } }

implementation: if ( opContext . getErrorReceivingResponseEventHandler ( ) . hasListeners ( ) || OperationContext . getGlobalErrorReceivingResponseEventHandler ( ) . hasListeners ( ) ) { ErrorReceivingResponseEvent event = new ErrorReceivingResponseEvent ( opContext , request , result ) ; opContext . getErrorReceivingResponseEventHandler ( ) . fireEvent ( event ) ; OperationContext . getGlobalErrorReceivingResponseEventHandler ( ) . fireEvent ( event ) ; }


signature:
public class ExecutionEngine { /** * Fires events representing that a response received from the service is fully processed . */
private static void fireRequestCompletedEvent ( OperationContext opContext , HttpURLConnection request , RequestResult result ) { } }

implementation: if ( opContext . getRequestCompletedEventHandler ( ) . hasListeners ( ) || OperationContext . getGlobalRequestCompletedEventHandler ( ) . hasListeners ( ) ) { RequestCompletedEvent event = new RequestCompletedEvent ( opContext , request , result ) ; opContext . getRequestCompletedEventHandler ( ) . fireEvent ( event ) ; OperationContext . getGlobalRequestCompletedEventHandler ( ) . fireEvent ( event ) ; }


signature:
public class ExecutionEngine { /** * Fires events representing that a request will be retried . */
private static void fireRetryingEvent ( OperationContext opContext , HttpURLConnection request , RequestResult result , RetryContext retryContext ) { } }

implementation: if ( opContext . getRetryingEventHandler ( ) . hasListeners ( ) || OperationContext . getGlobalRetryingEventHandler ( ) . hasListeners ( ) ) { RetryingEvent event = new RetryingEvent ( opContext , request , result , retryContext ) ; opContext . getRetryingEventHandler ( ) . fireEvent ( event ) ; OperationContext . getGlobalRetryingEventHandler ( ) . fireEvent ( event ) ; }


signature:
public class ServiceStatsHandler { /** * Constructs a { @ link ServiceStats } object from an XML document received from the service .
 * @ param inStream
 * The XMLStreamReader object .
 * @ return
 * A { @ link ServiceStats } object containing the properties in the XML document .
 * @ throws SAXException
 * @ throws ParserConfigurationException
 * @ throws IOException */
public static ServiceStats readServiceStatsFromStream ( final InputStream inStream ) throws ParserConfigurationException , SAXException , IOException { } }

implementation: SAXParser saxParser = Utility . getSAXParser ( ) ; ServiceStatsHandler handler = new ServiceStatsHandler ( ) ; saxParser . parse ( inStream , handler ) ; return handler . stats ;


signature:
public class Utility { /** * Asserts a continuation token is of the specified type .
 * @ param continuationToken
 * A { @ link ResultContinuation } object that represents the continuation token whose type is being
 * examined .
 * @ param continuationType
 * A { @ link ResultContinuationType } value that represents the continuation token type being asserted with
 * the specified continuation token . */
public static void assertContinuationType ( final ResultContinuation continuationToken , final ResultContinuationType continuationType ) { } }

implementation: if ( continuationToken != null ) { if ( ! ( continuationToken . getContinuationType ( ) == ResultContinuationType . NONE || continuationToken . getContinuationType ( ) == continuationType ) ) { final String errorMessage = String . format ( Utility . LOCALE_US , SR . UNEXPECTED_CONTINUATION_TYPE , continuationToken . getContinuationType ( ) , continuationType ) ; throw new IllegalArgumentException ( errorMessage ) ; } }


signature:
public class Utility { /** * Asserts that a value is not < code > null < / code > .
 * @ param param
 * A < code > String < / code > that represents the name of the parameter , which becomes the exception message
 * text if the < code > value < / code > parameter is < code > null < / code > .
 * @ param value
 * An < code > Object < / code > object that represents the value of the specified parameter . This is the value
 * being asserted as not < code > null < / code > . */
public static void assertNotNull ( final String param , final Object value ) { } }

implementation: if ( value == null ) { throw new IllegalArgumentException ( String . format ( Utility . LOCALE_US , SR . ARGUMENT_NULL_OR_EMPTY , param ) ) ; }


signature:
public class Utility { /** * Asserts that the specified string is not < code > null < / code > or empty .
 * @ param param
 * A < code > String < / code > that represents the name of the parameter , which becomes the exception message
 * text if the < code > value < / code > parameter is < code > null < / code > or an empty string .
 * @ param value
 * A < code > String < / code > that represents the value of the specified parameter . This is the value being
 * asserted as not < code > null < / code > and not an empty string . */
public static void assertNotNullOrEmpty ( final String param , final String value ) { } }

implementation: assertNotNull ( param , value ) ; if ( Utility . isNullOrEmpty ( value ) ) { throw new IllegalArgumentException ( String . format ( Utility . LOCALE_US , SR . ARGUMENT_NULL_OR_EMPTY , param ) ) ; }


signature:
public class Utility { /** * Asserts that the specified integer is in the valid range .
 * @ param param
 * A < code > String < / code > that represents the name of the parameter , which becomes the exception message
 * text if the < code > value < / code > parameter is out of bounds .
 * @ param value
 * The value of the specified parameter .
 * @ param min
 * The minimum value for the specified parameter .
 * @ param max
 * The maximum value for the specified parameter . */
public static void assertInBounds ( final String param , final long value , final long min , final long max ) { } }

implementation: if ( value < min || value > max ) { throw new IllegalArgumentException ( String . format ( SR . PARAMETER_NOT_IN_RANGE , param , min , max ) ) ; }


signature:
public class Utility { /** * Asserts that the specified value is greater than or equal to the min value .
 * @ param param
 * A < code > String < / code > that represents the name of the parameter , which becomes the exception message
 * text if the < code > value < / code > parameter is out of bounds .
 * @ param value
 * The value of the specified parameter .
 * @ param min
 * The minimum value for the specified parameter . */
public static void assertGreaterThanOrEqual ( final String param , final long value , final long min ) { } }

implementation: if ( value < min ) { throw new IllegalArgumentException ( String . format ( SR . PARAMETER_SHOULD_BE_GREATER_OR_EQUAL , param , min ) ) ; }


signature:
public class Utility { /** * Returns a value representing whether the maximum execution time would be surpassed .
 * @ param operationExpiryTimeInMs
 * the time the request expires
 * @ param additionalInterval
 * any additional time required from now
 * @ return < code > true < / code > if the maximum execution time would be surpassed ; otherwise , < code > false < / code > . */
public static boolean validateMaxExecutionTimeout ( Long operationExpiryTimeInMs , long additionalInterval ) { } }

implementation: if ( operationExpiryTimeInMs != null ) { long currentTime = new Date ( ) . getTime ( ) ; return operationExpiryTimeInMs < currentTime + additionalInterval ; } return false ;


signature:
public class Utility { /** * Returns a value representing the remaining time before the operation expires .
 * @ param operationExpiryTimeInMs
 * the time the request expires
 * @ param timeoutIntervalInMs
 * the server side timeout interval
 * @ return the remaining time before the operation expires
 * @ throws StorageException
 * wraps a TimeoutException if there is no more time remaining */
public static int getRemainingTimeout ( Long operationExpiryTimeInMs , Integer timeoutIntervalInMs ) throws StorageException { } }

implementation: if ( operationExpiryTimeInMs != null ) { long remainingTime = operationExpiryTimeInMs - new Date ( ) . getTime ( ) ; if ( remainingTime > Integer . MAX_VALUE ) { return Integer . MAX_VALUE ; } else if ( remainingTime > 0 ) { return ( int ) remainingTime ; } else { TimeoutException timeoutException = new TimeoutException ( SR . MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION ) ; StorageException translatedException = new StorageException ( StorageErrorCodeStrings . OPERATION_TIMED_OUT , SR . MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION , Constants . HeaderConstants . HTTP_UNUSED_306 , null , timeoutException ) ; throw translatedException ; } } else if ( timeoutIntervalInMs != null ) { return timeoutIntervalInMs + Constants . DEFAULT_READ_TIMEOUT ; } else { return Constants . DEFAULT_READ_TIMEOUT ; }


signature:
public class Utility { /** * Returns a value that indicates whether a specified URI is a path - style URI .
 * @ param baseURI
 * A < code > java . net . URI < / code > value that represents the URI being checked .
 * @ return < code > true < / code > if the specified URI is path - style ; otherwise , < code > false < / code > . */
public static boolean determinePathStyleFromUri ( final URI baseURI ) { } }

implementation:
String path = baseURI . getPath ( ) ; if ( path != null && path . startsWith ( "/" ) ) { path = path . substring ( 1 ) ; } // if the path is null or empty , this is not path - style
if ( Utility . isNullOrEmpty ( path ) ) { return false ; } // if this contains a port or has a host which is not DNS , this is path - style
return pathStylePorts . contains ( baseURI . getPort ( ) ) || ! isHostDnsName ( baseURI ) ;


signature:
public class Utility { /** * Returns a boolean indicating whether the host of the specified URI is DNS .
 * @ param uri
 * The URI whose host to evaluate .
 * @ return < code > true < / code > if the host is DNS ; otherwise , < code > false < / code > . */
private static boolean isHostDnsName ( URI uri ) { } }

implementation: String host = uri . getHost ( ) ; for ( int i = 0 ; i < host . length ( ) ; i ++ ) { char hostChar = host . charAt ( i ) ; if ( ! Character . isDigit ( hostChar ) && ! ( hostChar == '.' ) ) { return true ; } } return false ;


signature:
public class Utility { /** * Reads character data for the Etag element from an XML stream reader .
 * @ param xmlr
 * An < code > XMLStreamReader < / code > object that represents the source XML stream reader .
 * @ return A < code > String < / code > that represents the character data for the Etag element . */
public static String formatETag ( final String etag ) { } }

implementation: if ( etag . startsWith ( "\"" ) && etag . endsWith ( "\"" ) ) { return etag ; } else { return String . format ( "\"%s\"" , etag ) ; }


signature:
public class Utility { /** * Returns an unexpected storage exception .
 * @ param cause
 * An < code > Exception < / code > object that represents the initial exception that caused the unexpected
 * error .
 * @ return A { @ link StorageException } object that represents the unexpected storage exception being thrown . */
public static StorageException generateNewUnexpectedStorageException ( final Exception cause ) { } }

implementation:
final StorageException exceptionRef = new StorageException ( StorageErrorCode . NONE . toString ( ) , "Unexpected internal storage client error." , 306 , // unused
null , null ) ; exceptionRef . initCause ( cause ) ; return exceptionRef ;


signature:
public class Utility { /** * Returns a byte array that represents the data of a < code > long < / code > value .
 * @ param value
 * The value from which the byte array will be returned .
 * @ return A byte array that represents the data of the specified < code > long < / code > value . */
public static byte [ ] getBytesFromLong ( final long value ) { } }

implementation: final byte [ ] tempArray = new byte [ 8 ] ; for ( int m = 0 ; m < 8 ; m ++ ) { tempArray [ 7 - m ] = ( byte ) ( ( value >> ( 8 * m ) ) & 0xFF ) ; } return tempArray ;


signature:
public class Utility { /** * Returns the GTM date / time String for the specified value using the RFC1123 pattern .
 * @ param date
 * A < code > Date < / code > object that represents the date to convert to GMT date / time in the RFC1123
 * pattern .
 * @ return A < code > String < / code > that represents the GMT date / time for the specified value using the RFC1123
 * pattern . */
public static String getGMTTime ( final Date date ) { } }

implementation: final DateFormat formatter = new SimpleDateFormat ( RFC1123_GMT_PATTERN , LOCALE_US ) ; formatter . setTimeZone ( GMT_ZONE ) ; return formatter . format ( date ) ;


signature:
public class Utility { /** * Returns the UTC date / time String for the specified value using Java ' s version of the ISO8601 pattern ,
 * which is limited to millisecond precision .
 * @ param date
 * A < code > Date < / code > object that represents the date to convert to UTC date / time in Java ' s version
 * of the ISO8601 pattern .
 * @ return A < code > String < / code > that represents the UTC date / time for the specified value using Java ' s version
 * of the ISO8601 pattern . */
public static String getJavaISO8601Time ( Date date ) { } }

implementation: final DateFormat formatter = new SimpleDateFormat ( JAVA_ISO8601_PATTERN , LOCALE_US ) ; formatter . setTimeZone ( UTC_ZONE ) ; return formatter . format ( date ) ;


signature:
public class Utility { /** * Returns the standard header value from the specified connection request , or an empty string if no header value
 * has been specified for the request .
 * @ param conn
 * An < code > HttpURLConnection < / code > object that represents the request .
 * @ param headerName
 * A < code > String < / code > that represents the name of the header being requested .
 * @ return A < code > String < / code > that represents the header value , or < code > null < / code > if there is no corresponding
 * header value for < code > headerName < / code > . */
public static String getStandardHeaderValue ( final HttpURLConnection conn , final String headerName ) { } }

implementation:
final String headerValue = conn . getRequestProperty ( headerName ) ; // Coalesce null value
return headerValue == null ? Constants . EMPTY_STRING : headerValue ;


signature:
public class Utility { /** * Returns the UTC date / time for the specified value using the ISO8601 pattern .
 * @ param value
 * A < code > Date < / code > object that represents the date to convert to UTC date / time in the ISO8601
 * pattern . If this value is < code > null < / code > , this method returns an empty string .
 * @ return A < code > String < / code > that represents the UTC date / time for the specified value using the ISO8601
 * pattern , or an empty string if < code > value < / code > is < code > null < / code > . */
public static String getUTCTimeOrEmpty ( final Date value ) { } }

implementation: if ( value == null ) { return Constants . EMPTY_STRING ; } final DateFormat iso8601Format = new SimpleDateFormat ( ISO8601_PATTERN , LOCALE_US ) ; iso8601Format . setTimeZone ( UTC_ZONE ) ; return iso8601Format . format ( value ) ;


signature:
public class Utility { /** * Returns a < code > XmlSerializer < / code > which outputs to the specified < code > StringWriter < / code >
 * @ param outWriter
 * the < code > StringWriter < / code > to output to
 * @ return A < code > XmlSerializer < / code > instance
 * @ throws IOException
 * if there is an error setting the output .
 * @ throws IllegalStateException
 * if there is an error setting the output .
 * @ throws IllegalArgumentException
 * if there is an error setting the output . */
public static XmlSerializer getXmlSerializer ( StringWriter outWriter ) throws IllegalArgumentException , IllegalStateException , IOException { } }

implementation: XmlSerializer serializer = Xml . newSerializer ( ) ; serializer . setOutput ( outWriter ) ; return serializer ;


signature:
public class Utility { /** * Creates an instance of the < code > IOException < / code > class using the specified exception .
 * @ param ex
 * An < code > Exception < / code > object that represents the exception used to create the IO exception .
 * @ return A < code > java . io . IOException < / code > object that represents the created IO exception . */
public static IOException initIOException ( final Exception ex ) { } }

implementation: String message = null ; if ( ex != null && ex . getMessage ( ) != null ) { message = ex . getMessage ( ) + " Please see the cause for further information." ; } else { message = "Please see the cause for further information." ; } final IOException retEx = new IOException ( message , ex ) ; return retEx ;


signature:
public class Utility { /** * Parses a connection string and returns its values as a hash map of key / value pairs .
 * @ param parseString
 * A < code > String < / code > that represents the connection string to parse .
 * @ return A < code > java . util . HashMap < / code > object that represents the hash map of the key / value pairs parsed from
 * the connection string . */
public static HashMap < String , String > parseAccountString ( final String parseString ) { } }

implementation:
// 1 . split name value pairs by splitting on the ' ; ' character
final String [ ] valuePairs = parseString . split ( ";" ) ; final HashMap < String , String > retVals = new HashMap < String , String > ( ) ; // 2 . for each field value pair parse into appropriate map entries
for ( int m = 0 ; m < valuePairs . length ; m ++ ) { if ( valuePairs [ m ] . length ( ) == 0 ) { continue ; } final int equalDex = valuePairs [ m ] . indexOf ( "=" ) ; if ( equalDex < 1 ) { throw new IllegalArgumentException ( SR . INVALID_CONNECTION_STRING ) ; } final String key = valuePairs [ m ] . substring ( 0 , equalDex ) ; final String value = valuePairs [ m ] . substring ( equalDex + 1 ) ; // 2.1 add to map
retVals . put ( key , value ) ; } return retVals ;


signature:
public class Utility { /** * Returns a GMT date in the specified format
 * @ param value
 * the string to parse
 * @ return the GMT date , as a < code > Date < / code >
 * @ throws ParseException
 * If the specified string is invalid */
public static Date parseDateFromString ( final String value , final String pattern , final TimeZone timeZone ) throws ParseException { } }

implementation: final DateFormat rfc1123Format = new SimpleDateFormat ( pattern , Utility . LOCALE_US ) ; rfc1123Format . setTimeZone ( timeZone ) ; return rfc1123Format . parse ( value ) ;


signature:
public class Utility { /** * Returns a GMT date for the specified string in the RFC1123 pattern .
 * @ param value
 * A < code > String < / code > that represents the string to parse .
 * @ return A < code > Date < / code > object that represents the GMT date in the RFC1123 pattern .
 * @ throws ParseException
 * If the specified string is invalid . */
public static Date parseRFC1123DateFromStringInGMT ( final String value ) throws ParseException { } }

implementation: final DateFormat format = new SimpleDateFormat ( RFC1123_GMT_PATTERN , Utility . LOCALE_US ) ; format . setTimeZone ( GMT_ZONE ) ; return format . parse ( value ) ;


signature:
public class Utility { /** * Performs safe decoding of the specified string , taking care to preserve each < code > + < / code > character , rather
 * than replacing it with a space character .
 * @ param stringToDecode
 * A < code > String < / code > that represents the string to decode .
 * @ return A < code > String < / code > that represents the decoded string .
 * @ throws StorageException
 * If a storage service error occurred . */
public static String safeDecode ( final String stringToDecode ) throws StorageException { } }

implementation: if ( stringToDecode == null ) { return null ; } if ( stringToDecode . length ( ) == 0 ) { return Constants . EMPTY_STRING ; } try { if ( stringToDecode . contains ( "+" ) ) { final StringBuilder outBuilder = new StringBuilder ( ) ; int startDex = 0 ; for ( int m = 0 ; m < stringToDecode . length ( ) ; m ++ ) { if ( stringToDecode . charAt ( m ) == '+' ) { if ( m > startDex ) { outBuilder . append ( URLDecoder . decode ( stringToDecode . substring ( startDex , m ) , Constants . UTF8_CHARSET ) ) ; } outBuilder . append ( "+" ) ; startDex = m + 1 ; } } if ( startDex != stringToDecode . length ( ) ) { outBuilder . append ( URLDecoder . decode ( stringToDecode . substring ( startDex , stringToDecode . length ( ) ) , Constants . UTF8_CHARSET ) ) ; } return outBuilder . toString ( ) ; } else { return URLDecoder . decode ( stringToDecode , Constants . UTF8_CHARSET ) ; } } catch ( final UnsupportedEncodingException e ) { throw Utility . generateNewUnexpectedStorageException ( e ) ; }


signature:
public class Utility { /** * Performs safe encoding of the specified string , taking care to insert < code > % 20 < / code > for each space character ,
 * instead of inserting the < code > + < / code > character .
 * @ param stringToEncode
 * A < code > String < / code > that represents the string to encode .
 * @ return A < code > String < / code > that represents the encoded string .
 * @ throws StorageException
 * If a storage service error occurred . */
public static String safeEncode ( final String stringToEncode ) throws StorageException { } }

implementation: if ( stringToEncode == null ) { return null ; } if ( stringToEncode . length ( ) == 0 ) { return Constants . EMPTY_STRING ; } try { final String tString = URLEncoder . encode ( stringToEncode , Constants . UTF8_CHARSET ) ; if ( stringToEncode . contains ( " " ) ) { final StringBuilder outBuilder = new StringBuilder ( ) ; int startDex = 0 ; for ( int m = 0 ; m < stringToEncode . length ( ) ; m ++ ) { if ( stringToEncode . charAt ( m ) == ' ' ) { if ( m > startDex ) { outBuilder . append ( URLEncoder . encode ( stringToEncode . substring ( startDex , m ) , Constants . UTF8_CHARSET ) ) ; } outBuilder . append ( "%20" ) ; startDex = m + 1 ; } } if ( startDex != stringToEncode . length ( ) ) { outBuilder . append ( URLEncoder . encode ( stringToEncode . substring ( startDex , stringToEncode . length ( ) ) , Constants . UTF8_CHARSET ) ) ; } return outBuilder . toString ( ) ; } else { return tString ; } } catch ( final UnsupportedEncodingException e ) { throw Utility . generateNewUnexpectedStorageException ( e ) ; }


signature:
public class Utility { /** * Determines the relative difference between the two specified URIs .
 * @ param baseURI
 * A < code > java . net . URI < / code > object that represents the base URI for which < code > toUri < / code > will be
 * made relative .
 * @ param toUri
 * A < code > java . net . URI < / code > object that represents the URI to make relative to < code > baseURI < / code > .
 * @ return A < code > String < / code > that either represents the relative URI of < code > toUri < / code > to
 * < code > baseURI < / code > , or the URI of < code > toUri < / code > itself , depending on whether the hostname and
 * scheme are identical for < code > toUri < / code > and < code > baseURI < / code > . If the hostname and scheme of
 * < code > baseURI < / code > and < code > toUri < / code > are identical , this method returns an unencoded relative URI
 * such that if appended to < code > baseURI < / code > , it will yield < code > toUri < / code > . If the hostname or
 * scheme of < code > baseURI < / code > and < code > toUri < / code > are not identical , this method returns an unencoded
 * full URI specified by < code > toUri < / code > .
 * @ throws URISyntaxException
 * If < code > baseURI < / code > or < code > toUri < / code > is invalid . */
public static String safeRelativize ( final URI baseURI , final URI toUri ) throws URISyntaxException { } }

implementation:
// For compatibility followed
// http : / / msdn . microsoft . com / en - us / library / system . uri . makerelativeuri . aspx
// if host and scheme are not identical return from uri
if ( ! baseURI . getHost ( ) . equals ( toUri . getHost ( ) ) || ! baseURI . getScheme ( ) . equals ( toUri . getScheme ( ) ) ) { return toUri . toString ( ) ; } final String basePath = baseURI . getPath ( ) ; String toPath = toUri . getPath ( ) ; int truncatePtr = 1 ; // Seek to first Difference
// int maxLength = Math . min ( basePath . length ( ) , toPath . length ( ) ) ;
int m = 0 ; int ellipsesCount = 0 ; for ( ; m < basePath . length ( ) ; m ++ ) { if ( m >= toPath . length ( ) ) { if ( basePath . charAt ( m ) == '/' ) { ellipsesCount ++ ; } } else { if ( basePath . charAt ( m ) != toPath . charAt ( m ) ) { break ; } else if ( basePath . charAt ( m ) == '/' ) { truncatePtr = m + 1 ; } } } // . . / containername and . . / containername / { path } should increment the truncatePtr
// otherwise toPath will incorrectly begin with / containername
if ( m < toPath . length ( ) && toPath . charAt ( m ) == '/' ) { // this is to handle the empty directory case with the ' / ' delimiter
// for example , . . / containername / and . . / containername / / should not increment the truncatePtr
if ( ! ( toPath . charAt ( m - 1 ) == '/' && basePath . charAt ( m - 1 ) == '/' ) ) { truncatePtr = m + 1 ; } } if ( m == toPath . length ( ) ) { // No path difference , return query + fragment
return new URI ( null , null , null , toUri . getQuery ( ) , toUri . getFragment ( ) ) . toString ( ) ; } else { toPath = toPath . substring ( truncatePtr ) ; final StringBuilder sb = new StringBuilder ( ) ; while ( ellipsesCount > 0 ) { sb . append ( "../" ) ; ellipsesCount -- ; } if ( ! Utility . isNullOrEmpty ( toPath ) ) { sb . append ( toPath ) ; } if ( ! Utility . isNullOrEmpty ( toUri . getQuery ( ) ) ) { sb . append ( "?" ) ; sb . append ( toUri . getQuery ( ) ) ; } if ( ! Utility . isNullOrEmpty ( toUri . getFragment ( ) ) ) { sb . append ( "#" ) ; sb . append ( toUri . getRawFragment ( ) ) ; } return sb . toString ( ) ; }


signature:
public class Utility { /** * Serializes the parsed StorageException . If an exception is encountered , returns empty string .
 * @ param ex
 * The StorageException to serialize .
 * @ param opContext
 * The operation context which provides the logger . */
public static void logHttpError ( StorageException ex , OperationContext opContext ) { } }

implementation:
if ( Logger . shouldLog ( opContext , Log . DEBUG ) ) { try { StringBuilder bld = new StringBuilder ( ) ; bld . append ( "Error response received. " ) ; bld . append ( "HttpStatusCode= " ) ; bld . append ( ex . getHttpStatusCode ( ) ) ; bld . append ( ", HttpStatusMessage= " ) ; bld . append ( ex . getMessage ( ) ) ; bld . append ( ", ErrorCode= " ) ; bld . append ( ex . getErrorCode ( ) ) ; StorageExtendedErrorInformation extendedError = ex . getExtendedErrorInformation ( ) ; if ( extendedError != null ) { bld . append ( ", ExtendedErrorInformation= {ErrorMessage= " ) ; bld . append ( extendedError . getErrorMessage ( ) ) ; HashMap < String , String [ ] > details = extendedError . getAdditionalDetails ( ) ; if ( details != null ) { bld . append ( ", AdditionalDetails= { " ) ; for ( Entry < String , String [ ] > detail : details . entrySet ( ) ) { bld . append ( detail . getKey ( ) ) ; bld . append ( "= " ) ; for ( String value : detail . getValue ( ) ) { bld . append ( value ) ; } bld . append ( "," ) ; } bld . setCharAt ( bld . length ( ) - 1 , '}' ) ; } bld . append ( "}" ) ; } Logger . debug ( opContext , bld . toString ( ) ) ; } catch ( Exception e ) { // Do nothing
} }


signature:
public class Utility { /** * Logs the HttpURLConnection response . If an exception is encountered , logs nothing .
 * @ param conn
 * The HttpURLConnection to serialize .
 * @ param opContext
 * The operation context which provides the logger . */
public static void logHttpResponse ( HttpURLConnection conn , OperationContext opContext ) throws IOException { } }

implementation:
if ( Logger . shouldLog ( opContext , Log . VERBOSE ) ) { try { StringBuilder bld = new StringBuilder ( ) ; // This map ' s null key will contain the response code and message
for ( Map . Entry < String , List < String > > header : conn . getHeaderFields ( ) . entrySet ( ) ) { if ( header . getKey ( ) != null ) { bld . append ( header . getKey ( ) ) ; bld . append ( ": " ) ; } for ( int i = 0 ; i < header . getValue ( ) . size ( ) ; i ++ ) { bld . append ( header . getValue ( ) . get ( i ) ) ; if ( i < header . getValue ( ) . size ( ) - 1 ) { bld . append ( "," ) ; } } bld . append ( '\n' ) ; } Logger . verbose ( opContext , bld . toString ( ) ) ; } catch ( Exception e ) { // Do nothing
} }


signature:
public class Utility { /** * Trims the specified character from the end of a string .
 * @ param value
 * A < code > String < / code > that represents the string to trim .
 * @ param trimChar
 * The character to trim from the end of the string .
 * @ return The string with the specified character trimmed from the end . */
protected static String trimEnd ( final String value , final char trimChar ) { } }

implementation: int stopDex = value . length ( ) - 1 ; while ( stopDex > 0 && value . charAt ( stopDex ) == trimChar ) { stopDex -- ; } return stopDex == value . length ( ) - 1 ? value : value . substring ( stopDex ) ;


signature:
public class Utility { /** * Trims whitespace from the beginning of a string .
 * @ param value
 * A < code > String < / code > that represents the string to trim .
 * @ return The string with whitespace trimmed from the beginning . */
public static String trimStart ( final String value ) { } }

implementation: int spaceDex = 0 ; while ( spaceDex < value . length ( ) && value . charAt ( spaceDex ) == ' ' ) { spaceDex ++ ; } return value . substring ( spaceDex ) ;


signature:
public class Utility { /** * Reads data from an input stream and writes it to an output stream , calculates the length of the data written , and
 * optionally calculates the MD5 hash for the data .
 * @ param sourceStream
 * An < code > InputStream < / code > object that represents the input stream to use as the source .
 * @ param outStream
 * An < code > OutputStream < / code > object that represents the output stream to use as the destination .
 * @ param writeLength
 * The number of bytes to read from the stream .
 * @ param rewindSourceStream
 * < code > true < / code > if the input stream should be rewound < strong > before < / strong > it is read ; otherwise ,
 * < code > false < / code >
 * @ param calculateMD5
 * < code > true < / code > if an MD5 hash will be calculated ; otherwise , < code > false < / code > .
 * @ param opContext
 * An { @ link OperationContext } object that represents the context for the current operation . This object
 * is used to track requests to the storage service , and to provide additional runtime information about
 * the operation .
 * @ param options
 * A { @ link RequestOptions } object that specifies any additional options for the request . Namely , the
 * maximum execution time .
 * @ return A { @ link StreamMd5AndLength } object that contains the output stream length , and optionally the MD5 hash .
 * @ throws IOException
 * If an I / O error occurs .
 * @ throws StorageException
 * If a storage service error occurred . */
public static StreamMd5AndLength writeToOutputStream ( final InputStream sourceStream , final OutputStream outStream , long writeLength , final boolean rewindSourceStream , final boolean calculateMD5 , OperationContext opContext , final RequestOptions options ) throws IOException , StorageException { } }

implementation: return writeToOutputStream ( sourceStream , outStream , writeLength , rewindSourceStream , calculateMD5 , opContext , options , true ) ;


signature:
public class Utility { /** * Reads data from an input stream and writes it to an output stream , calculates the length of the data written , and
 * optionally calculates the MD5 hash for the data .
 * @ param sourceStream
 * An < code > InputStream < / code > object that represents the input stream to use as the source .
 * @ param outStream
 * An < code > OutputStream < / code > object that represents the output stream to use as the destination .
 * @ param writeLength
 * The number of bytes to read from the stream .
 * @ param rewindSourceStream
 * < code > true < / code > if the input stream should be rewound < strong > before < / strong > it is read ; otherwise ,
 * < code > false < / code >
 * @ param calculateMD5
 * < code > true < / code > if an MD5 hash will be calculated ; otherwise , < code > false < / code > .
 * @ param opContext
 * An { @ link OperationContext } object that represents the context for the current operation . This object
 * is used to track requests to the storage service , and to provide additional runtime information about
 * the operation .
 * @ param options
 * A { @ link RequestOptions } object that specifies any additional options for the request . Namely , the
 * maximum execution time .
 * @ return A { @ link StreamMd5AndLength } object that contains the output stream length , and optionally the MD5 hash .
 * @ throws IOException
 * If an I / O error occurs .
 * @ throws StorageException
 * If a storage service error occurred . */
public static StreamMd5AndLength writeToOutputStream ( final InputStream sourceStream , final OutputStream outStream , long writeLength , final boolean rewindSourceStream , final boolean calculateMD5 , OperationContext opContext , final RequestOptions options , final Boolean shouldFlush ) throws IOException , StorageException { } }

implementation:
return writeToOutputStream ( sourceStream , outStream , writeLength , rewindSourceStream , calculateMD5 , opContext , options , null /* StorageRequest */
, null /* descriptor */
) ;


signature:
public class Utility { /** * Reads data from an input stream and writes it to an output stream , calculates the length of the data written , and
 * optionally calculates the MD5 hash for the data .
 * @ param sourceStream
 * An < code > InputStream < / code > object that represents the input stream to use as the source .
 * @ param outStream
 * An < code > OutputStream < / code > object that represents the output stream to use as the destination .
 * @ param writeLength
 * The number of bytes to read from the stream .
 * @ param rewindSourceStream
 * < code > true < / code > if the input stream should be rewound < strong > before < / strong > it is read ; otherwise ,
 * < code > false < / code >
 * @ param calculateMD5
 * < code > true < / code > if an MD5 hash will be calculated ; otherwise , < code > false < / code > .
 * @ param opContext
 * An { @ link OperationContext } object that represents the context for the current operation . This object
 * is used to track requests to the storage service , and to provide additional runtime information about
 * the operation .
 * @ param options
 * A { @ link RequestOptions } object that specifies any additional options for the request . Namely , the
 * maximum execution time .
 * @ param request
 * Used by download resume to set currentRequestByteCount on the request . Otherwise , null is always used .
 * @ param descriptor
 * A { @ Link StreamMd5AndLength } object to append to in the case of recovery action or null if this is not called
 * from a recovery . This value needs to be passed for recovery in case part of the body has already been read ,
 * the recovery will attempt to download the remaining bytes but will do MD5 validation on the originally
 * requested range size .
 * @ return A { @ link StreamMd5AndLength } object that contains the output stream length , and optionally the MD5 hash .
 * @ throws IOException
 * If an I / O error occurs .
 * @ throws StorageException
 * If a storage service error occurred . */
public static StreamMd5AndLength writeToOutputStream ( final InputStream sourceStream , final OutputStream outStream , long writeLength , final boolean rewindSourceStream , final boolean calculateMD5 , OperationContext opContext , final RequestOptions options , StorageRequest < ? , ? , Integer > request , StreamMd5AndLength descriptor ) throws IOException , StorageException { } }

implementation:
if ( rewindSourceStream && sourceStream . markSupported ( ) ) { sourceStream . reset ( ) ; sourceStream . mark ( Constants . MAX_MARK_LENGTH ) ; } if ( descriptor == null ) { descriptor = new StreamMd5AndLength ( ) ; if ( calculateMD5 ) { try { descriptor . setDigest ( MessageDigest . getInstance ( "MD5" ) ) ; } catch ( final NoSuchAlgorithmException e ) { // This wont happen , throw fatal .
throw Utility . generateNewUnexpectedStorageException ( e ) ; } } } else { descriptor . setMd5 ( null ) ; } if ( writeLength < 0 ) { writeLength = Long . MAX_VALUE ; } final byte [ ] retrievedBuff = new byte [ Constants . BUFFER_COPY_LENGTH ] ; int nextCopy = ( int ) Math . min ( retrievedBuff . length , writeLength ) ; int count = sourceStream . read ( retrievedBuff , 0 , nextCopy ) ; while ( nextCopy > 0 && count != - 1 ) { // if maximum execution time would be exceeded
if ( Utility . validateMaxExecutionTimeout ( options . getOperationExpiryTimeInMs ( ) ) ) { // throw an exception
TimeoutException timeoutException = new TimeoutException ( SR . MAXIMUM_EXECUTION_TIMEOUT_EXCEPTION ) ; throw Utility . initIOException ( timeoutException ) ; } if ( outStream != null ) { outStream . write ( retrievedBuff , 0 , count ) ; } if ( calculateMD5 ) { descriptor . getDigest ( ) . update ( retrievedBuff , 0 , count ) ; } descriptor . setLength ( descriptor . getLength ( ) + count ) ; descriptor . setCurrentOperationByteCount ( descriptor . getCurrentOperationByteCount ( ) + count ) ; if ( request != null ) { request . setCurrentRequestByteCount ( request . getCurrentRequestByteCount ( ) + count ) ; request . setCurrentDescriptor ( descriptor ) ; } nextCopy = ( int ) Math . min ( retrievedBuff . length , writeLength - descriptor . getLength ( ) ) ; count = sourceStream . read ( retrievedBuff , 0 , nextCopy ) ; } if ( outStream != null ) { outStream . flush ( ) ; } return descriptor ;


signature:
public class Utility { /** * Given a String representing a date in a form of the ISO8601 pattern , generates a Date representing it
 * with up to millisecond precision .
 * @ param dateString
 * the < code > String < / code > to be interpreted as a < code > Date < / code >
 * @ return the corresponding < code > Date < / code > object */
public static Date parseDate ( String dateString ) { } }

implementation:
String pattern = MAX_PRECISION_PATTERN ; switch ( dateString . length ( ) ) { case 28 : // " yyyy - MM - dd ' T ' HH : mm : ss . SSSSS ' Z ' " - > [ 2012-01-04T23:21:59.1234567Z ] length = 28
case 27 : // " yyyy - MM - dd ' T ' HH : mm : ss . SSSSS ' Z ' " - > [ 2012-01-04T23:21:59.123456Z ] length = 27
case 26 : // " yyyy - MM - dd ' T ' HH : mm : ss . SSSSS ' Z ' " - > [ 2012-01-04T23:21:59.12345Z ] length = 26
case 25 : // " yyyy - MM - dd ' T ' HH : mm : ss . SSSS ' Z ' " - > [ 2012-01-04T23:21:59.1234Z ] length = 25
case 24 : // " yyyy - MM - dd ' T ' HH : mm : ss . SSS ' Z ' " - > [ 2012-01-04T23:21:59.123Z ] length = 24
dateString = dateString . substring ( 0 , MAX_PRECISION_DATESTRING_LENGTH ) ; break ; case 23 : // " yyyy - MM - dd ' T ' HH : mm : ss . SS ' Z ' " - > [ 2012-01-04T23:21:59.12Z ] length = 23
// SS is assumed to be milliseconds , so a trailing 0 is necessary
dateString = dateString . replace ( "Z" , "0" ) ; break ; case 22 : // " yyyy - MM - dd ' T ' HH : mm : ss . S ' Z ' " - > [ 2012-01-04T23:21:59.1Z ] length = 22
// S is assumed to be milliseconds , so trailing 0 ' s are necessary
dateString = dateString . replace ( "Z" , "00" ) ; break ; case 20 : // " yyyy - MM - dd ' T ' HH : mm : ss ' Z ' " - > [ 2012-01-04T23:21:59Z ] length = 20
pattern = Utility . ISO8601_PATTERN ; break ; case 17 : // " yyyy - MM - dd ' T ' HH : mm ' Z ' " - > [ 2012-01-04T23:21Z ] length = 17
pattern = Utility . ISO8601_PATTERN_NO_SECONDS ; break ; default : throw new IllegalArgumentException ( String . format ( SR . INVALID_DATE_STRING , dateString ) ) ; } final DateFormat format = new SimpleDateFormat ( pattern , Utility . LOCALE_US ) ; format . setTimeZone ( UTC_ZONE ) ; try { return format . parse ( dateString ) ; } catch ( final ParseException e ) { throw new IllegalArgumentException ( String . format ( SR . INVALID_DATE_STRING , dateString ) , e ) ; }


signature:
public class Utility { /** * Given a String representing a date in a form of the ISO8601 pattern , generates a Date representing it
 * with up to millisecond precision . Use { @ link # parseDate ( String ) } instead unless
 * < code > dateBackwardCompatibility < / code > is needed .
 * See < a href = " http : / / go . microsoft . com / fwlink / ? LinkId = 523753 " > here < / a > for more details .
 * @ param dateString
 * the < code > String < / code > to be interpreted as a < code > Date < / code >
 * @ param dateBackwardCompatibility
 * < code > true < / code > to correct Date values that may have been written
 * using versions of this library prior to 0.4.0 ; otherwise , < code > false < / code >
 * @ return the corresponding < code > Date < / code > object */
public static Date parseDate ( String dateString , boolean dateBackwardCompatibility ) { } }

implementation:
if ( ! dateBackwardCompatibility ) { return parseDate ( dateString ) ; } final int beginMilliIndex = 20 ; // Length of " yyyy - MM - ddTHH : mm : ss . "
final int endTenthMilliIndex = 24 ; // Length of " yyyy - MM - ddTHH : mm : ss . SSSS "
// Check whether the millisecond and tenth of a millisecond digits are all 0.
if ( dateString . length ( ) > endTenthMilliIndex && "0000" . equals ( dateString . substring ( beginMilliIndex , endTenthMilliIndex ) ) ) { // Remove the millisecond and tenth of a millisecond digits .
// Treat the final three digits ( ticks ) as milliseconds .
dateString = dateString . substring ( 0 , beginMilliIndex ) + dateString . substring ( endTenthMilliIndex ) ; } return parseDate ( dateString ) ;


signature:
public class Utility { /** * Determines which location can the listing command target by looking at the
 * continuation token .
 * @ param token
 * Continuation token
 * @ return
 * Location mode */
public static RequestLocationMode getListingLocationMode ( ResultContinuation token ) { } }

implementation: if ( ( token != null ) && token . getTargetLocation ( ) != null ) { switch ( token . getTargetLocation ( ) ) { case PRIMARY : return RequestLocationMode . PRIMARY_ONLY ; case SECONDARY : return RequestLocationMode . SECONDARY_ONLY ; default : throw new IllegalArgumentException ( String . format ( SR . ARGUMENT_OUT_OF_RANGE_ERROR , "token" , token . getTargetLocation ( ) ) ) ; } } return RequestLocationMode . PRIMARY_OR_SECONDARY ;


signature:
public class Utility { /** * Writes an XML element to the < code > XmlSerializer < / code > without a namespace .
 * @ param serializer
 * the < code > XmlSerializer < / code > to write to
 * @ param tag
 * the tag to use for the XML element
 * @ param text
 * the text to write inside the XML tags
 * @ throws IOException
 * if there is an error writing the output .
 * @ throws IllegalStateException
 * if there is an error writing the output .
 * @ throws IllegalArgumentException
 * if there is an error writing the output . */
public static void serializeElement ( XmlSerializer serializer , String tag , String text ) throws IllegalArgumentException , IllegalStateException , IOException { } }

implementation: serializer . startTag ( Constants . EMPTY_STRING , tag ) ; serializer . text ( text ) ; serializer . endTag ( Constants . EMPTY_STRING , tag ) ;


signature:
public class QueueRequestOptions { /** * Populates the default timeout and retry policy from client if they are not set .
 * @ param options
 * The input options to copy from when applying defaults
 * @ param client
 * The { @ link CloudQueueClient } service client to populate the
 * default values from . */
protected static final QueueRequestOptions populateAndApplyDefaults ( QueueRequestOptions options , final CloudQueueClient client ) { } }

implementation:
QueueRequestOptions modifiedOptions = new QueueRequestOptions ( options ) ; RequestOptions . populateRequestOptions ( modifiedOptions , client . getDefaultRequestOptions ( ) , true /* setStartTime */
) ; QueueRequestOptions . applyDefaults ( modifiedOptions ) ; return modifiedOptions ;


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

implementation:
if ( this . permissions == null ) { return Constants . EMPTY_STRING ; } // The service supports a fixed order = > raud
final StringBuilder builder = new StringBuilder ( ) ; if ( this . permissions . contains ( SharedAccessTablePermissions . QUERY ) ) { builder . append ( "r" ) ; } if ( this . permissions . contains ( SharedAccessTablePermissions . ADD ) ) { builder . append ( "a" ) ; } if ( this . permissions . contains ( SharedAccessTablePermissions . UPDATE ) ) { builder . append ( "u" ) ; } if ( this . permissions . contains ( SharedAccessTablePermissions . DELETE ) ) { builder . append ( "d" ) ; } return builder . toString ( ) ;


signature:
public class SharedAccessTablePolicy { /** * 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 that they must be lower case , and the order that they are specified
 * must be in the order of " raud " .
 * < ul >
 * < li > < code > r < / code > : Query access . < / li >
 * < li > < code > a < / code > : Add access . < / li >
 * < li > < code > u < / code > : Update access . < / li >
 * < li > < code > d < / code > : Delete access . < / li >
 * < / ul > */
@ Override public void setPermissionsFromString ( final String value ) { } }

implementation: final char [ ] chars = value . toCharArray ( ) ; final EnumSet < SharedAccessTablePermissions > retSet = EnumSet . noneOf ( SharedAccessTablePermissions . class ) ; for ( final char c : chars ) { switch ( c ) { case 'r' : retSet . add ( SharedAccessTablePermissions . QUERY ) ; break ; case 'a' : retSet . add ( SharedAccessTablePermissions . ADD ) ; break ; case 'u' : retSet . add ( SharedAccessTablePermissions . UPDATE ) ; break ; case 'd' : retSet . add ( SharedAccessTablePermissions . DELETE ) ; break ; default : throw new IllegalArgumentException ( String . format ( SR . ENUM_COULD_NOT_BE_PARSED , "Permissions" , value ) ) ; } } this . permissions = retSet ;


signature:
public class LogRecordStreamReader { /** * Read a String from the stream .
 * @ return
 * the String read .
 * @ throws IOException */
public String readString ( ) throws IOException { } }

implementation:
String temp = this . readField ( false /* isQuotedString */
) ; if ( Utility . isNullOrEmpty ( temp ) ) { return null ; } else { return temp ; }


signature:
public class LogRecordStreamReader { /** * Read a quoted String from the stream .
 * @ return
 * the String read .
 * @ throws IOException */
public String readQuotedString ( ) throws IOException { } }

implementation:
String temp = this . readField ( true /* isQuotedString */
) ; if ( Utility . isNullOrEmpty ( temp ) ) { return null ; } else { return temp ; }


signature:
public class LogRecordStreamReader { /** * Read a Boolean from the stream .
 * @ return
 * the Boolean read .
 * @ throws IOException */
public Boolean readBoolean ( ) throws IOException { } }

implementation:
String temp = this . readField ( false /* isQuotedString */
) ; if ( Utility . isNullOrEmpty ( temp ) ) { return null ; } else { return Boolean . parseBoolean ( temp ) ; }


signature:
public class LogRecordStreamReader { /** * Read a Date from the stream .
 * @ param format
 * the format in which the date is stored , for parsing purposes .
 * @ return
 * the Date read .
 * @ throws IOException
 * @ throws ParseException */
public Date readDate ( DateFormat format ) throws IOException , ParseException { } }

implementation:
String temp = this . readField ( false /* isQuotedString */
) ; if ( Utility . isNullOrEmpty ( temp ) ) { return null ; } else { return format . parse ( temp ) ; }


signature:
public class LogRecordStreamReader { /** * Read a Double from the stream .
 * @ return
 * the Double read .
 * @ throws IOException */
public Double readDouble ( ) throws IOException { } }

implementation:
String temp = this . readField ( false /* isQuotedString */
) ; if ( Utility . isNullOrEmpty ( temp ) ) { return null ; } else { return Double . parseDouble ( temp ) ; }


signature:
public class LogRecordStreamReader { /** * Read a UUID from the stream .
 * @ return
 * the UUID read .
 * @ throws IOException */
public UUID readUuid ( ) throws IOException { } }

implementation:
String temp = this . readField ( false /* isQuotedString */
) ; if ( Utility . isNullOrEmpty ( temp ) ) { return null ; } else { return UUID . fromString ( temp ) ; }


signature:
public class LogRecordStreamReader { /** * Read an Integer from the stream .
 * @ return
 * the Integer read .
 * @ throws IOException */
public Integer readInteger ( ) throws IOException { } }

implementation:
String temp = this . readField ( false /* isQuotedString */
) ; if ( Utility . isNullOrEmpty ( temp ) ) { return null ; } else { return Integer . parseInt ( temp ) ; }


signature:
public class LogRecordStreamReader { /** * Read a Long from the stream .
 * @ return
 * the Long read .
 * @ throws IOException */
public Long readLong ( ) throws IOException { } }

implementation:
String temp = this . readField ( false /* isQuotedString */
) ; if ( Utility . isNullOrEmpty ( temp ) ) { return null ; } else { return Long . parseLong ( temp ) ; }


signature:
public class LogRecordStreamReader { /** * Read a URI from the stream .
 * @ return
 * the URI read .
 * @ throws URISyntaxException
 * @ throws IOException */
public URI readUri ( ) throws URISyntaxException , IOException { } }

implementation:
String temp = this . readField ( true /* isQuotedString */
) ; if ( Utility . isNullOrEmpty ( temp ) ) { return null ; } else { return new URI ( Html . fromHtml ( temp ) . toString ( ) ) ; }


signature:
public class LogRecordStreamReader { /** * Read a delimiter from the stream .
 * @ param delimiter
 * the delimiter to read .
 * @ throws IOException */
private void readDelimiter ( char delimiter ) throws IOException { } }

implementation: if ( this . isEndOfFile ( ) ) { throw new EOFException ( SR . LOG_STREAM_END_ERROR ) ; } else { int read = this . read ( ) ; if ( read == - 1 || ( char ) read != delimiter ) { throw new IllegalStateException ( SR . LOG_STREAM_DELIMITER_ERROR ) ; } }


signature:
public class LogRecordStreamReader { /** * Checks to see if the next character is the delimiter expected .
 * @ param delimiter
 * the delimiter to try to peek .
 * @ return
 * @ throws IOException */
private boolean tryPeekDelimiter ( char delimiter ) throws IOException { } }

implementation: if ( this . isEndOfFile ( ) ) { throw new EOFException ( SR . LOG_STREAM_END_ERROR ) ; } else { if ( ( char ) this . peek ( ) != delimiter ) { return false ; } else { return true ; } }


signature:
public class LogRecordStreamReader { /** * Read a field from the stream .
 * @ param isQuotedString
 * whether the field is encased in quotes and escaped .
 * @ return
 * the field read .
 * @ throws IOException */
private String readField ( boolean isQuotedString ) throws IOException { } }

implementation:
if ( ! this . isFirstFieldInRecord ) { this . readDelimiter ( LogRecordStreamReader . FIELD_DELIMITER ) ; } else { this . isFirstFieldInRecord = false ; } // Read a field , handling field / record delimiters in quotes and not counting them ,
// and also check that there are no record delimiters since they are only expected
// outside of a field .
// Note : We only need to handle strings that are quoted once from the beginning ,
// ( e . g . " mystring " ) . We do not need to handle nested quotes or anything because
// we control the string format .
StringBuilder fieldBuilder = new StringBuilder ( ) ; boolean hasSeenQuoteForQuotedString = false ; boolean isExpectingDelimiterForNextCharacterForQuotedString = false ; while ( true ) { // If EOF when we haven ' t read the delimiter ; unexpected .
if ( this . isEndOfFile ( ) ) { throw new EOFException ( SR . LOG_STREAM_END_ERROR ) ; } // Since we just checked isEndOfFile above , we know this is a char .
char c = ( char ) this . peek ( ) ; // If we hit a delimiter that is not quoted or we hit the delimiter for
// a quoted string or we hit the empty value string and hit a delimiter ,
// then we have finished reading the field .
// Note : The empty value string is the only string that we don ' t require
// quotes for for a quoted string .
if ( ( ! isQuotedString || isExpectingDelimiterForNextCharacterForQuotedString || fieldBuilder . length ( ) == 0 ) && ( c == LogRecordStreamReader . FIELD_DELIMITER || c == LogRecordStreamReader . RECORD_DELIMITER ) ) { // The delimiter character was peeked but not read - - they ' ll be consumed
// on either the next call to readField or to EndCurrentRecord .
break ; } if ( isExpectingDelimiterForNextCharacterForQuotedString ) { // We finished reading a quoted string but found no delimiter following it .
throw new IllegalStateException ( SR . LOG_STREAM_QUOTE_ERROR ) ; } // The character was not a delimiter , so consume and add to builder .
this . read ( ) ; fieldBuilder . append ( c ) ; // We need to handle quotes specially since quoted delimiters
// do not count since they are considered to be part of the
// quoted string and not actually a delimiter .
// Note : We use a specific quote character since we control the format
// and we only allow non - encoded quote characters at the beginning / end
// of the string .
if ( c == LogRecordStreamReader . QUOTE_CHAR ) { if ( ! isQuotedString ) { // Non - encoded quote character only allowed for quoted strings .
throw new IllegalStateException ( SR . LOG_STREAM_QUOTE_ERROR ) ; } else if ( fieldBuilder . length ( ) == 1 ) { // Opening quote for a quoted string .
hasSeenQuoteForQuotedString = true ; } else if ( hasSeenQuoteForQuotedString ) { // Closing quote for a quoted string .
isExpectingDelimiterForNextCharacterForQuotedString = true ; } else { // Unexpected non - encoded quote .
throw new IllegalStateException ( SR . LOG_STREAM_QUOTE_ERROR ) ; } } } String field ; // Note : For quoted strings we remove the quotes .
// We do not do this for the empty value string since it represents empty
// and we don ' t write that out in quotes even for quoted strings .
if ( isQuotedString && fieldBuilder . length ( ) != 0 ) { field = fieldBuilder . substring ( 1 , fieldBuilder . length ( ) - 1 ) ; } else { field = fieldBuilder . toString ( ) ; } return field ;


signature:
public class RetryLinearRetry { /** * Determines whether the operation should be retried and specifies the interval until the next retry .
 * @ param retryContext
 * A { @ link RetryContext } object that indicates the number of retries , last request ' s results , whether
 * the next retry should happen in the primary or secondary location , and specifies the location mode .
 * @ param operationContext
 * An { @ link OperationContext } object for tracking the current operation .
 * @ return
 * A { @ link RetryInfo } object that indicates whether the next retry will happen in the primary or secondary
 * location , and specifies the location mode . If < code > null < / code > , the operation will not be retried . */
@ Override public RetryInfo evaluate ( RetryContext retryContext , OperationContext operationContext ) { } }

implementation:
boolean secondaryNotFound = this . evaluateLastAttemptAndSecondaryNotFound ( retryContext ) ; if ( retryContext . getCurrentRetryCount ( ) < this . maximumAttempts ) { // If this method is called after a successful response , it means
// we failed during the response body download . So , we should not
// check for success codes here .
int statusCode = retryContext . getLastRequestResult ( ) . getStatusCode ( ) ; if ( ( ! secondaryNotFound && statusCode >= 300 && statusCode < 500 && statusCode != 408 ) || statusCode == HttpURLConnection . HTTP_NOT_IMPLEMENTED || statusCode == HttpURLConnection . HTTP_VERSION ) { return null ; } final long retryInterval = Math . max ( Math . min ( this . deltaBackoffIntervalInMs , RetryPolicy . DEFAULT_MAX_BACKOFF ) , RetryPolicy . DEFAULT_MIN_BACKOFF ) ; return this . evaluateRetryInfo ( retryContext , secondaryNotFound , retryInterval ) ; } return null ;


signature:
public class RetryExponentialRetry { /** * Generates a new retry policy for the current request attempt .
 * @ param opContext
 * An { @ link OperationContext } object that represents the context for the current operation . This object
 * is used to track requests to the storage service , and to provide additional runtime information about
 * the operation .
 * @ return A { @ link RetryPolicy } object that represents the retry policy for the current request attempt . */
@ Override public RetryPolicy createInstance ( final OperationContext opContext ) { } }

implementation: return new RetryExponentialRetry ( this . resolvedMinBackoff , this . deltaBackoffIntervalInMs , this . resolvedMaxBackoff , this . maximumAttempts ) ;


signature:
public class RetryExponentialRetry { /** * Determines whether the operation should be retried and specifies the interval until the next retry .
 * @ param retryContext
 * A { @ link RetryContext } object that indicates the number of retries , last request ' s results , whether
 * the next retry should happen in the primary or secondary location , and specifies the location mode .
 * @ param operationContext
 * An { @ link OperationContext } object for tracking the current operation .
 * @ return
 * A { @ link RetryInfo } object that indicates whether the next retry will happen in the primary or secondary
 * location , and specifies the location mode . If < code > null < / code > , the operation will not be retried . */
@ Override public RetryInfo evaluate ( RetryContext retryContext , OperationContext operationContext ) { } }

implementation:
boolean secondaryNotFound = this . evaluateLastAttemptAndSecondaryNotFound ( retryContext ) ; if ( retryContext . getCurrentRetryCount ( ) < this . maximumAttempts ) { // If this method is called after a successful response , it means
// we failed during the response body download . So , we should not
// check for success codes here .
int statusCode = retryContext . getLastRequestResult ( ) . getStatusCode ( ) ; if ( ( ! secondaryNotFound && statusCode >= 300 && statusCode < 500 && statusCode != 408 ) || statusCode == HttpURLConnection . HTTP_NOT_IMPLEMENTED || statusCode == HttpURLConnection . HTTP_VERSION ) { return null ; } // Calculate backoff Interval between 80 % and 120 % of the desired
// backoff , multiply by 2 ^ n - 1 for exponential
double incrementDelta = ( Math . pow ( 2 , retryContext . getCurrentRetryCount ( ) ) - 1 ) ; final int boundedRandDelta = ( int ) ( this . deltaBackoffIntervalInMs * 0.8 ) + this . randRef . nextInt ( ( int ) ( this . deltaBackoffIntervalInMs * 1.2 ) - ( int ) ( this . deltaBackoffIntervalInMs * 0.8 ) ) ; incrementDelta *= boundedRandDelta ; final long retryInterval = ( int ) Math . round ( Math . min ( this . resolvedMinBackoff + incrementDelta , this . resolvedMaxBackoff ) ) ; return this . evaluateRetryInfo ( retryContext , secondaryNotFound , retryInterval ) ; } return null ;


signature:
public class LazySegmentedIterator { /** * Indicates if the iterator has another element . */
@ Override @ DoesServiceRequest public boolean hasNext ( ) { } }

implementation: while ( this . currentSegment == null || ( ! this . currentSegmentIterator . hasNext ( ) && this . currentSegment != null && this . currentSegment . getHasMoreResults ( ) ) ) { try { this . currentSegment = ExecutionEngine . executeWithRetry ( this . client , this . parentObject , this . segmentGenerator , this . policyFactory , this . opContext ) ; } catch ( final StorageException e ) { final NoSuchElementException ex = new NoSuchElementException ( SR . ENUMERATION_ERROR ) ; ex . initCause ( e ) ; throw ex ; } this . currentSegmentIterator = this . currentSegment . getResults ( ) . iterator ( ) ; if ( ! this . currentSegmentIterator . hasNext ( ) && ! this . currentSegment . getHasMoreResults ( ) ) { return false ; } } return this . currentSegmentIterator . hasNext ( ) ;


signature:
public class JsonUtilities { /** * Reserved for internal use . Asserts that the current name of the parser equals the expected value
 * @ param parser
 * The { @ link JsonParser } whose current token to check .
 * @ param expectedValue
 * The expected current name of the parser ' s current token . */
public static void assertIsExpectedFieldName ( final JsonParser parser , final String expectedValue ) throws JsonParseException , IOException { } }

implementation: final String actualValue = parser . getCurrentName ( ) ; if ( expectedValue == null ) { if ( actualValue != null ) { throw new JsonParseException ( String . format ( SR . UNEXPECTED_FIELD_NAME , expectedValue , actualValue ) , parser . getCurrentLocation ( ) ) ; } } else { if ( ! expectedValue . equals ( actualValue ) ) { throw new JsonParseException ( String . format ( SR . UNEXPECTED_FIELD_NAME , expectedValue , actualValue ) , parser . getCurrentLocation ( ) ) ; } }


signature:
public class JsonUtilities { /** * Reserved for internal use . Asserts that the current token of the parser is a field name .
 * @ param parser
 * The { @ link JsonParser } whose current token to check . */
public static void assertIsFieldNameJsonToken ( final JsonParser parser ) throws JsonParseException { } }

implementation: if ( ! ( parser . getCurrentToken ( ) == JsonToken . FIELD_NAME ) ) { throw new JsonParseException ( SR . EXPECTED_A_FIELD_NAME , parser . getCurrentLocation ( ) ) ; }


signature:
public class JsonUtilities { /** * Reserved for internal use . Asserts that the current token of the parser is the start of an object .
 * @ param parser
 * The { @ link JsonParser } whose current token to check . */
public static void assertIsStartObjectJsonToken ( final JsonParser parser ) throws JsonParseException { } }

implementation: if ( ! ( parser . getCurrentToken ( ) == JsonToken . START_OBJECT ) ) { throw new JsonParseException ( SR . EXPECTED_START_OBJECT , parser . getCurrentLocation ( ) ) ; }


signature:
public class JsonUtilities { /** * Reserved for internal use . Asserts that the current token of the parser is the end of an object .
 * @ param parser
 * The { @ link JsonParser } whose current token to check . */
public static void assertIsEndObjectJsonToken ( final JsonParser parser ) throws JsonParseException { } }

implementation: if ( ! ( parser . getCurrentToken ( ) == JsonToken . END_OBJECT ) ) { throw new JsonParseException ( SR . EXPECTED_END_OBJECT , parser . getCurrentLocation ( ) ) ; }


signature:
public class JsonUtilities { /** * Reserved for internal use . Asserts that the token type of the parser is the start of an array .
 * @ param parser
 * The { @ link JsonParser } whose current token to check . */
public static void assertIsStartArrayJsonToken ( final JsonParser parser ) throws JsonParseException { } }

implementation: if ( ! ( parser . getCurrentToken ( ) == JsonToken . START_ARRAY ) ) { throw new JsonParseException ( SR . EXPECTED_START_ARRAY , parser . getCurrentLocation ( ) ) ; }


signature:
public class JsonUtilities { /** * Reserved for internal use . Asserts that the token type of the parser is the end of an array .
 * @ param parser
 * The { @ link JsonParser } whose current token to check . */
public static void assertIsEndArrayJsonToken ( final JsonParser parser ) throws JsonParseException { } }

implementation: if ( ! ( parser . getCurrentToken ( ) == JsonToken . END_ARRAY ) ) { throw new JsonParseException ( SR . EXPECTED_END_ARRAY , parser . getCurrentLocation ( ) ) ; }


signature:
public class QueryTableOperation { /** * Reserved for internal use . Parses the table operation response into a { @ link TableResult } to return .
 * @ param inStream
 * An < code > InputStream < / code > containing the response to a query operation .
 * @ param httpStatusCode
 * The HTTP status code returned from the operation request .
 * @ param etagFromHeader
 * The < code > String < / code > containing 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 query 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 . */
@ Override 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 res = TableDeserializer . parseSingleOpResponse ( inStream , options , httpStatusCode , this . getClazzType ( ) , this . getResolver ( ) , opContext ) ; res . setEtag ( etagFromHeader ) ; return res ;


signature:
public class QueryTableOperation { /** * Reserved for internal use . Performs a retrieve 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 and storage account
 * credentials to use .
 * @ param tableName
 * A < code > String < / code > containing the name of the table to query .
 * @ 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 } containing the results of executing the query operation .
 * @ throws StorageException
 * if an error occurs in the storage operation . */
protected TableResult performRetrieve ( final CloudTableClient client , final String tableName , final TableRequestOptions options , final OperationContext opContext ) throws StorageException { } }

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


signature:
public class QueryTableOperation { /** * Reserved for internal use . Sets the class type of the entity returned by the query .
 * @ param clazzType
 * The < code > java . lang . Class < / code > implementing { @ link TableEntity } that represents the entity type for
 * the query . */
protected void setClazzType ( final Class < ? extends TableEntity > clazzType ) { } }

implementation: Utility . assertNotNull ( "clazzType" , clazzType ) ; Utility . checkNullaryCtor ( clazzType ) ; this . clazzType = clazzType ;


signature:
public class QueryTableOperation { /** * Reserved for internal use . Sets the resolver to project the entity retrieved as a particular type .
 * @ param resolver
 * The { @ link EntityResolver } instance to use . */
protected void setResolver ( final EntityResolver < ? > resolver ) { } }

implementation: Utility . assertNotNull ( SR . QUERY_REQUIRES_VALID_CLASSTYPE_OR_RESOLVER , resolver ) ; this . resolver = resolver ;


signature:
public class MimeHelper { /** * Reserved for internal use . Reads the response stream from a batch operation into an < code > ArrayList < / code > of
 * { @ link MimePart } objects .
 * @ param inStream
 * An { @ link InputStream } containing the operation response stream .
 * @ param expectedBundaryName
 * A < code > String < / code > containing the MIME part boundary string .
 * @ param opContext
 * An { @ link OperationContext } object for tracking the current operation . Specify < code > null < / code > to
 * safely ignore operation context .
 * @ param format
 * The { @ link TablePayloadFormat } that will be used for parsing
 * @ return
 * An < code > ArrayList < / code > of { @ link MimePart } objects parsed from the input stream .
 * @ throws StorageException
 * if a storage service error occurs .
 * @ throws IOException
 * if an error occurs while accessing the stream with Json . */
static ArrayList < MimePart > readBatchResponseStream ( final InputStream inStream , final String expectedBundaryName , final OperationContext opContext , TablePayloadFormat format ) throws IOException , StorageException { } }

implementation:
final ArrayList < MimePart > result = new ArrayList < MimePart > ( ) ; final InputStreamReader streamReader = new InputStreamReader ( inStream , Constants . UTF8_CHARSET ) ; final BufferedReader reader = new BufferedReader ( streamReader ) ; final String mungedExpectedBoundaryName = "--" . concat ( expectedBundaryName ) ; final MimeHeader docHeader = readMimeHeader ( reader , opContext ) ; if ( docHeader . boundary == null || ! docHeader . boundary . equals ( mungedExpectedBoundaryName ) ) { throw generateMimeParseException ( ) ; } MimeHeader currHeader = null ; // No explicit changeset present
if ( docHeader . subBoundary == null ) { do { result . add ( readMimePart ( reader , docHeader . boundary , opContext ) ) ; currHeader = readMimeHeader ( reader , opContext ) ; } while ( currHeader != null ) ; } else { // explicit changeset present .
currHeader = readMimeHeader ( reader , opContext ) ; if ( currHeader == null ) { throw generateMimeParseException ( ) ; } else { do { result . add ( readMimePart ( reader , docHeader . subBoundary , opContext ) ) ; currHeader = readMimeHeader ( reader , opContext ) ; } while ( currHeader != null ) ; } } return result ;


signature:
public class MimeHelper { /** * Reserved for internal use . Writes the batch operation to the output stream using batch request syntax .
 * Batch request syntax is described in the MSDN topic < a
 * href = " http : / / msdn . microsoft . com / en - us / library / azure / dd894038 . aspx " > Performing Entity Group
 * Transactions < / a > .
 * @ param outStream
 * The { @ link OutputStream } to write the batch request to .
 * @ param tableName
 * A < code > String < / code > containing the name of the table to apply each operation to .
 * @ param batch
 * A { @ link TableBatchOperation } containing the operations to write to the output stream
 * @ param batchID
 * A < code > String < / code > containing the identifier to use as the MIME boundary for the batch request .
 * @ param changeSet
 * A < code > String < / code > containing the identifier to use as the MIME boundary for operations within the
 * batch .
 * @ param opContext
 * An { @ link OperationContext } object for tracking the current operation . Specify < code > null < / code > to
 * safely ignore operation context .
 * @ throws IOException
 * if an IO error occurs .
 * @ throws URISyntaxException
 * if an invalid URI is used .
 * @ throws StorageException
 * if an error occurs accessing the Storage service . */
static void writeBatchToStream ( final OutputStream outStream , final TableRequestOptions options , final String tableName , final URI baseUri , final TableBatchOperation batch , final String batchID , final String changeSet , final OperationContext opContext ) throws IOException , URISyntaxException , StorageException { } }

implementation:
final OutputStreamWriter outWriter = new OutputStreamWriter ( outStream , Constants . UTF8_CHARSET ) ; MimePart mimePart ; int contentID = 0 ; boolean isQuery = batch . size ( ) == 1 && batch . get ( 0 ) . getOperationType ( ) == TableOperationType . RETRIEVE ; // when batch is made , a check is done to make sure only one retrieve is added
if ( isQuery ) { final QueryTableOperation qOp = ( QueryTableOperation ) batch . get ( 0 ) ; // Write MIME batch Header
MimeHelper . writeMIMEBoundary ( outWriter , batchID ) ; mimePart = new MimePart ( ) ; mimePart . op = qOp . getOperationType ( ) ; UriQueryBuilder builder = new UriQueryBuilder ( ) ; mimePart . requestIdentity = builder . addToURI ( PathUtility . appendPathToSingleUri ( baseUri , qOp . generateRequestIdentityWithTable ( tableName ) ) ) ; mimePart . headers . put ( Constants . HeaderConstants . ACCEPT , generateAcceptHeaderValue ( options . getTablePayloadFormat ( ) ) ) ; mimePart . headers . put ( TableConstants . HeaderConstants . MAX_DATA_SERVICE_VERSION , TableConstants . HeaderConstants . MAX_DATA_SERVICE_VERSION_VALUE ) ; outWriter . write ( mimePart . toRequestString ( ) ) ; } else { // Write MIME batch Header
MimeHelper . writeMIMEBoundary ( outWriter , batchID ) ; MimeHelper . writeMIMEContentType ( outWriter , changeSet ) ; outWriter . write ( "\r\n" ) ; // Write each operation
for ( final TableOperation op : batch ) { // New mime part for changeset
MimeHelper . writeMIMEBoundary ( outWriter , changeSet ) ; mimePart = new MimePart ( ) ; mimePart . op = op . getOperationType ( ) ; UriQueryBuilder builder = new UriQueryBuilder ( ) ; mimePart . requestIdentity = builder . addToURI ( PathUtility . appendPathToSingleUri ( baseUri , op . generateRequestIdentityWithTable ( tableName ) ) ) ; mimePart . headers . put ( TableConstants . HeaderConstants . CONTENT_ID , Integer . toString ( contentID ) ) ; mimePart . headers . put ( Constants . HeaderConstants . ACCEPT , generateAcceptHeaderValue ( options . getTablePayloadFormat ( ) ) ) ; mimePart . headers . put ( TableConstants . HeaderConstants . MAX_DATA_SERVICE_VERSION , TableConstants . HeaderConstants . MAX_DATA_SERVICE_VERSION_VALUE ) ; if ( op . getOperationType ( ) == TableOperationType . INSERT_OR_MERGE || op . getOperationType ( ) == TableOperationType . MERGE ) { // post tunnelling
mimePart . headers . put ( TableConstants . HeaderConstants . X_HTTP_METHOD , TableOperationType . MERGE . toString ( ) ) ; } // etag
if ( op . getOperationType ( ) == TableOperationType . DELETE || op . getOperationType ( ) == TableOperationType . REPLACE || op . getOperationType ( ) == TableOperationType . MERGE ) { if ( op . getEntity ( ) != null && op . getEntity ( ) . getEtag ( ) != null ) { mimePart . headers . put ( Constants . HeaderConstants . IF_MATCH , op . getEntity ( ) . getEtag ( ) ) ; } } // prefer header
if ( op . getOperationType ( ) == TableOperationType . INSERT ) { mimePart . headers . put ( TableConstants . HeaderConstants . PREFER , op . getEchoContent ( ) ? TableConstants . HeaderConstants . RETURN_CONTENT : TableConstants . HeaderConstants . RETURN_NO_CONTENT ) ; } if ( op . getOperationType ( ) != TableOperationType . DELETE ) { mimePart . headers . put ( Constants . HeaderConstants . CONTENT_TYPE , TableConstants . HeaderConstants . JSON_CONTENT_TYPE ) ; mimePart . payload = writeStringForOperation ( op , options . getTablePayloadFormat ( ) , opContext ) ; mimePart . headers . put ( Constants . HeaderConstants . CONTENT_LENGTH , Integer . toString ( mimePart . payload . getBytes ( Constants . UTF8_CHARSET ) . length ) ) ; } // write the request ( no body )
outWriter . write ( mimePart . toRequestString ( ) ) ; contentID = contentID + 1 ; } } if ( ! isQuery ) { // end changeset
MimeHelper . writeMIMEBoundaryClosure ( outWriter , changeSet ) ; } // end batch
MimeHelper . writeMIMEBoundaryClosure ( outWriter , batchID ) ; outWriter . flush ( ) ;