repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/SdkContext.java | SdkContext.delayedEmitAsync | public static <T> Observable<T> delayedEmitAsync(T event, int milliseconds) {
return delayProvider.delayedEmitAsync(event, milliseconds);
} | java | public static <T> Observable<T> delayedEmitAsync(T event, int milliseconds) {
return delayProvider.delayedEmitAsync(event, milliseconds);
} | [
"public",
"static",
"<",
"T",
">",
"Observable",
"<",
"T",
">",
"delayedEmitAsync",
"(",
"T",
"event",
",",
"int",
"milliseconds",
")",
"{",
"return",
"delayProvider",
".",
"delayedEmitAsync",
"(",
"event",
",",
"milliseconds",
")",
";",
"}"
] | Wrapper delayed emission, based on delayProvider.
@param event the event to emit
@param milliseconds the delay in milliseconds
@param <T> the type of event
@return delayed observable | [
"Wrapper",
"delayed",
"emission",
"based",
"on",
"delayProvider",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/utils/SdkContext.java#L101-L103 | train |
Azure/autorest-clientruntime-for-java | azure-client-authentication/src/main/java/com/microsoft/azure/credentials/MSICredentials.java | MSICredentials.withObjectId | @Beta
public MSICredentials withObjectId(String objectId) {
this.objectId = objectId;
this.clientId = null;
this.identityId = null;
return this;
} | java | @Beta
public MSICredentials withObjectId(String objectId) {
this.objectId = objectId;
this.clientId = null;
this.identityId = null;
return this;
} | [
"@",
"Beta",
"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.
@param objectId Object ID of the identity to use when authenticating to Azure AD.
@return MSICredentials | [
"Specifies",
"the",
"object",
"id",
"associated",
"with",
"a",
"user",
"assigned",
"managed",
"service",
"identity",
"resource",
"that",
"should",
"be",
"used",
"to",
"retrieve",
"the",
"access",
"token",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/MSICredentials.java#L89-L95 | train |
Azure/autorest-clientruntime-for-java | azure-client-authentication/src/main/java/com/microsoft/azure/credentials/MSICredentials.java | MSICredentials.withIdentityId | @Beta
public MSICredentials withIdentityId(String identityId) {
this.identityId = identityId;
this.clientId = null;
this.objectId = null;
return this;
} | java | @Beta
public MSICredentials withIdentityId(String identityId) {
this.identityId = identityId;
this.clientId = null;
this.objectId = null;
return this;
} | [
"@",
"Beta",
"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.
@param identityId the ARM resource id of the user assigned identity resource
@return MSICredentials | [
"Specifies",
"the",
"ARM",
"resource",
"id",
"of",
"the",
"user",
"assigned",
"managed",
"service",
"identity",
"resource",
"that",
"should",
"be",
"used",
"to",
"retrieve",
"the",
"access",
"token",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/MSICredentials.java#L119-L125 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/model/implementation/CreatableUpdatableImpl.java | CreatableUpdatableImpl.addPostRunDependent | protected String addPostRunDependent(TaskGroup.HasTaskGroup dependent) {
Objects.requireNonNull(dependent);
this.taskGroup.addPostRunDependentTaskGroup(dependent.taskGroup());
return dependent.taskGroup().key();
} | java | protected String addPostRunDependent(TaskGroup.HasTaskGroup dependent) {
Objects.requireNonNull(dependent);
this.taskGroup.addPostRunDependentTaskGroup(dependent.taskGroup());
return dependent.taskGroup().key();
} | [
"protected",
"String",
"addPostRunDependent",
"(",
"TaskGroup",
".",
"HasTaskGroup",
"dependent",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"dependent",
")",
";",
"this",
".",
"taskGroup",
".",
"addPostRunDependentTaskGroup",
"(",
"dependent",
".",
"taskGroup... | Add a "post-run" dependent for this model.
@param dependent the "post-run" dependent.
@return key to be used as parameter to taskResult(string) method to retrieve result of root
task in the given dependent task group | [
"Add",
"a",
"post",
"-",
"run",
"dependent",
"for",
"this",
"model",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/model/implementation/CreatableUpdatableImpl.java#L166-L170 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java | PollingState.create | 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;
} | java | 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;
} | [
"public",
"static",
"<",
"T",
">",
"PollingState",
"<",
"T",
">",
"create",
"(",
"Response",
"<",
"ResponseBody",
">",
"response",
",",
"LongRunningOperationOptions",
"lroOptions",
",",
"int",
"defaultRetryTimeout",
",",
"Type",
"resourceType",
",",
"SerializerAda... | Creates a polling state.
@param response the response from Retrofit REST call that initiate the long running operation.
@param lroOptions long running operation options.
@param defaultRetryTimeout the long running operation retry timeout.
@param resourceType the type of the resource the long running operation returns
@param serializerAdapter the adapter for the Jackson object mapper
@param <T> the result type
@return the polling state
@throws IOException thrown by deserialization | [
"Creates",
"a",
"polling",
"state",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java#L99-L138 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java | PollingState.createFromJSONString | 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;
} | java | 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;
} | [
"public",
"static",
"<",
"ResultT",
">",
"PollingState",
"<",
"ResultT",
">",
"createFromJSONString",
"(",
"String",
"serializedPollingState",
")",
"{",
"ObjectMapper",
"mapper",
"=",
"initMapper",
"(",
"new",
"ObjectMapper",
"(",
")",
")",
";",
"PollingState",
... | Creates PollingState from the json string.
@param serializedPollingState polling state as json string
@param <ResultT> the result that the poll operation produces
@return the polling state | [
"Creates",
"PollingState",
"from",
"the",
"json",
"string",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java#L147-L156 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java | PollingState.createFromPollingState | 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;
} | java | 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;
} | [
"public",
"static",
"<",
"ResultT",
">",
"PollingState",
"<",
"ResultT",
">",
"createFromPollingState",
"(",
"PollingState",
"<",
"?",
">",
"other",
",",
"ResultT",
"result",
")",
"{",
"PollingState",
"<",
"ResultT",
">",
"pollingState",
"=",
"new",
"PollingSt... | Creates PollingState from another polling state.
@param other other polling state
@param result the final result of the LRO
@param <ResultT> the result that the poll operation produces
@return the polling state | [
"Creates",
"PollingState",
"from",
"another",
"polling",
"state",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java#L166-L180 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java | PollingState.updateFromResponseOnPutPatch | 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));
} | java | 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));
} | [
"void",
"updateFromResponseOnPutPatch",
"(",
"Response",
"<",
"ResponseBody",
">",
"response",
")",
"throws",
"CloudException",
",",
"IOException",
"{",
"String",
"responseContent",
"=",
"null",
";",
"if",
"(",
"response",
".",
"body",
"(",
")",
"!=",
"null",
... | Updates the polling state from a PUT or PATCH operation.
@param response the response from Retrofit REST call
@throws CloudException thrown if the response is invalid
@throws IOException thrown by deserialization | [
"Updates",
"the",
"polling",
"state",
"from",
"a",
"PUT",
"or",
"PATCH",
"operation",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java#L261-L286 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java | PollingState.updateFromResponseOnDeletePost | 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());
} | java | 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());
} | [
"void",
"updateFromResponseOnDeletePost",
"(",
"Response",
"<",
"ResponseBody",
">",
"response",
")",
"throws",
"IOException",
"{",
"this",
".",
"withResponse",
"(",
"response",
")",
";",
"String",
"responseContent",
"=",
"null",
";",
"if",
"(",
"response",
".",... | Updates the polling state from a DELETE or POST operation.
@param response the response from Retrofit REST call
@throws IOException thrown by deserialization | [
"Updates",
"the",
"polling",
"state",
"from",
"a",
"DELETE",
"or",
"POST",
"operation",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java#L295-L304 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java | PollingState.withStatus | 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;
} | java | 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;
} | [
"PollingState",
"<",
"T",
">",
"withStatus",
"(",
"String",
"status",
",",
"int",
"statusCode",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"status",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Status is null.\"",
"... | Sets the polling status.
@param status the polling status.
@param statusCode the HTTP status code
@throws IllegalArgumentException thrown if status is null. | [
"Sets",
"the",
"polling",
"status",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java#L399-L406 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java | PollingState.withResponse | PollingState<T> withResponse(Response<ResponseBody> response) {
this.response = response;
withPollingUrlFromResponse(response);
withPollingRetryTimeoutFromResponse(response);
return this;
} | java | PollingState<T> withResponse(Response<ResponseBody> response) {
this.response = response;
withPollingUrlFromResponse(response);
withPollingRetryTimeoutFromResponse(response);
return this;
} | [
"PollingState",
"<",
"T",
">",
"withResponse",
"(",
"Response",
"<",
"ResponseBody",
">",
"response",
")",
"{",
"this",
".",
"response",
"=",
"response",
";",
"withPollingUrlFromResponse",
"(",
"response",
")",
";",
"withPollingRetryTimeoutFromResponse",
"(",
"res... | Sets the last operation response.
@param response the last operation response. | [
"Sets",
"the",
"last",
"operation",
"response",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java#L413-L418 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java | PollingState.throwCloudExceptionIfInFailedState | 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());
}
}
} | java | 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());
}
}
} | [
"void",
"throwCloudExceptionIfInFailedState",
"(",
")",
"{",
"if",
"(",
"this",
".",
"isStatusFailed",
"(",
")",
")",
"{",
"if",
"(",
"this",
".",
"errorBody",
"(",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"CloudException",
"(",
"\"Async operation failed... | If status is in failed state then throw CloudException. | [
"If",
"status",
"is",
"in",
"failed",
"state",
"then",
"throw",
"CloudException",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/PollingState.java#L538-L546 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/AzureAsyncOperation.java | AzureAsyncOperation.fromResponse | 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) {
// Exception will be handled below
} 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;
} | java | 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) {
// Exception will be handled below
} 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;
} | [
"static",
"AzureAsyncOperation",
"fromResponse",
"(",
"SerializerAdapter",
"<",
"?",
">",
"serializerAdapter",
",",
"Response",
"<",
"ResponseBody",
">",
"response",
")",
"throws",
"CloudException",
"{",
"AzureAsyncOperation",
"asyncOperation",
"=",
"null",
";",
"Stri... | Creates AzureAsyncOperation from the given HTTP response.
@param serializerAdapter the adapter to use for deserialization
@param response the response
@return the async operation object
@throws CloudException if the deserialization fails or response contains invalid body | [
"Creates",
"AzureAsyncOperation",
"from",
"the",
"given",
"HTTP",
"response",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/AzureAsyncOperation.java#L134-L154 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/Node.java | Node.setOwner | public void setOwner(Graph<DataT, NodeT> ownerGraph) {
if (this.ownerGraph != null) {
throw new RuntimeException("Changing owner graph is not allowed");
}
this.ownerGraph = ownerGraph;
} | java | public void setOwner(Graph<DataT, NodeT> ownerGraph) {
if (this.ownerGraph != null) {
throw new RuntimeException("Changing owner graph is not allowed");
}
this.ownerGraph = ownerGraph;
} | [
"public",
"void",
"setOwner",
"(",
"Graph",
"<",
"DataT",
",",
"NodeT",
">",
"ownerGraph",
")",
"{",
"if",
"(",
"this",
".",
"ownerGraph",
"!=",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Changing owner graph is not allowed\"",
")",
";",
"... | Sets reference to the graph owning this node.
@param ownerGraph the owning graph | [
"Sets",
"reference",
"to",
"the",
"graph",
"owning",
"this",
"node",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/Node.java#L96-L101 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGNode.java | DAGNode.onFaultedResolution | 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--;
} | java | 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--;
} | [
"protected",
"void",
"onFaultedResolution",
"(",
"String",
"dependencyKey",
",",
"Throwable",
"throwable",
")",
"{",
"if",
"(",
"toBeResolved",
"==",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"invalid state - \"",
"+",
"this",
".",
"key",
"(",
... | Reports a dependency of this node has been faulted.
@param dependencyKey the id of the dependency node
@param throwable the reason for unsuccessful resolution | [
"Reports",
"a",
"dependency",
"of",
"this",
"node",
"has",
"been",
"faulted",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/DAGNode.java#L154-L159 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceClient.java | AzureServiceClient.userAgent | 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);
} | java | 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);
} | [
"public",
"String",
"userAgent",
"(",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"Azure-SDK-For-Java/%s OS:%s MacAddressHash:%s Java:%s\"",
",",
"getClass",
"(",
")",
".",
"getPackage",
"(",
")",
".",
"getImplementationVersion",
"(",
")",
",",
"OS",
",",
... | The default User-Agent header. Override this method to override the user agent.
@return the user agent string. | [
"The",
"default",
"User",
"-",
"Agent",
"header",
".",
"Override",
"this",
"method",
"to",
"override",
"the",
"user",
"agent",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceClient.java#L59-L65 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java | ResourceUtilsCore.groupFromResourceId | public static String groupFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).resourceGroupName() : null;
} | java | public static String groupFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).resourceGroupName() : null;
} | [
"public",
"static",
"String",
"groupFromResourceId",
"(",
"String",
"id",
")",
"{",
"return",
"(",
"id",
"!=",
"null",
")",
"?",
"ResourceId",
".",
"fromString",
"(",
"id",
")",
".",
"resourceGroupName",
"(",
")",
":",
"null",
";",
"}"
] | Extract resource group from a resource ID string.
@param id the resource ID string
@return the resource group name | [
"Extract",
"resource",
"group",
"from",
"a",
"resource",
"ID",
"string",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java#L23-L25 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java | ResourceUtilsCore.subscriptionFromResourceId | public static String subscriptionFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).subscriptionId() : null;
} | java | public static String subscriptionFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).subscriptionId() : null;
} | [
"public",
"static",
"String",
"subscriptionFromResourceId",
"(",
"String",
"id",
")",
"{",
"return",
"(",
"id",
"!=",
"null",
")",
"?",
"ResourceId",
".",
"fromString",
"(",
"id",
")",
".",
"subscriptionId",
"(",
")",
":",
"null",
";",
"}"
] | Extract the subscription ID from a resource ID string.
@param id the resource ID string
@return the subscription ID | [
"Extract",
"the",
"subscription",
"ID",
"from",
"a",
"resource",
"ID",
"string",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java#L32-L34 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java | ResourceUtilsCore.resourceProviderFromResourceId | public static String resourceProviderFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).providerNamespace() : null;
} | java | public static String resourceProviderFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).providerNamespace() : null;
} | [
"public",
"static",
"String",
"resourceProviderFromResourceId",
"(",
"String",
"id",
")",
"{",
"return",
"(",
"id",
"!=",
"null",
")",
"?",
"ResourceId",
".",
"fromString",
"(",
"id",
")",
".",
"providerNamespace",
"(",
")",
":",
"null",
";",
"}"
] | Extract resource provider from a resource ID string.
@param id the resource ID string
@return the resource group name | [
"Extract",
"resource",
"provider",
"from",
"a",
"resource",
"ID",
"string",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java#L41-L43 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java | ResourceUtilsCore.resourceTypeFromResourceId | public static String resourceTypeFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).resourceType() : null;
} | java | public static String resourceTypeFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).resourceType() : null;
} | [
"public",
"static",
"String",
"resourceTypeFromResourceId",
"(",
"String",
"id",
")",
"{",
"return",
"(",
"id",
"!=",
"null",
")",
"?",
"ResourceId",
".",
"fromString",
"(",
"id",
")",
".",
"resourceType",
"(",
")",
":",
"null",
";",
"}"
] | Extract resource type from a resource ID string.
@param id the resource ID string
@return the resource type | [
"Extract",
"resource",
"type",
"from",
"a",
"resource",
"ID",
"string",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java#L50-L52 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java | ResourceUtilsCore.extractFromResourceId | 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;
}
} | java | 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;
}
} | [
"public",
"static",
"String",
"extractFromResourceId",
"(",
"String",
"id",
",",
"String",
"identifier",
")",
"{",
"if",
"(",
"id",
"==",
"null",
"||",
"identifier",
"==",
"null",
")",
"{",
"return",
"id",
";",
"}",
"Pattern",
"pattern",
"=",
"Pattern",
... | Extract information from a resource ID string with the resource type
as the identifier.
@param id the resource ID
@param identifier the identifier to match, e.g. "resourceGroups", "storageAccounts"
@return the information extracted from the identifier | [
"Extract",
"information",
"from",
"a",
"resource",
"ID",
"string",
"with",
"the",
"resource",
"type",
"as",
"the",
"identifier",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java#L121-L132 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java | ResourceUtilsCore.nameFromResourceId | public static String nameFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).name() : null;
} | java | public static String nameFromResourceId(String id) {
return (id != null) ? ResourceId.fromString(id).name() : null;
} | [
"public",
"static",
"String",
"nameFromResourceId",
"(",
"String",
"id",
")",
"{",
"return",
"(",
"id",
"!=",
"null",
")",
"?",
"ResourceId",
".",
"fromString",
"(",
"id",
")",
".",
"name",
"(",
")",
":",
"null",
";",
"}"
] | Extract name of the resource from a resource ID.
@param id the resource ID
@return the name of the resource | [
"Extract",
"name",
"of",
"the",
"resource",
"from",
"a",
"resource",
"ID",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java#L139-L141 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java | ResourceUtilsCore.constructResourceId | 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);
} | java | 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);
} | [
"public",
"static",
"String",
"constructResourceId",
"(",
"final",
"String",
"subscriptionId",
",",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"resourceProviderNamespace",
",",
"final",
"String",
"resourceType",
",",
"final",
"String",
"resourceName... | Creates a resource ID from information of a generic resource.
@param subscriptionId the subscription UUID
@param resourceGroupName the resource group name
@param resourceProviderNamespace the resource provider namespace
@param resourceType the type of the resource or nested resource
@param resourceName name of the resource or nested resource
@param parentResourcePath parent resource's relative path to the provider,
if the resource is a generic resource
@return the resource ID string | [
"Creates",
"a",
"resource",
"ID",
"from",
"information",
"of",
"a",
"generic",
"resource",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/ResourceUtilsCore.java#L155-L174 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java | AzureClient.getPutOrPatchResult | 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();
} | java | 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();
} | [
"private",
"<",
"T",
">",
"ServiceResponse",
"<",
"T",
">",
"getPutOrPatchResult",
"(",
"Observable",
"<",
"Response",
"<",
"ResponseBody",
">",
">",
"observable",
",",
"Type",
"resourceType",
")",
"throws",
"CloudException",
",",
"InterruptedException",
",",
"I... | Handles an initial response from a PUT or PATCH operation response by polling
the status of the operation until the long running operation terminates.
@param observable the initial observable from the PUT or PATCH operation.
@param <T> the return type of the caller
@param resourceType the java.lang.reflect.Type of the resource.
@return the terminal response for the operation.
@throws CloudException REST exception
@throws InterruptedException interrupted exception
@throws IOException thrown by deserialization | [
"Handles",
"an",
"initial",
"response",
"from",
"a",
"PUT",
"or",
"PATCH",
"operation",
"response",
"by",
"polling",
"the",
"status",
"of",
"the",
"operation",
"until",
"the",
"long",
"running",
"operation",
"terminates",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java#L88-L91 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java | AzureClient.getPutOrPatchResultAsync | 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>>>() {
@Override
public Observable<PollingState<T>> call(PollingState<T> pollingState) {
return pollPutOrPatchAsync(pollingState, resourceType);
}
})
.last()
.map(new Func1<PollingState<T>, ServiceResponse<T>>() {
@Override
public ServiceResponse<T> call(PollingState<T> pollingState) {
return new ServiceResponse<>(pollingState.resource(), pollingState.response());
}
});
} | java | 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>>>() {
@Override
public Observable<PollingState<T>> call(PollingState<T> pollingState) {
return pollPutOrPatchAsync(pollingState, resourceType);
}
})
.last()
.map(new Func1<PollingState<T>, ServiceResponse<T>>() {
@Override
public ServiceResponse<T> call(PollingState<T> pollingState) {
return new ServiceResponse<>(pollingState.resource(), pollingState.response());
}
});
} | [
"public",
"<",
"T",
">",
"Observable",
"<",
"ServiceResponse",
"<",
"T",
">",
">",
"getPutOrPatchResultAsync",
"(",
"Observable",
"<",
"Response",
"<",
"ResponseBody",
">",
">",
"observable",
",",
"final",
"Type",
"resourceType",
")",
"{",
"return",
"this",
... | 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.
@param observable the initial observable from the PUT or PATCH operation.
@param resourceType the java.lang.reflect.Type of the resource.
@param <T> the return type of the caller.
@return the observable of which a subscription will lead to a final 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",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java#L125-L141 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java | AzureClient.updateStateFromLocationHeaderOnPutAsync | private <T> Observable<PollingState<T>> updateStateFromLocationHeaderOnPutAsync(final PollingState<T> pollingState) {
return pollAsync(pollingState.locationHeaderLink(), pollingState.loggingContext())
.flatMap(new Func1<Response<ResponseBody>, Observable<PollingState<T>>>() {
@Override
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);
}
});
} | java | private <T> Observable<PollingState<T>> updateStateFromLocationHeaderOnPutAsync(final PollingState<T> pollingState) {
return pollAsync(pollingState.locationHeaderLink(), pollingState.loggingContext())
.flatMap(new Func1<Response<ResponseBody>, Observable<PollingState<T>>>() {
@Override
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);
}
});
} | [
"private",
"<",
"T",
">",
"Observable",
"<",
"PollingState",
"<",
"T",
">",
">",
"updateStateFromLocationHeaderOnPutAsync",
"(",
"final",
"PollingState",
"<",
"T",
">",
"pollingState",
")",
"{",
"return",
"pollAsync",
"(",
"pollingState",
".",
"locationHeaderLink"... | Polls from the location header and updates the polling state with the
polling response for a PUT operation.
@param pollingState the polling state for the current operation.
@param <T> the return type of the caller. | [
"Polls",
"from",
"the",
"location",
"header",
"and",
"updates",
"the",
"polling",
"state",
"with",
"the",
"polling",
"response",
"for",
"a",
"PUT",
"operation",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java#L564-L583 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java | AzureClient.updateStateFromGetResourceOperationAsync | 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>>>() {
@Override
public Observable<PollingState<T>> call(Response<ResponseBody> response) {
try {
pollingState.updateFromResponseOnPutPatch(response);
return Observable.just(pollingState);
} catch (CloudException | IOException e) {
return Observable.error(e);
}
}
});
} | java | 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>>>() {
@Override
public Observable<PollingState<T>> call(Response<ResponseBody> response) {
try {
pollingState.updateFromResponseOnPutPatch(response);
return Observable.just(pollingState);
} catch (CloudException | IOException e) {
return Observable.error(e);
}
}
});
} | [
"private",
"<",
"T",
">",
"Observable",
"<",
"PollingState",
"<",
"T",
">",
">",
"updateStateFromGetResourceOperationAsync",
"(",
"final",
"PollingState",
"<",
"T",
">",
"pollingState",
",",
"String",
"url",
")",
"{",
"return",
"pollAsync",
"(",
"url",
",",
... | Polls from the provided URL and updates the polling state with the
polling response.
@param pollingState the polling state for the current operation.
@param url the url to poll from
@param <T> the return type of the caller. | [
"Polls",
"from",
"the",
"provided",
"URL",
"and",
"updates",
"the",
"polling",
"state",
"with",
"the",
"polling",
"response",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java#L621-L634 | train |
Azure/autorest-clientruntime-for-java | azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java | AzureClient.pollAsync | 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>>>() {
@Override
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);
}
}
});
} | java | 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>>>() {
@Override
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);
}
}
});
} | [
"private",
"Observable",
"<",
"Response",
"<",
"ResponseBody",
">",
">",
"pollAsync",
"(",
"String",
"url",
",",
"String",
"loggingContext",
")",
"{",
"URL",
"endpoint",
";",
"try",
"{",
"endpoint",
"=",
"new",
"URL",
"(",
"url",
")",
";",
"}",
"catch",
... | Polls from the URL provided.
@param url the URL to poll from.
@return the raw response. | [
"Polls",
"from",
"the",
"URL",
"provided",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java#L701-L724 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java | TaskGroup.taskResult | 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");
} | java | 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");
} | [
"public",
"Indexable",
"taskResult",
"(",
"String",
"taskId",
")",
"{",
"TaskGroupEntry",
"<",
"TaskItem",
">",
"taskGroupEntry",
"=",
"super",
".",
"getNode",
"(",
"taskId",
")",
";",
"if",
"(",
"taskGroupEntry",
"!=",
"null",
")",
"{",
"return",
"taskGroup... | Retrieve the result produced by a task with the given id in the group.
This method can be used to retrieve the result of invocation of both dependency
and "post-run" dependent tasks. If task with the given id does not exists then
IllegalArgumentException exception will be thrown.
@param taskId the task item id
@return the task result, null will be returned if task has not yet been invoked | [
"Retrieve",
"the",
"result",
"produced",
"by",
"a",
"task",
"with",
"the",
"given",
"id",
"in",
"the",
"group",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java#L124-L137 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java | TaskGroup.addDependency | public String addDependency(FunctionalTaskItem dependencyTaskItem) {
IndexableTaskItem dependency = IndexableTaskItem.create(dependencyTaskItem);
this.addDependency(dependency);
return dependency.key();
} | java | public String addDependency(FunctionalTaskItem dependencyTaskItem) {
IndexableTaskItem dependency = IndexableTaskItem.create(dependencyTaskItem);
this.addDependency(dependency);
return dependency.key();
} | [
"public",
"String",
"addDependency",
"(",
"FunctionalTaskItem",
"dependencyTaskItem",
")",
"{",
"IndexableTaskItem",
"dependency",
"=",
"IndexableTaskItem",
".",
"create",
"(",
"dependencyTaskItem",
")",
";",
"this",
".",
"addDependency",
"(",
"dependency",
")",
";",
... | 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.
@param dependencyTaskItem the task item that this task group depends on
@return the key of the dependency | [
"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",
... | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java#L164-L168 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java | TaskGroup.addDependencyTaskGroup | public void addDependencyTaskGroup(TaskGroup dependencyTaskGroup) {
if (dependencyTaskGroup.proxyTaskGroupWrapper.isActive()) {
dependencyTaskGroup.proxyTaskGroupWrapper.addDependentTaskGroup(this);
} else {
DAGraph<TaskItem, TaskGroupEntry<TaskItem>> dependencyGraph = dependencyTaskGroup;
super.addDependencyGraph(dependencyGraph);
}
} | java | public void addDependencyTaskGroup(TaskGroup dependencyTaskGroup) {
if (dependencyTaskGroup.proxyTaskGroupWrapper.isActive()) {
dependencyTaskGroup.proxyTaskGroupWrapper.addDependentTaskGroup(this);
} else {
DAGraph<TaskItem, TaskGroupEntry<TaskItem>> dependencyGraph = dependencyTaskGroup;
super.addDependencyGraph(dependencyGraph);
}
} | [
"public",
"void",
"addDependencyTaskGroup",
"(",
"TaskGroup",
"dependencyTaskGroup",
")",
"{",
"if",
"(",
"dependencyTaskGroup",
".",
"proxyTaskGroupWrapper",
".",
"isActive",
"(",
")",
")",
"{",
"dependencyTaskGroup",
".",
"proxyTaskGroupWrapper",
".",
"addDependentTas... | 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.
@param dependencyTaskGroup the task group that this task group depends on | [
"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",
... | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java#L188-L195 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java | TaskGroup.addPostRunDependent | public String addPostRunDependent(FunctionalTaskItem dependentTaskItem) {
IndexableTaskItem taskItem = IndexableTaskItem.create(dependentTaskItem);
this.addPostRunDependent(taskItem);
return taskItem.key();
} | java | public String addPostRunDependent(FunctionalTaskItem dependentTaskItem) {
IndexableTaskItem taskItem = IndexableTaskItem.create(dependentTaskItem);
this.addPostRunDependent(taskItem);
return taskItem.key();
} | [
"public",
"String",
"addPostRunDependent",
"(",
"FunctionalTaskItem",
"dependentTaskItem",
")",
"{",
"IndexableTaskItem",
"taskItem",
"=",
"IndexableTaskItem",
".",
"create",
"(",
"dependentTaskItem",
")",
";",
"this",
".",
"addPostRunDependent",
"(",
"taskItem",
")",
... | Mark the given TaskItem depends on this taskGroup.
@param dependentTaskItem the task item that depends on this task group
@return key to be used as parameter to taskResult(string) method to retrieve result of
invocation of given task item. | [
"Mark",
"the",
"given",
"TaskItem",
"depends",
"on",
"this",
"taskGroup",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java#L204-L208 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java | TaskGroup.invokeReadyTasksAsync | private Observable<Indexable> invokeReadyTasksAsync(final InvocationContext context) {
TaskGroupEntry<TaskItem> readyTaskEntry = super.getNext();
final List<Observable<Indexable>> observables = new ArrayList<>();
// Enumerate the ready tasks (those with dependencies resolved) and kickoff them concurrently
//
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);
} | java | private Observable<Indexable> invokeReadyTasksAsync(final InvocationContext context) {
TaskGroupEntry<TaskItem> readyTaskEntry = super.getNext();
final List<Observable<Indexable>> observables = new ArrayList<>();
// Enumerate the ready tasks (those with dependencies resolved) and kickoff them concurrently
//
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);
} | [
"private",
"Observable",
"<",
"Indexable",
">",
"invokeReadyTasksAsync",
"(",
"final",
"InvocationContext",
"context",
")",
"{",
"TaskGroupEntry",
"<",
"TaskItem",
">",
"readyTaskEntry",
"=",
"super",
".",
"getNext",
"(",
")",
";",
"final",
"List",
"<",
"Observa... | Invokes the ready tasks.
@param context group level shared context that need be passed to
{@link TaskGroupEntry#invokeTaskAsync(boolean, InvocationContext)}
method of each entry in the group when it is selected for execution
@return an observable that emits the result of tasks in the order they finishes. | [
"Invokes",
"the",
"ready",
"tasks",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java#L349-L365 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java | TaskGroup.processFaultedTaskAsync | 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);
}
} | java | 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);
}
} | [
"private",
"Observable",
"<",
"Indexable",
">",
"processFaultedTaskAsync",
"(",
"final",
"TaskGroupEntry",
"<",
"TaskItem",
">",
"faultedEntry",
",",
"final",
"Throwable",
"throwable",
",",
"final",
"InvocationContext",
"context",
")",
"{",
"markGroupAsCancelledIfTermin... | Handles a faulted task.
@param faultedEntry the entry holding faulted task
@param throwable the reason for fault
@param context the context object shared across all the task entries in this group during execution
@return an observable represents asynchronous operation in the next stage | [
"Handles",
"a",
"faulted",
"task",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/TaskGroup.java#L502-L517 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/retry/ExponentialBackoffRetryStrategy.java | ExponentialBackoffRetryStrategy.shouldRetry | @Override
public boolean shouldRetry(int retryCount, Response response) {
int code = response.code();
//CHECKSTYLE IGNORE MagicNumber FOR NEXT 2 LINES
return retryCount < this.retryCount
&& (code == 408 || (code >= 500 && code != 501 && code != 505));
} | java | @Override
public boolean shouldRetry(int retryCount, Response response) {
int code = response.code();
//CHECKSTYLE IGNORE MagicNumber FOR NEXT 2 LINES
return retryCount < this.retryCount
&& (code == 408 || (code >= 500 && code != 501 && code != 505));
} | [
"@",
"Override",
"public",
"boolean",
"shouldRetry",
"(",
"int",
"retryCount",
",",
"Response",
"response",
")",
"{",
"int",
"code",
"=",
"response",
".",
"code",
"(",
")",
";",
"//CHECKSTYLE IGNORE MagicNumber FOR NEXT 2 LINES",
"return",
"retryCount",
"<",
"this... | Returns if a request should be retried based on the retry count, current response,
and the current strategy.
@param retryCount The current retry attempt count.
@param response The exception that caused the retry conditions to occur.
@return true if the request should be retried; false otherwise. | [
"Returns",
"if",
"a",
"request",
"should",
"be",
"retried",
"based",
"on",
"the",
"retry",
"count",
"current",
"response",
"and",
"the",
"current",
"strategy",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/retry/ExponentialBackoffRetryStrategy.java#L98-L104 | train |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/RestClient.java | RestClient.close | @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();
}
} | java | @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();
}
} | [
"@",
"Beta",
"(",
"SinceVersion",
".",
"V1_1_0",
")",
"public",
"void",
"close",
"(",
")",
"{",
"httpClient",
".",
"dispatcher",
"(",
")",
".",
"executorService",
"(",
")",
".",
"shutdown",
"(",
")",
";",
"httpClient",
".",
"connectionPool",
"(",
")",
... | Closes the HTTP client and recycles the resources associated. The threads will
be recycled after 60 seconds of inactivity. | [
"Closes",
"the",
"HTTP",
"client",
"and",
"recycles",
"the",
"resources",
"associated",
".",
"The",
"threads",
"will",
"be",
"recycled",
"after",
"60",
"seconds",
"of",
"inactivity",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/RestClient.java#L128-L138 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ReadableWrappersImpl.java | ReadableWrappersImpl.convertToPagedList | 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) {
@Override
public Page<InnerT> nextPage(String nextPageLink) {
return null;
}
};
} | java | 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) {
@Override
public Page<InnerT> nextPage(String nextPageLink) {
return null;
}
};
} | [
"public",
"static",
"<",
"InnerT",
">",
"PagedList",
"<",
"InnerT",
">",
"convertToPagedList",
"(",
"List",
"<",
"InnerT",
">",
"list",
")",
"{",
"PageImpl",
"<",
"InnerT",
">",
"page",
"=",
"new",
"PageImpl",
"<>",
"(",
")",
";",
"page",
".",
"setItem... | Converts the List to PagedList.
@param list list to be converted in to paged list
@param <InnerT> the wrapper inner type
@return the Paged list for the inner type. | [
"Converts",
"the",
"List",
"to",
"PagedList",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ReadableWrappersImpl.java#L55-L65 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ReadableWrappersImpl.java | ReadableWrappersImpl.convertListToInnerAsync | public static <InnerT> Observable<InnerT> convertListToInnerAsync(Observable<List<InnerT>> innerList) {
return innerList.flatMap(new Func1<List<InnerT>, Observable<InnerT>>() {
@Override
public Observable<InnerT> call(List<InnerT> inners) {
return Observable.from(inners);
}
});
} | java | public static <InnerT> Observable<InnerT> convertListToInnerAsync(Observable<List<InnerT>> innerList) {
return innerList.flatMap(new Func1<List<InnerT>, Observable<InnerT>>() {
@Override
public Observable<InnerT> call(List<InnerT> inners) {
return Observable.from(inners);
}
});
} | [
"public",
"static",
"<",
"InnerT",
">",
"Observable",
"<",
"InnerT",
">",
"convertListToInnerAsync",
"(",
"Observable",
"<",
"List",
"<",
"InnerT",
">",
">",
"innerList",
")",
"{",
"return",
"innerList",
".",
"flatMap",
"(",
"new",
"Func1",
"<",
"List",
"<... | Converts Observable of list to Observable of Inner.
@param innerList list to be converted.
@param <InnerT> type of inner.
@return Observable for list of inner. | [
"Converts",
"Observable",
"of",
"list",
"to",
"Observable",
"of",
"Inner",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ReadableWrappersImpl.java#L82-L89 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ReadableWrappersImpl.java | ReadableWrappersImpl.convertPageToInnerAsync | public static <InnerT> Observable<InnerT> convertPageToInnerAsync(Observable<Page<InnerT>> innerPage) {
return innerPage.flatMap(new Func1<Page<InnerT>, Observable<InnerT>>() {
@Override
public Observable<InnerT> call(Page<InnerT> pageInner) {
return Observable.from(pageInner.items());
}
});
} | java | public static <InnerT> Observable<InnerT> convertPageToInnerAsync(Observable<Page<InnerT>> innerPage) {
return innerPage.flatMap(new Func1<Page<InnerT>, Observable<InnerT>>() {
@Override
public Observable<InnerT> call(Page<InnerT> pageInner) {
return Observable.from(pageInner.items());
}
});
} | [
"public",
"static",
"<",
"InnerT",
">",
"Observable",
"<",
"InnerT",
">",
"convertPageToInnerAsync",
"(",
"Observable",
"<",
"Page",
"<",
"InnerT",
">",
">",
"innerPage",
")",
"{",
"return",
"innerPage",
".",
"flatMap",
"(",
"new",
"Func1",
"<",
"Page",
"<... | Converts Observable of page to Observable of Inner.
@param <InnerT> type of inner.
@param innerPage Page to be converted.
@return Observable for list of inner. | [
"Converts",
"Observable",
"of",
"page",
"to",
"Observable",
"of",
"Inner",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/resources/collection/implementation/ReadableWrappersImpl.java#L97-L104 | train |
Azure/autorest-clientruntime-for-java | azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/PostRunTaskCollection.java | PostRunTaskCollection.add | public void add(final IndexableTaskItem taskItem) {
this.dependsOnTaskGroup.addPostRunDependentTaskGroup(taskItem.taskGroup());
this.collection.add(taskItem);
} | java | public void add(final IndexableTaskItem taskItem) {
this.dependsOnTaskGroup.addPostRunDependentTaskGroup(taskItem.taskGroup());
this.collection.add(taskItem);
} | [
"public",
"void",
"add",
"(",
"final",
"IndexableTaskItem",
"taskItem",
")",
"{",
"this",
".",
"dependsOnTaskGroup",
".",
"addPostRunDependentTaskGroup",
"(",
"taskItem",
".",
"taskGroup",
"(",
")",
")",
";",
"this",
".",
"collection",
".",
"add",
"(",
"taskIt... | Adds a "Post Run" task to the collection.
@param taskItem the "Post Run" task | [
"Adds",
"a",
"Post",
"Run",
"task",
"to",
"the",
"collection",
"."
] | 04621e07dbb0456dd5459dd641f06a9fd4f3abad | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/azure-arm-client-runtime/src/main/java/com/microsoft/azure/arm/dag/PostRunTaskCollection.java#L36-L39 | train |
aol/micro-server | micro-s3/src/main/java/com/oath/micro/server/s3/data/S3ObjectWriter.java | S3ObjectWriter.putAsync | 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()));
} | java | 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()));
} | [
"public",
"Eval",
"<",
"UploadResult",
">",
"putAsync",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"return",
"Eval",
".",
"later",
"(",
"(",
")",
"->",
"put",
"(",
"key",
",",
"value",
")",
")",
".",
"map",
"(",
"t",
"->",
"t",
".",
... | Non-blocking call that will throw any Exceptions in the traditional
manner on access
@param key
@param value
@return | [
"Non",
"-",
"blocking",
"call",
"that",
"will",
"throw",
"any",
"Exceptions",
"in",
"the",
"traditional",
"manner",
"on",
"access"
] | 5c7103c5b43d2f4d16350dbd2f9802af307c63f7 | https://github.com/aol/micro-server/blob/5c7103c5b43d2f4d16350dbd2f9802af307c63f7/micro-s3/src/main/java/com/oath/micro/server/s3/data/S3ObjectWriter.java#L123-L128 | train |
aol/micro-server | micro-s3/src/main/java/com/oath/micro/server/s3/data/S3StringWriter.java | S3StringWriter.putAsync | 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)));
} | java | 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)));
} | [
"public",
"Future",
"<",
"PutObjectResult",
">",
"putAsync",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"return",
"Future",
".",
"of",
"(",
"(",
")",
"->",
"put",
"(",
"key",
",",
"value",
")",
",",
"this",
".",
"uploadService",
")",
"."... | Non-blocking call
@param key
@param value
@return | [
"Non",
"-",
"blocking",
"call"
] | 5c7103c5b43d2f4d16350dbd2f9802af307c63f7 | https://github.com/aol/micro-server/blob/5c7103c5b43d2f4d16350dbd2f9802af307c63f7/micro-s3/src/main/java/com/oath/micro/server/s3/data/S3StringWriter.java#L59-L62 | train |
aol/micro-server | micro-events/src/main/java/com/oath/micro/server/events/LabelledEvents.java | LabelledEvents.finish | 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);
}
} | java | 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);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"finish",
"(",
"T",
"query",
",",
"long",
"correlationId",
",",
"EventBus",
"bus",
",",
"String",
"...",
"labels",
")",
"{",
"for",
"(",
"String",
"type",
":",
"labels",
")",
"{",
"RemoveLabelledQuery",
"<",
"... | Publish finish events for each of the specified query labels
<pre>
{@code
LabelledEvents.start("get", 1l, bus, "typeA", "custom");
try {
return "ok";
} finally {
RequestEvents.finish("get", 1l, bus, "typeA", "custom");
}
}
</pre>
@param query Completed query
@param correlationId Identifier
@param bus EventBus to post events to
@param labels Query types to post to event bus | [
"Publish",
"finish",
"events",
"for",
"each",
"of",
"the",
"specified",
"query",
"labels"
] | 5c7103c5b43d2f4d16350dbd2f9802af307c63f7 | https://github.com/aol/micro-server/blob/5c7103c5b43d2f4d16350dbd2f9802af307c63f7/micro-events/src/main/java/com/oath/micro/server/events/LabelledEvents.java#L96-L101 | train |
aol/micro-server | micro-events/src/main/java/com/oath/micro/server/events/RequestEvents.java | RequestEvents.start | public static <T> AddQuery<T> start(T query, long correlationId) {
return start(query, correlationId, "default", null);
} | java | public static <T> AddQuery<T> start(T query, long correlationId) {
return start(query, correlationId, "default", null);
} | [
"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
@param query - Query data
@param correlationId - Identifier
@return Start event to pass to the Events systems EventBus | [
"Marks",
"the",
"start",
"of",
"a",
"query",
"identified",
"by",
"the",
"provided",
"correlationId"
] | 5c7103c5b43d2f4d16350dbd2f9802af307c63f7 | https://github.com/aol/micro-server/blob/5c7103c5b43d2f4d16350dbd2f9802af307c63f7/micro-events/src/main/java/com/oath/micro/server/events/RequestEvents.java#L23-L25 | train |
aol/micro-server | micro-events/src/main/java/com/oath/micro/server/events/RequestEvents.java | RequestEvents.finish | 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);
}
} | java | 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);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"finish",
"(",
"T",
"query",
",",
"long",
"correlationId",
",",
"EventBus",
"bus",
",",
"String",
"...",
"types",
")",
"{",
"for",
"(",
"String",
"type",
":",
"types",
")",
"{",
"RemoveQuery",
"<",
"T",
">",... | Publish finish events for each of the specified query types
<pre>
{@code
RequestEvents.start("get", 1l, bus, "typeA", "custom");
try {
return "ok";
} finally {
RequestEvents.finish("get", 1l, bus, "typeA", "custom");
}
}
</pre>
@param query Completed query
@param correlationId Identifier
@param bus EventBus to post events to
@param types Query types to post to event bus | [
"Publish",
"finish",
"events",
"for",
"each",
"of",
"the",
"specified",
"query",
"types"
] | 5c7103c5b43d2f4d16350dbd2f9802af307c63f7 | https://github.com/aol/micro-server/blob/5c7103c5b43d2f4d16350dbd2f9802af307c63f7/micro-events/src/main/java/com/oath/micro/server/events/RequestEvents.java#L119-L124 | train |
aol/micro-server | micro-transactions/src/main/java/com/oath/micro/server/transactions/TransactionFlow.java | TransactionFlow.execute | public Try<R,Throwable> execute(T input){
return Try.withCatch( ()->transactionTemplate.execute(status-> transaction.apply(input)));
} | java | public Try<R,Throwable> execute(T input){
return Try.withCatch( ()->transactionTemplate.execute(status-> transaction.apply(input)));
} | [
"public",
"Try",
"<",
"R",
",",
"Throwable",
">",
"execute",
"(",
"T",
"input",
")",
"{",
"return",
"Try",
".",
"withCatch",
"(",
"(",
")",
"->",
"transactionTemplate",
".",
"execute",
"(",
"status",
"->",
"transaction",
".",
"apply",
"(",
"input",
")"... | Execute the transactional flow - catch all exceptions
@param input Initial data input
@return Try that represents either success (with result) or failure (with errors) | [
"Execute",
"the",
"transactional",
"flow",
"-",
"catch",
"all",
"exceptions"
] | 5c7103c5b43d2f4d16350dbd2f9802af307c63f7 | https://github.com/aol/micro-server/blob/5c7103c5b43d2f4d16350dbd2f9802af307c63f7/micro-transactions/src/main/java/com/oath/micro/server/transactions/TransactionFlow.java#L93-L96 | train |
aol/micro-server | micro-transactions/src/main/java/com/oath/micro/server/transactions/TransactionFlow.java | TransactionFlow.execute | public <Ex extends Throwable> Try<R,Ex> execute(T input,Class<Ex> classes){
return Try.withCatch( ()->transactionTemplate.execute(status-> transaction.apply(input)),classes);
} | java | public <Ex extends Throwable> Try<R,Ex> execute(T input,Class<Ex> classes){
return Try.withCatch( ()->transactionTemplate.execute(status-> transaction.apply(input)),classes);
} | [
"public",
"<",
"Ex",
"extends",
"Throwable",
">",
"Try",
"<",
"R",
",",
"Ex",
">",
"execute",
"(",
"T",
"input",
",",
"Class",
"<",
"Ex",
">",
"classes",
")",
"{",
"return",
"Try",
".",
"withCatch",
"(",
"(",
")",
"->",
"transactionTemplate",
".",
... | Execute the transactional flow - catch only specified exceptions
@param input Initial data input
@param classes Exception types to catch
@return Try that represents either success (with result) or failure (with errors) | [
"Execute",
"the",
"transactional",
"flow",
"-",
"catch",
"only",
"specified",
"exceptions"
] | 5c7103c5b43d2f4d16350dbd2f9802af307c63f7 | https://github.com/aol/micro-server/blob/5c7103c5b43d2f4d16350dbd2f9802af307c63f7/micro-transactions/src/main/java/com/oath/micro/server/transactions/TransactionFlow.java#L104-L108 | train |
darrachequesne/spring-data-jpa-datatables | src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java | DataTablesInput.getColumn | public Column getColumn(String columnName) {
if (columnName == null) {
return null;
}
for (Column column : columns) {
if (columnName.equals(column.getData())) {
return column;
}
}
return null;
} | java | public Column getColumn(String columnName) {
if (columnName == null) {
return null;
}
for (Column column : columns) {
if (columnName.equals(column.getData())) {
return column;
}
}
return null;
} | [
"public",
"Column",
"getColumn",
"(",
"String",
"columnName",
")",
"{",
"if",
"(",
"columnName",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"Column",
"column",
":",
"columns",
")",
"{",
"if",
"(",
"columnName",
".",
"equals",
"(",
... | Find a column by its name
@param columnName the name of the column
@return the given Column, or <code>null</code> if not found | [
"Find",
"a",
"column",
"by",
"its",
"name"
] | 0174dec8f52595a8e4b79f32c79922d64b02b732 | https://github.com/darrachequesne/spring-data-jpa-datatables/blob/0174dec8f52595a8e4b79f32c79922d64b02b732/src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java#L80-L90 | train |
darrachequesne/spring-data-jpa-datatables | src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java | DataTablesInput.addColumn | public void addColumn(String columnName, boolean searchable, boolean orderable,
String searchValue) {
this.columns.add(new Column(columnName, "", searchable, orderable,
new Search(searchValue, false)));
} | java | public void addColumn(String columnName, boolean searchable, boolean orderable,
String searchValue) {
this.columns.add(new Column(columnName, "", searchable, orderable,
new Search(searchValue, false)));
} | [
"public",
"void",
"addColumn",
"(",
"String",
"columnName",
",",
"boolean",
"searchable",
",",
"boolean",
"orderable",
",",
"String",
"searchValue",
")",
"{",
"this",
".",
"columns",
".",
"add",
"(",
"new",
"Column",
"(",
"columnName",
",",
"\"\"",
",",
"s... | Add a new column
@param columnName the name of the column
@param searchable whether the column is searchable or not
@param orderable whether the column is orderable or not
@param searchValue if any, the search value to apply | [
"Add",
"a",
"new",
"column"
] | 0174dec8f52595a8e4b79f32c79922d64b02b732 | https://github.com/darrachequesne/spring-data-jpa-datatables/blob/0174dec8f52595a8e4b79f32c79922d64b02b732/src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java#L100-L104 | train |
darrachequesne/spring-data-jpa-datatables | src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java | DataTablesInput.addOrder | 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"));
}
} | java | 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"));
}
} | [
"public",
"void",
"addOrder",
"(",
"String",
"columnName",
",",
"boolean",
"ascending",
")",
"{",
"if",
"(",
"columnName",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"columns",
".",
"size",
"(",
")"... | Add an order on the given column
@param columnName the name of the column
@param ascending whether the sorting is ascending or descending | [
"Add",
"an",
"order",
"on",
"the",
"given",
"column"
] | 0174dec8f52595a8e4b79f32c79922d64b02b732 | https://github.com/darrachequesne/spring-data-jpa-datatables/blob/0174dec8f52595a8e4b79f32c79922d64b02b732/src/main/java/org/springframework/data/jpa/datatables/mapping/DataTablesInput.java#L112-L122 | train |
mojohaus/flatten-maven-plugin | src/main/java/org/codehaus/mojo/flatten/cifriendly/CiModelInterpolator.java | CiModelInterpolator.interpolateModel | public Model interpolateModel(Model model, File projectDir, ModelBuildingRequest config,
ModelProblemCollector problems) {
interpolateObject(model, model, projectDir, config, problems);
return model;
} | java | public Model interpolateModel(Model model, File projectDir, ModelBuildingRequest config,
ModelProblemCollector problems) {
interpolateObject(model, model, projectDir, config, problems);
return model;
} | [
"public",
"Model",
"interpolateModel",
"(",
"Model",
"model",
",",
"File",
"projectDir",
",",
"ModelBuildingRequest",
"config",
",",
"ModelProblemCollector",
"problems",
")",
"{",
"interpolateObject",
"(",
"model",
",",
"model",
",",
"projectDir",
",",
"config",
"... | Empirical data from 3.x, actual =40 | [
"Empirical",
"data",
"from",
"3",
".",
"x",
"actual",
"=",
"40"
] | df25d03a4d6c06c4de5cfd9f52dfbe72e823e403 | https://github.com/mojohaus/flatten-maven-plugin/blob/df25d03a4d6c06c4de5cfd9f52dfbe72e823e403/src/main/java/org/codehaus/mojo/flatten/cifriendly/CiModelInterpolator.java#L114-L119 | train |
mojohaus/flatten-maven-plugin | src/main/java/org/codehaus/mojo/flatten/cifriendly/CiInterpolatorImpl.java | CiInterpolatorImpl.interpolate | public String interpolate( String input, RecursionInterceptor recursionInterceptor )
throws InterpolationException
{
try
{
return interpolate( input, recursionInterceptor, new HashSet<String>() );
}
finally
{
if ( !cacheAnswers )
{
existingAnswers.clear();
}
}
} | java | public String interpolate( String input, RecursionInterceptor recursionInterceptor )
throws InterpolationException
{
try
{
return interpolate( input, recursionInterceptor, new HashSet<String>() );
}
finally
{
if ( !cacheAnswers )
{
existingAnswers.clear();
}
}
} | [
"public",
"String",
"interpolate",
"(",
"String",
"input",
",",
"RecursionInterceptor",
"recursionInterceptor",
")",
"throws",
"InterpolationException",
"{",
"try",
"{",
"return",
"interpolate",
"(",
"input",
",",
"recursionInterceptor",
",",
"new",
"HashSet",
"<",
... | Entry point for recursive resolution of an expression and all of its
nested expressions.
@todo Ensure unresolvable expressions don't trigger infinite recursion. | [
"Entry",
"point",
"for",
"recursive",
"resolution",
"of",
"an",
"expression",
"and",
"all",
"of",
"its",
"nested",
"expressions",
"."
] | df25d03a4d6c06c4de5cfd9f52dfbe72e823e403 | https://github.com/mojohaus/flatten-maven-plugin/blob/df25d03a4d6c06c4de5cfd9f52dfbe72e823e403/src/main/java/org/codehaus/mojo/flatten/cifriendly/CiInterpolatorImpl.java#L131-L145 | train |
mojohaus/flatten-maven-plugin | src/main/java/org/codehaus/mojo/flatten/cifriendly/CiInterpolatorImpl.java | CiInterpolatorImpl.getFeedback | 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;
} | java | 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;
} | [
"public",
"List",
"getFeedback",
"(",
")",
"{",
"List",
"<",
"?",
">",
"messages",
"=",
"new",
"ArrayList",
"(",
")",
";",
"for",
"(",
"ValueSource",
"vs",
":",
"valueSources",
")",
"{",
"List",
"feedback",
"=",
"vs",
".",
"getFeedback",
"(",
")",
";... | 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.
@return a {@link List} that may be interspersed with {@link String} and
{@link Throwable} instances. | [
"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",... | df25d03a4d6c06c4de5cfd9f52dfbe72e823e403 | https://github.com/mojohaus/flatten-maven-plugin/blob/df25d03a4d6c06c4de5cfd9f52dfbe72e823e403/src/main/java/org/codehaus/mojo/flatten/cifriendly/CiInterpolatorImpl.java#L301-L314 | train |
mojohaus/flatten-maven-plugin | src/main/java/org/codehaus/mojo/flatten/model/resolution/FlattenModelResolver.java | FlattenModelResolver.resolveModel | 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() );
} | java | 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() );
} | [
"public",
"ModelSource",
"resolveModel",
"(",
"Parent",
"parent",
")",
"throws",
"UnresolvableModelException",
"{",
"Dependency",
"parentDependency",
"=",
"new",
"Dependency",
"(",
")",
";",
"parentDependency",
".",
"setGroupId",
"(",
"parent",
".",
"getGroupId",
"(... | Resolves the POM for the specified parent.
@param parent the parent coordinates to resolve, must not be {@code null}
@return The source of the requested POM, never {@code null}
@since Apache-Maven-3.2.2 (MNG-5639) | [
"Resolves",
"the",
"POM",
"for",
"the",
"specified",
"parent",
"."
] | df25d03a4d6c06c4de5cfd9f52dfbe72e823e403 | https://github.com/mojohaus/flatten-maven-plugin/blob/df25d03a4d6c06c4de5cfd9f52dfbe72e823e403/src/main/java/org/codehaus/mojo/flatten/model/resolution/FlattenModelResolver.java#L138-L163 | train |
mojohaus/flatten-maven-plugin | src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java | FlattenMojo.extractHeaderComment | 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 );
}
} | java | 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 );
}
} | [
"protected",
"String",
"extractHeaderComment",
"(",
"File",
"xmlFile",
")",
"throws",
"MojoExecutionException",
"{",
"try",
"{",
"SAXParser",
"parser",
"=",
"SAXParserFactory",
".",
"newInstance",
"(",
")",
".",
"newSAXParser",
"(",
")",
";",
"SaxHeaderCommentHandle... | This method extracts the XML header comment if available.
@param xmlFile is the XML {@link File} to parse.
@return the XML comment between the XML header declaration and the root tag or <code>null</code> if NOT
available.
@throws MojoExecutionException if anything goes wrong. | [
"This",
"method",
"extracts",
"the",
"XML",
"header",
"comment",
"if",
"available",
"."
] | df25d03a4d6c06c4de5cfd9f52dfbe72e823e403 | https://github.com/mojohaus/flatten-maven-plugin/blob/df25d03a4d6c06c4de5cfd9f52dfbe72e823e403/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java#L356-L372 | train |
mojohaus/flatten-maven-plugin | src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java | FlattenMojo.createFlattenedPom | protected Model createFlattenedPom( File pomFile )
throws MojoExecutionException, MojoFailureException
{
ModelBuildingRequest buildingRequest = createModelBuildingRequest( pomFile );
Model effectivePom = createEffectivePom( buildingRequest, isEmbedBuildProfileDependencies(), this.flattenMode );
Model flattenedPom = new Model();
// keep original encoding (we could also normalize to UTF-8 here)
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 );
// copy the configured additional POM elements...
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;
} | java | protected Model createFlattenedPom( File pomFile )
throws MojoExecutionException, MojoFailureException
{
ModelBuildingRequest buildingRequest = createModelBuildingRequest( pomFile );
Model effectivePom = createEffectivePom( buildingRequest, isEmbedBuildProfileDependencies(), this.flattenMode );
Model flattenedPom = new Model();
// keep original encoding (we could also normalize to UTF-8 here)
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 );
// copy the configured additional POM elements...
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;
} | [
"protected",
"Model",
"createFlattenedPom",
"(",
"File",
"pomFile",
")",
"throws",
"MojoExecutionException",
",",
"MojoFailureException",
"{",
"ModelBuildingRequest",
"buildingRequest",
"=",
"createModelBuildingRequest",
"(",
"pomFile",
")",
";",
"Model",
"effectivePom",
... | This method creates the flattened POM what is the main task of this plugin.
@param pomFile is the name of the original POM file to read and transform.
@return the {@link Model} of the flattened POM.
@throws MojoExecutionException if anything goes wrong (e.g. POM can not be processed).
@throws MojoFailureException if anything goes wrong (logical error). | [
"This",
"method",
"creates",
"the",
"flattened",
"POM",
"what",
"is",
"the",
"main",
"task",
"of",
"this",
"plugin",
"."
] | df25d03a4d6c06c4de5cfd9f52dfbe72e823e403 | https://github.com/mojohaus/flatten-maven-plugin/blob/df25d03a4d6c06c4de5cfd9f52dfbe72e823e403/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java#L466-L514 | train |
twitter/twitter-korean-text | src/main/java/com/twitter/penguin/korean/util/CharacterUtils.java | CharacterUtils.toCodePoints | 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;
} | java | 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;
} | [
"public",
"final",
"int",
"toCodePoints",
"(",
"char",
"[",
"]",
"src",
",",
"int",
"srcOff",
",",
"int",
"srcLen",
",",
"int",
"[",
"]",
"dest",
",",
"int",
"destOff",
")",
"{",
"if",
"(",
"srcLen",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgu... | Converts a sequence of Java characters to a sequence of unicode code points.
@return the number of code points written to the destination buffer | [
"Converts",
"a",
"sequence",
"of",
"Java",
"characters",
"to",
"a",
"sequence",
"of",
"unicode",
"code",
"points",
"."
] | 95bbe21fcc62fa7bf50b769ae80a5734fef6b903 | https://github.com/twitter/twitter-korean-text/blob/95bbe21fcc62fa7bf50b769ae80a5734fef6b903/src/main/java/com/twitter/penguin/korean/util/CharacterUtils.java#L134-L146 | train |
twitter/twitter-korean-text | src/main/java/com/twitter/penguin/korean/util/CharacterUtils.java | CharacterUtils.toChars | 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;
} | java | 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;
} | [
"public",
"final",
"int",
"toChars",
"(",
"int",
"[",
"]",
"src",
",",
"int",
"srcOff",
",",
"int",
"srcLen",
",",
"char",
"[",
"]",
"dest",
",",
"int",
"destOff",
")",
"{",
"if",
"(",
"srcLen",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentE... | Converts a sequence of unicode code points to a sequence of Java characters.
@return the number of chars written to the destination buffer | [
"Converts",
"a",
"sequence",
"of",
"unicode",
"code",
"points",
"to",
"a",
"sequence",
"of",
"Java",
"characters",
"."
] | 95bbe21fcc62fa7bf50b769ae80a5734fef6b903 | https://github.com/twitter/twitter-korean-text/blob/95bbe21fcc62fa7bf50b769ae80a5734fef6b903/src/main/java/com/twitter/penguin/korean/util/CharacterUtils.java#L153-L162 | train |
twitter/twitter-korean-text | src/main/java/com/twitter/penguin/korean/TwitterKoreanProcessorJava.java | TwitterKoreanProcessorJava.splitSentences | public static List<Sentence> splitSentences(CharSequence text) {
return JavaConversions.seqAsJavaList(
TwitterKoreanProcessor.splitSentences(text)
);
} | java | public static List<Sentence> splitSentences(CharSequence text) {
return JavaConversions.seqAsJavaList(
TwitterKoreanProcessor.splitSentences(text)
);
} | [
"public",
"static",
"List",
"<",
"Sentence",
">",
"splitSentences",
"(",
"CharSequence",
"text",
")",
"{",
"return",
"JavaConversions",
".",
"seqAsJavaList",
"(",
"TwitterKoreanProcessor",
".",
"splitSentences",
"(",
"text",
")",
")",
";",
"}"
] | Split input text into sentences.
@param text Input text.
@return List of Sentence objects. | [
"Split",
"input",
"text",
"into",
"sentences",
"."
] | 95bbe21fcc62fa7bf50b769ae80a5734fef6b903 | https://github.com/twitter/twitter-korean-text/blob/95bbe21fcc62fa7bf50b769ae80a5734fef6b903/src/main/java/com/twitter/penguin/korean/TwitterKoreanProcessorJava.java#L143-L147 | train |
twitter/twitter-korean-text | src/main/java/com/twitter/penguin/korean/TwitterKoreanProcessorJava.java | TwitterKoreanProcessorJava.extractPhrases | public static List<KoreanPhraseExtractor.KoreanPhrase> extractPhrases(Seq<KoreanToken> tokens, boolean filterSpam, boolean includeHashtags) {
return JavaConversions.seqAsJavaList(
TwitterKoreanProcessor.extractPhrases(tokens, filterSpam, includeHashtags)
);
} | java | public static List<KoreanPhraseExtractor.KoreanPhrase> extractPhrases(Seq<KoreanToken> tokens, boolean filterSpam, boolean includeHashtags) {
return JavaConversions.seqAsJavaList(
TwitterKoreanProcessor.extractPhrases(tokens, filterSpam, includeHashtags)
);
} | [
"public",
"static",
"List",
"<",
"KoreanPhraseExtractor",
".",
"KoreanPhrase",
">",
"extractPhrases",
"(",
"Seq",
"<",
"KoreanToken",
">",
"tokens",
",",
"boolean",
"filterSpam",
",",
"boolean",
"includeHashtags",
")",
"{",
"return",
"JavaConversions",
".",
"seqAs... | Extract phrases from Korean input text
@param tokens Korean tokens (output of tokenize(CharSequence text)).
@return List of phrase CharSequences. | [
"Extract",
"phrases",
"from",
"Korean",
"input",
"text"
] | 95bbe21fcc62fa7bf50b769ae80a5734fef6b903 | https://github.com/twitter/twitter-korean-text/blob/95bbe21fcc62fa7bf50b769ae80a5734fef6b903/src/main/java/com/twitter/penguin/korean/TwitterKoreanProcessorJava.java#L155-L159 | train |
twitter/twitter-korean-text | src/main/java/com/twitter/penguin/korean/TwitterKoreanProcessorJava.java | TwitterKoreanProcessorJava.detokenize | public static String detokenize(List<String> tokens) {
return TwitterKoreanProcessor.detokenize(JavaConversions.iterableAsScalaIterable(tokens));
} | java | public static String detokenize(List<String> tokens) {
return TwitterKoreanProcessor.detokenize(JavaConversions.iterableAsScalaIterable(tokens));
} | [
"public",
"static",
"String",
"detokenize",
"(",
"List",
"<",
"String",
">",
"tokens",
")",
"{",
"return",
"TwitterKoreanProcessor",
".",
"detokenize",
"(",
"JavaConversions",
".",
"iterableAsScalaIterable",
"(",
"tokens",
")",
")",
";",
"}"
] | Detokenize the input list of words.
@param tokens List of words.
@return Detokenized string. | [
"Detokenize",
"the",
"input",
"list",
"of",
"words",
"."
] | 95bbe21fcc62fa7bf50b769ae80a5734fef6b903 | https://github.com/twitter/twitter-korean-text/blob/95bbe21fcc62fa7bf50b769ae80a5734fef6b903/src/main/java/com/twitter/penguin/korean/TwitterKoreanProcessorJava.java#L167-L169 | train |
documents4j/documents4j | documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java | ConverterServerBuilder.baseUri | public ConverterServerBuilder baseUri(String baseUri) {
checkNotNull(baseUri);
this.baseUri = URI.create(baseUri);
return this;
} | java | public ConverterServerBuilder baseUri(String baseUri) {
checkNotNull(baseUri);
this.baseUri = URI.create(baseUri);
return this;
} | [
"public",
"ConverterServerBuilder",
"baseUri",
"(",
"String",
"baseUri",
")",
"{",
"checkNotNull",
"(",
"baseUri",
")",
";",
"this",
".",
"baseUri",
"=",
"URI",
".",
"create",
"(",
"baseUri",
")",
";",
"return",
"this",
";",
"}"
] | Specifies the base URI of this conversion server.
@param baseUri The URI under which this remote conversion server is reachable.
@return This builder instance. | [
"Specifies",
"the",
"base",
"URI",
"of",
"this",
"conversion",
"server",
"."
] | eebb3ede43ffeb5fbfc85b3134f67a9c379a5594 | https://github.com/documents4j/documents4j/blob/eebb3ede43ffeb5fbfc85b3134f67a9c379a5594/documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java#L92-L96 | train |
documents4j/documents4j | documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java | ConverterServerBuilder.workerPool | 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;
} | java | 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;
} | [
"public",
"ConverterServerBuilder",
"workerPool",
"(",
"int",
"corePoolSize",
",",
"int",
"maximumPoolSize",
",",
"long",
"keepAliveTime",
",",
"TimeUnit",
"unit",
")",
"{",
"assertNumericArgument",
"(",
"corePoolSize",
",",
"true",
")",
";",
"assertNumericArgument",
... | Configures a worker pool for the converter.
@param corePoolSize The core pool size of the worker pool.
@param maximumPoolSize The maximum pool size of the worker pool.
@param keepAliveTime The keep alive time of the worker pool.
@param unit The time unit of the specified keep alive time.
@return This builder instance. | [
"Configures",
"a",
"worker",
"pool",
"for",
"the",
"converter",
"."
] | eebb3ede43ffeb5fbfc85b3134f67a9c379a5594 | https://github.com/documents4j/documents4j/blob/eebb3ede43ffeb5fbfc85b3134f67a9c379a5594/documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java#L119-L128 | train |
documents4j/documents4j | documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java | ConverterServerBuilder.requestTimeout | public ConverterServerBuilder requestTimeout(long timeout, TimeUnit unit) {
assertNumericArgument(timeout, true);
this.requestTimeout = unit.toMillis(timeout);
return this;
} | java | public ConverterServerBuilder requestTimeout(long timeout, TimeUnit unit) {
assertNumericArgument(timeout, true);
this.requestTimeout = unit.toMillis(timeout);
return this;
} | [
"public",
"ConverterServerBuilder",
"requestTimeout",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"assertNumericArgument",
"(",
"timeout",
",",
"true",
")",
";",
"this",
".",
"requestTimeout",
"=",
"unit",
".",
"toMillis",
"(",
"timeout",
")",
"... | Specifies the timeout for a network request.
@param timeout The timeout for a network request.
@param unit The time unit of the specified timeout.
@return This builder instance. | [
"Specifies",
"the",
"timeout",
"for",
"a",
"network",
"request",
"."
] | eebb3ede43ffeb5fbfc85b3134f67a9c379a5594 | https://github.com/documents4j/documents4j/blob/eebb3ede43ffeb5fbfc85b3134f67a9c379a5594/documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java#L137-L141 | train |
documents4j/documents4j | documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java | ConverterServerBuilder.processTimeout | public ConverterServerBuilder processTimeout(long processTimeout, TimeUnit timeUnit) {
assertNumericArgument(processTimeout, false);
this.processTimeout = timeUnit.toMillis(processTimeout);
return this;
} | java | public ConverterServerBuilder processTimeout(long processTimeout, TimeUnit timeUnit) {
assertNumericArgument(processTimeout, false);
this.processTimeout = timeUnit.toMillis(processTimeout);
return this;
} | [
"public",
"ConverterServerBuilder",
"processTimeout",
"(",
"long",
"processTimeout",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"assertNumericArgument",
"(",
"processTimeout",
",",
"false",
")",
";",
"this",
".",
"processTimeout",
"=",
"timeUnit",
".",
"toMillis",
"(",
... | Returns the specified process time out in milliseconds.
@return The process time out in milliseconds. | [
"Returns",
"the",
"specified",
"process",
"time",
"out",
"in",
"milliseconds",
"."
] | eebb3ede43ffeb5fbfc85b3134f67a9c379a5594 | https://github.com/documents4j/documents4j/blob/eebb3ede43ffeb5fbfc85b3134f67a9c379a5594/documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java#L148-L152 | train |
documents4j/documents4j | documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java | ConverterServerBuilder.build | public HttpServer build() {
checkNotNull(baseUri);
StandaloneWebConverterConfiguration configuration = makeConfiguration();
// The configuration has to be configured both by a binder to make it injectable
// and directly in order to trigger life cycle methods on the deployment container.
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));
}
} | java | public HttpServer build() {
checkNotNull(baseUri);
StandaloneWebConverterConfiguration configuration = makeConfiguration();
// The configuration has to be configured both by a binder to make it injectable
// and directly in order to trigger life cycle methods on the deployment container.
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));
}
} | [
"public",
"HttpServer",
"build",
"(",
")",
"{",
"checkNotNull",
"(",
"baseUri",
")",
";",
"StandaloneWebConverterConfiguration",
"configuration",
"=",
"makeConfiguration",
"(",
")",
";",
"// The configuration has to be configured both by a binder to make it injectable",
"// and... | Creates the conversion server that is specified by this builder.
@return The conversion server that is specified by this builder. | [
"Creates",
"the",
"conversion",
"server",
"that",
"is",
"specified",
"by",
"this",
"builder",
"."
] | eebb3ede43ffeb5fbfc85b3134f67a9c379a5594 | https://github.com/documents4j/documents4j/blob/eebb3ede43ffeb5fbfc85b3134f67a9c379a5594/documents4j-server-standalone/src/main/java/com/documents4j/builder/ConverterServerBuilder.java#L195-L208 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ParentViewHolder.java | ParentViewHolder.getParentAdapterPosition | @UiThread
public int getParentAdapterPosition() {
int flatPosition = getAdapterPosition();
if (flatPosition == RecyclerView.NO_POSITION) {
return flatPosition;
}
return mExpandableAdapter.getNearestParentPosition(flatPosition);
} | java | @UiThread
public int getParentAdapterPosition() {
int flatPosition = getAdapterPosition();
if (flatPosition == RecyclerView.NO_POSITION) {
return flatPosition;
}
return mExpandableAdapter.getNearestParentPosition(flatPosition);
} | [
"@",
"UiThread",
"public",
"int",
"getParentAdapterPosition",
"(",
")",
"{",
"int",
"flatPosition",
"=",
"getAdapterPosition",
"(",
")",
";",
"if",
"(",
"flatPosition",
"==",
"RecyclerView",
".",
"NO_POSITION",
")",
"{",
"return",
"flatPosition",
";",
"}",
"re... | Returns the adapter position of the Parent associated with this ParentViewHolder
@return The adapter position of the Parent if it still exists in the adapter.
RecyclerView.NO_POSITION if item has been removed from the adapter,
RecyclerView.Adapter.notifyDataSetChanged() has been called after the last
layout pass or the ViewHolder has already been recycled. | [
"Returns",
"the",
"adapter",
"position",
"of",
"the",
"Parent",
"associated",
"with",
"this",
"ParentViewHolder"
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ParentViewHolder.java#L78-L86 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ParentViewHolder.java | ParentViewHolder.expandView | @UiThread
protected void expandView() {
setExpanded(true);
onExpansionToggled(false);
if (mParentViewHolderExpandCollapseListener != null) {
mParentViewHolderExpandCollapseListener.onParentExpanded(getAdapterPosition());
}
} | java | @UiThread
protected void expandView() {
setExpanded(true);
onExpansionToggled(false);
if (mParentViewHolderExpandCollapseListener != null) {
mParentViewHolderExpandCollapseListener.onParentExpanded(getAdapterPosition());
}
} | [
"@",
"UiThread",
"protected",
"void",
"expandView",
"(",
")",
"{",
"setExpanded",
"(",
"true",
")",
";",
"onExpansionToggled",
"(",
"false",
")",
";",
"if",
"(",
"mParentViewHolderExpandCollapseListener",
"!=",
"null",
")",
"{",
"mParentViewHolderExpandCollapseListe... | Triggers expansion of the parent. | [
"Triggers",
"expansion",
"of",
"the",
"parent",
"."
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ParentViewHolder.java#L180-L188 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ParentViewHolder.java | ParentViewHolder.collapseView | @UiThread
protected void collapseView() {
setExpanded(false);
onExpansionToggled(true);
if (mParentViewHolderExpandCollapseListener != null) {
mParentViewHolderExpandCollapseListener.onParentCollapsed(getAdapterPosition());
}
} | java | @UiThread
protected void collapseView() {
setExpanded(false);
onExpansionToggled(true);
if (mParentViewHolderExpandCollapseListener != null) {
mParentViewHolderExpandCollapseListener.onParentCollapsed(getAdapterPosition());
}
} | [
"@",
"UiThread",
"protected",
"void",
"collapseView",
"(",
")",
"{",
"setExpanded",
"(",
"false",
")",
";",
"onExpansionToggled",
"(",
"true",
")",
";",
"if",
"(",
"mParentViewHolderExpandCollapseListener",
"!=",
"null",
")",
"{",
"mParentViewHolderExpandCollapseLis... | Triggers collapse of the parent. | [
"Triggers",
"collapse",
"of",
"the",
"parent",
"."
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ParentViewHolder.java#L193-L201 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.parentExpandedFromViewHolder | @UiThread
protected void parentExpandedFromViewHolder(int flatParentPosition) {
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
updateExpandedParent(parentWrapper, flatParentPosition, true);
} | java | @UiThread
protected void parentExpandedFromViewHolder(int flatParentPosition) {
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
updateExpandedParent(parentWrapper, flatParentPosition, true);
} | [
"@",
"UiThread",
"protected",
"void",
"parentExpandedFromViewHolder",
"(",
"int",
"flatParentPosition",
")",
"{",
"ExpandableWrapper",
"<",
"P",
",",
"C",
">",
"parentWrapper",
"=",
"mFlatItemList",
".",
"get",
"(",
"flatParentPosition",
")",
";",
"updateExpandedPar... | Called when a ParentViewHolder has triggered an expansion for it's parent
@param flatParentPosition the position of the parent that is calling to be expanded | [
"Called",
"when",
"a",
"ParentViewHolder",
"has",
"triggered",
"an",
"expansion",
"for",
"it",
"s",
"parent"
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L417-L421 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.parentCollapsedFromViewHolder | @UiThread
protected void parentCollapsedFromViewHolder(int flatParentPosition) {
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
updateCollapsedParent(parentWrapper, flatParentPosition, true);
} | java | @UiThread
protected void parentCollapsedFromViewHolder(int flatParentPosition) {
ExpandableWrapper<P, C> parentWrapper = mFlatItemList.get(flatParentPosition);
updateCollapsedParent(parentWrapper, flatParentPosition, true);
} | [
"@",
"UiThread",
"protected",
"void",
"parentCollapsedFromViewHolder",
"(",
"int",
"flatParentPosition",
")",
"{",
"ExpandableWrapper",
"<",
"P",
",",
"C",
">",
"parentWrapper",
"=",
"mFlatItemList",
".",
"get",
"(",
"flatParentPosition",
")",
";",
"updateCollapsedP... | Called when a ParentViewHolder has triggered a collapse for it's parent
@param flatParentPosition the position of the parent that is calling to be collapsed | [
"Called",
"when",
"a",
"ParentViewHolder",
"has",
"triggered",
"a",
"collapse",
"for",
"it",
"s",
"parent"
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L428-L432 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.expandParentRange | @UiThread
public void expandParentRange(int startParentPosition, int parentCount) {
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
expandParent(i);
}
} | java | @UiThread
public void expandParentRange(int startParentPosition, int parentCount) {
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
expandParent(i);
}
} | [
"@",
"UiThread",
"public",
"void",
"expandParentRange",
"(",
"int",
"startParentPosition",
",",
"int",
"parentCount",
")",
"{",
"int",
"endParentPosition",
"=",
"startParentPosition",
"+",
"parentCount",
";",
"for",
"(",
"int",
"i",
"=",
"startParentPosition",
";"... | Expands all parents in a range of indices in the list of parents.
@param startParentPosition The index at which to to start expanding parents
@param parentCount The number of parents to expand | [
"Expands",
"all",
"parents",
"in",
"a",
"range",
"of",
"indices",
"in",
"the",
"list",
"of",
"parents",
"."
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L497-L503 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.collapseParentRange | @UiThread
public void collapseParentRange(int startParentPosition, int parentCount) {
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
collapseParent(i);
}
} | java | @UiThread
public void collapseParentRange(int startParentPosition, int parentCount) {
int endParentPosition = startParentPosition + parentCount;
for (int i = startParentPosition; i < endParentPosition; i++) {
collapseParent(i);
}
} | [
"@",
"UiThread",
"public",
"void",
"collapseParentRange",
"(",
"int",
"startParentPosition",
",",
"int",
"parentCount",
")",
"{",
"int",
"endParentPosition",
"=",
"startParentPosition",
"+",
"parentCount",
";",
"for",
"(",
"int",
"i",
"=",
"startParentPosition",
"... | Collapses all parents in a range of indices in the list of parents.
@param startParentPosition The index at which to to start collapsing parents
@param parentCount The number of parents to collapse | [
"Collapses",
"all",
"parents",
"in",
"a",
"range",
"of",
"indices",
"in",
"the",
"list",
"of",
"parents",
"."
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L547-L553 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.generateFlattenedParentChildList | 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;
} | java | 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;
} | [
"private",
"List",
"<",
"ExpandableWrapper",
"<",
"P",
",",
"C",
">",
">",
"generateFlattenedParentChildList",
"(",
"List",
"<",
"P",
">",
"parentList",
")",
"{",
"List",
"<",
"ExpandableWrapper",
"<",
"P",
",",
"C",
">",
">",
"flatItemList",
"=",
"new",
... | Generates a full list of all parents and their children, in order.
@param parentList A list of the parents from
the {@link ExpandableRecyclerAdapter}
@return A list of all parents and their children, expanded | [
"Generates",
"a",
"full",
"list",
"of",
"all",
"parents",
"and",
"their",
"children",
"in",
"order",
"."
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L1320-L1330 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.generateFlattenedParentChildList | 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;
} | java | 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;
} | [
"private",
"List",
"<",
"ExpandableWrapper",
"<",
"P",
",",
"C",
">",
">",
"generateFlattenedParentChildList",
"(",
"List",
"<",
"P",
">",
"parentList",
",",
"Map",
"<",
"P",
",",
"Boolean",
">",
"savedLastExpansionState",
")",
"{",
"List",
"<",
"ExpandableW... | Generates a full list of all parents and their children, in order. Uses Map to preserve
last expanded state.
@param parentList A list of the parents from
the {@link ExpandableRecyclerAdapter}
@param savedLastExpansionState A map of the last expanded state for a given parent key.
@return A list of all parents and their children, expanded accordingly | [
"Generates",
"a",
"full",
"list",
"of",
"all",
"parents",
"and",
"their",
"children",
"in",
"order",
".",
"Uses",
"Map",
"to",
"preserve",
"last",
"expanded",
"state",
"."
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L1341-L1354 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.generateExpandedStateMap | @NonNull
@UiThread
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;
} | java | @NonNull
@UiThread
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;
} | [
"@",
"NonNull",
"@",
"UiThread",
"private",
"HashMap",
"<",
"Integer",
",",
"Boolean",
">",
"generateExpandedStateMap",
"(",
")",
"{",
"HashMap",
"<",
"Integer",
",",
"Boolean",
">",
"parentHashMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"int",
"chil... | Generates a HashMap used to store expanded state for items in the list
on configuration change or whenever onResume is called.
@return A HashMap containing the expanded state of all parents | [
"Generates",
"a",
"HashMap",
"used",
"to",
"store",
"expanded",
"state",
"for",
"items",
"in",
"the",
"list",
"on",
"configuration",
"change",
"or",
"whenever",
"onResume",
"is",
"called",
"."
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L1381-L1400 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java | ExpandableRecyclerAdapter.getFlatParentPosition | @UiThread
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;
} | java | @UiThread
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;
} | [
"@",
"UiThread",
"private",
"int",
"getFlatParentPosition",
"(",
"int",
"parentPosition",
")",
"{",
"int",
"parentCount",
"=",
"0",
";",
"int",
"listItemCount",
"=",
"mFlatItemList",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",... | Gets the index of a ExpandableWrapper within the helper item list based on
the index of the ExpandableWrapper.
@param parentPosition The index of the parent in the list of parents
@return The index of the parent in the merged list of children and parents | [
"Gets",
"the",
"index",
"of",
"a",
"ExpandableWrapper",
"within",
"the",
"helper",
"item",
"list",
"based",
"on",
"the",
"index",
"of",
"the",
"ExpandableWrapper",
"."
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ExpandableRecyclerAdapter.java#L1409-L1424 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ChildViewHolder.java | ChildViewHolder.getParentAdapterPosition | @UiThread
public int getParentAdapterPosition() {
int flatPosition = getAdapterPosition();
if (mExpandableAdapter == null || flatPosition == RecyclerView.NO_POSITION) {
return RecyclerView.NO_POSITION;
}
return mExpandableAdapter.getNearestParentPosition(flatPosition);
} | java | @UiThread
public int getParentAdapterPosition() {
int flatPosition = getAdapterPosition();
if (mExpandableAdapter == null || flatPosition == RecyclerView.NO_POSITION) {
return RecyclerView.NO_POSITION;
}
return mExpandableAdapter.getNearestParentPosition(flatPosition);
} | [
"@",
"UiThread",
"public",
"int",
"getParentAdapterPosition",
"(",
")",
"{",
"int",
"flatPosition",
"=",
"getAdapterPosition",
"(",
")",
";",
"if",
"(",
"mExpandableAdapter",
"==",
"null",
"||",
"flatPosition",
"==",
"RecyclerView",
".",
"NO_POSITION",
")",
"{",... | Returns the adapter position of the Parent associated with this ChildViewHolder
@return The adapter position of the Parent if it still exists in the adapter.
RecyclerView.NO_POSITION if item has been removed from the adapter,
RecyclerView.Adapter.notifyDataSetChanged() has been called after the last
layout pass or the ViewHolder has already been recycled. | [
"Returns",
"the",
"adapter",
"position",
"of",
"the",
"Parent",
"associated",
"with",
"this",
"ChildViewHolder"
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ChildViewHolder.java#L43-L51 | train |
bignerdranch/expandable-recycler-view | expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ChildViewHolder.java | ChildViewHolder.getChildAdapterPosition | @UiThread
public int getChildAdapterPosition() {
int flatPosition = getAdapterPosition();
if (mExpandableAdapter == null || flatPosition == RecyclerView.NO_POSITION) {
return RecyclerView.NO_POSITION;
}
return mExpandableAdapter.getChildPosition(flatPosition);
} | java | @UiThread
public int getChildAdapterPosition() {
int flatPosition = getAdapterPosition();
if (mExpandableAdapter == null || flatPosition == RecyclerView.NO_POSITION) {
return RecyclerView.NO_POSITION;
}
return mExpandableAdapter.getChildPosition(flatPosition);
} | [
"@",
"UiThread",
"public",
"int",
"getChildAdapterPosition",
"(",
")",
"{",
"int",
"flatPosition",
"=",
"getAdapterPosition",
"(",
")",
";",
"if",
"(",
"mExpandableAdapter",
"==",
"null",
"||",
"flatPosition",
"==",
"RecyclerView",
".",
"NO_POSITION",
")",
"{",
... | Returns the adapter position of the Child associated with this ChildViewHolder
@return The adapter position of the Child if it still exists in the adapter.
RecyclerView.NO_POSITION if item has been removed from the adapter,
RecyclerView.Adapter.notifyDataSetChanged() has been called after the last
layout pass or the ViewHolder has already been recycled. | [
"Returns",
"the",
"adapter",
"position",
"of",
"the",
"Child",
"associated",
"with",
"this",
"ChildViewHolder"
] | 930912510620894c531d236856fa79d646e2f1ed | https://github.com/bignerdranch/expandable-recycler-view/blob/930912510620894c531d236856fa79d646e2f1ed/expandablerecyclerview/src/main/java/com/bignerdranch/expandablerecyclerview/ChildViewHolder.java#L61-L69 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/PoolUtil.java | PoolUtil.fillLogParams | 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();
} | java | 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();
} | [
"public",
"static",
"String",
"fillLogParams",
"(",
"String",
"sql",
",",
"Map",
"<",
"Object",
",",
"Object",
">",
"logParams",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Map",
"<",
"Object",
",",
"Object",
">",
"t... | Returns sql statement used in this prepared statement together with the parameters.
@param sql base sql statement
@param logParams parameters to print out
@return returns printable statement | [
"Returns",
"sql",
"statement",
"used",
"in",
"this",
"prepared",
"statement",
"together",
"with",
"the",
"parameters",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/PoolUtil.java#L46-L76 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java | ConnectionHandle.sendInitSQL | protected static void sendInitSQL(Connection connection, String initSQL) throws SQLException{
// fetch any configured setup sql.
if (initSQL != null){
Statement stmt = null;
try{
stmt = connection.createStatement();
stmt.execute(initSQL);
if (testSupport){ // only to aid code coverage, normally set to false
stmt = null;
}
} finally{
if (stmt != null){
stmt.close();
}
}
}
} | java | protected static void sendInitSQL(Connection connection, String initSQL) throws SQLException{
// fetch any configured setup sql.
if (initSQL != null){
Statement stmt = null;
try{
stmt = connection.createStatement();
stmt.execute(initSQL);
if (testSupport){ // only to aid code coverage, normally set to false
stmt = null;
}
} finally{
if (stmt != null){
stmt.close();
}
}
}
} | [
"protected",
"static",
"void",
"sendInitSQL",
"(",
"Connection",
"connection",
",",
"String",
"initSQL",
")",
"throws",
"SQLException",
"{",
"// fetch any configured setup sql.\r",
"if",
"(",
"initSQL",
"!=",
"null",
")",
"{",
"Statement",
"stmt",
"=",
"null",
";"... | Sends out the SQL as defined in the config upon first init of the connection.
@param connection
@param initSQL
@throws SQLException | [
"Sends",
"out",
"the",
"SQL",
"as",
"defined",
"in",
"the",
"config",
"upon",
"first",
"init",
"of",
"the",
"connection",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java#L351-L367 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java | ConnectionHandle.close | public void close() throws SQLException {
try {
if (this.resetConnectionOnClose /*FIXME: && !getAutoCommit() && !isTxResolved() */){
/*if (this.autoCommitStackTrace != null){
logger.debug(this.autoCommitStackTrace);
this.autoCommitStackTrace = null;
} else {
logger.debug(DISABLED_AUTO_COMMIT_WARNING);
}*/
rollback();
if (!getAutoCommit()){
setAutoCommit(true);
}
}
if (this.logicallyClosed.compareAndSet(false, true)) {
if (this.threadWatch != null){
this.threadWatch.interrupt(); // if we returned the connection to the pool, terminate thread watch thread if it's
// running even if thread is still alive (eg thread has been recycled for use in some
// container).
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;
//recreate can throw a SQLException in constructor on recreation
try {
handle = this.recreateConnectionHandle();
this.pool.connectionStrategy.cleanupConnection(this, handle);
this.pool.releaseConnection(handle);
} catch(SQLException e) {
//check if the connection was already closed by the recreation
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);
}
} | java | public void close() throws SQLException {
try {
if (this.resetConnectionOnClose /*FIXME: && !getAutoCommit() && !isTxResolved() */){
/*if (this.autoCommitStackTrace != null){
logger.debug(this.autoCommitStackTrace);
this.autoCommitStackTrace = null;
} else {
logger.debug(DISABLED_AUTO_COMMIT_WARNING);
}*/
rollback();
if (!getAutoCommit()){
setAutoCommit(true);
}
}
if (this.logicallyClosed.compareAndSet(false, true)) {
if (this.threadWatch != null){
this.threadWatch.interrupt(); // if we returned the connection to the pool, terminate thread watch thread if it's
// running even if thread is still alive (eg thread has been recycled for use in some
// container).
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;
//recreate can throw a SQLException in constructor on recreation
try {
handle = this.recreateConnectionHandle();
this.pool.connectionStrategy.cleanupConnection(this, handle);
this.pool.releaseConnection(handle);
} catch(SQLException e) {
//check if the connection was already closed by the recreation
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);
}
} | [
"public",
"void",
"close",
"(",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"if",
"(",
"this",
".",
"resetConnectionOnClose",
"/*FIXME: && !getAutoCommit() && !isTxResolved() */",
")",
"{",
"/*if (this.autoCommitStackTrace != null){\r\n\t\t\t\t\t\tlogger.debug(this.autoCommit... | Release the connection back to the pool.
@throws SQLException Never really thrown | [
"Release",
"the",
"connection",
"back",
"to",
"the",
"pool",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java#L469-L538 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java | ConnectionHandle.internalClose | protected void internalClose() throws SQLException {
try {
clearStatementCaches(true);
if (this.connection != null){ // safety!
this.connection.close();
if (!this.connectionTrackingDisabled && this.finalizableRefs != null){
this.finalizableRefs.remove(this.connection);
}
}
this.logicallyClosed.set(true);
} catch (SQLException e) {
throw markPossiblyBroken(e);
}
} | java | protected void internalClose() throws SQLException {
try {
clearStatementCaches(true);
if (this.connection != null){ // safety!
this.connection.close();
if (!this.connectionTrackingDisabled && this.finalizableRefs != null){
this.finalizableRefs.remove(this.connection);
}
}
this.logicallyClosed.set(true);
} catch (SQLException e) {
throw markPossiblyBroken(e);
}
} | [
"protected",
"void",
"internalClose",
"(",
")",
"throws",
"SQLException",
"{",
"try",
"{",
"clearStatementCaches",
"(",
"true",
")",
";",
"if",
"(",
"this",
".",
"connection",
"!=",
"null",
")",
"{",
"// safety!\r",
"this",
".",
"connection",
".",
"close",
... | Close off the connection.
@throws SQLException | [
"Close",
"off",
"the",
"connection",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java#L546-L560 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java | ConnectionHandle.clearStatementCaches | protected void clearStatementCaches(boolean internalClose) {
if (this.statementCachingEnabled){ // safety
if (internalClose){
this.callableStatementCache.clear();
this.preparedStatementCache.clear();
} else {
if (this.pool.closeConnectionWatch){ // debugging enabled?
this.callableStatementCache.checkForProperClosure();
this.preparedStatementCache.checkForProperClosure();
}
}
}
} | java | protected void clearStatementCaches(boolean internalClose) {
if (this.statementCachingEnabled){ // safety
if (internalClose){
this.callableStatementCache.clear();
this.preparedStatementCache.clear();
} else {
if (this.pool.closeConnectionWatch){ // debugging enabled?
this.callableStatementCache.checkForProperClosure();
this.preparedStatementCache.checkForProperClosure();
}
}
}
} | [
"protected",
"void",
"clearStatementCaches",
"(",
"boolean",
"internalClose",
")",
"{",
"if",
"(",
"this",
".",
"statementCachingEnabled",
")",
"{",
"// safety\r",
"if",
"(",
"internalClose",
")",
"{",
"this",
".",
"callableStatementCache",
".",
"clear",
"(",
")... | Clears out the statement handles.
@param internalClose if true, close the inner statement handle too. | [
"Clears",
"out",
"the",
"statement",
"handles",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java#L1490-L1504 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java | ConnectionHandle.getProxyTarget | 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);
}
} | java | 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);
}
} | [
"public",
"Object",
"getProxyTarget",
"(",
")",
"{",
"try",
"{",
"return",
"Proxy",
".",
"getInvocationHandler",
"(",
"this",
".",
"connection",
")",
".",
"invoke",
"(",
"null",
",",
"this",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"getProxyTarg... | This method will be intercepted by the proxy if it is enabled to return the internal target.
@return the target. | [
"This",
"method",
"will",
"be",
"intercepted",
"by",
"the",
"proxy",
"if",
"it",
"is",
"enabled",
"to",
"return",
"the",
"internal",
"target",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java#L1611-L1617 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java | ConnectionHandle.refreshConnection | public void refreshConnection() throws SQLException{
this.connection.close(); // if it's still in use, close it.
try{
this.connection = this.pool.obtainRawInternalConnection();
} catch(SQLException e){
throw markPossiblyBroken(e);
}
} | java | public void refreshConnection() throws SQLException{
this.connection.close(); // if it's still in use, close it.
try{
this.connection = this.pool.obtainRawInternalConnection();
} catch(SQLException e){
throw markPossiblyBroken(e);
}
} | [
"public",
"void",
"refreshConnection",
"(",
")",
"throws",
"SQLException",
"{",
"this",
".",
"connection",
".",
"close",
"(",
")",
";",
"// if it's still in use, close it.\r",
"try",
"{",
"this",
".",
"connection",
"=",
"this",
".",
"pool",
".",
"obtainRawIntern... | Destroys the internal connection handle and creates a new one.
@throws SQLException | [
"Destroys",
"the",
"internal",
"connection",
"handle",
"and",
"creates",
"a",
"new",
"one",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/ConnectionHandle.java#L1705-L1712 | train |
wwadge/bonecp | bonecp-spring/src/main/java/com/jolbox/bonecp/spring/DynamicDataSourceProxy.java | DynamicDataSourceProxy.switchDataSource | 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(); // initialize a connection (+ throw it away) to force the datasource to initialize the pool
// force application to start using the new one
setTargetDataSource(newDS);
logger.info("Shutting down old datasource slowly. Old Config: "+oldDS);
// tell the old datasource to terminate. This terminates the pool lazily so existing checked out connections can still be used.
((BoneCPDataSource)oldDS).close();
} | java | 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(); // initialize a connection (+ throw it away) to force the datasource to initialize the pool
// force application to start using the new one
setTargetDataSource(newDS);
logger.info("Shutting down old datasource slowly. Old Config: "+oldDS);
// tell the old datasource to terminate. This terminates the pool lazily so existing checked out connections can still be used.
((BoneCPDataSource)oldDS).close();
} | [
"public",
"void",
"switchDataSource",
"(",
"BoneCPConfig",
"newConfig",
")",
"throws",
"SQLException",
"{",
"logger",
".",
"info",
"(",
"\"Switch to new datasource requested. New Config: \"",
"+",
"newConfig",
")",
";",
"DataSource",
"oldDS",
"=",
"getTargetDataSource",
... | Switch to a new DataSource using the given configuration.
@param newConfig BoneCP DataSource to use.
@throws SQLException | [
"Switch",
"to",
"a",
"new",
"DataSource",
"using",
"the",
"given",
"configuration",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp-spring/src/main/java/com/jolbox/bonecp/spring/DynamicDataSourceProxy.java#L64-L81 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java | MemorizeTransactionProxy.memorize | 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));
} | java | 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));
} | [
"protected",
"static",
"Connection",
"memorize",
"(",
"final",
"Connection",
"target",
",",
"final",
"ConnectionHandle",
"connectionHandle",
")",
"{",
"return",
"(",
"Connection",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"ConnectionProxy",
".",
"class",
".",
"g... | Wrap connection with a proxy.
@param target connection handle
@param connectionHandle originating bonecp connection
@return Proxy to a connection. | [
"Wrap",
"connection",
"with",
"a",
"proxy",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java#L79-L85 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java | MemorizeTransactionProxy.memorize | 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));
} | java | 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));
} | [
"protected",
"static",
"Statement",
"memorize",
"(",
"final",
"Statement",
"target",
",",
"final",
"ConnectionHandle",
"connectionHandle",
")",
"{",
"return",
"(",
"Statement",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"StatementProxy",
".",
"class",
".",
"getCl... | Wrap Statement with a proxy.
@param target statement handle
@param connectionHandle originating bonecp connection
@return Proxy to a statement. | [
"Wrap",
"Statement",
"with",
"a",
"proxy",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java#L92-L97 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java | MemorizeTransactionProxy.memorize | 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));
} | java | 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));
} | [
"protected",
"static",
"PreparedStatement",
"memorize",
"(",
"final",
"PreparedStatement",
"target",
",",
"final",
"ConnectionHandle",
"connectionHandle",
")",
"{",
"return",
"(",
"PreparedStatement",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"PreparedStatementProxy",
... | Wrap PreparedStatement with a proxy.
@param target statement handle
@param connectionHandle originating bonecp connection
@return Proxy to a Preparedstatement. | [
"Wrap",
"PreparedStatement",
"with",
"a",
"proxy",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java#L104-L109 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java | MemorizeTransactionProxy.memorize | protected static CallableStatement memorize(final CallableStatement target, final ConnectionHandle connectionHandle) {
return (CallableStatement) Proxy.newProxyInstance(
CallableStatementProxy.class.getClassLoader(),
new Class[] {CallableStatementProxy.class},
new MemorizeTransactionProxy(target, connectionHandle));
} | java | protected static CallableStatement memorize(final CallableStatement target, final ConnectionHandle connectionHandle) {
return (CallableStatement) Proxy.newProxyInstance(
CallableStatementProxy.class.getClassLoader(),
new Class[] {CallableStatementProxy.class},
new MemorizeTransactionProxy(target, connectionHandle));
} | [
"protected",
"static",
"CallableStatement",
"memorize",
"(",
"final",
"CallableStatement",
"target",
",",
"final",
"ConnectionHandle",
"connectionHandle",
")",
"{",
"return",
"(",
"CallableStatement",
")",
"Proxy",
".",
"newProxyInstance",
"(",
"CallableStatementProxy",
... | Wrap CallableStatement with a proxy.
@param target statement handle
@param connectionHandle originating bonecp connection
@return Proxy to a Callablestatement. | [
"Wrap",
"CallableStatement",
"with",
"a",
"proxy",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java#L117-L122 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java | MemorizeTransactionProxy.runWithPossibleProxySwap | private Object runWithPossibleProxySwap(Method method, Object target, Object[] args)
throws IllegalAccessException, InvocationTargetException {
Object result;
// swap with proxies to these too.
if (method.getName().equals("createStatement")){
result = memorize((Statement)method.invoke(target, args), this.connectionHandle.get());
}
else if (method.getName().equals("prepareStatement")){
result = memorize((PreparedStatement)method.invoke(target, args), this.connectionHandle.get());
}
else if (method.getName().equals("prepareCall")){
result = memorize((CallableStatement)method.invoke(target, args), this.connectionHandle.get());
}
else result = method.invoke(target, args);
return result;
} | java | private Object runWithPossibleProxySwap(Method method, Object target, Object[] args)
throws IllegalAccessException, InvocationTargetException {
Object result;
// swap with proxies to these too.
if (method.getName().equals("createStatement")){
result = memorize((Statement)method.invoke(target, args), this.connectionHandle.get());
}
else if (method.getName().equals("prepareStatement")){
result = memorize((PreparedStatement)method.invoke(target, args), this.connectionHandle.get());
}
else if (method.getName().equals("prepareCall")){
result = memorize((CallableStatement)method.invoke(target, args), this.connectionHandle.get());
}
else result = method.invoke(target, args);
return result;
} | [
"private",
"Object",
"runWithPossibleProxySwap",
"(",
"Method",
"method",
",",
"Object",
"target",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"Object",
"result",
";",
"// swap with proxies to these to... | Runs the given method with the specified arguments, substituting with proxies where necessary
@param method
@param target proxy target
@param args
@return Proxy-fied result for statements, actual call result otherwise
@throws IllegalAccessException
@throws InvocationTargetException | [
"Runs",
"the",
"given",
"method",
"with",
"the",
"specified",
"arguments",
"substituting",
"with",
"proxies",
"where",
"necessary"
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/MemorizeTransactionProxy.java#L246-L261 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/PoolWatchThread.java | PoolWatchThread.fillConnections | private void fillConnections(int connectionsToCreate) throws InterruptedException {
try {
for (int i=0; i < connectionsToCreate; i++){
// boolean dbDown = this.pool.getDbIsDown().get();
if (this.pool.poolShuttingDown){
break;
}
this.partition.addFreeConnection(new ConnectionHandle(null, this.partition, this.pool, false));
}
} catch (Exception e) {
logger.error("Error in trying to obtain a connection. Retrying in "+this.acquireRetryDelayInMs+"ms", e);
Thread.sleep(this.acquireRetryDelayInMs);
}
} | java | private void fillConnections(int connectionsToCreate) throws InterruptedException {
try {
for (int i=0; i < connectionsToCreate; i++){
// boolean dbDown = this.pool.getDbIsDown().get();
if (this.pool.poolShuttingDown){
break;
}
this.partition.addFreeConnection(new ConnectionHandle(null, this.partition, this.pool, false));
}
} catch (Exception e) {
logger.error("Error in trying to obtain a connection. Retrying in "+this.acquireRetryDelayInMs+"ms", e);
Thread.sleep(this.acquireRetryDelayInMs);
}
} | [
"private",
"void",
"fillConnections",
"(",
"int",
"connectionsToCreate",
")",
"throws",
"InterruptedException",
"{",
"try",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"connectionsToCreate",
";",
"i",
"++",
")",
"{",
"//\tboolean dbDown = this.pool.get... | Adds new connections to the partition.
@param connectionsToCreate number of connections to create
@throws InterruptedException | [
"Adds",
"new",
"connections",
"to",
"the",
"partition",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/PoolWatchThread.java#L108-L122 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java | StatementCache.calculateCacheKey | public String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability){
StringBuilder tmp = calculateCacheKeyInternal(sql, resultSetType,
resultSetConcurrency);
tmp.append(", H:");
tmp.append(resultSetHoldability);
return tmp.toString();
} | java | public String calculateCacheKey(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability){
StringBuilder tmp = calculateCacheKeyInternal(sql, resultSetType,
resultSetConcurrency);
tmp.append(", H:");
tmp.append(resultSetHoldability);
return tmp.toString();
} | [
"public",
"String",
"calculateCacheKey",
"(",
"String",
"sql",
",",
"int",
"resultSetType",
",",
"int",
"resultSetConcurrency",
",",
"int",
"resultSetHoldability",
")",
"{",
"StringBuilder",
"tmp",
"=",
"calculateCacheKeyInternal",
"(",
"sql",
",",
"resultSetType",
... | Simply appends the given parameters and returns it to obtain a cache key
@param sql
@param resultSetConcurrency
@param resultSetHoldability
@param resultSetType
@return cache key to use | [
"Simply",
"appends",
"the",
"given",
"parameters",
"and",
"returns",
"it",
"to",
"obtain",
"a",
"cache",
"key"
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java#L68-L76 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java | StatementCache.calculateCacheKeyInternal | private StringBuilder calculateCacheKeyInternal(String sql,
int resultSetType, int resultSetConcurrency) {
StringBuilder tmp = new StringBuilder(sql.length()+20);
tmp.append(sql);
tmp.append(", T");
tmp.append(resultSetType);
tmp.append(", C");
tmp.append(resultSetConcurrency);
return tmp;
} | java | private StringBuilder calculateCacheKeyInternal(String sql,
int resultSetType, int resultSetConcurrency) {
StringBuilder tmp = new StringBuilder(sql.length()+20);
tmp.append(sql);
tmp.append(", T");
tmp.append(resultSetType);
tmp.append(", C");
tmp.append(resultSetConcurrency);
return tmp;
} | [
"private",
"StringBuilder",
"calculateCacheKeyInternal",
"(",
"String",
"sql",
",",
"int",
"resultSetType",
",",
"int",
"resultSetConcurrency",
")",
"{",
"StringBuilder",
"tmp",
"=",
"new",
"StringBuilder",
"(",
"sql",
".",
"length",
"(",
")",
"+",
"20",
")",
... | Cache key calculation.
@param sql
@param resultSetType
@param resultSetConcurrency
@return cache key | [
"Cache",
"key",
"calculation",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java#L97-L107 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java | StatementCache.calculateCacheKey | public String calculateCacheKey(String sql, int autoGeneratedKeys) {
StringBuilder tmp = new StringBuilder(sql.length()+4);
tmp.append(sql);
tmp.append(autoGeneratedKeys);
return tmp.toString();
} | java | public String calculateCacheKey(String sql, int autoGeneratedKeys) {
StringBuilder tmp = new StringBuilder(sql.length()+4);
tmp.append(sql);
tmp.append(autoGeneratedKeys);
return tmp.toString();
} | [
"public",
"String",
"calculateCacheKey",
"(",
"String",
"sql",
",",
"int",
"autoGeneratedKeys",
")",
"{",
"StringBuilder",
"tmp",
"=",
"new",
"StringBuilder",
"(",
"sql",
".",
"length",
"(",
")",
"+",
"4",
")",
";",
"tmp",
".",
"append",
"(",
"sql",
")",... | Alternate version of autoGeneratedKeys.
@param sql
@param autoGeneratedKeys
@return cache key to use. | [
"Alternate",
"version",
"of",
"autoGeneratedKeys",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java#L115-L120 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java | StatementCache.calculateCacheKey | public String calculateCacheKey(String sql, int[] columnIndexes) {
StringBuilder tmp = new StringBuilder(sql.length()+4);
tmp.append(sql);
for (int i=0; i < columnIndexes.length; i++){
tmp.append(columnIndexes[i]);
tmp.append("CI,");
}
return tmp.toString();
} | java | public String calculateCacheKey(String sql, int[] columnIndexes) {
StringBuilder tmp = new StringBuilder(sql.length()+4);
tmp.append(sql);
for (int i=0; i < columnIndexes.length; i++){
tmp.append(columnIndexes[i]);
tmp.append("CI,");
}
return tmp.toString();
} | [
"public",
"String",
"calculateCacheKey",
"(",
"String",
"sql",
",",
"int",
"[",
"]",
"columnIndexes",
")",
"{",
"StringBuilder",
"tmp",
"=",
"new",
"StringBuilder",
"(",
"sql",
".",
"length",
"(",
")",
"+",
"4",
")",
";",
"tmp",
".",
"append",
"(",
"sq... | Calculate a cache key.
@param sql to use
@param columnIndexes to use
@return cache key to use. | [
"Calculate",
"a",
"cache",
"key",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/StatementCache.java#L127-L135 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/ConnectionMaxAgeThread.java | ConnectionMaxAgeThread.run | public void run() {
ConnectionHandle connection = null;
long tmp;
long nextCheckInMs = this.maxAgeInMs;
int partitionSize= this.partition.getAvailableConnections();
long currentTime = System.currentTimeMillis();
for (int i=0; i < partitionSize; i++){
try {
connection = this.partition.getFreeConnections().poll();
if (connection != null){
connection.setOriginatingPartition(this.partition);
tmp = this.maxAgeInMs - (currentTime - connection.getConnectionCreationTimeInMs());
if (tmp < nextCheckInMs){
nextCheckInMs = tmp;
}
if (connection.isExpired(currentTime)){
// kill off this connection
closeConnection(connection);
continue;
}
if (this.lifoMode){
// we can't put it back normally or it will end up in front again.
if (!(connection.getOriginatingPartition().getFreeConnections().offer(connection))){
connection.internalClose();
}
} else {
this.pool.putConnectionBackInPartition(connection);
}
Thread.sleep(20L); // test slowly, this is not an operation that we're in a hurry to deal with (avoid CPU spikes)...
}
} catch (Throwable e) {
logger.error("Connection max age thread exception.", e);
}
} // throw it back on the queue
} | java | public void run() {
ConnectionHandle connection = null;
long tmp;
long nextCheckInMs = this.maxAgeInMs;
int partitionSize= this.partition.getAvailableConnections();
long currentTime = System.currentTimeMillis();
for (int i=0; i < partitionSize; i++){
try {
connection = this.partition.getFreeConnections().poll();
if (connection != null){
connection.setOriginatingPartition(this.partition);
tmp = this.maxAgeInMs - (currentTime - connection.getConnectionCreationTimeInMs());
if (tmp < nextCheckInMs){
nextCheckInMs = tmp;
}
if (connection.isExpired(currentTime)){
// kill off this connection
closeConnection(connection);
continue;
}
if (this.lifoMode){
// we can't put it back normally or it will end up in front again.
if (!(connection.getOriginatingPartition().getFreeConnections().offer(connection))){
connection.internalClose();
}
} else {
this.pool.putConnectionBackInPartition(connection);
}
Thread.sleep(20L); // test slowly, this is not an operation that we're in a hurry to deal with (avoid CPU spikes)...
}
} catch (Throwable e) {
logger.error("Connection max age thread exception.", e);
}
} // throw it back on the queue
} | [
"public",
"void",
"run",
"(",
")",
"{",
"ConnectionHandle",
"connection",
"=",
"null",
";",
"long",
"tmp",
";",
"long",
"nextCheckInMs",
"=",
"this",
".",
"maxAgeInMs",
";",
"int",
"partitionSize",
"=",
"this",
".",
"partition",
".",
"getAvailableConnections",... | Invoked periodically. | [
"Invoked",
"periodically",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/ConnectionMaxAgeThread.java#L59-L105 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/ConnectionMaxAgeThread.java | ConnectionMaxAgeThread.closeConnection | protected void closeConnection(ConnectionHandle connection) {
if (connection != null) {
try {
connection.internalClose();
} catch (Throwable t) {
logger.error("Destroy connection exception", t);
} finally {
this.pool.postDestroyConnection(connection);
}
}
} | java | protected void closeConnection(ConnectionHandle connection) {
if (connection != null) {
try {
connection.internalClose();
} catch (Throwable t) {
logger.error("Destroy connection exception", t);
} finally {
this.pool.postDestroyConnection(connection);
}
}
} | [
"protected",
"void",
"closeConnection",
"(",
"ConnectionHandle",
"connection",
")",
"{",
"if",
"(",
"connection",
"!=",
"null",
")",
"{",
"try",
"{",
"connection",
".",
"internalClose",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"logger"... | Closes off this connection
@param connection to close | [
"Closes",
"off",
"this",
"connection"
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/ConnectionMaxAgeThread.java#L111-L121 | train |
wwadge/bonecp | bonecp/src/main/java/com/jolbox/bonecp/BoneCPConfig.java | BoneCPConfig.setIdleMaxAge | public void setIdleMaxAge(long idleMaxAge, TimeUnit timeUnit) {
this.idleMaxAgeInSeconds = TimeUnit.SECONDS.convert(idleMaxAge, checkNotNull(timeUnit));
} | java | public void setIdleMaxAge(long idleMaxAge, TimeUnit timeUnit) {
this.idleMaxAgeInSeconds = TimeUnit.SECONDS.convert(idleMaxAge, checkNotNull(timeUnit));
} | [
"public",
"void",
"setIdleMaxAge",
"(",
"long",
"idleMaxAge",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"this",
".",
"idleMaxAgeInSeconds",
"=",
"TimeUnit",
".",
"SECONDS",
".",
"convert",
"(",
"idleMaxAge",
",",
"checkNotNull",
"(",
"timeUnit",
")",
")",
";",
... | Sets Idle max age.
The time, for a connection to remain unused before it is closed off. Do not use aggressive values here!
@param idleMaxAge time after which a connection is closed off
@param timeUnit idleMaxAge time granularity. | [
"Sets",
"Idle",
"max",
"age",
"."
] | 74bc3287025fc137ca28909f0f7693edae37a15d | https://github.com/wwadge/bonecp/blob/74bc3287025fc137ca28909f0f7693edae37a15d/bonecp/src/main/java/com/jolbox/bonecp/BoneCPConfig.java#L490-L492 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.