idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
26,300
public CustomHeadersInterceptor addHeader ( String name , String value ) { if ( ! this . headers . containsKey ( name ) ) { this . headers . put ( name , new ArrayList < String > ( ) ) ; } this . headers . get ( name ) . add ( value ) ; return this ; }
Add a single header key - value pair . If one with the name already exists both stay in the header map .
26,301
public CustomHeadersInterceptor addHeaderMap ( Map < String , String > headers ) { for ( Map . Entry < String , String > header : headers . entrySet ( ) ) { this . headers . put ( header . getKey ( ) , Collections . singletonList ( header . getValue ( ) ) ) ; } return this ; }
Add all headers in a header map .
26,302
public CustomHeadersInterceptor addHeaderMultimap ( Map < String , List < String > > headers ) { this . headers . putAll ( headers ) ; return this ; }
Add all headers in a header multimap .
26,303
public static < T > Observable < T > map ( Observable < ? > fromObservable , final T toValue ) { if ( fromObservable != null ) { return fromObservable . subscribeOn ( Schedulers . io ( ) ) . map ( new RXMapper < T > ( toValue ) ) ; } else { return Observable . empty ( ) ; } }
Shortcut for mapping the output of an arbitrary observable to one returning an instance of a specific type using the IO scheduler .
26,304
public static Observable < Void > mapToVoid ( Observable < ? > fromObservable ) { if ( fromObservable != null ) { return fromObservable . subscribeOn ( Schedulers . io ( ) ) . map ( new RXMapper < Void > ( ) ) ; } else { return Observable . empty ( ) ; } }
Shortcut for mapping an arbitrary observable to void using the IO scheduler .
26,305
@ SuppressWarnings ( "unchecked" ) public final FluentModelImplT withTag ( String key , String value ) { if ( this . inner ( ) . getTags ( ) == null ) { this . inner ( ) . withTags ( new HashMap < String , String > ( ) ) ; } this . inner ( ) . getTags ( ) . put ( key , value ) ; return ( FluentModelImplT ) this ; }
Adds a tag to the resource .
26,306
@ SuppressWarnings ( "unchecked" ) public final FluentModelImplT withoutTag ( String key ) { if ( this . inner ( ) . getTags ( ) != null ) { this . inner ( ) . getTags ( ) . remove ( key ) ; } return ( FluentModelImplT ) this ; }
Removes a tag from the resource .
26,307
public void load ( List < E > result ) { ++ pageCount ; if ( this . result == null || this . result . isEmpty ( ) ) { this . result = result ; } else { this . result . addAll ( result ) ; } }
This method is called by the client to load the most recent list of resources . This method should only be called by the service client .
26,308
public < T > Observable < T > delayedEmitAsync ( T event , int milliseconds ) { return Observable . just ( event ) . delay ( milliseconds , TimeUnit . MILLISECONDS , Schedulers . immediate ( ) ) ; }
Creates an observable that emits the given item after the specified time in milliseconds .
26,309
public static String [ ] randomResourceNames ( String prefix , int maxLen , int count ) { String [ ] names = new String [ count ] ; ResourceNamer resourceNamer = SdkContext . getResourceNamerFactory ( ) . createResourceNamer ( "" ) ; for ( int i = 0 ; i < count ; i ++ ) { names [ i ] = resourceNamer . randomName ( prefix , maxLen ) ; } return names ; }
Generates the specified number of random resource names with the same prefix .
26,310
public static < T > Observable < T > delayedEmitAsync ( T event , int milliseconds ) { return delayProvider . delayedEmitAsync ( event , milliseconds ) ; }
Wrapper delayed emission based on delayProvider .
26,311
public MSICredentials withObjectId ( String objectId ) { this . objectId = objectId ; this . clientId = null ; this . identityId = null ; return this ; }
Specifies the object id associated with a user assigned managed service identity resource that should be used to retrieve the access token .
26,312
public MSICredentials withIdentityId ( String identityId ) { this . identityId = identityId ; this . clientId = null ; this . objectId = null ; return this ; }
Specifies the ARM resource id of the user assigned managed service identity resource that should be used to retrieve the access token .
26,313
protected String addPostRunDependent ( TaskGroup . HasTaskGroup dependent ) { Objects . requireNonNull ( dependent ) ; this . taskGroup . addPostRunDependentTaskGroup ( dependent . taskGroup ( ) ) ; return dependent . taskGroup ( ) . key ( ) ; }
Add a post - run dependent for this model .
26,314
public static < T > PollingState < T > create ( Response < ResponseBody > response , LongRunningOperationOptions lroOptions , int defaultRetryTimeout , Type resourceType , SerializerAdapter < ? > serializerAdapter ) throws IOException { PollingState < T > pollingState = new PollingState < > ( ) ; pollingState . initialHttpMethod = response . raw ( ) . request ( ) . method ( ) ; pollingState . defaultRetryTimeout = defaultRetryTimeout ; pollingState . withResponse ( response ) ; pollingState . resourceType = resourceType ; pollingState . serializerAdapter = serializerAdapter ; pollingState . loggingContext = response . raw ( ) . request ( ) . header ( LOGGING_HEADER ) ; pollingState . finalStateVia = lroOptions . finalStateVia ( ) ; String responseContent = null ; PollingResource resource = null ; if ( response . body ( ) != null ) { responseContent = response . body ( ) . string ( ) ; response . body ( ) . close ( ) ; } if ( responseContent != null && ! responseContent . isEmpty ( ) ) { pollingState . resource = serializerAdapter . deserialize ( responseContent , resourceType ) ; resource = serializerAdapter . deserialize ( responseContent , PollingResource . class ) ; } final int statusCode = pollingState . response . code ( ) ; if ( resource != null && resource . properties != null && resource . properties . provisioningState != null ) { pollingState . withStatus ( resource . properties . provisioningState , statusCode ) ; } else { switch ( statusCode ) { case 202 : pollingState . withStatus ( AzureAsyncOperation . IN_PROGRESS_STATUS , statusCode ) ; break ; case 204 : case 201 : case 200 : pollingState . withStatus ( AzureAsyncOperation . SUCCESS_STATUS , statusCode ) ; break ; default : pollingState . withStatus ( AzureAsyncOperation . FAILED_STATUS , statusCode ) ; } } return pollingState ; }
Creates a polling state .
26,315
public static < ResultT > PollingState < ResultT > createFromJSONString ( String serializedPollingState ) { ObjectMapper mapper = initMapper ( new ObjectMapper ( ) ) ; PollingState < ResultT > pollingState ; try { pollingState = mapper . readValue ( serializedPollingState , PollingState . class ) ; } catch ( IOException exception ) { throw new RuntimeException ( exception ) ; } return pollingState ; }
Creates PollingState from the json string .
26,316
public static < ResultT > PollingState < ResultT > createFromPollingState ( PollingState < ? > other , ResultT result ) { PollingState < ResultT > pollingState = new PollingState < > ( ) ; pollingState . resource = result ; pollingState . initialHttpMethod = other . initialHttpMethod ( ) ; pollingState . status = other . status ( ) ; pollingState . statusCode = other . statusCode ( ) ; pollingState . azureAsyncOperationHeaderLink = other . azureAsyncOperationHeaderLink ( ) ; pollingState . locationHeaderLink = other . locationHeaderLink ( ) ; pollingState . putOrPatchResourceUri = other . putOrPatchResourceUri ( ) ; pollingState . defaultRetryTimeout = other . defaultRetryTimeout ; pollingState . retryTimeout = other . retryTimeout ; pollingState . loggingContext = other . loggingContext ; pollingState . finalStateVia = other . finalStateVia ; return pollingState ; }
Creates PollingState from another polling state .
26,317
void updateFromResponseOnPutPatch ( Response < ResponseBody > response ) throws CloudException , IOException { String responseContent = null ; if ( response . body ( ) != null ) { responseContent = response . body ( ) . string ( ) ; response . body ( ) . close ( ) ; } if ( responseContent == null || responseContent . isEmpty ( ) ) { throw new CloudException ( "polling response does not contain a valid body" , response ) ; } PollingResource resource = serializerAdapter . deserialize ( responseContent , PollingResource . class ) ; final int statusCode = response . code ( ) ; if ( resource != null && resource . properties != null && resource . properties . provisioningState != null ) { this . withStatus ( resource . properties . provisioningState , statusCode ) ; } else { this . withStatus ( AzureAsyncOperation . SUCCESS_STATUS , statusCode ) ; } CloudError error = new CloudError ( ) ; this . withErrorBody ( error ) ; error . withCode ( this . status ( ) ) ; error . withMessage ( "Long running operation failed" ) ; this . withResponse ( response ) ; this . withResource ( serializerAdapter . < T > deserialize ( responseContent , resourceType ) ) ; }
Updates the polling state from a PUT or PATCH operation .
26,318
void updateFromResponseOnDeletePost ( Response < ResponseBody > response ) throws IOException { this . withResponse ( response ) ; String responseContent = null ; if ( response . body ( ) != null ) { responseContent = response . body ( ) . string ( ) ; response . body ( ) . close ( ) ; } this . withResource ( serializerAdapter . < T > deserialize ( responseContent , resourceType ) ) ; withStatus ( AzureAsyncOperation . SUCCESS_STATUS , response . code ( ) ) ; }
Updates the polling state from a DELETE or POST operation .
26,319
PollingState < T > withStatus ( String status , int statusCode ) throws IllegalArgumentException { if ( status == null ) { throw new IllegalArgumentException ( "Status is null." ) ; } this . status = status ; this . statusCode = statusCode ; return this ; }
Sets the polling status .
26,320
PollingState < T > withResponse ( Response < ResponseBody > response ) { this . response = response ; withPollingUrlFromResponse ( response ) ; withPollingRetryTimeoutFromResponse ( response ) ; return this ; }
Sets the last operation response .
26,321
void throwCloudExceptionIfInFailedState ( ) { if ( this . isStatusFailed ( ) ) { if ( this . errorBody ( ) != null ) { throw new CloudException ( "Async operation failed with provisioning state: " + this . status ( ) , this . response ( ) , this . errorBody ( ) ) ; } else { throw new CloudException ( "Async operation failed with provisioning state: " + this . status ( ) , this . response ( ) ) ; } } }
If status is in failed state then throw CloudException .
26,322
static AzureAsyncOperation fromResponse ( SerializerAdapter < ? > serializerAdapter , Response < ResponseBody > response ) throws CloudException { AzureAsyncOperation asyncOperation = null ; String rawString = null ; if ( response . body ( ) != null ) { try { rawString = response . body ( ) . string ( ) ; asyncOperation = serializerAdapter . deserialize ( rawString , AzureAsyncOperation . class ) ; } catch ( IOException exception ) { } finally { response . body ( ) . close ( ) ; } } if ( asyncOperation == null || asyncOperation . status ( ) == null ) { throw new CloudException ( "polling response does not contain a valid body: " + rawString , response ) ; } else { asyncOperation . rawString = rawString ; } return asyncOperation ; }
Creates AzureAsyncOperation from the given HTTP response .
26,323
public void setOwner ( Graph < DataT , NodeT > ownerGraph ) { if ( this . ownerGraph != null ) { throw new RuntimeException ( "Changing owner graph is not allowed" ) ; } this . ownerGraph = ownerGraph ; }
Sets reference to the graph owning this node .
26,324
protected void onFaultedResolution ( String dependencyKey , Throwable throwable ) { if ( toBeResolved == 0 ) { throw new RuntimeException ( "invalid state - " + this . key ( ) + ": The dependency '" + dependencyKey + "' is already reported or there is no such dependencyKey" ) ; } toBeResolved -- ; }
Reports a dependency of this node has been faulted .
26,325
public String userAgent ( ) { return String . format ( "Azure-SDK-For-Java/%s OS:%s MacAddressHash:%s Java:%s" , getClass ( ) . getPackage ( ) . getImplementationVersion ( ) , OS , MAC_ADDRESS_HASH , JAVA_VERSION ) ; }
The default User - Agent header . Override this method to override the user agent .
26,326
public static String groupFromResourceId ( String id ) { return ( id != null ) ? ResourceId . fromString ( id ) . resourceGroupName ( ) : null ; }
Extract resource group from a resource ID string .
26,327
public static String subscriptionFromResourceId ( String id ) { return ( id != null ) ? ResourceId . fromString ( id ) . subscriptionId ( ) : null ; }
Extract the subscription ID from a resource ID string .
26,328
public static String resourceProviderFromResourceId ( String id ) { return ( id != null ) ? ResourceId . fromString ( id ) . providerNamespace ( ) : null ; }
Extract resource provider from a resource ID string .
26,329
public static String resourceTypeFromResourceId ( String id ) { return ( id != null ) ? ResourceId . fromString ( id ) . resourceType ( ) : null ; }
Extract resource type from a resource ID string .
26,330
public static String extractFromResourceId ( String id , String identifier ) { if ( id == null || identifier == null ) { return id ; } Pattern pattern = Pattern . compile ( identifier + "/[-\\w._]+" ) ; Matcher matcher = pattern . matcher ( id ) ; if ( matcher . find ( ) ) { return matcher . group ( ) . split ( "/" ) [ 1 ] ; } else { return null ; } }
Extract information from a resource ID string with the resource type as the identifier .
26,331
public static String nameFromResourceId ( String id ) { return ( id != null ) ? ResourceId . fromString ( id ) . name ( ) : null ; }
Extract name of the resource from a resource ID .
26,332
public static String constructResourceId ( final String subscriptionId , final String resourceGroupName , final String resourceProviderNamespace , final String resourceType , final String resourceName , final String parentResourcePath ) { String prefixedParentPath = parentResourcePath ; if ( parentResourcePath != null && ! parentResourcePath . isEmpty ( ) ) { prefixedParentPath = "/" + parentResourcePath ; } return String . format ( "/subscriptions/%s/resourcegroups/%s/providers/%s%s/%s/%s" , subscriptionId , resourceGroupName , resourceProviderNamespace , prefixedParentPath , resourceType , resourceName ) ; }
Creates a resource ID from information of a generic resource .
26,333
private < T > ServiceResponse < T > getPutOrPatchResult ( Observable < Response < ResponseBody > > observable , Type resourceType ) throws CloudException , InterruptedException , IOException { Observable < ServiceResponse < T > > asyncObservable = getPutOrPatchResultAsync ( observable , resourceType ) ; return asyncObservable . toBlocking ( ) . last ( ) ; }
Handles an initial response from a PUT or PATCH operation response by polling the status of the operation until the long running operation terminates .
26,334
public < T > Observable < ServiceResponse < T > > getPutOrPatchResultAsync ( Observable < Response < ResponseBody > > observable , final Type resourceType ) { return this . < T > beginPutOrPatchAsync ( observable , resourceType ) . toObservable ( ) . flatMap ( new Func1 < PollingState < T > , Observable < PollingState < T > > > ( ) { public Observable < PollingState < T > > call ( PollingState < T > pollingState ) { return pollPutOrPatchAsync ( pollingState , resourceType ) ; } } ) . last ( ) . map ( new Func1 < PollingState < T > , ServiceResponse < T > > ( ) { public ServiceResponse < T > call ( PollingState < T > pollingState ) { return new ServiceResponse < > ( pollingState . resource ( ) , pollingState . response ( ) ) ; } } ) ; }
Handles an initial response from a PUT or PATCH operation response by polling the status of the operation asynchronously once the operation finishes emits the final response .
26,335
private < T > Observable < PollingState < T > > updateStateFromLocationHeaderOnPutAsync ( final PollingState < T > pollingState ) { return pollAsync ( pollingState . locationHeaderLink ( ) , pollingState . loggingContext ( ) ) . flatMap ( new Func1 < Response < ResponseBody > , Observable < PollingState < T > > > ( ) { public Observable < PollingState < T > > call ( Response < ResponseBody > response ) { int statusCode = response . code ( ) ; if ( statusCode == 202 ) { pollingState . withResponse ( response ) ; pollingState . withStatus ( AzureAsyncOperation . IN_PROGRESS_STATUS , statusCode ) ; } else if ( statusCode == 200 || statusCode == 201 ) { try { pollingState . updateFromResponseOnPutPatch ( response ) ; } catch ( CloudException | IOException e ) { return Observable . error ( e ) ; } } return Observable . just ( pollingState ) ; } } ) ; }
Polls from the location header and updates the polling state with the polling response for a PUT operation .
26,336
private < T > Observable < PollingState < T > > updateStateFromGetResourceOperationAsync ( final PollingState < T > pollingState , String url ) { return pollAsync ( url , pollingState . loggingContext ( ) ) . flatMap ( new Func1 < Response < ResponseBody > , Observable < PollingState < T > > > ( ) { public Observable < PollingState < T > > call ( Response < ResponseBody > response ) { try { pollingState . updateFromResponseOnPutPatch ( response ) ; return Observable . just ( pollingState ) ; } catch ( CloudException | IOException e ) { return Observable . error ( e ) ; } } } ) ; }
Polls from the provided URL and updates the polling state with the polling response .
26,337
private Observable < Response < ResponseBody > > pollAsync ( String url , String loggingContext ) { URL endpoint ; try { endpoint = new URL ( url ) ; } catch ( MalformedURLException e ) { return Observable . error ( e ) ; } AsyncService service = restClient ( ) . retrofit ( ) . create ( AsyncService . class ) ; if ( loggingContext != null && ! loggingContext . endsWith ( " (poll)" ) ) { loggingContext += " (poll)" ; } return service . get ( endpoint . getFile ( ) , serviceClientUserAgent , loggingContext ) . flatMap ( new Func1 < Response < ResponseBody > , Observable < Response < ResponseBody > > > ( ) { public Observable < Response < ResponseBody > > call ( Response < ResponseBody > response ) { RuntimeException exception = createExceptionFromResponse ( response , 200 , 201 , 202 , 204 ) ; if ( exception != null ) { return Observable . error ( exception ) ; } else { return Observable . just ( response ) ; } } } ) ; }
Polls from the URL provided .
26,338
public Indexable taskResult ( String taskId ) { TaskGroupEntry < TaskItem > taskGroupEntry = super . getNode ( taskId ) ; if ( taskGroupEntry != null ) { return taskGroupEntry . taskResult ( ) ; } if ( ! this . proxyTaskGroupWrapper . isActive ( ) ) { throw new IllegalArgumentException ( "A dependency task with id '" + taskId + "' is not found" ) ; } taskGroupEntry = this . proxyTaskGroupWrapper . proxyTaskGroup . getNode ( taskId ) ; if ( taskGroupEntry != null ) { return taskGroupEntry . taskResult ( ) ; } throw new IllegalArgumentException ( "A dependency task or 'post-run' dependent task with with id '" + taskId + "' not found" ) ; }
Retrieve the result produced by a task with the given id in the group .
26,339
public String addDependency ( FunctionalTaskItem dependencyTaskItem ) { IndexableTaskItem dependency = IndexableTaskItem . create ( dependencyTaskItem ) ; this . addDependency ( dependency ) ; return dependency . key ( ) ; }
Mark root of this task task group depends on the given TaskItem . This ensure this task group s root get picked for execution only after the completion of invocation of provided TaskItem .
26,340
public void addDependencyTaskGroup ( TaskGroup dependencyTaskGroup ) { if ( dependencyTaskGroup . proxyTaskGroupWrapper . isActive ( ) ) { dependencyTaskGroup . proxyTaskGroupWrapper . addDependentTaskGroup ( this ) ; } else { DAGraph < TaskItem , TaskGroupEntry < TaskItem > > dependencyGraph = dependencyTaskGroup ; super . addDependencyGraph ( dependencyGraph ) ; } }
Mark root of this task task group depends on the given task group s root . This ensure this task group s root get picked for execution only after the completion of all tasks in the given group .
26,341
public String addPostRunDependent ( FunctionalTaskItem dependentTaskItem ) { IndexableTaskItem taskItem = IndexableTaskItem . create ( dependentTaskItem ) ; this . addPostRunDependent ( taskItem ) ; return taskItem . key ( ) ; }
Mark the given TaskItem depends on this taskGroup .
26,342
private Observable < Indexable > invokeReadyTasksAsync ( final InvocationContext context ) { TaskGroupEntry < TaskItem > readyTaskEntry = super . getNext ( ) ; final List < Observable < Indexable > > observables = new ArrayList < > ( ) ; while ( readyTaskEntry != null ) { final TaskGroupEntry < TaskItem > currentEntry = readyTaskEntry ; final TaskItem currentTaskItem = currentEntry . data ( ) ; if ( currentTaskItem instanceof ProxyTaskItem ) { observables . add ( invokeAfterPostRunAsync ( currentEntry , context ) ) ; } else { observables . add ( invokeTaskAsync ( currentEntry , context ) ) ; } readyTaskEntry = super . getNext ( ) ; } return Observable . mergeDelayError ( observables ) ; }
Invokes the ready tasks .
26,343
private Observable < Indexable > processFaultedTaskAsync ( final TaskGroupEntry < TaskItem > faultedEntry , final Throwable throwable , final InvocationContext context ) { markGroupAsCancelledIfTerminationStrategyIsIPTC ( ) ; reportError ( faultedEntry , throwable ) ; if ( isRootEntry ( faultedEntry ) ) { if ( shouldPropagateException ( throwable ) ) { return toErrorObservable ( throwable ) ; } return Observable . empty ( ) ; } else if ( shouldPropagateException ( throwable ) ) { return Observable . concatDelayError ( invokeReadyTasksAsync ( context ) , toErrorObservable ( throwable ) ) ; } else { return invokeReadyTasksAsync ( context ) ; } }
Handles a faulted task .
26,344
public boolean shouldRetry ( int retryCount , Response response ) { int code = response . code ( ) ; return retryCount < this . retryCount && ( code == 408 || ( code >= 500 && code != 501 && code != 505 ) ) ; }
Returns if a request should be retried based on the retry count current response and the current strategy .
26,345
@ Beta ( SinceVersion . V1_1_0 ) public void close ( ) { httpClient . dispatcher ( ) . executorService ( ) . shutdown ( ) ; httpClient . connectionPool ( ) . evictAll ( ) ; synchronized ( httpClient . connectionPool ( ) ) { httpClient . connectionPool ( ) . notifyAll ( ) ; } synchronized ( AsyncTimeout . class ) { AsyncTimeout . class . notifyAll ( ) ; } }
Closes the HTTP client and recycles the resources associated . The threads will be recycled after 60 seconds of inactivity .
26,346
public static < InnerT > PagedList < InnerT > convertToPagedList ( List < InnerT > list ) { PageImpl < InnerT > page = new PageImpl < > ( ) ; page . setItems ( list ) ; page . setNextPageLink ( null ) ; return new PagedList < InnerT > ( page ) { public Page < InnerT > nextPage ( String nextPageLink ) { return null ; } } ; }
Converts the List to PagedList .
26,347
public static < InnerT > Observable < InnerT > convertListToInnerAsync ( Observable < List < InnerT > > innerList ) { return innerList . flatMap ( new Func1 < List < InnerT > , Observable < InnerT > > ( ) { public Observable < InnerT > call ( List < InnerT > inners ) { return Observable . from ( inners ) ; } } ) ; }
Converts Observable of list to Observable of Inner .
26,348
public static < InnerT > Observable < InnerT > convertPageToInnerAsync ( Observable < Page < InnerT > > innerPage ) { return innerPage . flatMap ( new Func1 < Page < InnerT > , Observable < InnerT > > ( ) { public Observable < InnerT > call ( Page < InnerT > pageInner ) { return Observable . from ( pageInner . items ( ) ) ; } } ) ; }
Converts Observable of page to Observable of Inner .
26,349
public void add ( final IndexableTaskItem taskItem ) { this . dependsOnTaskGroup . addPostRunDependentTaskGroup ( taskItem . taskGroup ( ) ) ; this . collection . add ( taskItem ) ; }
Adds a Post Run task to the collection .
26,350
public Eval < UploadResult > putAsync ( String key , Object value ) { return Eval . later ( ( ) -> put ( key , value ) ) . map ( t -> t . orElse ( null ) ) . map ( FluentFunctions . ofChecked ( up -> up . waitForUploadResult ( ) ) ) ; }
Non - blocking call that will throw any Exceptions in the traditional manner on access
26,351
public Future < PutObjectResult > putAsync ( String key , String value ) { return Future . of ( ( ) -> put ( key , value ) , this . uploadService ) . flatMap ( t -> t . fold ( p -> Future . ofResult ( p ) , e -> Future . ofError ( e ) ) ) ; }
Non - blocking call
26,352
public static < T > void finish ( T query , long correlationId , EventBus bus , String ... labels ) { for ( String type : labels ) { RemoveLabelledQuery < T > next = finish ( query , correlationId , type ) ; bus . post ( next ) ; } }
Publish finish events for each of the specified query labels
26,353
public static < T > AddQuery < T > start ( T query , long correlationId ) { return start ( query , correlationId , "default" , null ) ; }
Marks the start of a query identified by the provided correlationId
26,354
public static < T > void finish ( T query , long correlationId , EventBus bus , String ... types ) { for ( String type : types ) { RemoveQuery < T > next = finish ( query , correlationId , type ) ; bus . post ( next ) ; } }
Publish finish events for each of the specified query types
26,355
public Try < R , Throwable > execute ( T input ) { return Try . withCatch ( ( ) -> transactionTemplate . execute ( status -> transaction . apply ( input ) ) ) ; }
Execute the transactional flow - catch all exceptions
26,356
public < Ex extends Throwable > Try < R , Ex > execute ( T input , Class < Ex > classes ) { return Try . withCatch ( ( ) -> transactionTemplate . execute ( status -> transaction . apply ( input ) ) , classes ) ; }
Execute the transactional flow - catch only specified exceptions
26,357
public Column getColumn ( String columnName ) { if ( columnName == null ) { return null ; } for ( Column column : columns ) { if ( columnName . equals ( column . getData ( ) ) ) { return column ; } } return null ; }
Find a column by its name
26,358
public void addColumn ( String columnName , boolean searchable , boolean orderable , String searchValue ) { this . columns . add ( new Column ( columnName , "" , searchable , orderable , new Search ( searchValue , false ) ) ) ; }
Add a new column
26,359
public void addOrder ( String columnName , boolean ascending ) { if ( columnName == null ) { return ; } for ( int i = 0 ; i < columns . size ( ) ; i ++ ) { if ( ! columnName . equals ( columns . get ( i ) . getData ( ) ) ) { continue ; } order . add ( new Order ( i , ascending ? "asc" : "desc" ) ) ; } }
Add an order on the given column
26,360
public Model interpolateModel ( Model model , File projectDir , ModelBuildingRequest config , ModelProblemCollector problems ) { interpolateObject ( model , model , projectDir , config , problems ) ; return model ; }
Empirical data from 3 . x actual = 40
26,361
public String interpolate ( String input , RecursionInterceptor recursionInterceptor ) throws InterpolationException { try { return interpolate ( input , recursionInterceptor , new HashSet < String > ( ) ) ; } finally { if ( ! cacheAnswers ) { existingAnswers . clear ( ) ; } } }
Entry point for recursive resolution of an expression and all of its nested expressions .
26,362
public List getFeedback ( ) { List < ? > messages = new ArrayList ( ) ; for ( ValueSource vs : valueSources ) { List feedback = vs . getFeedback ( ) ; if ( feedback != null && ! feedback . isEmpty ( ) ) { messages . addAll ( feedback ) ; } } return messages ; }
Return any feedback messages and errors that were generated - but suppressed - during the interpolation process . Since unresolvable expressions will be left in the source string as - is this feedback is optional and will only be useful for debugging interpolation problems .
26,363
public ModelSource resolveModel ( Parent parent ) throws UnresolvableModelException { Dependency parentDependency = new Dependency ( ) ; parentDependency . setGroupId ( parent . getGroupId ( ) ) ; parentDependency . setArtifactId ( parent . getArtifactId ( ) ) ; parentDependency . setVersion ( parent . getVersion ( ) ) ; parentDependency . setClassifier ( "" ) ; parentDependency . setType ( "pom" ) ; Artifact parentArtifact = null ; try { Iterable < ArtifactResult > artifactResults = depencencyResolver . resolveDependencies ( projectBuildingRequest , singleton ( parentDependency ) , null , null ) ; Iterator < ArtifactResult > iterator = artifactResults . iterator ( ) ; if ( iterator . hasNext ( ) ) { parentArtifact = iterator . next ( ) . getArtifact ( ) ; } } catch ( DependencyResolverException e ) { throw new UnresolvableModelException ( e . getMessage ( ) , parent . getGroupId ( ) , parent . getArtifactId ( ) , parent . getVersion ( ) , e ) ; } return resolveModel ( parentArtifact . getGroupId ( ) , parentArtifact . getArtifactId ( ) , parentArtifact . getVersion ( ) ) ; }
Resolves the POM for the specified parent .
26,364
protected String extractHeaderComment ( File xmlFile ) throws MojoExecutionException { try { SAXParser parser = SAXParserFactory . newInstance ( ) . newSAXParser ( ) ; SaxHeaderCommentHandler handler = new SaxHeaderCommentHandler ( ) ; parser . setProperty ( "http://xml.org/sax/properties/lexical-handler" , handler ) ; parser . parse ( xmlFile , handler ) ; return handler . getHeaderComment ( ) ; } catch ( Exception e ) { throw new MojoExecutionException ( "Failed to parse XML from " + xmlFile , e ) ; } }
This method extracts the XML header comment if available .
26,365
protected Model createFlattenedPom ( File pomFile ) throws MojoExecutionException , MojoFailureException { ModelBuildingRequest buildingRequest = createModelBuildingRequest ( pomFile ) ; Model effectivePom = createEffectivePom ( buildingRequest , isEmbedBuildProfileDependencies ( ) , this . flattenMode ) ; Model flattenedPom = new Model ( ) ; String modelEncoding = effectivePom . getModelEncoding ( ) ; if ( StringUtils . isEmpty ( modelEncoding ) ) { modelEncoding = "UTF-8" ; } flattenedPom . setModelEncoding ( modelEncoding ) ; Model cleanPom = createCleanPom ( effectivePom ) ; FlattenDescriptor descriptor = getFlattenDescriptor ( ) ; Model originalPom = this . project . getOriginalModel ( ) ; Model resolvedPom = this . project . getModel ( ) ; Model interpolatedPom = createResolvedPom ( buildingRequest ) ; for ( PomProperty < ? > property : PomProperty . getPomProperties ( ) ) { if ( property . isElement ( ) ) { Model sourceModel = getSourceModel ( descriptor , property , effectivePom , originalPom , resolvedPom , interpolatedPom , cleanPom ) ; if ( sourceModel == null ) { if ( property . isRequired ( ) ) { throw new MojoFailureException ( "Property " + property . getName ( ) + " is required and can not be removed!" ) ; } } else { property . copy ( sourceModel , flattenedPom ) ; } } } return flattenedPom ; }
This method creates the flattened POM what is the main task of this plugin .
26,366
public final int toCodePoints ( char [ ] src , int srcOff , int srcLen , int [ ] dest , int destOff ) { if ( srcLen < 0 ) { throw new IllegalArgumentException ( "srcLen must be >= 0" ) ; } int codePointCount = 0 ; for ( int i = 0 ; i < srcLen ; ) { final int cp = codePointAt ( src , srcOff + i , srcOff + srcLen ) ; final int charCount = Character . charCount ( cp ) ; dest [ destOff + codePointCount ++ ] = cp ; i += charCount ; } return codePointCount ; }
Converts a sequence of Java characters to a sequence of unicode code points .
26,367
public final int toChars ( int [ ] src , int srcOff , int srcLen , char [ ] dest , int destOff ) { if ( srcLen < 0 ) { throw new IllegalArgumentException ( "srcLen must be >= 0" ) ; } int written = 0 ; for ( int i = 0 ; i < srcLen ; ++ i ) { written += Character . toChars ( src [ srcOff + i ] , dest , destOff + written ) ; } return written ; }
Converts a sequence of unicode code points to a sequence of Java characters .
26,368
public static List < Sentence > splitSentences ( CharSequence text ) { return JavaConversions . seqAsJavaList ( TwitterKoreanProcessor . splitSentences ( text ) ) ; }
Split input text into sentences .
26,369
public static List < KoreanPhraseExtractor . KoreanPhrase > extractPhrases ( Seq < KoreanToken > tokens , boolean filterSpam , boolean includeHashtags ) { return JavaConversions . seqAsJavaList ( TwitterKoreanProcessor . extractPhrases ( tokens , filterSpam , includeHashtags ) ) ; }
Extract phrases from Korean input text
26,370
public static String detokenize ( List < String > tokens ) { return TwitterKoreanProcessor . detokenize ( JavaConversions . iterableAsScalaIterable ( tokens ) ) ; }
Detokenize the input list of words .
26,371
public ConverterServerBuilder baseUri ( String baseUri ) { checkNotNull ( baseUri ) ; this . baseUri = URI . create ( baseUri ) ; return this ; }
Specifies the base URI of this conversion server .
26,372
public ConverterServerBuilder workerPool ( int corePoolSize , int maximumPoolSize , long keepAliveTime , TimeUnit unit ) { assertNumericArgument ( corePoolSize , true ) ; assertNumericArgument ( maximumPoolSize , true ) ; assertNumericArgument ( corePoolSize + maximumPoolSize , false ) ; assertNumericArgument ( keepAliveTime , true ) ; this . corePoolSize = corePoolSize ; this . maximumPoolSize = maximumPoolSize ; this . keepAliveTime = unit . toMillis ( keepAliveTime ) ; return this ; }
Configures a worker pool for the converter .
26,373
public ConverterServerBuilder requestTimeout ( long timeout , TimeUnit unit ) { assertNumericArgument ( timeout , true ) ; this . requestTimeout = unit . toMillis ( timeout ) ; return this ; }
Specifies the timeout for a network request .
26,374
public ConverterServerBuilder processTimeout ( long processTimeout , TimeUnit timeUnit ) { assertNumericArgument ( processTimeout , false ) ; this . processTimeout = timeUnit . toMillis ( processTimeout ) ; return this ; }
Returns the specified process time out in milliseconds .
26,375
public HttpServer build ( ) { checkNotNull ( baseUri ) ; StandaloneWebConverterConfiguration configuration = makeConfiguration ( ) ; ResourceConfig resourceConfig = ResourceConfig . forApplication ( new WebConverterApplication ( configuration ) ) . register ( configuration ) ; if ( sslContext == null ) { return GrizzlyHttpServerFactory . createHttpServer ( baseUri , resourceConfig ) ; } else { return GrizzlyHttpServerFactory . createHttpServer ( baseUri , resourceConfig , true , new SSLEngineConfigurator ( sslContext ) ) ; } }
Creates the conversion server that is specified by this builder .
26,376
public int getParentAdapterPosition ( ) { int flatPosition = getAdapterPosition ( ) ; if ( flatPosition == RecyclerView . NO_POSITION ) { return flatPosition ; } return mExpandableAdapter . getNearestParentPosition ( flatPosition ) ; }
Returns the adapter position of the Parent associated with this ParentViewHolder
26,377
protected void expandView ( ) { setExpanded ( true ) ; onExpansionToggled ( false ) ; if ( mParentViewHolderExpandCollapseListener != null ) { mParentViewHolderExpandCollapseListener . onParentExpanded ( getAdapterPosition ( ) ) ; } }
Triggers expansion of the parent .
26,378
protected void collapseView ( ) { setExpanded ( false ) ; onExpansionToggled ( true ) ; if ( mParentViewHolderExpandCollapseListener != null ) { mParentViewHolderExpandCollapseListener . onParentCollapsed ( getAdapterPosition ( ) ) ; } }
Triggers collapse of the parent .
26,379
protected void parentExpandedFromViewHolder ( int flatParentPosition ) { ExpandableWrapper < P , C > parentWrapper = mFlatItemList . get ( flatParentPosition ) ; updateExpandedParent ( parentWrapper , flatParentPosition , true ) ; }
Called when a ParentViewHolder has triggered an expansion for it s parent
26,380
protected void parentCollapsedFromViewHolder ( int flatParentPosition ) { ExpandableWrapper < P , C > parentWrapper = mFlatItemList . get ( flatParentPosition ) ; updateCollapsedParent ( parentWrapper , flatParentPosition , true ) ; }
Called when a ParentViewHolder has triggered a collapse for it s parent
26,381
public void expandParentRange ( int startParentPosition , int parentCount ) { int endParentPosition = startParentPosition + parentCount ; for ( int i = startParentPosition ; i < endParentPosition ; i ++ ) { expandParent ( i ) ; } }
Expands all parents in a range of indices in the list of parents .
26,382
public void collapseParentRange ( int startParentPosition , int parentCount ) { int endParentPosition = startParentPosition + parentCount ; for ( int i = startParentPosition ; i < endParentPosition ; i ++ ) { collapseParent ( i ) ; } }
Collapses all parents in a range of indices in the list of parents .
26,383
private List < ExpandableWrapper < P , C > > generateFlattenedParentChildList ( List < P > parentList ) { List < ExpandableWrapper < P , C > > flatItemList = new ArrayList < > ( ) ; int parentCount = parentList . size ( ) ; for ( int i = 0 ; i < parentCount ; i ++ ) { P parent = parentList . get ( i ) ; generateParentWrapper ( flatItemList , parent , parent . isInitiallyExpanded ( ) ) ; } return flatItemList ; }
Generates a full list of all parents and their children in order .
26,384
private List < ExpandableWrapper < P , C > > generateFlattenedParentChildList ( List < P > parentList , Map < P , Boolean > savedLastExpansionState ) { List < ExpandableWrapper < P , C > > flatItemList = new ArrayList < > ( ) ; int parentCount = parentList . size ( ) ; for ( int i = 0 ; i < parentCount ; i ++ ) { P parent = parentList . get ( i ) ; Boolean lastExpandedState = savedLastExpansionState . get ( parent ) ; boolean shouldExpand = lastExpandedState == null ? parent . isInitiallyExpanded ( ) : lastExpandedState ; generateParentWrapper ( flatItemList , parent , shouldExpand ) ; } return flatItemList ; }
Generates a full list of all parents and their children in order . Uses Map to preserve last expanded state .
26,385
private HashMap < Integer , Boolean > generateExpandedStateMap ( ) { HashMap < Integer , Boolean > parentHashMap = new HashMap < > ( ) ; int childCount = 0 ; int listItemCount = mFlatItemList . size ( ) ; for ( int i = 0 ; i < listItemCount ; i ++ ) { if ( mFlatItemList . get ( i ) != null ) { ExpandableWrapper < P , C > listItem = mFlatItemList . get ( i ) ; if ( listItem . isParent ( ) ) { parentHashMap . put ( i - childCount , listItem . isExpanded ( ) ) ; } else { childCount ++ ; } } } return parentHashMap ; }
Generates a HashMap used to store expanded state for items in the list on configuration change or whenever onResume is called .
26,386
private int getFlatParentPosition ( int parentPosition ) { int parentCount = 0 ; int listItemCount = mFlatItemList . size ( ) ; for ( int i = 0 ; i < listItemCount ; i ++ ) { if ( mFlatItemList . get ( i ) . isParent ( ) ) { parentCount ++ ; if ( parentCount > parentPosition ) { return i ; } } } return INVALID_FLAT_POSITION ; }
Gets the index of a ExpandableWrapper within the helper item list based on the index of the ExpandableWrapper .
26,387
public int getParentAdapterPosition ( ) { int flatPosition = getAdapterPosition ( ) ; if ( mExpandableAdapter == null || flatPosition == RecyclerView . NO_POSITION ) { return RecyclerView . NO_POSITION ; } return mExpandableAdapter . getNearestParentPosition ( flatPosition ) ; }
Returns the adapter position of the Parent associated with this ChildViewHolder
26,388
public int getChildAdapterPosition ( ) { int flatPosition = getAdapterPosition ( ) ; if ( mExpandableAdapter == null || flatPosition == RecyclerView . NO_POSITION ) { return RecyclerView . NO_POSITION ; } return mExpandableAdapter . getChildPosition ( flatPosition ) ; }
Returns the adapter position of the Child associated with this ChildViewHolder
26,389
public static String fillLogParams ( String sql , Map < Object , Object > logParams ) { StringBuilder result = new StringBuilder ( ) ; Map < Object , Object > tmpLogParam = ( logParams == null ? new HashMap < Object , Object > ( ) : logParams ) ; Iterator < Object > it = tmpLogParam . values ( ) . iterator ( ) ; boolean inQuote = false ; boolean inQuote2 = false ; char [ ] sqlChar = sql != null ? sql . toCharArray ( ) : new char [ ] { } ; for ( int i = 0 ; i < sqlChar . length ; i ++ ) { if ( sqlChar [ i ] == '\'' ) { inQuote = ! inQuote ; } if ( sqlChar [ i ] == '"' ) { inQuote2 = ! inQuote2 ; } if ( sqlChar [ i ] == '?' && ! ( inQuote || inQuote2 ) ) { if ( it . hasNext ( ) ) { result . append ( prettyPrint ( it . next ( ) ) ) ; } else { result . append ( '?' ) ; } } else { result . append ( sqlChar [ i ] ) ; } } return result . toString ( ) ; }
Returns sql statement used in this prepared statement together with the parameters .
26,390
protected static void sendInitSQL ( Connection connection , String initSQL ) throws SQLException { if ( initSQL != null ) { Statement stmt = null ; try { stmt = connection . createStatement ( ) ; stmt . execute ( initSQL ) ; if ( testSupport ) { stmt = null ; } } finally { if ( stmt != null ) { stmt . close ( ) ; } } } }
Sends out the SQL as defined in the config upon first init of the connection .
26,391
public void close ( ) throws SQLException { try { if ( this . resetConnectionOnClose ) { rollback ( ) ; if ( ! getAutoCommit ( ) ) { setAutoCommit ( true ) ; } } if ( this . logicallyClosed . compareAndSet ( false , true ) ) { if ( this . threadWatch != null ) { this . threadWatch . interrupt ( ) ; this . threadWatch = null ; } if ( this . closeOpenStatements ) { for ( Entry < Statement , String > statementEntry : this . trackedStatement . entrySet ( ) ) { statementEntry . getKey ( ) . close ( ) ; if ( this . detectUnclosedStatements ) { logger . warn ( String . format ( UNCLOSED_LOG_ERROR_MESSAGE , statementEntry . getValue ( ) ) ) ; } } this . trackedStatement . clear ( ) ; } if ( ! this . connectionTrackingDisabled ) { pool . getFinalizableRefs ( ) . remove ( this . connection ) ; } ConnectionHandle handle = null ; try { handle = this . recreateConnectionHandle ( ) ; this . pool . connectionStrategy . cleanupConnection ( this , handle ) ; this . pool . releaseConnection ( handle ) ; } catch ( SQLException e ) { if ( ! isClosed ( ) ) { this . pool . connectionStrategy . cleanupConnection ( this , handle ) ; this . pool . releaseConnection ( this ) ; } throw e ; } if ( this . doubleCloseCheck ) { this . doubleCloseException = this . pool . captureStackTrace ( CLOSED_TWICE_EXCEPTION_MESSAGE ) ; } } else { if ( this . doubleCloseCheck && this . doubleCloseException != null ) { String currentLocation = this . pool . captureStackTrace ( "Last closed trace from thread [" + Thread . currentThread ( ) . getName ( ) + "]:\n" ) ; logger . error ( String . format ( LOG_ERROR_MESSAGE , this . doubleCloseException , currentLocation ) ) ; } } } catch ( SQLException e ) { throw markPossiblyBroken ( e ) ; } }
Release the connection back to the pool .
26,392
protected void internalClose ( ) throws SQLException { try { clearStatementCaches ( true ) ; if ( this . connection != null ) { this . connection . close ( ) ; if ( ! this . connectionTrackingDisabled && this . finalizableRefs != null ) { this . finalizableRefs . remove ( this . connection ) ; } } this . logicallyClosed . set ( true ) ; } catch ( SQLException e ) { throw markPossiblyBroken ( e ) ; } }
Close off the connection .
26,393
protected void clearStatementCaches ( boolean internalClose ) { if ( this . statementCachingEnabled ) { if ( internalClose ) { this . callableStatementCache . clear ( ) ; this . preparedStatementCache . clear ( ) ; } else { if ( this . pool . closeConnectionWatch ) { this . callableStatementCache . checkForProperClosure ( ) ; this . preparedStatementCache . checkForProperClosure ( ) ; } } } }
Clears out the statement handles .
26,394
public Object getProxyTarget ( ) { try { return Proxy . getInvocationHandler ( this . connection ) . invoke ( null , this . getClass ( ) . getMethod ( "getProxyTarget" ) , null ) ; } catch ( Throwable t ) { throw new RuntimeException ( "BoneCP: Internal error - transaction replay log is not turned on?" , t ) ; } }
This method will be intercepted by the proxy if it is enabled to return the internal target .
26,395
public void refreshConnection ( ) throws SQLException { this . connection . close ( ) ; try { this . connection = this . pool . obtainRawInternalConnection ( ) ; } catch ( SQLException e ) { throw markPossiblyBroken ( e ) ; } }
Destroys the internal connection handle and creates a new one .
26,396
public void switchDataSource ( BoneCPConfig newConfig ) throws SQLException { logger . info ( "Switch to new datasource requested. New Config: " + newConfig ) ; DataSource oldDS = getTargetDataSource ( ) ; if ( ! ( oldDS instanceof BoneCPDataSource ) ) { throw new SQLException ( "Unknown datasource type! Was expecting BoneCPDataSource but received " + oldDS . getClass ( ) + ". Not switching datasource!" ) ; } BoneCPDataSource newDS = new BoneCPDataSource ( newConfig ) ; newDS . getConnection ( ) . close ( ) ; setTargetDataSource ( newDS ) ; logger . info ( "Shutting down old datasource slowly. Old Config: " + oldDS ) ; ( ( BoneCPDataSource ) oldDS ) . close ( ) ; }
Switch to a new DataSource using the given configuration .
26,397
protected static Connection memorize ( final Connection target , final ConnectionHandle connectionHandle ) { return ( Connection ) Proxy . newProxyInstance ( ConnectionProxy . class . getClassLoader ( ) , new Class [ ] { ConnectionProxy . class } , new MemorizeTransactionProxy ( target , connectionHandle ) ) ; }
Wrap connection with a proxy .
26,398
protected static Statement memorize ( final Statement target , final ConnectionHandle connectionHandle ) { return ( Statement ) Proxy . newProxyInstance ( StatementProxy . class . getClassLoader ( ) , new Class [ ] { StatementProxy . class } , new MemorizeTransactionProxy ( target , connectionHandle ) ) ; }
Wrap Statement with a proxy .
26,399
protected static PreparedStatement memorize ( final PreparedStatement target , final ConnectionHandle connectionHandle ) { return ( PreparedStatement ) Proxy . newProxyInstance ( PreparedStatementProxy . class . getClassLoader ( ) , new Class [ ] { PreparedStatementProxy . class } , new MemorizeTransactionProxy ( target , connectionHandle ) ) ; }
Wrap PreparedStatement with a proxy .