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/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerTableAuditingPoliciesInner.java | ServerTableAuditingPoliciesInner.createOrUpdateAsync | public Observable<ServerTableAuditingPolicyInner> createOrUpdateAsync(String resourceGroupName, String serverName, ServerTableAuditingPolicyInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1<ServiceResponse<ServerTableAuditingPolicyInner>, ServerTableAuditingPolicyInner>() {
@Override
public ServerTableAuditingPolicyInner call(ServiceResponse<ServerTableAuditingPolicyInner> response) {
return response.body();
}
});
} | java | public Observable<ServerTableAuditingPolicyInner> createOrUpdateAsync(String resourceGroupName, String serverName, ServerTableAuditingPolicyInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, parameters).map(new Func1<ServiceResponse<ServerTableAuditingPolicyInner>, ServerTableAuditingPolicyInner>() {
@Override
public ServerTableAuditingPolicyInner call(ServiceResponse<ServerTableAuditingPolicyInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ServerTableAuditingPolicyInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"ServerTableAuditingPolicyInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
... | Creates or updates a servers's table auditing policy. Table auditing is deprecated, use blob auditing instead.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param parameters The server table auditing policy.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServerTableAuditingPolicyInner object | [
"Creates",
"or",
"updates",
"a",
"servers",
"s",
"table",
"auditing",
"policy",
".",
"Table",
"auditing",
"is",
"deprecated",
"use",
"blob",
"auditing",
"instead",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerTableAuditingPoliciesInner.java#L196-L203 | train |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerTableAuditingPoliciesInner.java | ServerTableAuditingPoliciesInner.listByServerAsync | public Observable<ServerTableAuditingPolicyListResultInner> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<ServerTableAuditingPolicyListResultInner>, ServerTableAuditingPolicyListResultInner>() {
@Override
public ServerTableAuditingPolicyListResultInner call(ServiceResponse<ServerTableAuditingPolicyListResultInner> response) {
return response.body();
}
});
} | java | public Observable<ServerTableAuditingPolicyListResultInner> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<ServerTableAuditingPolicyListResultInner>, ServerTableAuditingPolicyListResultInner>() {
@Override
public ServerTableAuditingPolicyListResultInner call(ServiceResponse<ServerTableAuditingPolicyListResultInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ServerTableAuditingPolicyListResultInner",
">",
"listByServerAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
... | Lists a servers's table auditing policies. Table auditing is deprecated, use blob auditing instead.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServerTableAuditingPolicyListResultInner object | [
"Lists",
"a",
"servers",
"s",
"table",
"auditing",
"policies",
".",
"Table",
"auditing",
"is",
"deprecated",
"use",
"blob",
"auditing",
"instead",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/ServerTableAuditingPoliciesInner.java#L289-L296 | train |
Azure/azure-sdk-for-java | mediaservices/data-plane/src/main/java/com/microsoft/windowsazure/services/media/Exports.java | Exports.register | @Override
public void register(Builder.Registry registry) {
registry.add(new AzureAdTokenFactory());
registry.add(MediaContract.class, MediaExceptionProcessor.class);
registry.add(MediaRestProxy.class);
registry.add(OAuthFilter.class);
registry.add(ResourceLocationManager.class);
registry.add(RedirectFilter.class);
registry.add(VersionHeadersFilter.class);
registry.add(UserAgentFilter.class);
registry.alter(MediaContract.class, ClientConfig.class,
new Builder.Alteration<ClientConfig>() {
@SuppressWarnings("rawtypes")
@Override
public ClientConfig alter(String profile,
ClientConfig instance, Builder builder,
Map<String, Object> properties) {
instance.getProperties().put(
JSONConfiguration.FEATURE_POJO_MAPPING, true);
// Turn off auto-follow redirects, because Media
// Services rest calls break if it's on
instance.getProperties().put(
ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false);
try {
instance.getSingletons().add(
new ODataEntityProvider());
instance.getSingletons().add(
new ODataEntityCollectionProvider());
instance.getSingletons().add(
new MediaContentProvider());
instance.getSingletons().add(
new BatchMimeMultipartBodyWritter());
} catch (JAXBException e) {
throw new RuntimeException(e);
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
}
return instance;
}
});
} | java | @Override
public void register(Builder.Registry registry) {
registry.add(new AzureAdTokenFactory());
registry.add(MediaContract.class, MediaExceptionProcessor.class);
registry.add(MediaRestProxy.class);
registry.add(OAuthFilter.class);
registry.add(ResourceLocationManager.class);
registry.add(RedirectFilter.class);
registry.add(VersionHeadersFilter.class);
registry.add(UserAgentFilter.class);
registry.alter(MediaContract.class, ClientConfig.class,
new Builder.Alteration<ClientConfig>() {
@SuppressWarnings("rawtypes")
@Override
public ClientConfig alter(String profile,
ClientConfig instance, Builder builder,
Map<String, Object> properties) {
instance.getProperties().put(
JSONConfiguration.FEATURE_POJO_MAPPING, true);
// Turn off auto-follow redirects, because Media
// Services rest calls break if it's on
instance.getProperties().put(
ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false);
try {
instance.getSingletons().add(
new ODataEntityProvider());
instance.getSingletons().add(
new ODataEntityCollectionProvider());
instance.getSingletons().add(
new MediaContentProvider());
instance.getSingletons().add(
new BatchMimeMultipartBodyWritter());
} catch (JAXBException e) {
throw new RuntimeException(e);
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
}
return instance;
}
});
} | [
"@",
"Override",
"public",
"void",
"register",
"(",
"Builder",
".",
"Registry",
"registry",
")",
"{",
"registry",
".",
"add",
"(",
"new",
"AzureAdTokenFactory",
"(",
")",
")",
";",
"registry",
".",
"add",
"(",
"MediaContract",
".",
"class",
",",
"MediaExce... | register the Media services. | [
"register",
"the",
"Media",
"services",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mediaservices/data-plane/src/main/java/com/microsoft/windowsazure/services/media/Exports.java#L43-L88 | train |
Azure/azure-sdk-for-java | eventhubs/data-plane/azure-eventhubs/src/main/java/com/microsoft/azure/eventhubs/impl/ReceivePump.java | ReceivePump.run | public void run() {
try {
ReceivePump.this.receiveAndProcess();
} catch (final Exception exception) {
if (TRACE_LOGGER.isErrorEnabled()) {
TRACE_LOGGER.error(
String.format(Locale.US, "Receive pump for eventHub (%s), consumerGroup (%s), partition (%s) "
+ "encountered unrecoverable error and exited with exception %s.",
this.eventHubName, this.consumerGroupName, this.receiver.getPartitionId(), exception.toString()));
}
throw exception;
}
} | java | public void run() {
try {
ReceivePump.this.receiveAndProcess();
} catch (final Exception exception) {
if (TRACE_LOGGER.isErrorEnabled()) {
TRACE_LOGGER.error(
String.format(Locale.US, "Receive pump for eventHub (%s), consumerGroup (%s), partition (%s) "
+ "encountered unrecoverable error and exited with exception %s.",
this.eventHubName, this.consumerGroupName, this.receiver.getPartitionId(), exception.toString()));
}
throw exception;
}
} | [
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"ReceivePump",
".",
"this",
".",
"receiveAndProcess",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"exception",
")",
"{",
"if",
"(",
"TRACE_LOGGER",
".",
"isErrorEnabled",
"(",
")",
")",
"{... | entry-point - for runnable | [
"entry",
"-",
"point",
"-",
"for",
"runnable"
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventhubs/data-plane/azure-eventhubs/src/main/java/com/microsoft/azure/eventhubs/impl/ReceivePump.java#L53-L66 | train |
Azure/azure-sdk-for-java | eventhubs/data-plane/azure-eventhubs/src/main/java/com/microsoft/azure/eventhubs/impl/ReceivePump.java | ReceivePump.receiveAndProcess | public void receiveAndProcess() {
if (this.shouldContinue()) {
this.receiver.receive(this.onReceiveHandler.getMaxEventCount())
.handleAsync(this.processAndReschedule, this.executor);
} else {
if (TRACE_LOGGER.isInfoEnabled()) {
TRACE_LOGGER.info(String.format(Locale.US, "Stopping receive pump for eventHub (%s), consumerGroup (%s), partition (%s) as %s",
this.eventHubName, this.consumerGroupName, this.receiver.getPartitionId(),
this.stopPumpRaised.get() ? "per the request." : "pump ran into errors."));
}
this.stopPump.complete(null);
}
} | java | public void receiveAndProcess() {
if (this.shouldContinue()) {
this.receiver.receive(this.onReceiveHandler.getMaxEventCount())
.handleAsync(this.processAndReschedule, this.executor);
} else {
if (TRACE_LOGGER.isInfoEnabled()) {
TRACE_LOGGER.info(String.format(Locale.US, "Stopping receive pump for eventHub (%s), consumerGroup (%s), partition (%s) as %s",
this.eventHubName, this.consumerGroupName, this.receiver.getPartitionId(),
this.stopPumpRaised.get() ? "per the request." : "pump ran into errors."));
}
this.stopPump.complete(null);
}
} | [
"public",
"void",
"receiveAndProcess",
"(",
")",
"{",
"if",
"(",
"this",
".",
"shouldContinue",
"(",
")",
")",
"{",
"this",
".",
"receiver",
".",
"receive",
"(",
"this",
".",
"onReceiveHandler",
".",
"getMaxEventCount",
"(",
")",
")",
".",
"handleAsync",
... | receives and invokes user-callback if success or stops pump if fails | [
"receives",
"and",
"invokes",
"user",
"-",
"callback",
"if",
"success",
"or",
"stops",
"pump",
"if",
"fails"
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventhubs/data-plane/azure-eventhubs/src/main/java/com/microsoft/azure/eventhubs/impl/ReceivePump.java#L69-L82 | train |
Azure/azure-sdk-for-java | profiles/2018-03-01-hybrid/azure/src/main/java/com/microsoft/azure/management/profile_2018_03_01_hybrid/Azure.java | Azure.authenticate | public static Authenticated authenticate(AzureTokenCredentials credentials) {
return new AuthenticatedImpl(new RestClient.Builder()
.withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withCredentials(credentials)
.withSerializerAdapter(new AzureJacksonAdapter())
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.build());
} | java | public static Authenticated authenticate(AzureTokenCredentials credentials) {
return new AuthenticatedImpl(new RestClient.Builder()
.withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withCredentials(credentials)
.withSerializerAdapter(new AzureJacksonAdapter())
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.build());
} | [
"public",
"static",
"Authenticated",
"authenticate",
"(",
"AzureTokenCredentials",
"credentials",
")",
"{",
"return",
"new",
"AuthenticatedImpl",
"(",
"new",
"RestClient",
".",
"Builder",
"(",
")",
".",
"withBaseUrl",
"(",
"credentials",
".",
"environment",
"(",
"... | Creates an instance of Azure.Authenticated that exposes subscription, tenant, and authorization API entry points.
@param credentials the credentials to use
@return the Azure.Authenticated | [
"Creates",
"an",
"instance",
"of",
"Azure",
".",
"Authenticated",
"that",
"exposes",
"subscription",
"tenant",
"and",
"authorization",
"API",
"entry",
"points",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/profiles/2018-03-01-hybrid/azure/src/main/java/com/microsoft/azure/management/profile_2018_03_01_hybrid/Azure.java#L131-L138 | train |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DataMaskingPoliciesInner.java | DataMaskingPoliciesInner.getAsync | public Observable<DataMaskingPolicyInner> getAsync(String resourceGroupName, String serverName, String databaseName) {
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<DataMaskingPolicyInner>, DataMaskingPolicyInner>() {
@Override
public DataMaskingPolicyInner call(ServiceResponse<DataMaskingPolicyInner> response) {
return response.body();
}
});
} | java | public Observable<DataMaskingPolicyInner> getAsync(String resourceGroupName, String serverName, String databaseName) {
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<DataMaskingPolicyInner>, DataMaskingPolicyInner>() {
@Override
public DataMaskingPolicyInner call(ServiceResponse<DataMaskingPolicyInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DataMaskingPolicyInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
... | Gets a database data masking policy.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DataMaskingPolicyInner object | [
"Gets",
"a",
"database",
"data",
"masking",
"policy",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DataMaskingPoliciesInner.java#L207-L214 | train |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscNodeConfigurationsInner.java | DscNodeConfigurationsInner.listByAutomationAccountNextAsync | public Observable<Page<DscNodeConfigurationInner>> listByAutomationAccountNextAsync(final String nextPageLink) {
return listByAutomationAccountNextWithServiceResponseAsync(nextPageLink)
.map(new Func1<ServiceResponse<Page<DscNodeConfigurationInner>>, Page<DscNodeConfigurationInner>>() {
@Override
public Page<DscNodeConfigurationInner> call(ServiceResponse<Page<DscNodeConfigurationInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<DscNodeConfigurationInner>> listByAutomationAccountNextAsync(final String nextPageLink) {
return listByAutomationAccountNextWithServiceResponseAsync(nextPageLink)
.map(new Func1<ServiceResponse<Page<DscNodeConfigurationInner>>, Page<DscNodeConfigurationInner>>() {
@Override
public Page<DscNodeConfigurationInner> call(ServiceResponse<Page<DscNodeConfigurationInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"DscNodeConfigurationInner",
">",
">",
"listByAutomationAccountNextAsync",
"(",
"final",
"String",
"nextPageLink",
")",
"{",
"return",
"listByAutomationAccountNextWithServiceResponseAsync",
"(",
"nextPageLink",
")",
".",
"map",
"(... | Retrieve a list of dsc node configurations.
@param nextPageLink The NextLink from the previous successful call to List operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<DscNodeConfigurationInner> object | [
"Retrieve",
"a",
"list",
"of",
"dsc",
"node",
"configurations",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/DscNodeConfigurationsInner.java#L655-L663 | train |
Azure/azure-sdk-for-java | logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountAssembliesInner.java | IntegrationAccountAssembliesInner.listAsync | public Observable<List<AssemblyDefinitionInner>> listAsync(String resourceGroupName, String integrationAccountName) {
return listWithServiceResponseAsync(resourceGroupName, integrationAccountName).map(new Func1<ServiceResponse<List<AssemblyDefinitionInner>>, List<AssemblyDefinitionInner>>() {
@Override
public List<AssemblyDefinitionInner> call(ServiceResponse<List<AssemblyDefinitionInner>> response) {
return response.body();
}
});
} | java | public Observable<List<AssemblyDefinitionInner>> listAsync(String resourceGroupName, String integrationAccountName) {
return listWithServiceResponseAsync(resourceGroupName, integrationAccountName).map(new Func1<ServiceResponse<List<AssemblyDefinitionInner>>, List<AssemblyDefinitionInner>>() {
@Override
public List<AssemblyDefinitionInner> call(ServiceResponse<List<AssemblyDefinitionInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"AssemblyDefinitionInner",
">",
">",
"listAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"integrationAccountName",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"integrationAccountN... | List the assemblies for an integration account.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<AssemblyDefinitionInner> object | [
"List",
"the",
"assemblies",
"for",
"an",
"integration",
"account",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/IntegrationAccountAssembliesInner.java#L117-L124 | train |
Azure/azure-sdk-for-java | servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/primitives/TrackingUtil.java | TrackingUtil.parseRoleIdentifier | static String parseRoleIdentifier(final String trackingId)
{
if (StringUtil.isNullOrWhiteSpace(trackingId) || !trackingId.contains(TRACKING_ID_TOKEN_SEPARATOR))
{
return null;
}
return trackingId.substring(trackingId.indexOf(TRACKING_ID_TOKEN_SEPARATOR));
} | java | static String parseRoleIdentifier(final String trackingId)
{
if (StringUtil.isNullOrWhiteSpace(trackingId) || !trackingId.contains(TRACKING_ID_TOKEN_SEPARATOR))
{
return null;
}
return trackingId.substring(trackingId.indexOf(TRACKING_ID_TOKEN_SEPARATOR));
} | [
"static",
"String",
"parseRoleIdentifier",
"(",
"final",
"String",
"trackingId",
")",
"{",
"if",
"(",
"StringUtil",
".",
"isNullOrWhiteSpace",
"(",
"trackingId",
")",
"||",
"!",
"trackingId",
".",
"contains",
"(",
"TRACKING_ID_TOKEN_SEPARATOR",
")",
")",
"{",
"r... | parses ServiceBus role identifiers from trackingId
@return null if no roleIdentifier found | [
"parses",
"ServiceBus",
"role",
"identifiers",
"from",
"trackingId"
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/primitives/TrackingUtil.java#L19-L27 | train |
Azure/azure-sdk-for-java | mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/MySQLManager.java | MySQLManager.authenticate | public static MySQLManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
return new MySQLManager(new RestClient.Builder()
.withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withCredentials(credentials)
.withSerializerAdapter(new AzureJacksonAdapter())
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.build(), subscriptionId);
} | java | public static MySQLManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
return new MySQLManager(new RestClient.Builder()
.withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withCredentials(credentials)
.withSerializerAdapter(new AzureJacksonAdapter())
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.build(), subscriptionId);
} | [
"public",
"static",
"MySQLManager",
"authenticate",
"(",
"AzureTokenCredentials",
"credentials",
",",
"String",
"subscriptionId",
")",
"{",
"return",
"new",
"MySQLManager",
"(",
"new",
"RestClient",
".",
"Builder",
"(",
")",
".",
"withBaseUrl",
"(",
"credentials",
... | Creates an instance of MySQLManager that exposes DBforMySQL resource management API entry points.
@param credentials the credentials to use
@param subscriptionId the subscription UUID
@return the MySQLManager | [
"Creates",
"an",
"instance",
"of",
"MySQLManager",
"that",
"exposes",
"DBforMySQL",
"resource",
"management",
"API",
"entry",
"points",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/MySQLManager.java#L59-L66 | train |
Azure/azure-sdk-for-java | automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/JobSchedulesInner.java | JobSchedulesInner.delete | public void delete(String resourceGroupName, String automationAccountName, UUID jobScheduleId) {
deleteWithServiceResponseAsync(resourceGroupName, automationAccountName, jobScheduleId).toBlocking().single().body();
} | java | public void delete(String resourceGroupName, String automationAccountName, UUID jobScheduleId) {
deleteWithServiceResponseAsync(resourceGroupName, automationAccountName, jobScheduleId).toBlocking().single().body();
} | [
"public",
"void",
"delete",
"(",
"String",
"resourceGroupName",
",",
"String",
"automationAccountName",
",",
"UUID",
"jobScheduleId",
")",
"{",
"deleteWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"automationAccountName",
",",
"jobScheduleId",
")",
".",
"toB... | Delete the job schedule identified by job schedule name.
@param resourceGroupName Name of an Azure Resource group.
@param automationAccountName The name of the automation account.
@param jobScheduleId The job schedule name.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent | [
"Delete",
"the",
"job",
"schedule",
"identified",
"by",
"job",
"schedule",
"name",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/automation/resource-manager/v2015_10_31/src/main/java/com/microsoft/azure/management/automation/v2015_10_31/implementation/JobSchedulesInner.java#L98-L100 | train |
Azure/azure-sdk-for-java | applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ComponentsInner.java | ComponentsInner.getByResourceGroupAsync | public Observable<ApplicationInsightsComponentInner> getByResourceGroupAsync(String resourceGroupName, String resourceName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ApplicationInsightsComponentInner>, ApplicationInsightsComponentInner>() {
@Override
public ApplicationInsightsComponentInner call(ServiceResponse<ApplicationInsightsComponentInner> response) {
return response.body();
}
});
} | java | public Observable<ApplicationInsightsComponentInner> getByResourceGroupAsync(String resourceGroupName, String resourceName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ApplicationInsightsComponentInner>, ApplicationInsightsComponentInner>() {
@Override
public ApplicationInsightsComponentInner call(ServiceResponse<ApplicationInsightsComponentInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ApplicationInsightsComponentInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
... | Returns an Application Insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentInner object | [
"Returns",
"an",
"Application",
"Insights",
"component",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ComponentsInner.java#L457-L464 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/Validator.java | Validator.validate | public static void validate(Object parameter) {
// Validation of top level payload is done outside
if (parameter == null) {
return;
}
Class<?> type = parameter.getClass();
if (type == Double.class
|| type == Float.class
|| type == Long.class
|| type == Integer.class
|| type == Short.class
|| type == Character.class
|| type == Byte.class
|| type == Boolean.class) {
type = wrapperToPrimitive(type);
}
if (type.isPrimitive()
|| type.isEnum()
|| type.isAssignableFrom(Class.class)
|| type.isAssignableFrom(LocalDate.class)
|| type.isAssignableFrom(OffsetDateTime.class)
|| type.isAssignableFrom(String.class)
|| type.isAssignableFrom(DateTimeRfc1123.class)
|| type.isAssignableFrom(Duration.class)) {
return;
}
Annotation skipParentAnnotation = type.getAnnotation(SkipParentValidation.class);
//
if (skipParentAnnotation == null) {
for (Class<?> c : TypeUtil.getAllClasses(type)) {
validateClass(c, parameter);
}
} else {
validateClass(type, parameter);
}
} | java | public static void validate(Object parameter) {
// Validation of top level payload is done outside
if (parameter == null) {
return;
}
Class<?> type = parameter.getClass();
if (type == Double.class
|| type == Float.class
|| type == Long.class
|| type == Integer.class
|| type == Short.class
|| type == Character.class
|| type == Byte.class
|| type == Boolean.class) {
type = wrapperToPrimitive(type);
}
if (type.isPrimitive()
|| type.isEnum()
|| type.isAssignableFrom(Class.class)
|| type.isAssignableFrom(LocalDate.class)
|| type.isAssignableFrom(OffsetDateTime.class)
|| type.isAssignableFrom(String.class)
|| type.isAssignableFrom(DateTimeRfc1123.class)
|| type.isAssignableFrom(Duration.class)) {
return;
}
Annotation skipParentAnnotation = type.getAnnotation(SkipParentValidation.class);
//
if (skipParentAnnotation == null) {
for (Class<?> c : TypeUtil.getAllClasses(type)) {
validateClass(c, parameter);
}
} else {
validateClass(type, parameter);
}
} | [
"public",
"static",
"void",
"validate",
"(",
"Object",
"parameter",
")",
"{",
"// Validation of top level payload is done outside",
"if",
"(",
"parameter",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Class",
"<",
"?",
">",
"type",
"=",
"parameter",
".",
"getC... | Validates a user provided required parameter to be not null.
An {@link IllegalArgumentException} is thrown if a property fails the validation.
@param parameter the parameter to validate
@throws IllegalArgumentException thrown when the Validator determines the argument is invalid | [
"Validates",
"a",
"user",
"provided",
"required",
"parameter",
"to",
"be",
"not",
"null",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/Validator.java#L36-L73 | train |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java | DatabasesInner.getAsync | public Observable<DatabaseInner> getAsync(String resourceGroupName, String serverName, String databaseName, String expand) {
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName, expand).map(new Func1<ServiceResponse<DatabaseInner>, DatabaseInner>() {
@Override
public DatabaseInner call(ServiceResponse<DatabaseInner> response) {
return response.body();
}
});
} | java | public Observable<DatabaseInner> getAsync(String resourceGroupName, String serverName, String databaseName, String expand) {
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName, expand).map(new Func1<ServiceResponse<DatabaseInner>, DatabaseInner>() {
@Override
public DatabaseInner call(ServiceResponse<DatabaseInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DatabaseInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"String",
"expand",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
... | Gets a database.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database to be retrieved.
@param expand A comma separated list of child objects to expand in the response. Possible properties: serviceTierAdvisors, transparentDataEncryption.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DatabaseInner object | [
"Gets",
"a",
"database",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java#L1089-L1096 | train |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java | DatabasesInner.listByServer | public List<DatabaseInner> listByServer(String resourceGroupName, String serverName, String expand, String filter) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName, expand, filter).toBlocking().single().body();
} | java | public List<DatabaseInner> listByServer(String resourceGroupName, String serverName, String expand, String filter) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName, expand, filter).toBlocking().single().body();
} | [
"public",
"List",
"<",
"DatabaseInner",
">",
"listByServer",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"expand",
",",
"String",
"filter",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
... | Returns a list of databases in a server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param expand A comma separated list of child objects to expand in the response. Possible properties: serviceTierAdvisors, transparentDataEncryption.
@param filter An OData filter expression that describes a subset of databases to return.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the List<DatabaseInner> object if successful. | [
"Returns",
"a",
"list",
"of",
"databases",
"in",
"a",
"server",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java#L1243-L1245 | train |
Azure/azure-sdk-for-java | sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/JobExecutionsInner.java | JobExecutionsInner.get | public JobExecutionInner get(String resourceGroupName, String serverName, String jobAgentName, String jobName, UUID jobExecutionId) {
return getWithServiceResponseAsync(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId).toBlocking().single().body();
} | java | public JobExecutionInner get(String resourceGroupName, String serverName, String jobAgentName, String jobName, UUID jobExecutionId) {
return getWithServiceResponseAsync(resourceGroupName, serverName, jobAgentName, jobName, jobExecutionId).toBlocking().single().body();
} | [
"public",
"JobExecutionInner",
"get",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"jobAgentName",
",",
"String",
"jobName",
",",
"UUID",
"jobExecutionId",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
... | Gets a job execution.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param jobAgentName The name of the job agent.
@param jobName The name of the job.
@param jobExecutionId The id of the job execution
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the JobExecutionInner object if successful. | [
"Gets",
"a",
"job",
"execution",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2017_03_01_preview/src/main/java/com/microsoft/azure/management/sql/v2017_03_01_preview/implementation/JobExecutionsInner.java#L1019-L1021 | train |
Azure/azure-sdk-for-java | datalakestore/resource-manager/v2016_11_01/src/main/java/com/microsoft/azure/management/datalakestore/v2016_11_01/implementation/VirtualNetworkRulesInner.java | VirtualNetworkRulesInner.getAsync | public Observable<VirtualNetworkRuleInner> getAsync(String resourceGroupName, String accountName, String virtualNetworkRuleName) {
return getWithServiceResponseAsync(resourceGroupName, accountName, virtualNetworkRuleName).map(new Func1<ServiceResponse<VirtualNetworkRuleInner>, VirtualNetworkRuleInner>() {
@Override
public VirtualNetworkRuleInner call(ServiceResponse<VirtualNetworkRuleInner> response) {
return response.body();
}
});
} | java | public Observable<VirtualNetworkRuleInner> getAsync(String resourceGroupName, String accountName, String virtualNetworkRuleName) {
return getWithServiceResponseAsync(resourceGroupName, accountName, virtualNetworkRuleName).map(new Func1<ServiceResponse<VirtualNetworkRuleInner>, VirtualNetworkRuleInner>() {
@Override
public VirtualNetworkRuleInner call(ServiceResponse<VirtualNetworkRuleInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"VirtualNetworkRuleInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"String",
"virtualNetworkRuleName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountNa... | Gets the specified Data Lake Store virtual network rule.
@param resourceGroupName The name of the Azure resource group.
@param accountName The name of the Data Lake Store account.
@param virtualNetworkRuleName The name of the virtual network rule to retrieve.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the VirtualNetworkRuleInner object | [
"Gets",
"the",
"specified",
"Data",
"Lake",
"Store",
"virtual",
"network",
"rule",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/datalakestore/resource-manager/v2016_11_01/src/main/java/com/microsoft/azure/management/datalakestore/v2016_11_01/implementation/VirtualNetworkRulesInner.java#L355-L362 | train |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildsInner.java | BuildsInner.cancelAsync | public Observable<Void> cancelAsync(String resourceGroupName, String registryName, String buildId) {
return cancelWithServiceResponseAsync(resourceGroupName, registryName, buildId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> cancelAsync(String resourceGroupName, String registryName, String buildId) {
return cancelWithServiceResponseAsync(resourceGroupName, registryName, buildId).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"cancelAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"buildId",
")",
"{",
"return",
"cancelWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"buildId",
... | Cancel an existing build.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildId The build ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Cancel",
"an",
"existing",
"build",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildsInner.java#L911-L918 | train |
Azure/azure-sdk-for-java | common/azure-common-mgmt/src/main/java/com/azure/common/mgmt/PagedList.java | PagedList.loadNextPage | public void loadNextPage() {
this.currentPage = cachedPage;
cachedPage = null;
this.items.addAll(currentPage.items());
cachePage(currentPage.nextPageLink());
} | java | public void loadNextPage() {
this.currentPage = cachedPage;
cachedPage = null;
this.items.addAll(currentPage.items());
cachePage(currentPage.nextPageLink());
} | [
"public",
"void",
"loadNextPage",
"(",
")",
"{",
"this",
".",
"currentPage",
"=",
"cachedPage",
";",
"cachedPage",
"=",
"null",
";",
"this",
".",
"items",
".",
"addAll",
"(",
"currentPage",
".",
"items",
"(",
")",
")",
";",
"cachePage",
"(",
"currentPage... | Loads a page from next page link.
The exceptions are wrapped into Java Runtime exceptions. | [
"Loads",
"a",
"page",
"from",
"next",
"page",
"link",
".",
"The",
"exceptions",
"are",
"wrapped",
"into",
"Java",
"Runtime",
"exceptions",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common-mgmt/src/main/java/com/azure/common/mgmt/PagedList.java#L97-L102 | train |
Azure/azure-sdk-for-java | common/azure-common-mgmt/src/main/java/com/azure/common/mgmt/PagedList.java | PagedList.setCurrentPage | protected void setCurrentPage(Page<E> currentPage) {
this.currentPage = currentPage;
List<E> retrievedItems = currentPage.items();
if (retrievedItems != null) {
items.addAll(retrievedItems);
}
cachePage(currentPage.nextPageLink());
} | java | protected void setCurrentPage(Page<E> currentPage) {
this.currentPage = currentPage;
List<E> retrievedItems = currentPage.items();
if (retrievedItems != null) {
items.addAll(retrievedItems);
}
cachePage(currentPage.nextPageLink());
} | [
"protected",
"void",
"setCurrentPage",
"(",
"Page",
"<",
"E",
">",
"currentPage",
")",
"{",
"this",
".",
"currentPage",
"=",
"currentPage",
";",
"List",
"<",
"E",
">",
"retrievedItems",
"=",
"currentPage",
".",
"items",
"(",
")",
";",
"if",
"(",
"retriev... | Sets the current page.
@param currentPage the current page. | [
"Sets",
"the",
"current",
"page",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common-mgmt/src/main/java/com/azure/common/mgmt/PagedList.java#L127-L134 | train |
Azure/azure-sdk-for-java | eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java | EventGridSubscriber.putCustomEventMapping | @Beta
public void putCustomEventMapping(final String eventType, final Type eventDataType) {
if (eventType == null || eventType.isEmpty()) {
throw new IllegalArgumentException("eventType parameter is required and cannot be null or empty");
}
if (eventDataType == null) {
throw new IllegalArgumentException("eventDataType parameter is required and cannot be null");
}
this.eventTypeToEventDataMapping.put(canonicalizeEventType(eventType), eventDataType);
} | java | @Beta
public void putCustomEventMapping(final String eventType, final Type eventDataType) {
if (eventType == null || eventType.isEmpty()) {
throw new IllegalArgumentException("eventType parameter is required and cannot be null or empty");
}
if (eventDataType == null) {
throw new IllegalArgumentException("eventDataType parameter is required and cannot be null");
}
this.eventTypeToEventDataMapping.put(canonicalizeEventType(eventType), eventDataType);
} | [
"@",
"Beta",
"public",
"void",
"putCustomEventMapping",
"(",
"final",
"String",
"eventType",
",",
"final",
"Type",
"eventDataType",
")",
"{",
"if",
"(",
"eventType",
"==",
"null",
"||",
"eventType",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"Ille... | Add a custom event mapping. If a mapping with same eventType exists then the old eventDataType is replaced by
the specified eventDataType.
@param eventType the event type name.
@param eventDataType type of the Java model that the event type name mapped to. | [
"Add",
"a",
"custom",
"event",
"mapping",
".",
"If",
"a",
"mapping",
"with",
"same",
"eventType",
"exists",
"then",
"the",
"old",
"eventDataType",
"is",
"replaced",
"by",
"the",
"specified",
"eventDataType",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java#L52-L61 | train |
Azure/azure-sdk-for-java | eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java | EventGridSubscriber.getCustomEventMapping | @Beta
public Type getCustomEventMapping(final String eventType) {
if (!containsCustomEventMappingFor(eventType)) {
return null;
} else {
return this.eventTypeToEventDataMapping.get(canonicalizeEventType(eventType));
}
} | java | @Beta
public Type getCustomEventMapping(final String eventType) {
if (!containsCustomEventMappingFor(eventType)) {
return null;
} else {
return this.eventTypeToEventDataMapping.get(canonicalizeEventType(eventType));
}
} | [
"@",
"Beta",
"public",
"Type",
"getCustomEventMapping",
"(",
"final",
"String",
"eventType",
")",
"{",
"if",
"(",
"!",
"containsCustomEventMappingFor",
"(",
"eventType",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"this",
".",
"eventTyp... | Get type of the Java model that is mapped to the given eventType.
@param eventType the event type name.
@return type of the Java model if mapping exists, null otherwise. | [
"Get",
"type",
"of",
"the",
"Java",
"model",
"that",
"is",
"mapped",
"to",
"the",
"given",
"eventType",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java#L69-L76 | train |
Azure/azure-sdk-for-java | eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java | EventGridSubscriber.removeCustomEventMapping | @Beta
public boolean removeCustomEventMapping(final String eventType) {
if (!containsCustomEventMappingFor(eventType)) {
return false;
} else {
this.eventTypeToEventDataMapping.remove(canonicalizeEventType(eventType));
return true;
}
} | java | @Beta
public boolean removeCustomEventMapping(final String eventType) {
if (!containsCustomEventMappingFor(eventType)) {
return false;
} else {
this.eventTypeToEventDataMapping.remove(canonicalizeEventType(eventType));
return true;
}
} | [
"@",
"Beta",
"public",
"boolean",
"removeCustomEventMapping",
"(",
"final",
"String",
"eventType",
")",
"{",
"if",
"(",
"!",
"containsCustomEventMappingFor",
"(",
"eventType",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"this",
".",
"eventTypeToEv... | Removes the mapping with the given eventType.
@param eventType the event type name.
@return true if the mapping exists and removed, false if mapping does not exists. | [
"Removes",
"the",
"mapping",
"with",
"the",
"given",
"eventType",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java#L92-L100 | train |
Azure/azure-sdk-for-java | eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java | EventGridSubscriber.containsCustomEventMappingFor | @Beta
public boolean containsCustomEventMappingFor(final String eventType) {
if (eventType == null || eventType.isEmpty()) {
return false;
} else {
return this.eventTypeToEventDataMapping.containsKey(canonicalizeEventType(eventType));
}
} | java | @Beta
public boolean containsCustomEventMappingFor(final String eventType) {
if (eventType == null || eventType.isEmpty()) {
return false;
} else {
return this.eventTypeToEventDataMapping.containsKey(canonicalizeEventType(eventType));
}
} | [
"@",
"Beta",
"public",
"boolean",
"containsCustomEventMappingFor",
"(",
"final",
"String",
"eventType",
")",
"{",
"if",
"(",
"eventType",
"==",
"null",
"||",
"eventType",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return... | Checks if an event mapping with the given eventType exists.
@param eventType the event type name.
@return true if the mapping exists, false otherwise. | [
"Checks",
"if",
"an",
"event",
"mapping",
"with",
"the",
"given",
"eventType",
"exists",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java#L108-L115 | train |
Azure/azure-sdk-for-java | eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java | EventGridSubscriber.deserializeEventGridEvents | @Beta
public EventGridEvent[] deserializeEventGridEvents(final String requestContent, final SerializerAdapter<ObjectMapper> serializerAdapter) throws IOException {
EventGridEvent[] eventGridEvents = serializerAdapter.<EventGridEvent[]>deserialize(requestContent, EventGridEvent[].class);
for (EventGridEvent receivedEvent : eventGridEvents) {
if (receivedEvent.data() == null) {
continue;
} else {
final String eventType = receivedEvent.eventType();
final Type eventDataType;
if (SystemEventTypeMappings.containsMappingFor(eventType)) {
eventDataType = SystemEventTypeMappings.getMapping(eventType);
} else if (containsCustomEventMappingFor(eventType)) {
eventDataType = getCustomEventMapping(eventType);
} else {
eventDataType = null;
}
if (eventDataType != null) {
final String eventDataAsString = serializerAdapter.serializeRaw(receivedEvent.data());
final Object eventData = serializerAdapter.<Object>deserialize(eventDataAsString, eventDataType);
setEventData(receivedEvent, eventData);
}
}
}
return eventGridEvents;
} | java | @Beta
public EventGridEvent[] deserializeEventGridEvents(final String requestContent, final SerializerAdapter<ObjectMapper> serializerAdapter) throws IOException {
EventGridEvent[] eventGridEvents = serializerAdapter.<EventGridEvent[]>deserialize(requestContent, EventGridEvent[].class);
for (EventGridEvent receivedEvent : eventGridEvents) {
if (receivedEvent.data() == null) {
continue;
} else {
final String eventType = receivedEvent.eventType();
final Type eventDataType;
if (SystemEventTypeMappings.containsMappingFor(eventType)) {
eventDataType = SystemEventTypeMappings.getMapping(eventType);
} else if (containsCustomEventMappingFor(eventType)) {
eventDataType = getCustomEventMapping(eventType);
} else {
eventDataType = null;
}
if (eventDataType != null) {
final String eventDataAsString = serializerAdapter.serializeRaw(receivedEvent.data());
final Object eventData = serializerAdapter.<Object>deserialize(eventDataAsString, eventDataType);
setEventData(receivedEvent, eventData);
}
}
}
return eventGridEvents;
} | [
"@",
"Beta",
"public",
"EventGridEvent",
"[",
"]",
"deserializeEventGridEvents",
"(",
"final",
"String",
"requestContent",
",",
"final",
"SerializerAdapter",
"<",
"ObjectMapper",
">",
"serializerAdapter",
")",
"throws",
"IOException",
"{",
"EventGridEvent",
"[",
"]",
... | De-serialize the events in the given requested content using the provided de-serializer.
@param requestContent the request content as string.
@param serializerAdapter the de-serializer.
@return de-serialized events.
@throws IOException | [
"De",
"-",
"serialize",
"the",
"events",
"in",
"the",
"given",
"requested",
"content",
"using",
"the",
"provided",
"de",
"-",
"serializer",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/customization/EventGridSubscriber.java#L138-L162 | train |
Azure/azure-sdk-for-java | applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ComponentAvailableFeaturesInner.java | ComponentAvailableFeaturesInner.getAsync | public Observable<ApplicationInsightsComponentAvailableFeaturesInner> getAsync(String resourceGroupName, String resourceName) {
return getWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ApplicationInsightsComponentAvailableFeaturesInner>, ApplicationInsightsComponentAvailableFeaturesInner>() {
@Override
public ApplicationInsightsComponentAvailableFeaturesInner call(ServiceResponse<ApplicationInsightsComponentAvailableFeaturesInner> response) {
return response.body();
}
});
} | java | public Observable<ApplicationInsightsComponentAvailableFeaturesInner> getAsync(String resourceGroupName, String resourceName) {
return getWithServiceResponseAsync(resourceGroupName, resourceName).map(new Func1<ServiceResponse<ApplicationInsightsComponentAvailableFeaturesInner>, ApplicationInsightsComponentAvailableFeaturesInner>() {
@Override
public ApplicationInsightsComponentAvailableFeaturesInner call(ServiceResponse<ApplicationInsightsComponentAvailableFeaturesInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ApplicationInsightsComponentAvailableFeaturesInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
")",
".",... | Returns all available features of the application insights component.
@param resourceGroupName The name of the resource group.
@param resourceName The name of the Application Insights component resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ApplicationInsightsComponentAvailableFeaturesInner object | [
"Returns",
"all",
"available",
"features",
"of",
"the",
"application",
"insights",
"component",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/applicationinsights/resource-manager/v2015_05_01/src/main/java/com/microsoft/azure/management/applicationinsights/v2015_05_01/implementation/ComponentAvailableFeaturesInner.java#L95-L102 | train |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/RestorableDroppedDatabasesInner.java | RestorableDroppedDatabasesInner.listByServerAsync | public Observable<List<RestorableDroppedDatabaseInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<RestorableDroppedDatabaseInner>>, List<RestorableDroppedDatabaseInner>>() {
@Override
public List<RestorableDroppedDatabaseInner> call(ServiceResponse<List<RestorableDroppedDatabaseInner>> response) {
return response.body();
}
});
} | java | public Observable<List<RestorableDroppedDatabaseInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<RestorableDroppedDatabaseInner>>, List<RestorableDroppedDatabaseInner>>() {
@Override
public List<RestorableDroppedDatabaseInner> call(ServiceResponse<List<RestorableDroppedDatabaseInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"RestorableDroppedDatabaseInner",
">",
">",
"listByServerAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverNa... | Gets a list of deleted databases that can be restored.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<RestorableDroppedDatabaseInner> object | [
"Gets",
"a",
"list",
"of",
"deleted",
"databases",
"that",
"can",
"be",
"restored",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/RestorableDroppedDatabasesInner.java#L193-L200 | train |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVisionManager.java | ComputerVisionManager.authenticate | public static ComputerVisionClient authenticate(ServiceClientCredentials credentials, String endpoint) {
return authenticate("https://{endpoint}/vision/v2.0/", credentials)
.withEndpoint(endpoint);
} | java | public static ComputerVisionClient authenticate(ServiceClientCredentials credentials, String endpoint) {
return authenticate("https://{endpoint}/vision/v2.0/", credentials)
.withEndpoint(endpoint);
} | [
"public",
"static",
"ComputerVisionClient",
"authenticate",
"(",
"ServiceClientCredentials",
"credentials",
",",
"String",
"endpoint",
")",
"{",
"return",
"authenticate",
"(",
"\"https://{endpoint}/vision/v2.0/\"",
",",
"credentials",
")",
".",
"withEndpoint",
"(",
"endpo... | Initializes an instance of Computer Vision API client.
@param credentials the management credentials for Azure
@param endpoint Supported Cognitive Services endpoints.
@return the Computer Vision API client | [
"Initializes",
"an",
"instance",
"of",
"Computer",
"Vision",
"API",
"client",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/computervision/src/main/java/com/microsoft/azure/cognitiveservices/vision/computervision/ComputerVisionManager.java#L69-L72 | train |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ExamplesImpl.java | ExamplesImpl.deleteAsync | public Observable<OperationStatus> deleteAsync(UUID appId, String versionId, int exampleId) {
return deleteWithServiceResponseAsync(appId, versionId, exampleId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | java | public Observable<OperationStatus> deleteAsync(UUID appId, String versionId, int exampleId) {
return deleteWithServiceResponseAsync(appId, versionId, exampleId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"OperationStatus",
">",
"deleteAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"int",
"exampleId",
")",
"{",
"return",
"deleteWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"exampleId",
")",
".",
"map"... | Deletes the labeled example with the specified ID.
@param appId The application ID.
@param versionId The version ID.
@param exampleId The example ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object | [
"Deletes",
"the",
"labeled",
"example",
"with",
"the",
"specified",
"ID",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ExamplesImpl.java#L487-L494 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/Base64Util.java | Base64Util.encodeURLWithoutPadding | public static byte[] encodeURLWithoutPadding(byte[] src) {
return src == null ? null : Base64.getUrlEncoder().withoutPadding().encode(src);
} | java | public static byte[] encodeURLWithoutPadding(byte[] src) {
return src == null ? null : Base64.getUrlEncoder().withoutPadding().encode(src);
} | [
"public",
"static",
"byte",
"[",
"]",
"encodeURLWithoutPadding",
"(",
"byte",
"[",
"]",
"src",
")",
"{",
"return",
"src",
"==",
"null",
"?",
"null",
":",
"Base64",
".",
"getUrlEncoder",
"(",
")",
".",
"withoutPadding",
"(",
")",
".",
"encode",
"(",
"sr... | Encodes a byte array to base64 URL format.
@param src the byte array to encode
@return the base64 URL encoded bytes | [
"Encodes",
"a",
"byte",
"array",
"to",
"base64",
"URL",
"format",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/Base64Util.java#L26-L28 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/Base64Util.java | Base64Util.encodeToString | public static String encodeToString(byte[] src) {
return src == null ? null : Base64.getEncoder().encodeToString(src);
} | java | public static String encodeToString(byte[] src) {
return src == null ? null : Base64.getEncoder().encodeToString(src);
} | [
"public",
"static",
"String",
"encodeToString",
"(",
"byte",
"[",
"]",
"src",
")",
"{",
"return",
"src",
"==",
"null",
"?",
"null",
":",
"Base64",
".",
"getEncoder",
"(",
")",
".",
"encodeToString",
"(",
"src",
")",
";",
"}"
] | Encodes a byte array to a base 64 string.
@param src the byte array to encode
@return the base64 encoded string | [
"Encodes",
"a",
"byte",
"array",
"to",
"a",
"base",
"64",
"string",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/Base64Util.java#L35-L37 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/Base64Util.java | Base64Util.decodeString | public static byte[] decodeString(String encoded) {
return encoded == null ? null : Base64.getDecoder().decode(encoded);
} | java | public static byte[] decodeString(String encoded) {
return encoded == null ? null : Base64.getDecoder().decode(encoded);
} | [
"public",
"static",
"byte",
"[",
"]",
"decodeString",
"(",
"String",
"encoded",
")",
"{",
"return",
"encoded",
"==",
"null",
"?",
"null",
":",
"Base64",
".",
"getDecoder",
"(",
")",
".",
"decode",
"(",
"encoded",
")",
";",
"}"
] | Decodes a base64 encoded string.
@param encoded the string to decode
@return the decoded byte array | [
"Decodes",
"a",
"base64",
"encoded",
"string",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/Base64Util.java#L62-L64 | train |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabaseThreatDetectionPoliciesInner.java | DatabaseThreatDetectionPoliciesInner.getAsync | public Observable<DatabaseSecurityAlertPolicyInner> getAsync(String resourceGroupName, String serverName, String databaseName) {
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<DatabaseSecurityAlertPolicyInner>, DatabaseSecurityAlertPolicyInner>() {
@Override
public DatabaseSecurityAlertPolicyInner call(ServiceResponse<DatabaseSecurityAlertPolicyInner> response) {
return response.body();
}
});
} | java | public Observable<DatabaseSecurityAlertPolicyInner> getAsync(String resourceGroupName, String serverName, String databaseName) {
return getWithServiceResponseAsync(resourceGroupName, serverName, databaseName).map(new Func1<ServiceResponse<DatabaseSecurityAlertPolicyInner>, DatabaseSecurityAlertPolicyInner>() {
@Override
public DatabaseSecurityAlertPolicyInner call(ServiceResponse<DatabaseSecurityAlertPolicyInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DatabaseSecurityAlertPolicyInner",
">",
"getAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
")",
"{",
"return",
"getWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName"... | Gets a database's threat detection policy.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database for which database Threat Detection policy is defined.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DatabaseSecurityAlertPolicyInner object | [
"Gets",
"a",
"database",
"s",
"threat",
"detection",
"policy",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabaseThreatDetectionPoliciesInner.java#L105-L112 | train |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabaseThreatDetectionPoliciesInner.java | DatabaseThreatDetectionPoliciesInner.createOrUpdateAsync | public Observable<DatabaseSecurityAlertPolicyInner> createOrUpdateAsync(String resourceGroupName, String serverName, String databaseName, DatabaseSecurityAlertPolicyInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).map(new Func1<ServiceResponse<DatabaseSecurityAlertPolicyInner>, DatabaseSecurityAlertPolicyInner>() {
@Override
public DatabaseSecurityAlertPolicyInner call(ServiceResponse<DatabaseSecurityAlertPolicyInner> response) {
return response.body();
}
});
} | java | public Observable<DatabaseSecurityAlertPolicyInner> createOrUpdateAsync(String resourceGroupName, String serverName, String databaseName, DatabaseSecurityAlertPolicyInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).map(new Func1<ServiceResponse<DatabaseSecurityAlertPolicyInner>, DatabaseSecurityAlertPolicyInner>() {
@Override
public DatabaseSecurityAlertPolicyInner call(ServiceResponse<DatabaseSecurityAlertPolicyInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DatabaseSecurityAlertPolicyInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"DatabaseSecurityAlertPolicyInner",
"parameters",
")",
"{",
"return",
"createOrU... | Creates or updates a database's threat detection policy.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database for which database Threat Detection policy is defined.
@param parameters The database Threat Detection policy.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DatabaseSecurityAlertPolicyInner object | [
"Creates",
"or",
"updates",
"a",
"database",
"s",
"threat",
"detection",
"policy",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabaseThreatDetectionPoliciesInner.java#L202-L209 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java | TypeUtil.getAllClasses | public static List<Class<?>> getAllClasses(Class<?> clazz) {
List<Class<?>> types = new ArrayList<>();
while (clazz != null) {
types.add(clazz);
clazz = clazz.getSuperclass();
}
return types;
} | java | public static List<Class<?>> getAllClasses(Class<?> clazz) {
List<Class<?>> types = new ArrayList<>();
while (clazz != null) {
types.add(clazz);
clazz = clazz.getSuperclass();
}
return types;
} | [
"public",
"static",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"getAllClasses",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"types",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"while",
"(",
"clazz",... | Find all super classes including provided class.
@param clazz the raw class to find super types for
@return the list of super classes | [
"Find",
"all",
"super",
"classes",
"including",
"provided",
"class",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java#L22-L29 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java | TypeUtil.getTypeArguments | public static Type[] getTypeArguments(Type type) {
if (!(type instanceof ParameterizedType)) {
return new Type[0];
}
return ((ParameterizedType) type).getActualTypeArguments();
} | java | public static Type[] getTypeArguments(Type type) {
if (!(type instanceof ParameterizedType)) {
return new Type[0];
}
return ((ParameterizedType) type).getActualTypeArguments();
} | [
"public",
"static",
"Type",
"[",
"]",
"getTypeArguments",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"!",
"(",
"type",
"instanceof",
"ParameterizedType",
")",
")",
"{",
"return",
"new",
"Type",
"[",
"0",
"]",
";",
"}",
"return",
"(",
"(",
"Parameterized... | Get the generic arguments for a type.
@param type the type to get arguments
@return the generic arguments, empty if type is not parameterized | [
"Get",
"the",
"generic",
"arguments",
"for",
"a",
"type",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java#L37-L42 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java | TypeUtil.getTypeArgument | public static Type getTypeArgument(Type type) {
if (!(type instanceof ParameterizedType)) {
return null;
}
return ((ParameterizedType) type).getActualTypeArguments()[0];
} | java | public static Type getTypeArgument(Type type) {
if (!(type instanceof ParameterizedType)) {
return null;
}
return ((ParameterizedType) type).getActualTypeArguments()[0];
} | [
"public",
"static",
"Type",
"getTypeArgument",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"!",
"(",
"type",
"instanceof",
"ParameterizedType",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"(",
"(",
"ParameterizedType",
")",
"type",
")",
".",
"getA... | Get the generic argument, or the first if the type has more than one.
@param type the type to get arguments
@return the generic argument, null if type is not parameterized | [
"Get",
"the",
"generic",
"argument",
"or",
"the",
"first",
"if",
"the",
"type",
"has",
"more",
"than",
"one",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java#L50-L55 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java | TypeUtil.getSuperType | public static Type getSuperType(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Type genericSuperClass = ((Class<?>) parameterizedType.getRawType()).getGenericSuperclass();
if (genericSuperClass instanceof ParameterizedType) {
/*
* Find erased generic types for the super class and replace
* with actual type arguments from the parameterized type
*/
Type[] superTypeArguments = getTypeArguments(genericSuperClass);
List<Type> typeParameters = Arrays.asList(((Class<?>) parameterizedType.getRawType()).getTypeParameters());
int j = 0;
for (int i = 0; i != superTypeArguments.length; i++) {
if (typeParameters.contains(superTypeArguments[i])) {
superTypeArguments[i] = parameterizedType.getActualTypeArguments()[j++];
}
}
return new ParameterizedType() {
@Override
public Type[] getActualTypeArguments() {
return superTypeArguments;
}
@Override
public Type getRawType() {
return ((ParameterizedType) genericSuperClass).getRawType();
}
@Override
public Type getOwnerType() {
return null;
}
};
} else {
return genericSuperClass;
}
} else {
return ((Class<?>) type).getGenericSuperclass();
}
} | java | public static Type getSuperType(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Type genericSuperClass = ((Class<?>) parameterizedType.getRawType()).getGenericSuperclass();
if (genericSuperClass instanceof ParameterizedType) {
/*
* Find erased generic types for the super class and replace
* with actual type arguments from the parameterized type
*/
Type[] superTypeArguments = getTypeArguments(genericSuperClass);
List<Type> typeParameters = Arrays.asList(((Class<?>) parameterizedType.getRawType()).getTypeParameters());
int j = 0;
for (int i = 0; i != superTypeArguments.length; i++) {
if (typeParameters.contains(superTypeArguments[i])) {
superTypeArguments[i] = parameterizedType.getActualTypeArguments()[j++];
}
}
return new ParameterizedType() {
@Override
public Type[] getActualTypeArguments() {
return superTypeArguments;
}
@Override
public Type getRawType() {
return ((ParameterizedType) genericSuperClass).getRawType();
}
@Override
public Type getOwnerType() {
return null;
}
};
} else {
return genericSuperClass;
}
} else {
return ((Class<?>) type).getGenericSuperclass();
}
} | [
"public",
"static",
"Type",
"getSuperType",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"ParameterizedType",
")",
"{",
"ParameterizedType",
"parameterizedType",
"=",
"(",
"ParameterizedType",
")",
"type",
";",
"Type",
"genericSuperClass",
"=",
... | Get the super type for a given type.
@param type the input type
@return the direct super type | [
"Get",
"the",
"super",
"type",
"for",
"a",
"given",
"type",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java#L77-L116 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java | TypeUtil.getSuperType | public static Type getSuperType(Type subType, Class<?> rawSuperType) {
while (subType != null && getRawClass(subType) != rawSuperType) {
subType = getSuperType(subType);
}
return subType;
} | java | public static Type getSuperType(Type subType, Class<?> rawSuperType) {
while (subType != null && getRawClass(subType) != rawSuperType) {
subType = getSuperType(subType);
}
return subType;
} | [
"public",
"static",
"Type",
"getSuperType",
"(",
"Type",
"subType",
",",
"Class",
"<",
"?",
">",
"rawSuperType",
")",
"{",
"while",
"(",
"subType",
"!=",
"null",
"&&",
"getRawClass",
"(",
"subType",
")",
"!=",
"rawSuperType",
")",
"{",
"subType",
"=",
"g... | Get the super type for a type in its super type chain, which has
a raw class that matches the specified class.
@param subType the sub type to find super type for
@param rawSuperType the raw class for the super type
@return the super type that matches the requirement | [
"Get",
"the",
"super",
"type",
"for",
"a",
"type",
"in",
"its",
"super",
"type",
"chain",
"which",
"has",
"a",
"raw",
"class",
"that",
"matches",
"the",
"specified",
"class",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java#L126-L131 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java | TypeUtil.isTypeOrSubTypeOf | public static boolean isTypeOrSubTypeOf(Type subType, Type superType) {
Class<?> sub = getRawClass(subType);
Class<?> sup = getRawClass(superType);
return sup.isAssignableFrom(sub);
} | java | public static boolean isTypeOrSubTypeOf(Type subType, Type superType) {
Class<?> sub = getRawClass(subType);
Class<?> sup = getRawClass(superType);
return sup.isAssignableFrom(sub);
} | [
"public",
"static",
"boolean",
"isTypeOrSubTypeOf",
"(",
"Type",
"subType",
",",
"Type",
"superType",
")",
"{",
"Class",
"<",
"?",
">",
"sub",
"=",
"getRawClass",
"(",
"subType",
")",
";",
"Class",
"<",
"?",
">",
"sup",
"=",
"getRawClass",
"(",
"superTyp... | Determines if a type is the same or a subtype for another type.
@param subType the supposed sub type
@param superType the supposed super type
@return true if the first type is the same or a subtype for the second type | [
"Determines",
"if",
"a",
"type",
"is",
"the",
"same",
"or",
"a",
"subtype",
"for",
"another",
"type",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java#L140-L145 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java | TypeUtil.createParameterizedType | public static ParameterizedType createParameterizedType(Class<?> rawClass, Type... genericTypes) {
return new ParameterizedType() {
@Override
public Type[] getActualTypeArguments() {
return genericTypes;
}
@Override
public Type getRawType() {
return rawClass;
}
@Override
public Type getOwnerType() {
return null;
}
};
} | java | public static ParameterizedType createParameterizedType(Class<?> rawClass, Type... genericTypes) {
return new ParameterizedType() {
@Override
public Type[] getActualTypeArguments() {
return genericTypes;
}
@Override
public Type getRawType() {
return rawClass;
}
@Override
public Type getOwnerType() {
return null;
}
};
} | [
"public",
"static",
"ParameterizedType",
"createParameterizedType",
"(",
"Class",
"<",
"?",
">",
"rawClass",
",",
"Type",
"...",
"genericTypes",
")",
"{",
"return",
"new",
"ParameterizedType",
"(",
")",
"{",
"@",
"Override",
"public",
"Type",
"[",
"]",
"getAct... | Create a parameterized type from a raw class and its type arguments.
@param rawClass the raw class to construct the parameterized type
@param genericTypes the generic arguments
@return the parameterized type | [
"Create",
"a",
"parameterized",
"type",
"from",
"a",
"raw",
"class",
"and",
"its",
"type",
"arguments",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java#L154-L171 | train |
Azure/azure-sdk-for-java | common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java | TypeUtil.getRestResponseBodyType | public static Type getRestResponseBodyType(Type restResponseReturnType) {
// if this type has type arguments, then we look at the last one to determine if it expects a body
final Type[] restResponseTypeArguments = TypeUtil.getTypeArguments(restResponseReturnType);
if (restResponseTypeArguments != null && restResponseTypeArguments.length > 0) {
return restResponseTypeArguments[restResponseTypeArguments.length - 1];
} else {
// no generic type on this RestResponse sub-type, so we go up to parent
return getRestResponseBodyType(TypeUtil.getSuperType(restResponseReturnType));
}
} | java | public static Type getRestResponseBodyType(Type restResponseReturnType) {
// if this type has type arguments, then we look at the last one to determine if it expects a body
final Type[] restResponseTypeArguments = TypeUtil.getTypeArguments(restResponseReturnType);
if (restResponseTypeArguments != null && restResponseTypeArguments.length > 0) {
return restResponseTypeArguments[restResponseTypeArguments.length - 1];
} else {
// no generic type on this RestResponse sub-type, so we go up to parent
return getRestResponseBodyType(TypeUtil.getSuperType(restResponseReturnType));
}
} | [
"public",
"static",
"Type",
"getRestResponseBodyType",
"(",
"Type",
"restResponseReturnType",
")",
"{",
"// if this type has type arguments, then we look at the last one to determine if it expects a body",
"final",
"Type",
"[",
"]",
"restResponseTypeArguments",
"=",
"TypeUtil",
"."... | Returns the body type expected in the rest response.
@param restResponseReturnType The RestResponse subtype containing the type arguments we are inspecting.
@return The type of the body. | [
"Returns",
"the",
"body",
"type",
"expected",
"in",
"the",
"rest",
"response",
"."
] | aab183ddc6686c82ec10386d5a683d2691039626 | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/common/azure-common/src/main/java/com/azure/common/implementation/util/TypeUtil.java#L190-L199 | train |
wstrange/GoogleAuth | src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java | GoogleAuthenticator.calculateCode | int calculateCode(byte[] key, long tm)
{
// Allocating an array of bytes to represent the specified instant
// of time.
byte[] data = new byte[8];
long value = tm;
// Converting the instant of time from the long representation to a
// big-endian array of bytes (RFC4226, 5.2. Description).
for (int i = 8; i-- > 0; value >>>= 8)
{
data[i] = (byte) value;
}
// Building the secret key specification for the HmacSHA1 algorithm.
SecretKeySpec signKey = new SecretKeySpec(key, config.getHmacHashFunction().toString());
try
{
// Getting an HmacSHA1/HmacSHA256 algorithm implementation from the JCE.
Mac mac = Mac.getInstance(config.getHmacHashFunction().toString());
// Initializing the MAC algorithm.
mac.init(signKey);
// Processing the instant of time and getting the encrypted data.
byte[] hash = mac.doFinal(data);
// Building the validation code performing dynamic truncation
// (RFC4226, 5.3. Generating an HOTP value)
int offset = hash[hash.length - 1] & 0xF;
// We are using a long because Java hasn't got an unsigned integer type
// and we need 32 unsigned bits).
long truncatedHash = 0;
for (int i = 0; i < 4; ++i)
{
truncatedHash <<= 8;
// Java bytes are signed but we need an unsigned integer:
// cleaning off all but the LSB.
truncatedHash |= (hash[offset + i] & 0xFF);
}
// Clean bits higher than the 32nd (inclusive) and calculate the
// module with the maximum validation code value.
truncatedHash &= 0x7FFFFFFF;
truncatedHash %= config.getKeyModulus();
// Returning the validation code to the caller.
return (int) truncatedHash;
}
catch (NoSuchAlgorithmException | InvalidKeyException ex)
{
// Logging the exception.
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
// We're not disclosing internal error details to our clients.
throw new GoogleAuthenticatorException("The operation cannot be performed now.");
}
} | java | int calculateCode(byte[] key, long tm)
{
// Allocating an array of bytes to represent the specified instant
// of time.
byte[] data = new byte[8];
long value = tm;
// Converting the instant of time from the long representation to a
// big-endian array of bytes (RFC4226, 5.2. Description).
for (int i = 8; i-- > 0; value >>>= 8)
{
data[i] = (byte) value;
}
// Building the secret key specification for the HmacSHA1 algorithm.
SecretKeySpec signKey = new SecretKeySpec(key, config.getHmacHashFunction().toString());
try
{
// Getting an HmacSHA1/HmacSHA256 algorithm implementation from the JCE.
Mac mac = Mac.getInstance(config.getHmacHashFunction().toString());
// Initializing the MAC algorithm.
mac.init(signKey);
// Processing the instant of time and getting the encrypted data.
byte[] hash = mac.doFinal(data);
// Building the validation code performing dynamic truncation
// (RFC4226, 5.3. Generating an HOTP value)
int offset = hash[hash.length - 1] & 0xF;
// We are using a long because Java hasn't got an unsigned integer type
// and we need 32 unsigned bits).
long truncatedHash = 0;
for (int i = 0; i < 4; ++i)
{
truncatedHash <<= 8;
// Java bytes are signed but we need an unsigned integer:
// cleaning off all but the LSB.
truncatedHash |= (hash[offset + i] & 0xFF);
}
// Clean bits higher than the 32nd (inclusive) and calculate the
// module with the maximum validation code value.
truncatedHash &= 0x7FFFFFFF;
truncatedHash %= config.getKeyModulus();
// Returning the validation code to the caller.
return (int) truncatedHash;
}
catch (NoSuchAlgorithmException | InvalidKeyException ex)
{
// Logging the exception.
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
// We're not disclosing internal error details to our clients.
throw new GoogleAuthenticatorException("The operation cannot be performed now.");
}
} | [
"int",
"calculateCode",
"(",
"byte",
"[",
"]",
"key",
",",
"long",
"tm",
")",
"{",
"// Allocating an array of bytes to represent the specified instant",
"// of time.",
"byte",
"[",
"]",
"data",
"=",
"new",
"byte",
"[",
"8",
"]",
";",
"long",
"value",
"=",
"tm"... | Calculates the verification code of the provided key at the specified
instant of time using the algorithm specified in RFC 6238.
@param key the secret key in binary format.
@param tm the instant of time.
@return the validation code for the provided key at the specified instant
of time. | [
"Calculates",
"the",
"verification",
"code",
"of",
"the",
"provided",
"key",
"at",
"the",
"specified",
"instant",
"of",
"time",
"using",
"the",
"algorithm",
"specified",
"in",
"RFC",
"6238",
"."
] | 03f37333f8b3e411e10e63a7c85c4d2155929321 | https://github.com/wstrange/GoogleAuth/blob/03f37333f8b3e411e10e63a7c85c4d2155929321/src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java#L209-L270 | train |
wstrange/GoogleAuth | src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java | GoogleAuthenticator.checkCode | private boolean checkCode(
String secret,
long code,
long timestamp,
int window)
{
byte[] decodedKey = decodeSecret(secret);
// convert unix time into a 30 second "window" as specified by the
// TOTP specification. Using Google's default interval of 30 seconds.
final long timeWindow = getTimeWindowFromTime(timestamp);
// Calculating the verification code of the given key in each of the
// time intervals and returning true if the provided code is equal to
// one of them.
for (int i = -((window - 1) / 2); i <= window / 2; ++i)
{
// Calculating the verification code for the current time interval.
long hash = calculateCode(decodedKey, timeWindow + i);
// Checking if the provided code is equal to the calculated one.
if (hash == code)
{
// The verification code is valid.
return true;
}
}
// The verification code is invalid.
return false;
} | java | private boolean checkCode(
String secret,
long code,
long timestamp,
int window)
{
byte[] decodedKey = decodeSecret(secret);
// convert unix time into a 30 second "window" as specified by the
// TOTP specification. Using Google's default interval of 30 seconds.
final long timeWindow = getTimeWindowFromTime(timestamp);
// Calculating the verification code of the given key in each of the
// time intervals and returning true if the provided code is equal to
// one of them.
for (int i = -((window - 1) / 2); i <= window / 2; ++i)
{
// Calculating the verification code for the current time interval.
long hash = calculateCode(decodedKey, timeWindow + i);
// Checking if the provided code is equal to the calculated one.
if (hash == code)
{
// The verification code is valid.
return true;
}
}
// The verification code is invalid.
return false;
} | [
"private",
"boolean",
"checkCode",
"(",
"String",
"secret",
",",
"long",
"code",
",",
"long",
"timestamp",
",",
"int",
"window",
")",
"{",
"byte",
"[",
"]",
"decodedKey",
"=",
"decodeSecret",
"(",
"secret",
")",
";",
"// convert unix time into a 30 second \"wind... | This method implements the algorithm specified in RFC 6238 to check if a
validation code is valid in a given instant of time for the given secret
key.
@param secret the Base32 encoded secret key.
@param code the code to validate.
@param timestamp the instant of time to use during the validation process.
@param window the window size to use during the validation process.
@return <code>true</code> if the validation code is valid,
<code>false</code> otherwise. | [
"This",
"method",
"implements",
"the",
"algorithm",
"specified",
"in",
"RFC",
"6238",
"to",
"check",
"if",
"a",
"validation",
"code",
"is",
"valid",
"in",
"a",
"given",
"instant",
"of",
"time",
"for",
"the",
"given",
"secret",
"key",
"."
] | 03f37333f8b3e411e10e63a7c85c4d2155929321 | https://github.com/wstrange/GoogleAuth/blob/03f37333f8b3e411e10e63a7c85c4d2155929321/src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java#L289-L319 | train |
wstrange/GoogleAuth | src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java | GoogleAuthenticator.generateScratchCode | private int generateScratchCode()
{
while (true)
{
byte[] scratchCodeBuffer = new byte[BYTES_PER_SCRATCH_CODE];
secureRandom.nextBytes(scratchCodeBuffer);
int scratchCode = calculateScratchCode(scratchCodeBuffer);
if (scratchCode != SCRATCH_CODE_INVALID)
{
return scratchCode;
}
}
} | java | private int generateScratchCode()
{
while (true)
{
byte[] scratchCodeBuffer = new byte[BYTES_PER_SCRATCH_CODE];
secureRandom.nextBytes(scratchCodeBuffer);
int scratchCode = calculateScratchCode(scratchCodeBuffer);
if (scratchCode != SCRATCH_CODE_INVALID)
{
return scratchCode;
}
}
} | [
"private",
"int",
"generateScratchCode",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"byte",
"[",
"]",
"scratchCodeBuffer",
"=",
"new",
"byte",
"[",
"BYTES_PER_SCRATCH_CODE",
"]",
";",
"secureRandom",
".",
"nextBytes",
"(",
"scratchCodeBuffer",
")",
";",
... | This method creates a new random byte buffer from which a new scratch
code is generated. This function is invoked if a scratch code generated
from the main buffer is invalid because it does not satisfy the scratch
code restrictions.
@return A valid scratch code. | [
"This",
"method",
"creates",
"a",
"new",
"random",
"byte",
"buffer",
"from",
"which",
"a",
"new",
"scratch",
"code",
"is",
"generated",
".",
"This",
"function",
"is",
"invoked",
"if",
"a",
"scratch",
"code",
"generated",
"from",
"the",
"main",
"buffer",
"i... | 03f37333f8b3e411e10e63a7c85c4d2155929321 | https://github.com/wstrange/GoogleAuth/blob/03f37333f8b3e411e10e63a7c85c4d2155929321/src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java#L452-L466 | train |
wstrange/GoogleAuth | src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java | GoogleAuthenticator.calculateSecretKey | private String calculateSecretKey(byte[] secretKey)
{
switch (config.getKeyRepresentation())
{
case BASE32:
return new Base32().encodeToString(secretKey);
case BASE64:
return new Base64().encodeToString(secretKey);
default:
throw new IllegalArgumentException("Unknown key representation type.");
}
} | java | private String calculateSecretKey(byte[] secretKey)
{
switch (config.getKeyRepresentation())
{
case BASE32:
return new Base32().encodeToString(secretKey);
case BASE64:
return new Base64().encodeToString(secretKey);
default:
throw new IllegalArgumentException("Unknown key representation type.");
}
} | [
"private",
"String",
"calculateSecretKey",
"(",
"byte",
"[",
"]",
"secretKey",
")",
"{",
"switch",
"(",
"config",
".",
"getKeyRepresentation",
"(",
")",
")",
"{",
"case",
"BASE32",
":",
"return",
"new",
"Base32",
"(",
")",
".",
"encodeToString",
"(",
"secr... | This method calculates the secret key given a random byte buffer.
@param secretKey a random byte buffer.
@return the secret key. | [
"This",
"method",
"calculates",
"the",
"secret",
"key",
"given",
"a",
"random",
"byte",
"buffer",
"."
] | 03f37333f8b3e411e10e63a7c85c4d2155929321 | https://github.com/wstrange/GoogleAuth/blob/03f37333f8b3e411e10e63a7c85c4d2155929321/src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java#L510-L521 | train |
wstrange/GoogleAuth | src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java | GoogleAuthenticator.getValidCredentialRepository | private ICredentialRepository getValidCredentialRepository()
{
ICredentialRepository repository = getCredentialRepository();
if (repository == null)
{
throw new UnsupportedOperationException(
String.format("An instance of the %s service must be " +
"configured in order to use this feature.",
ICredentialRepository.class.getName()
)
);
}
return repository;
} | java | private ICredentialRepository getValidCredentialRepository()
{
ICredentialRepository repository = getCredentialRepository();
if (repository == null)
{
throw new UnsupportedOperationException(
String.format("An instance of the %s service must be " +
"configured in order to use this feature.",
ICredentialRepository.class.getName()
)
);
}
return repository;
} | [
"private",
"ICredentialRepository",
"getValidCredentialRepository",
"(",
")",
"{",
"ICredentialRepository",
"repository",
"=",
"getCredentialRepository",
"(",
")",
";",
"if",
"(",
"repository",
"==",
"null",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"("... | This method loads the first available and valid ICredentialRepository
registered using the Java service loader API.
@return the first registered ICredentialRepository.
@throws java.lang.UnsupportedOperationException if no valid service is
found. | [
"This",
"method",
"loads",
"the",
"first",
"available",
"and",
"valid",
"ICredentialRepository",
"registered",
"using",
"the",
"Java",
"service",
"loader",
"API",
"."
] | 03f37333f8b3e411e10e63a7c85c4d2155929321 | https://github.com/wstrange/GoogleAuth/blob/03f37333f8b3e411e10e63a7c85c4d2155929321/src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java#L577-L592 | train |
wstrange/GoogleAuth | src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java | GoogleAuthenticator.getCredentialRepository | public ICredentialRepository getCredentialRepository()
{
if (this.credentialRepositorySearched) return this.credentialRepository;
this.credentialRepositorySearched = true;
ServiceLoader<ICredentialRepository> loader =
ServiceLoader.load(ICredentialRepository.class);
//noinspection LoopStatementThatDoesntLoop
for (ICredentialRepository repository : loader)
{
this.credentialRepository = repository;
break;
}
return this.credentialRepository;
} | java | public ICredentialRepository getCredentialRepository()
{
if (this.credentialRepositorySearched) return this.credentialRepository;
this.credentialRepositorySearched = true;
ServiceLoader<ICredentialRepository> loader =
ServiceLoader.load(ICredentialRepository.class);
//noinspection LoopStatementThatDoesntLoop
for (ICredentialRepository repository : loader)
{
this.credentialRepository = repository;
break;
}
return this.credentialRepository;
} | [
"public",
"ICredentialRepository",
"getCredentialRepository",
"(",
")",
"{",
"if",
"(",
"this",
".",
"credentialRepositorySearched",
")",
"return",
"this",
".",
"credentialRepository",
";",
"this",
".",
"credentialRepositorySearched",
"=",
"true",
";",
"ServiceLoader",
... | This method loads the first available ICredentialRepository
registered using the Java service loader API.
@return the first registered ICredentialRepository or <code>null</code>
if none is found. | [
"This",
"method",
"loads",
"the",
"first",
"available",
"ICredentialRepository",
"registered",
"using",
"the",
"Java",
"service",
"loader",
"API",
"."
] | 03f37333f8b3e411e10e63a7c85c4d2155929321 | https://github.com/wstrange/GoogleAuth/blob/03f37333f8b3e411e10e63a7c85c4d2155929321/src/main/java/com/warrenstrange/googleauth/GoogleAuthenticator.java#L601-L618 | train |
bbossgroups/bboss-elasticsearch | bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/client/BuildTool.java | BuildTool.buildMeta | public static void buildMeta(Writer writer ,String indexType,String indexName, Object params,String action,ClientOptions clientOption,boolean upper7) throws IOException {
if(params instanceof Map){
buildMapMeta( writer , indexType, indexName, (Map) params, action, clientOption, upper7);
return;
}
Object id = null;
Object parentId = null;
Object routing = null;
Object esRetryOnConflict = null;
Object version = null;
Object versionType = null;
if(clientOption != null) {
ClassUtil.ClassInfo beanClassInfo = ClassUtil.getClassInfo(params.getClass());
id = clientOption.getIdField() != null ? BuildTool.getId(params, beanClassInfo, clientOption.getIdField()) : null;
parentId = clientOption.getParentIdField() != null ? BuildTool.getParentId(params, beanClassInfo, clientOption.getParentIdField()) : null;
routing = clientOption.getRountField() != null ? BuildTool.getRouting(params, beanClassInfo, clientOption.getRountField()) : null;
esRetryOnConflict = clientOption.getEsRetryOnConflictField() != null ? BuildTool.getEsRetryOnConflict(params, beanClassInfo,
clientOption.getEsRetryOnConflictField()) : null;
version = clientOption.getVersionField() != null ? BuildTool.getEsRetryOnConflict(params, beanClassInfo,clientOption.getVersionField()) : null;
versionType = clientOption.getVersionTypeField() != null ? BuildTool.getEsRetryOnConflict(params, beanClassInfo,clientOption.getVersionTypeField()) : null;
}
buildMeta( writer , indexType, indexName, params, action, id, parentId,routing,esRetryOnConflict,version,versionType, upper7);
} | java | public static void buildMeta(Writer writer ,String indexType,String indexName, Object params,String action,ClientOptions clientOption,boolean upper7) throws IOException {
if(params instanceof Map){
buildMapMeta( writer , indexType, indexName, (Map) params, action, clientOption, upper7);
return;
}
Object id = null;
Object parentId = null;
Object routing = null;
Object esRetryOnConflict = null;
Object version = null;
Object versionType = null;
if(clientOption != null) {
ClassUtil.ClassInfo beanClassInfo = ClassUtil.getClassInfo(params.getClass());
id = clientOption.getIdField() != null ? BuildTool.getId(params, beanClassInfo, clientOption.getIdField()) : null;
parentId = clientOption.getParentIdField() != null ? BuildTool.getParentId(params, beanClassInfo, clientOption.getParentIdField()) : null;
routing = clientOption.getRountField() != null ? BuildTool.getRouting(params, beanClassInfo, clientOption.getRountField()) : null;
esRetryOnConflict = clientOption.getEsRetryOnConflictField() != null ? BuildTool.getEsRetryOnConflict(params, beanClassInfo,
clientOption.getEsRetryOnConflictField()) : null;
version = clientOption.getVersionField() != null ? BuildTool.getEsRetryOnConflict(params, beanClassInfo,clientOption.getVersionField()) : null;
versionType = clientOption.getVersionTypeField() != null ? BuildTool.getEsRetryOnConflict(params, beanClassInfo,clientOption.getVersionTypeField()) : null;
}
buildMeta( writer , indexType, indexName, params, action, id, parentId,routing,esRetryOnConflict,version,versionType, upper7);
} | [
"public",
"static",
"void",
"buildMeta",
"(",
"Writer",
"writer",
",",
"String",
"indexType",
",",
"String",
"indexName",
",",
"Object",
"params",
",",
"String",
"action",
",",
"ClientOptions",
"clientOption",
",",
"boolean",
"upper7",
")",
"throws",
"IOExceptio... | String docIdKey,String parentIdKey,String routingKey
@param writer
@param indexType
@param indexName
@param params
@param action
@throws IOException | [
"String",
"docIdKey",
"String",
"parentIdKey",
"String",
"routingKey"
] | 31717c8aa2c4c880987be53aeeb8a0cf5183c3a7 | https://github.com/bbossgroups/bboss-elasticsearch/blob/31717c8aa2c4c880987be53aeeb8a0cf5183c3a7/bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/client/BuildTool.java#L347-L369 | train |
bbossgroups/bboss-elasticsearch | bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/template/ESTemplate.java | ESTemplate.process | public boolean process()
throws ResourceNotFoundException, ParseErrorException
{
if(processed)
return true;
synchronized(this)
{
if(processed)
return true;
data = null;
errorCondition = null;
Reader is = null;
/*
* first, try to get the stream from the loader
*/
try
{
is = new BBossStringReader(template);
}
catch( ResourceNotFoundException rnfe )
{
/*
* remember and re-throw
*/
errorCondition = rnfe;
processed = true;
throw rnfe;
}
/*
* if that worked, lets protect in case a loader impl
* forgets to throw a proper exception
*/
if (is != null)
{
/*
* now parse the template
*/
try
{
BufferedReader br = new BufferedReader( is);
data = rsvc.parse(br, name);
initDocument();
processed = true;
try {
rechecksqlistpl();
} catch (Exception e) {
}
return true;
}
catch ( ParseException pex )
{
/*
* remember the error and convert
*/
errorCondition = new ParseErrorException(pex, name);
processed = true;
throw errorCondition;
}
catch ( TemplateInitException pex )
{
errorCondition = new ParseErrorException( pex, name);
processed = true;
throw errorCondition;
}
/**
* pass through runtime exceptions
*/
catch( RuntimeException e )
{
errorCondition = new VelocityException("Exception thrown processing Template "
+getName(), e);
processed = true;
throw errorCondition;
}
finally
{
processed = true;
/*
* Make sure to close the inputstream when we are done.
*/
try
{
is.close();
}
catch(IOException e)
{
// If we are already throwing an exception then we want the original
// exception to be continued to be thrown, otherwise, throw a new Exception.
if (errorCondition == null)
{
throw new VelocityException(e);
}
}
}
}
else
{
/*
* is == null, therefore we have some kind of file issue
*/
errorCondition = new ResourceNotFoundException("Unknown resource error for resource " + name );
processed = true;
throw errorCondition;
}
}
} | java | public boolean process()
throws ResourceNotFoundException, ParseErrorException
{
if(processed)
return true;
synchronized(this)
{
if(processed)
return true;
data = null;
errorCondition = null;
Reader is = null;
/*
* first, try to get the stream from the loader
*/
try
{
is = new BBossStringReader(template);
}
catch( ResourceNotFoundException rnfe )
{
/*
* remember and re-throw
*/
errorCondition = rnfe;
processed = true;
throw rnfe;
}
/*
* if that worked, lets protect in case a loader impl
* forgets to throw a proper exception
*/
if (is != null)
{
/*
* now parse the template
*/
try
{
BufferedReader br = new BufferedReader( is);
data = rsvc.parse(br, name);
initDocument();
processed = true;
try {
rechecksqlistpl();
} catch (Exception e) {
}
return true;
}
catch ( ParseException pex )
{
/*
* remember the error and convert
*/
errorCondition = new ParseErrorException(pex, name);
processed = true;
throw errorCondition;
}
catch ( TemplateInitException pex )
{
errorCondition = new ParseErrorException( pex, name);
processed = true;
throw errorCondition;
}
/**
* pass through runtime exceptions
*/
catch( RuntimeException e )
{
errorCondition = new VelocityException("Exception thrown processing Template "
+getName(), e);
processed = true;
throw errorCondition;
}
finally
{
processed = true;
/*
* Make sure to close the inputstream when we are done.
*/
try
{
is.close();
}
catch(IOException e)
{
// If we are already throwing an exception then we want the original
// exception to be continued to be thrown, otherwise, throw a new Exception.
if (errorCondition == null)
{
throw new VelocityException(e);
}
}
}
}
else
{
/*
* is == null, therefore we have some kind of file issue
*/
errorCondition = new ResourceNotFoundException("Unknown resource error for resource " + name );
processed = true;
throw errorCondition;
}
}
} | [
"public",
"boolean",
"process",
"(",
")",
"throws",
"ResourceNotFoundException",
",",
"ParseErrorException",
"{",
"if",
"(",
"processed",
")",
"return",
"true",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"processed",
")",
"return",
"true",
";",
"... | gets the named resource as a stream, parses and inits
@return true if successful
@throws ResourceNotFoundException if template not found
from any available source.
@throws ParseErrorException if template cannot be parsed due
to syntax (or other) error.
@throws IOException problem reading input stream | [
"gets",
"the",
"named",
"resource",
"as",
"a",
"stream",
"parses",
"and",
"inits"
] | 31717c8aa2c4c880987be53aeeb8a0cf5183c3a7 | https://github.com/bbossgroups/bboss-elasticsearch/blob/31717c8aa2c4c880987be53aeeb8a0cf5183c3a7/bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/template/ESTemplate.java#L116-L231 | train |
bbossgroups/bboss-elasticsearch | bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/client/ConfigRestClientUtil.java | ConfigRestClientUtil.addDateDocumentsNew | public String addDateDocumentsNew(String indexName, String addTemplate, List<?> beans, String refreshOption) throws ElasticSearchException{
return addDateDocuments( indexName, _doc, addTemplate, beans, refreshOption);
} | java | public String addDateDocumentsNew(String indexName, String addTemplate, List<?> beans, String refreshOption) throws ElasticSearchException{
return addDateDocuments( indexName, _doc, addTemplate, beans, refreshOption);
} | [
"public",
"String",
"addDateDocumentsNew",
"(",
"String",
"indexName",
",",
"String",
"addTemplate",
",",
"List",
"<",
"?",
">",
"beans",
",",
"String",
"refreshOption",
")",
"throws",
"ElasticSearchException",
"{",
"return",
"addDateDocuments",
"(",
"indexName",
... | For Elasticsearch 7 and 7+
@param indexName
@param addTemplate
@param beans
@param refreshOption
refresh=wait_for
refresh=false
refresh=true
refresh
Empty string or true
Refresh the relevant primary and replica shards (not the whole index) immediately after the operation occurs, so that the updated document appears in search results immediately. This should ONLY be done after careful thought and verification that it does not lead to poor performance, both from an indexing and a search standpoint.
wait_for
Wait for the changes made by the request to be made visible by a refresh before replying. This doesn’t force an immediate refresh, rather, it waits for a refresh to happen. Elasticsearch automatically refreshes shards that have changed every index.refresh_interval which defaults to one second. That setting is dynamic. Calling the Refresh API or setting refresh to true on any of the APIs that support it will also cause a refresh, in turn causing already running requests with refresh=wait_for to return.
false (the default)
Take no refresh related actions. The changes made by this request will be made visible at some point after the request returns.
@return
@throws ElasticSearchException | [
"For",
"Elasticsearch",
"7",
"and",
"7",
"+"
] | 31717c8aa2c4c880987be53aeeb8a0cf5183c3a7 | https://github.com/bbossgroups/bboss-elasticsearch/blob/31717c8aa2c4c880987be53aeeb8a0cf5183c3a7/bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/client/ConfigRestClientUtil.java#L1452-L1454 | train |
bbossgroups/bboss-elasticsearch | bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/BucketPath.java | BucketPath.getEscapeMapping | @Deprecated
public static Map<String, String> getEscapeMapping(String in,
Map<String, String> headers) {
return getEscapeMapping(in, headers, false, 0, 0);
} | java | @Deprecated
public static Map<String, String> getEscapeMapping(String in,
Map<String, String> headers) {
return getEscapeMapping(in, headers, false, 0, 0);
} | [
"@",
"Deprecated",
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"getEscapeMapping",
"(",
"String",
"in",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
")",
"{",
"return",
"getEscapeMapping",
"(",
"in",
",",
"headers",
",",
"f... | Instead of replacing escape sequences in a string, this method returns a
mapping of an attribute name to the value based on the escape sequence
found in the argument string. | [
"Instead",
"of",
"replacing",
"escape",
"sequences",
"in",
"a",
"string",
"this",
"method",
"returns",
"a",
"mapping",
"of",
"an",
"attribute",
"name",
"to",
"the",
"value",
"based",
"on",
"the",
"escape",
"sequence",
"found",
"in",
"the",
"argument",
"strin... | 31717c8aa2c4c880987be53aeeb8a0cf5183c3a7 | https://github.com/bbossgroups/bboss-elasticsearch/blob/31717c8aa2c4c880987be53aeeb8a0cf5183c3a7/bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/BucketPath.java#L487-L491 | train |
bbossgroups/bboss-elasticsearch | bboss-elasticsearch/src/main/java/org/frameworkset/elasticsearch/client/ElasticSearchTransportClient.java | ElasticSearchTransportClient.openClient | private void openClient(String clusterName) {
logger.info("Using ElasticSearch hostnames: {} ", Arrays.toString(serverAddresses));
Settings settings = null;
Settings.Builder builder = Settings.builder();
if (this.elasticUser != null && !this.elasticUser.equals("")) {
builder.put("cluster.name", clusterName)
.put("xpack.security.user", this.elasticUser + ":" + this.elasticPassword);
// .put("shield.user",
// this.elasticUser+":"+this.elasticPassword)
} else {
builder.put("cluster.name", clusterName);
}
if(this.extendElasticsearchPropes != null && extendElasticsearchPropes.size() > 0){
Iterator<Entry<Object, Object>> iterator = extendElasticsearchPropes.entrySet().iterator();
while(iterator.hasNext()){
Entry<Object, Object> entry = iterator.next();
builder.put((String)entry.getKey(),String.valueOf(entry.getValue()));
}
}
settings = builder.build();
try{
TransportClient transportClient = this.elasticUser != null && !this.elasticUser.equals("")
? new PreBuiltXPackTransportClient(settings) : new PreBuiltTransportClient(settings);
// TransportClient transportClient = new TransportClient(settings);
for (TransportAddress host : serverAddresses) {
transportClient.addTransportAddress(host);
}
if (client != null) {
client.close();
}
client = transportClient;
}
catch(RuntimeException e){
e.printStackTrace();
}
catch(Throwable e){
e.printStackTrace();
}
} | java | private void openClient(String clusterName) {
logger.info("Using ElasticSearch hostnames: {} ", Arrays.toString(serverAddresses));
Settings settings = null;
Settings.Builder builder = Settings.builder();
if (this.elasticUser != null && !this.elasticUser.equals("")) {
builder.put("cluster.name", clusterName)
.put("xpack.security.user", this.elasticUser + ":" + this.elasticPassword);
// .put("shield.user",
// this.elasticUser+":"+this.elasticPassword)
} else {
builder.put("cluster.name", clusterName);
}
if(this.extendElasticsearchPropes != null && extendElasticsearchPropes.size() > 0){
Iterator<Entry<Object, Object>> iterator = extendElasticsearchPropes.entrySet().iterator();
while(iterator.hasNext()){
Entry<Object, Object> entry = iterator.next();
builder.put((String)entry.getKey(),String.valueOf(entry.getValue()));
}
}
settings = builder.build();
try{
TransportClient transportClient = this.elasticUser != null && !this.elasticUser.equals("")
? new PreBuiltXPackTransportClient(settings) : new PreBuiltTransportClient(settings);
// TransportClient transportClient = new TransportClient(settings);
for (TransportAddress host : serverAddresses) {
transportClient.addTransportAddress(host);
}
if (client != null) {
client.close();
}
client = transportClient;
}
catch(RuntimeException e){
e.printStackTrace();
}
catch(Throwable e){
e.printStackTrace();
}
} | [
"private",
"void",
"openClient",
"(",
"String",
"clusterName",
")",
"{",
"logger",
".",
"info",
"(",
"\"Using ElasticSearch hostnames: {} \"",
",",
"Arrays",
".",
"toString",
"(",
"serverAddresses",
")",
")",
";",
"Settings",
"settings",
"=",
"null",
";",
"Setti... | Open client to elaticsearch cluster
@param clusterName | [
"Open",
"client",
"to",
"elaticsearch",
"cluster"
] | 31717c8aa2c4c880987be53aeeb8a0cf5183c3a7 | https://github.com/bbossgroups/bboss-elasticsearch/blob/31717c8aa2c4c880987be53aeeb8a0cf5183c3a7/bboss-elasticsearch/src/main/java/org/frameworkset/elasticsearch/client/ElasticSearchTransportClient.java#L226-L269 | train |
bbossgroups/bboss-elasticsearch | bboss-elasticsearch-spring-boot-starter/src/main/java/org/frameworkset/elasticsearch/boot/BBossESStarter.java | BBossESStarter.getRestClient | public ClientInterface getRestClient(){
if(restClient == null) {
synchronized (this) {
if(restClient == null) {
restClient = ElasticSearchHelper.getRestClientUtil();
}
}
}
return restClient;
} | java | public ClientInterface getRestClient(){
if(restClient == null) {
synchronized (this) {
if(restClient == null) {
restClient = ElasticSearchHelper.getRestClientUtil();
}
}
}
return restClient;
} | [
"public",
"ClientInterface",
"getRestClient",
"(",
")",
"{",
"if",
"(",
"restClient",
"==",
"null",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"restClient",
"==",
"null",
")",
"{",
"restClient",
"=",
"ElasticSearchHelper",
".",
"getRestClien... | Get default elasticsearch server ClientInterface
@return | [
"Get",
"default",
"elasticsearch",
"server",
"ClientInterface"
] | 31717c8aa2c4c880987be53aeeb8a0cf5183c3a7 | https://github.com/bbossgroups/bboss-elasticsearch/blob/31717c8aa2c4c880987be53aeeb8a0cf5183c3a7/bboss-elasticsearch-spring-boot-starter/src/main/java/org/frameworkset/elasticsearch/boot/BBossESStarter.java#L60-L69 | train |
bbossgroups/bboss-elasticsearch | bboss-elasticsearch-spring-boot-starter/src/main/java/org/frameworkset/elasticsearch/boot/BBossESStarter.java | BBossESStarter.getConfigRestClient | public ClientInterface getConfigRestClient(String elasticsearchName,String configFile){
return ElasticSearchHelper.getConfigRestClientUtil(elasticsearchName,configFile);
} | java | public ClientInterface getConfigRestClient(String elasticsearchName,String configFile){
return ElasticSearchHelper.getConfigRestClientUtil(elasticsearchName,configFile);
} | [
"public",
"ClientInterface",
"getConfigRestClient",
"(",
"String",
"elasticsearchName",
",",
"String",
"configFile",
")",
"{",
"return",
"ElasticSearchHelper",
".",
"getConfigRestClientUtil",
"(",
"elasticsearchName",
",",
"configFile",
")",
";",
"}"
] | Get Special elasticsearch server ConfigFile ClientInterface
@param elasticsearchName elasticsearch server name which defined in bboss spring boot application configfile
@param configFile
@return | [
"Get",
"Special",
"elasticsearch",
"server",
"ConfigFile",
"ClientInterface"
] | 31717c8aa2c4c880987be53aeeb8a0cf5183c3a7 | https://github.com/bbossgroups/bboss-elasticsearch/blob/31717c8aa2c4c880987be53aeeb8a0cf5183c3a7/bboss-elasticsearch-spring-boot-starter/src/main/java/org/frameworkset/elasticsearch/boot/BBossESStarter.java#L77-L81 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/StyleClassedTextArea.java | StyleClassedTextArea.setStyleClass | public void setStyleClass(int from, int to, String styleClass) {
setStyle(from, to, Collections.singletonList(styleClass));
} | java | public void setStyleClass(int from, int to, String styleClass) {
setStyle(from, to, Collections.singletonList(styleClass));
} | [
"public",
"void",
"setStyleClass",
"(",
"int",
"from",
",",
"int",
"to",
",",
"String",
"styleClass",
")",
"{",
"setStyle",
"(",
"from",
",",
"to",
",",
"Collections",
".",
"singletonList",
"(",
"styleClass",
")",
")",
";",
"}"
] | Convenient method to assign a single style class. | [
"Convenient",
"method",
"to",
"assign",
"a",
"single",
"style",
"class",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/StyleClassedTextArea.java#L47-L49 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java | GenericStyledArea.currentLine | TwoDimensional.Position currentLine() {
int parIdx = getCurrentParagraph();
Cell<Paragraph<PS, SEG, S>, ParagraphBox<PS, SEG, S>> cell = virtualFlow.getCell(parIdx);
int lineIdx = cell.getNode().getCurrentLineIndex(caretSelectionBind.getUnderlyingCaret());
return paragraphLineNavigator.position(parIdx, lineIdx);
} | java | TwoDimensional.Position currentLine() {
int parIdx = getCurrentParagraph();
Cell<Paragraph<PS, SEG, S>, ParagraphBox<PS, SEG, S>> cell = virtualFlow.getCell(parIdx);
int lineIdx = cell.getNode().getCurrentLineIndex(caretSelectionBind.getUnderlyingCaret());
return paragraphLineNavigator.position(parIdx, lineIdx);
} | [
"TwoDimensional",
".",
"Position",
"currentLine",
"(",
")",
"{",
"int",
"parIdx",
"=",
"getCurrentParagraph",
"(",
")",
";",
"Cell",
"<",
"Paragraph",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
",",
"ParagraphBox",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
">... | Returns the current line as a two-level index.
The major number is the paragraph index, the minor
number is the line number within the paragraph.
<p>This method has a side-effect of bringing the current
paragraph to the viewport if it is not already visible. | [
"Returns",
"the",
"current",
"line",
"as",
"a",
"two",
"-",
"level",
"index",
".",
"The",
"major",
"number",
"is",
"the",
"paragraph",
"index",
"the",
"minor",
"number",
"is",
"the",
"line",
"number",
"within",
"the",
"paragraph",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java#L1271-L1276 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java | GenericStyledArea.getCaretOffsetX | final ParagraphBox.CaretOffsetX getCaretOffsetX(CaretNode caret) {
return getCell(caret.getParagraphIndex()).getCaretOffsetX(caret);
} | java | final ParagraphBox.CaretOffsetX getCaretOffsetX(CaretNode caret) {
return getCell(caret.getParagraphIndex()).getCaretOffsetX(caret);
} | [
"final",
"ParagraphBox",
".",
"CaretOffsetX",
"getCaretOffsetX",
"(",
"CaretNode",
"caret",
")",
"{",
"return",
"getCell",
"(",
"caret",
".",
"getParagraphIndex",
"(",
")",
")",
".",
"getCaretOffsetX",
"(",
"caret",
")",
";",
"}"
] | Returns x coordinate of the caret in the current paragraph. | [
"Returns",
"x",
"coordinate",
"of",
"the",
"caret",
"in",
"the",
"current",
"paragraph",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java#L1297-L1299 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/model/Paragraph.java | Paragraph.restyle | public Paragraph<PS, SEG, S> restyle(S style) {
return new Paragraph<>(paragraphStyle, segmentOps, segments, StyleSpans.singleton(style, length()));
} | java | public Paragraph<PS, SEG, S> restyle(S style) {
return new Paragraph<>(paragraphStyle, segmentOps, segments, StyleSpans.singleton(style, length()));
} | [
"public",
"Paragraph",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
"restyle",
"(",
"S",
"style",
")",
"{",
"return",
"new",
"Paragraph",
"<>",
"(",
"paragraphStyle",
",",
"segmentOps",
",",
"segments",
",",
"StyleSpans",
".",
"singleton",
"(",
"style",
",",
... | Restyles every segment in the paragraph to have the given style.
Note: because Paragraph is immutable, this method returns a new Paragraph.
The current Paragraph is unchanged.
@param style The new style for each segment in the paragraph.
@return The new paragraph with the restyled segments. | [
"Restyles",
"every",
"segment",
"in",
"the",
"paragraph",
"to",
"have",
"the",
"given",
"style",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/model/Paragraph.java#L304-L306 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/model/Paragraph.java | Paragraph.setParagraphStyle | public Paragraph<PS, SEG, S> setParagraphStyle(PS paragraphStyle) {
return new Paragraph<>(paragraphStyle, segmentOps, segments, styles);
} | java | public Paragraph<PS, SEG, S> setParagraphStyle(PS paragraphStyle) {
return new Paragraph<>(paragraphStyle, segmentOps, segments, styles);
} | [
"public",
"Paragraph",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
"setParagraphStyle",
"(",
"PS",
"paragraphStyle",
")",
"{",
"return",
"new",
"Paragraph",
"<>",
"(",
"paragraphStyle",
",",
"segmentOps",
",",
"segments",
",",
"styles",
")",
";",
"}"
] | Creates a new Paragraph which has the same contents as the current Paragraph,
but the given paragraph style.
Note that because Paragraph is immutable, a new Paragraph is returned.
Despite the setX name, the current object is unchanged.
@param paragraphStyle The new paragraph style
@return A new paragraph with the same segment contents, but a new paragraph style. | [
"Creates",
"a",
"new",
"Paragraph",
"which",
"has",
"the",
"same",
"contents",
"as",
"the",
"current",
"Paragraph",
"but",
"the",
"given",
"paragraph",
"style",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/model/Paragraph.java#L347-L349 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/model/Paragraph.java | Paragraph.getText | public String getText() {
if(text == null) {
StringBuilder sb = new StringBuilder(length());
for(SEG seg: segments)
sb.append(segmentOps.getText(seg));
text = sb.toString();
}
return text;
} | java | public String getText() {
if(text == null) {
StringBuilder sb = new StringBuilder(length());
for(SEG seg: segments)
sb.append(segmentOps.getText(seg));
text = sb.toString();
}
return text;
} | [
"public",
"String",
"getText",
"(",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"length",
"(",
")",
")",
";",
"for",
"(",
"SEG",
"seg",
":",
"segments",
")",
"sb",
".",
"append",
"("... | Returns the plain text content of this paragraph,
not including the line terminator. | [
"Returns",
"the",
"plain",
"text",
"content",
"of",
"this",
"paragraph",
"not",
"including",
"the",
"line",
"terminator",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/model/Paragraph.java#L412-L420 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java | ReadOnlyStyledDocument.split | public Tuple2<ReadOnlyStyledDocument<PS, SEG, S>, ReadOnlyStyledDocument<PS, SEG, S>> split(int position) {
return tree.locate(NAVIGATE, position).map(this::split);
} | java | public Tuple2<ReadOnlyStyledDocument<PS, SEG, S>, ReadOnlyStyledDocument<PS, SEG, S>> split(int position) {
return tree.locate(NAVIGATE, position).map(this::split);
} | [
"public",
"Tuple2",
"<",
"ReadOnlyStyledDocument",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
",",
"ReadOnlyStyledDocument",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
">",
"split",
"(",
"int",
"position",
")",
"{",
"return",
"tree",
".",
"locate",
"(",
"NAVIGAT... | Splits this document into two at the given position and returns both halves. | [
"Splits",
"this",
"document",
"into",
"two",
"at",
"the",
"given",
"position",
"and",
"returns",
"both",
"halves",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java#L274-L276 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java | ReadOnlyStyledDocument.split | public Tuple2<ReadOnlyStyledDocument<PS, SEG, S>, ReadOnlyStyledDocument<PS, SEG, S>> split(
int paragraphIndex, int columnPosition) {
return tree.splitAt(paragraphIndex).map((l, p, r) -> {
Paragraph<PS, SEG, S> p1 = p.trim(columnPosition);
Paragraph<PS, SEG, S> p2 = p.subSequence(columnPosition);
ReadOnlyStyledDocument<PS, SEG, S> doc1 = new ReadOnlyStyledDocument<>(l.append(p1));
ReadOnlyStyledDocument<PS, SEG, S> doc2 = new ReadOnlyStyledDocument<>(r.prepend(p2));
return t(doc1, doc2);
});
} | java | public Tuple2<ReadOnlyStyledDocument<PS, SEG, S>, ReadOnlyStyledDocument<PS, SEG, S>> split(
int paragraphIndex, int columnPosition) {
return tree.splitAt(paragraphIndex).map((l, p, r) -> {
Paragraph<PS, SEG, S> p1 = p.trim(columnPosition);
Paragraph<PS, SEG, S> p2 = p.subSequence(columnPosition);
ReadOnlyStyledDocument<PS, SEG, S> doc1 = new ReadOnlyStyledDocument<>(l.append(p1));
ReadOnlyStyledDocument<PS, SEG, S> doc2 = new ReadOnlyStyledDocument<>(r.prepend(p2));
return t(doc1, doc2);
});
} | [
"public",
"Tuple2",
"<",
"ReadOnlyStyledDocument",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
",",
"ReadOnlyStyledDocument",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
">",
"split",
"(",
"int",
"paragraphIndex",
",",
"int",
"columnPosition",
")",
"{",
"return",
"t... | Splits this document into two at the given paragraph's column position and returns both halves. | [
"Splits",
"this",
"document",
"into",
"two",
"at",
"the",
"given",
"paragraph",
"s",
"column",
"position",
"and",
"returns",
"both",
"halves",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java#L281-L290 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocumentBuilder.java | ReadOnlyStyledDocumentBuilder.constructDocument | public static <PS, SEG, S> ReadOnlyStyledDocument<PS, SEG, S> constructDocument(
SegmentOps<SEG, S> segmentOps, PS defaultParagraphStyle,
Consumer<ReadOnlyStyledDocumentBuilder<PS, SEG, S>> configuration) {
ReadOnlyStyledDocumentBuilder<PS, SEG, S> builder = new ReadOnlyStyledDocumentBuilder<>(segmentOps, defaultParagraphStyle);
configuration.accept(builder);
return builder.build();
} | java | public static <PS, SEG, S> ReadOnlyStyledDocument<PS, SEG, S> constructDocument(
SegmentOps<SEG, S> segmentOps, PS defaultParagraphStyle,
Consumer<ReadOnlyStyledDocumentBuilder<PS, SEG, S>> configuration) {
ReadOnlyStyledDocumentBuilder<PS, SEG, S> builder = new ReadOnlyStyledDocumentBuilder<>(segmentOps, defaultParagraphStyle);
configuration.accept(builder);
return builder.build();
} | [
"public",
"static",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
"ReadOnlyStyledDocument",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
"constructDocument",
"(",
"SegmentOps",
"<",
"SEG",
",",
"S",
">",
"segmentOps",
",",
"PS",
"defaultParagraphStyle",
",",
"Consumer",
... | Constructs a list of paragraphs
@param segmentOps the {@link SegmentOps} object to use for one of the {@link Paragraph}'s constructors
@param defaultParagraphStyle the paragraph style object to use when it is not specified in the
"addParagraph" methods
@param configuration call the builder's {@link #addParagraph(Object, Object)} methods here | [
"Constructs",
"a",
"list",
"of",
"paragraphs"
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocumentBuilder.java#L29-L35 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocumentBuilder.java | ReadOnlyStyledDocumentBuilder.addParagraph | public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(List<SEG> segments, StyleSpans<S> styles) {
return addParagraph(segments, styles, null);
} | java | public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraph(List<SEG> segments, StyleSpans<S> styles) {
return addParagraph(segments, styles, null);
} | [
"public",
"ReadOnlyStyledDocumentBuilder",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
"addParagraph",
"(",
"List",
"<",
"SEG",
">",
"segments",
",",
"StyleSpans",
"<",
"S",
">",
"styles",
")",
"{",
"return",
"addParagraph",
"(",
"segments",
",",
"styles",
",",
... | Adds to the list a paragraph that has multiple segments with multiple styles throughout those segments | [
"Adds",
"to",
"the",
"list",
"a",
"paragraph",
"that",
"has",
"multiple",
"segments",
"with",
"multiple",
"styles",
"throughout",
"those",
"segments"
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocumentBuilder.java#L134-L136 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocumentBuilder.java | ReadOnlyStyledDocumentBuilder.addParagraphs0 | public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraphs0(List<Tuple2<PS, List<SEG>>> paragraphArgList,
StyleSpans<S> entireDocumentStyleSpans) {
return addParagraphList(paragraphArgList, entireDocumentStyleSpans, Tuple2::get1, Tuple2::get2);
} | java | public ReadOnlyStyledDocumentBuilder<PS, SEG, S> addParagraphs0(List<Tuple2<PS, List<SEG>>> paragraphArgList,
StyleSpans<S> entireDocumentStyleSpans) {
return addParagraphList(paragraphArgList, entireDocumentStyleSpans, Tuple2::get1, Tuple2::get2);
} | [
"public",
"ReadOnlyStyledDocumentBuilder",
"<",
"PS",
",",
"SEG",
",",
"S",
">",
"addParagraphs0",
"(",
"List",
"<",
"Tuple2",
"<",
"PS",
",",
"List",
"<",
"SEG",
">",
">",
">",
"paragraphArgList",
",",
"StyleSpans",
"<",
"S",
">",
"entireDocumentStyleSpans"... | Adds multiple paragraphs to the list, allowing one to specify each paragraph's paragraph style.
@param paragraphArgList each item is a Tuple2 that represents the paragraph style and segment list
for a single paragraph. If the paragraph style is {@code null},
the {@link #defaultParagraphStyle} will be used instead.
@param entireDocumentStyleSpans style spans for the entire document. It's length should be equal to the length
of all the segments' length combined | [
"Adds",
"multiple",
"paragraphs",
"to",
"the",
"list",
"allowing",
"one",
"to",
"specify",
"each",
"paragraph",
"s",
"paragraph",
"style",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocumentBuilder.java#L167-L170 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/CaretNode.java | CaretNode.moveContentBreaks | private void moveContentBreaks(int numOfBreaks, BreakIterator breakIterator, boolean followingNotPreceding) {
if (area.getLength() == 0) {
return;
}
breakIterator.setText(area.getText());
if (followingNotPreceding) {
breakIterator.following(getPosition());
} else {
breakIterator.preceding(getPosition());
}
for (int i = 1; i < numOfBreaks; i++) {
breakIterator.next();
}
moveTo(breakIterator.current());
} | java | private void moveContentBreaks(int numOfBreaks, BreakIterator breakIterator, boolean followingNotPreceding) {
if (area.getLength() == 0) {
return;
}
breakIterator.setText(area.getText());
if (followingNotPreceding) {
breakIterator.following(getPosition());
} else {
breakIterator.preceding(getPosition());
}
for (int i = 1; i < numOfBreaks; i++) {
breakIterator.next();
}
moveTo(breakIterator.current());
} | [
"private",
"void",
"moveContentBreaks",
"(",
"int",
"numOfBreaks",
",",
"BreakIterator",
"breakIterator",
",",
"boolean",
"followingNotPreceding",
")",
"{",
"if",
"(",
"area",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"breakIterator"... | Helper method for reducing duplicate code
@param numOfBreaks the number of breaks
@param breakIterator the type of iterator to use
@param followingNotPreceding if true, use {@link BreakIterator#following(int)}.
Otherwise, use {@link BreakIterator#preceding(int)}. | [
"Helper",
"method",
"for",
"reducing",
"duplicate",
"code"
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/CaretNode.java#L372-L387 | train |
FXMisc/RichTextFX | richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/richtext/RichTextDemo.java | RichTextDemo.insertImage | private void insertImage() {
String initialDir = System.getProperty("user.dir");
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Insert image");
fileChooser.setInitialDirectory(new File(initialDir));
File selectedFile = fileChooser.showOpenDialog(mainStage);
if (selectedFile != null) {
String imagePath = selectedFile.getAbsolutePath();
imagePath = imagePath.replace('\\', '/');
ReadOnlyStyledDocument<ParStyle, Either<String, LinkedImage>, TextStyle> ros =
ReadOnlyStyledDocument.fromSegment(Either.right(new RealLinkedImage(imagePath)),
ParStyle.EMPTY, TextStyle.EMPTY, area.getSegOps());
area.replaceSelection(ros);
}
} | java | private void insertImage() {
String initialDir = System.getProperty("user.dir");
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Insert image");
fileChooser.setInitialDirectory(new File(initialDir));
File selectedFile = fileChooser.showOpenDialog(mainStage);
if (selectedFile != null) {
String imagePath = selectedFile.getAbsolutePath();
imagePath = imagePath.replace('\\', '/');
ReadOnlyStyledDocument<ParStyle, Either<String, LinkedImage>, TextStyle> ros =
ReadOnlyStyledDocument.fromSegment(Either.right(new RealLinkedImage(imagePath)),
ParStyle.EMPTY, TextStyle.EMPTY, area.getSegOps());
area.replaceSelection(ros);
}
} | [
"private",
"void",
"insertImage",
"(",
")",
"{",
"String",
"initialDir",
"=",
"System",
".",
"getProperty",
"(",
"\"user.dir\"",
")",
";",
"FileChooser",
"fileChooser",
"=",
"new",
"FileChooser",
"(",
")",
";",
"fileChooser",
".",
"setTitle",
"(",
"\"Insert im... | Action listener which inserts a new image at the current caret position. | [
"Action",
"listener",
"which",
"inserts",
"a",
"new",
"image",
"at",
"the",
"current",
"caret",
"position",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/richtext/RichTextDemo.java#L452-L466 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/ParagraphBox.java | ParagraphBox.hitTextLine | CharacterHit hitTextLine(CaretOffsetX x, int line) {
return text.hitLine(x.value, line);
} | java | CharacterHit hitTextLine(CaretOffsetX x, int line) {
return text.hitLine(x.value, line);
} | [
"CharacterHit",
"hitTextLine",
"(",
"CaretOffsetX",
"x",
",",
"int",
"line",
")",
"{",
"return",
"text",
".",
"hitLine",
"(",
"x",
".",
"value",
",",
"line",
")",
";",
"}"
] | Hits the embedded TextFlow at the given line and x offset.
@param x x coordinate relative to the embedded TextFlow.
@param line index of the line in the embedded TextFlow.
@return hit info for the given line and x coordinate | [
"Hits",
"the",
"embedded",
"TextFlow",
"at",
"the",
"given",
"line",
"and",
"x",
"offset",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphBox.java#L263-L265 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/ParagraphBox.java | ParagraphBox.hitText | CharacterHit hitText(CaretOffsetX x, double y) {
return text.hit(x.value, y);
} | java | CharacterHit hitText(CaretOffsetX x, double y) {
return text.hit(x.value, y);
} | [
"CharacterHit",
"hitText",
"(",
"CaretOffsetX",
"x",
",",
"double",
"y",
")",
"{",
"return",
"text",
".",
"hit",
"(",
"x",
".",
"value",
",",
"y",
")",
";",
"}"
] | Hits the embedded TextFlow at the given x and y offset.
@return hit info for the given x and y coordinates | [
"Hits",
"the",
"embedded",
"TextFlow",
"at",
"the",
"given",
"x",
"and",
"y",
"offset",
"."
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/ParagraphBox.java#L272-L274 | train |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/CaretSelectionBindImpl.java | CaretSelectionBindImpl.selectRangeExpl | @Override
public void selectRangeExpl(int anchorParagraph, int anchorColumn, int caretParagraph, int caretColumn) {
selectRangeExpl(textPosition(anchorParagraph, anchorColumn), textPosition(caretParagraph, caretColumn));
} | java | @Override
public void selectRangeExpl(int anchorParagraph, int anchorColumn, int caretParagraph, int caretColumn) {
selectRangeExpl(textPosition(anchorParagraph, anchorColumn), textPosition(caretParagraph, caretColumn));
} | [
"@",
"Override",
"public",
"void",
"selectRangeExpl",
"(",
"int",
"anchorParagraph",
",",
"int",
"anchorColumn",
",",
"int",
"caretParagraph",
",",
"int",
"caretColumn",
")",
"{",
"selectRangeExpl",
"(",
"textPosition",
"(",
"anchorParagraph",
",",
"anchorColumn",
... | caret selection bind | [
"caret",
"selection",
"bind"
] | bc7cab6a637855e0f37d9b9c12a9172c31545f0b | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/CaretSelectionBindImpl.java#L346-L349 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/impl/LogMonitors.java | LogMonitors.logMonitor | public static LogMonitor logMonitor()
{
return new LogMonitor()
{
@Override
public void corruption(long bytes, String reason)
{
System.out.println(String.format("corruption of %s bytes: %s", bytes, reason));
}
@Override
public void corruption(long bytes, Throwable reason)
{
System.out.println(String.format("corruption of %s bytes", bytes));
reason.printStackTrace();
}
};
} | java | public static LogMonitor logMonitor()
{
return new LogMonitor()
{
@Override
public void corruption(long bytes, String reason)
{
System.out.println(String.format("corruption of %s bytes: %s", bytes, reason));
}
@Override
public void corruption(long bytes, Throwable reason)
{
System.out.println(String.format("corruption of %s bytes", bytes));
reason.printStackTrace();
}
};
} | [
"public",
"static",
"LogMonitor",
"logMonitor",
"(",
")",
"{",
"return",
"new",
"LogMonitor",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"corruption",
"(",
"long",
"bytes",
",",
"String",
"reason",
")",
"{",
"System",
".",
"out",
".",
"println",
"... | todo implement real logging | [
"todo",
"implement",
"real",
"logging"
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/impl/LogMonitors.java#L41-L58 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/table/BlockIterator.java | BlockIterator.seek | @Override
public void seek(Slice targetKey)
{
if (restartCount == 0) {
return;
}
int left = 0;
int right = restartCount - 1;
// binary search restart positions to find the restart position immediately before the targetKey
while (left < right) {
int mid = (left + right + 1) / 2;
seekToRestartPosition(mid);
if (comparator.compare(nextEntry.getKey(), targetKey) < 0) {
// key at mid is smaller than targetKey. Therefore all restart
// blocks before mid are uninteresting.
left = mid;
}
else {
// key at mid is greater than or equal to targetKey. Therefore
// all restart blocks at or after mid are uninteresting.
right = mid - 1;
}
}
// linear search (within restart block) for first key greater than or equal to targetKey
for (seekToRestartPosition(left); nextEntry != null; next()) {
if (comparator.compare(peek().getKey(), targetKey) >= 0) {
break;
}
}
} | java | @Override
public void seek(Slice targetKey)
{
if (restartCount == 0) {
return;
}
int left = 0;
int right = restartCount - 1;
// binary search restart positions to find the restart position immediately before the targetKey
while (left < right) {
int mid = (left + right + 1) / 2;
seekToRestartPosition(mid);
if (comparator.compare(nextEntry.getKey(), targetKey) < 0) {
// key at mid is smaller than targetKey. Therefore all restart
// blocks before mid are uninteresting.
left = mid;
}
else {
// key at mid is greater than or equal to targetKey. Therefore
// all restart blocks at or after mid are uninteresting.
right = mid - 1;
}
}
// linear search (within restart block) for first key greater than or equal to targetKey
for (seekToRestartPosition(left); nextEntry != null; next()) {
if (comparator.compare(peek().getKey(), targetKey) >= 0) {
break;
}
}
} | [
"@",
"Override",
"public",
"void",
"seek",
"(",
"Slice",
"targetKey",
")",
"{",
"if",
"(",
"restartCount",
"==",
"0",
")",
"{",
"return",
";",
"}",
"int",
"left",
"=",
"0",
";",
"int",
"right",
"=",
"restartCount",
"-",
"1",
";",
"// binary search rest... | Repositions the iterator so the key of the next BlockElement returned greater than or equal to the specified targetKey. | [
"Repositions",
"the",
"iterator",
"so",
"the",
"key",
"of",
"the",
"next",
"BlockElement",
"returned",
"greater",
"than",
"or",
"equal",
"to",
"the",
"specified",
"targetKey",
"."
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/table/BlockIterator.java#L118-L153 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/table/BlockIterator.java | BlockIterator.readEntry | private static BlockEntry readEntry(SliceInput data, BlockEntry previousEntry)
{
requireNonNull(data, "data is null");
// read entry header
int sharedKeyLength = VariableLengthQuantity.readVariableLengthInt(data);
int nonSharedKeyLength = VariableLengthQuantity.readVariableLengthInt(data);
int valueLength = VariableLengthQuantity.readVariableLengthInt(data);
// read key
Slice key = Slices.allocate(sharedKeyLength + nonSharedKeyLength);
SliceOutput sliceOutput = key.output();
if (sharedKeyLength > 0) {
checkState(previousEntry != null, "Entry has a shared key but no previous entry was provided");
sliceOutput.writeBytes(previousEntry.getKey(), 0, sharedKeyLength);
}
sliceOutput.writeBytes(data, nonSharedKeyLength);
// read value
Slice value = data.readSlice(valueLength);
return new BlockEntry(key, value);
} | java | private static BlockEntry readEntry(SliceInput data, BlockEntry previousEntry)
{
requireNonNull(data, "data is null");
// read entry header
int sharedKeyLength = VariableLengthQuantity.readVariableLengthInt(data);
int nonSharedKeyLength = VariableLengthQuantity.readVariableLengthInt(data);
int valueLength = VariableLengthQuantity.readVariableLengthInt(data);
// read key
Slice key = Slices.allocate(sharedKeyLength + nonSharedKeyLength);
SliceOutput sliceOutput = key.output();
if (sharedKeyLength > 0) {
checkState(previousEntry != null, "Entry has a shared key but no previous entry was provided");
sliceOutput.writeBytes(previousEntry.getKey(), 0, sharedKeyLength);
}
sliceOutput.writeBytes(data, nonSharedKeyLength);
// read value
Slice value = data.readSlice(valueLength);
return new BlockEntry(key, value);
} | [
"private",
"static",
"BlockEntry",
"readEntry",
"(",
"SliceInput",
"data",
",",
"BlockEntry",
"previousEntry",
")",
"{",
"requireNonNull",
"(",
"data",
",",
"\"data is null\"",
")",
";",
"// read entry header",
"int",
"sharedKeyLength",
"=",
"VariableLengthQuantity",
... | Reads the entry at the current data readIndex.
After this method, data readIndex is positioned at the beginning of the next entry
or at the end of data if there was not a next entry.
@return true if an entry was read | [
"Reads",
"the",
"entry",
"at",
"the",
"current",
"data",
"readIndex",
".",
"After",
"this",
"method",
"data",
"readIndex",
"is",
"positioned",
"at",
"the",
"beginning",
"of",
"the",
"next",
"entry",
"or",
"at",
"the",
"end",
"of",
"data",
"if",
"there",
... | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/table/BlockIterator.java#L182-L204 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/impl/Filename.java | Filename.setCurrentFile | public static boolean setCurrentFile(File databaseDir, long descriptorNumber)
throws IOException
{
String manifest = descriptorFileName(descriptorNumber);
String temp = tempFileName(descriptorNumber);
File tempFile = new File(databaseDir, temp);
writeStringToFileSync(manifest + "\n", tempFile);
File to = new File(databaseDir, currentFileName());
boolean ok = tempFile.renameTo(to);
if (!ok) {
tempFile.delete();
writeStringToFileSync(manifest + "\n", to);
}
return ok;
} | java | public static boolean setCurrentFile(File databaseDir, long descriptorNumber)
throws IOException
{
String manifest = descriptorFileName(descriptorNumber);
String temp = tempFileName(descriptorNumber);
File tempFile = new File(databaseDir, temp);
writeStringToFileSync(manifest + "\n", tempFile);
File to = new File(databaseDir, currentFileName());
boolean ok = tempFile.renameTo(to);
if (!ok) {
tempFile.delete();
writeStringToFileSync(manifest + "\n", to);
}
return ok;
} | [
"public",
"static",
"boolean",
"setCurrentFile",
"(",
"File",
"databaseDir",
",",
"long",
"descriptorNumber",
")",
"throws",
"IOException",
"{",
"String",
"manifest",
"=",
"descriptorFileName",
"(",
"descriptorNumber",
")",
";",
"String",
"temp",
"=",
"tempFileName"... | Make the CURRENT file point to the descriptor file with the
specified number.
@return true if successful; false otherwise | [
"Make",
"the",
"CURRENT",
"file",
"point",
"to",
"the",
"descriptor",
"file",
"with",
"the",
"specified",
"number",
"."
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/impl/Filename.java#L165-L181 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/impl/Compaction.java | Compaction.isBaseLevelForKey | public boolean isBaseLevelForKey(Slice userKey)
{
// Maybe use binary search to find right entry instead of linear search?
UserComparator userComparator = inputVersion.getInternalKeyComparator().getUserComparator();
for (int level = this.level + 2; level < NUM_LEVELS; level++) {
List<FileMetaData> files = inputVersion.getFiles(level);
while (levelPointers[level] < files.size()) {
FileMetaData f = files.get(levelPointers[level]);
if (userComparator.compare(userKey, f.getLargest().getUserKey()) <= 0) {
// We've advanced far enough
if (userComparator.compare(userKey, f.getSmallest().getUserKey()) >= 0) {
// Key falls in this file's range, so definitely not base level
return false;
}
break;
}
levelPointers[level]++;
}
}
return true;
} | java | public boolean isBaseLevelForKey(Slice userKey)
{
// Maybe use binary search to find right entry instead of linear search?
UserComparator userComparator = inputVersion.getInternalKeyComparator().getUserComparator();
for (int level = this.level + 2; level < NUM_LEVELS; level++) {
List<FileMetaData> files = inputVersion.getFiles(level);
while (levelPointers[level] < files.size()) {
FileMetaData f = files.get(levelPointers[level]);
if (userComparator.compare(userKey, f.getLargest().getUserKey()) <= 0) {
// We've advanced far enough
if (userComparator.compare(userKey, f.getSmallest().getUserKey()) >= 0) {
// Key falls in this file's range, so definitely not base level
return false;
}
break;
}
levelPointers[level]++;
}
}
return true;
} | [
"public",
"boolean",
"isBaseLevelForKey",
"(",
"Slice",
"userKey",
")",
"{",
"// Maybe use binary search to find right entry instead of linear search?",
"UserComparator",
"userComparator",
"=",
"inputVersion",
".",
"getInternalKeyComparator",
"(",
")",
".",
"getUserComparator",
... | in levels greater than "level+1". | [
"in",
"levels",
"greater",
"than",
"level",
"+",
"1",
"."
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/impl/Compaction.java#L151-L171 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/impl/Compaction.java | Compaction.shouldStopBefore | public boolean shouldStopBefore(InternalKey internalKey)
{
// Scan to find earliest grandparent file that contains key.
InternalKeyComparator internalKeyComparator = inputVersion.getInternalKeyComparator();
while (grandparentIndex < grandparents.size() && internalKeyComparator.compare(internalKey, grandparents.get(grandparentIndex).getLargest()) > 0) {
if (seenKey) {
overlappedBytes += grandparents.get(grandparentIndex).getFileSize();
}
grandparentIndex++;
}
seenKey = true;
if (overlappedBytes > MAX_GRAND_PARENT_OVERLAP_BYTES) {
// Too much overlap for current output; start new output
overlappedBytes = 0;
return true;
}
else {
return false;
}
} | java | public boolean shouldStopBefore(InternalKey internalKey)
{
// Scan to find earliest grandparent file that contains key.
InternalKeyComparator internalKeyComparator = inputVersion.getInternalKeyComparator();
while (grandparentIndex < grandparents.size() && internalKeyComparator.compare(internalKey, grandparents.get(grandparentIndex).getLargest()) > 0) {
if (seenKey) {
overlappedBytes += grandparents.get(grandparentIndex).getFileSize();
}
grandparentIndex++;
}
seenKey = true;
if (overlappedBytes > MAX_GRAND_PARENT_OVERLAP_BYTES) {
// Too much overlap for current output; start new output
overlappedBytes = 0;
return true;
}
else {
return false;
}
} | [
"public",
"boolean",
"shouldStopBefore",
"(",
"InternalKey",
"internalKey",
")",
"{",
"// Scan to find earliest grandparent file that contains key.",
"InternalKeyComparator",
"internalKeyComparator",
"=",
"inputVersion",
".",
"getInternalKeyComparator",
"(",
")",
";",
"while",
... | before processing "internal_key". | [
"before",
"processing",
"internal_key",
"."
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/impl/Compaction.java#L175-L195 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/util/Slice.java | Slice.copySlice | public Slice copySlice(int index, int length)
{
checkPositionIndexes(index, index + length, this.length);
index += offset;
byte[] copiedArray = new byte[length];
System.arraycopy(data, index, copiedArray, 0, length);
return new Slice(copiedArray);
} | java | public Slice copySlice(int index, int length)
{
checkPositionIndexes(index, index + length, this.length);
index += offset;
byte[] copiedArray = new byte[length];
System.arraycopy(data, index, copiedArray, 0, length);
return new Slice(copiedArray);
} | [
"public",
"Slice",
"copySlice",
"(",
"int",
"index",
",",
"int",
"length",
")",
"{",
"checkPositionIndexes",
"(",
"index",
",",
"index",
"+",
"length",
",",
"this",
".",
"length",
")",
";",
"index",
"+=",
"offset",
";",
"byte",
"[",
"]",
"copiedArray",
... | Returns a copy of this buffer's sub-region. Modifying the content of
the returned buffer or this buffer does not affect each other at all. | [
"Returns",
"a",
"copy",
"of",
"this",
"buffer",
"s",
"sub",
"-",
"region",
".",
"Modifying",
"the",
"content",
"of",
"the",
"returned",
"buffer",
"or",
"this",
"buffer",
"does",
"not",
"affect",
"each",
"other",
"at",
"all",
"."
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/util/Slice.java#L527-L535 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/util/Slice.java | Slice.slice | public Slice slice(int index, int length)
{
if (index == 0 && length == this.length) {
return this;
}
checkPositionIndexes(index, index + length, this.length);
if (index >= 0 && length == 0) {
return Slices.EMPTY_SLICE;
}
return new Slice(data, offset + index, length);
} | java | public Slice slice(int index, int length)
{
if (index == 0 && length == this.length) {
return this;
}
checkPositionIndexes(index, index + length, this.length);
if (index >= 0 && length == 0) {
return Slices.EMPTY_SLICE;
}
return new Slice(data, offset + index, length);
} | [
"public",
"Slice",
"slice",
"(",
"int",
"index",
",",
"int",
"length",
")",
"{",
"if",
"(",
"index",
"==",
"0",
"&&",
"length",
"==",
"this",
".",
"length",
")",
"{",
"return",
"this",
";",
"}",
"checkPositionIndexes",
"(",
"index",
",",
"index",
"+"... | Returns a slice of this buffer's sub-region. Modifying the content of
the returned buffer or this buffer affects each other's content while
they maintain separate indexes and marks. | [
"Returns",
"a",
"slice",
"of",
"this",
"buffer",
"s",
"sub",
"-",
"region",
".",
"Modifying",
"the",
"content",
"of",
"the",
"returned",
"buffer",
"or",
"this",
"buffer",
"affects",
"each",
"other",
"s",
"content",
"while",
"they",
"maintain",
"separate",
... | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/util/Slice.java#L571-L582 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/util/Slice.java | Slice.toByteBuffer | public ByteBuffer toByteBuffer(int index, int length)
{
checkPositionIndexes(index, index + length, this.length);
index += offset;
return ByteBuffer.wrap(data, index, length).order(LITTLE_ENDIAN);
} | java | public ByteBuffer toByteBuffer(int index, int length)
{
checkPositionIndexes(index, index + length, this.length);
index += offset;
return ByteBuffer.wrap(data, index, length).order(LITTLE_ENDIAN);
} | [
"public",
"ByteBuffer",
"toByteBuffer",
"(",
"int",
"index",
",",
"int",
"length",
")",
"{",
"checkPositionIndexes",
"(",
"index",
",",
"index",
"+",
"length",
",",
"this",
".",
"length",
")",
";",
"index",
"+=",
"offset",
";",
"return",
"ByteBuffer",
".",... | Converts this buffer's sub-region into a NIO buffer. The returned
buffer shares the content with this buffer. | [
"Converts",
"this",
"buffer",
"s",
"sub",
"-",
"region",
"into",
"a",
"NIO",
"buffer",
".",
"The",
"returned",
"buffer",
"shares",
"the",
"content",
"with",
"this",
"buffer",
"."
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/util/Slice.java#L613-L618 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/impl/LogReader.java | LogReader.readNextChunk | private LogChunkType readNextChunk()
{
// clear the current chunk
currentChunk = Slices.EMPTY_SLICE;
// read the next block if necessary
if (currentBlock.available() < HEADER_SIZE) {
if (!readNextBlock()) {
if (eof) {
return EOF;
}
}
}
// parse header
int expectedChecksum = currentBlock.readInt();
int length = currentBlock.readUnsignedByte();
length = length | currentBlock.readUnsignedByte() << 8;
byte chunkTypeId = currentBlock.readByte();
LogChunkType chunkType = getLogChunkTypeByPersistentId(chunkTypeId);
// verify length
if (length > currentBlock.available()) {
int dropSize = currentBlock.available() + HEADER_SIZE;
reportCorruption(dropSize, "Invalid chunk length");
currentBlock = Slices.EMPTY_SLICE.input();
return BAD_CHUNK;
}
// skip zero length records
if (chunkType == ZERO_TYPE && length == 0) {
// Skip zero length record without reporting any drops since
// such records are produced by the writing code.
currentBlock = Slices.EMPTY_SLICE.input();
return BAD_CHUNK;
}
// Skip physical record that started before initialOffset
if (endOfBufferOffset - HEADER_SIZE - length < initialOffset) {
currentBlock.skipBytes(length);
return BAD_CHUNK;
}
// read the chunk
currentChunk = currentBlock.readBytes(length);
if (verifyChecksums) {
int actualChecksum = getChunkChecksum(chunkTypeId, currentChunk);
if (actualChecksum != expectedChecksum) {
// Drop the rest of the buffer since "length" itself may have
// been corrupted and if we trust it, we could find some
// fragment of a real log record that just happens to look
// like a valid log record.
int dropSize = currentBlock.available() + HEADER_SIZE;
currentBlock = Slices.EMPTY_SLICE.input();
reportCorruption(dropSize, "Invalid chunk checksum");
return BAD_CHUNK;
}
}
// Skip unknown chunk types
// Since this comes last so we the, know it is a valid chunk, and is just a type we don't understand
if (chunkType == UNKNOWN) {
reportCorruption(length, String.format("Unknown chunk type %d", chunkType.getPersistentId()));
return BAD_CHUNK;
}
return chunkType;
} | java | private LogChunkType readNextChunk()
{
// clear the current chunk
currentChunk = Slices.EMPTY_SLICE;
// read the next block if necessary
if (currentBlock.available() < HEADER_SIZE) {
if (!readNextBlock()) {
if (eof) {
return EOF;
}
}
}
// parse header
int expectedChecksum = currentBlock.readInt();
int length = currentBlock.readUnsignedByte();
length = length | currentBlock.readUnsignedByte() << 8;
byte chunkTypeId = currentBlock.readByte();
LogChunkType chunkType = getLogChunkTypeByPersistentId(chunkTypeId);
// verify length
if (length > currentBlock.available()) {
int dropSize = currentBlock.available() + HEADER_SIZE;
reportCorruption(dropSize, "Invalid chunk length");
currentBlock = Slices.EMPTY_SLICE.input();
return BAD_CHUNK;
}
// skip zero length records
if (chunkType == ZERO_TYPE && length == 0) {
// Skip zero length record without reporting any drops since
// such records are produced by the writing code.
currentBlock = Slices.EMPTY_SLICE.input();
return BAD_CHUNK;
}
// Skip physical record that started before initialOffset
if (endOfBufferOffset - HEADER_SIZE - length < initialOffset) {
currentBlock.skipBytes(length);
return BAD_CHUNK;
}
// read the chunk
currentChunk = currentBlock.readBytes(length);
if (verifyChecksums) {
int actualChecksum = getChunkChecksum(chunkTypeId, currentChunk);
if (actualChecksum != expectedChecksum) {
// Drop the rest of the buffer since "length" itself may have
// been corrupted and if we trust it, we could find some
// fragment of a real log record that just happens to look
// like a valid log record.
int dropSize = currentBlock.available() + HEADER_SIZE;
currentBlock = Slices.EMPTY_SLICE.input();
reportCorruption(dropSize, "Invalid chunk checksum");
return BAD_CHUNK;
}
}
// Skip unknown chunk types
// Since this comes last so we the, know it is a valid chunk, and is just a type we don't understand
if (chunkType == UNKNOWN) {
reportCorruption(length, String.format("Unknown chunk type %d", chunkType.getPersistentId()));
return BAD_CHUNK;
}
return chunkType;
} | [
"private",
"LogChunkType",
"readNextChunk",
"(",
")",
"{",
"// clear the current chunk",
"currentChunk",
"=",
"Slices",
".",
"EMPTY_SLICE",
";",
"// read the next block if necessary",
"if",
"(",
"currentBlock",
".",
"available",
"(",
")",
"<",
"HEADER_SIZE",
")",
"{",... | Return type, or one of the preceding special values | [
"Return",
"type",
"or",
"one",
"of",
"the",
"preceding",
"special",
"values"
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/impl/LogReader.java#L231-L299 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/impl/LogReader.java | LogReader.reportCorruption | private void reportCorruption(long bytes, String reason)
{
if (monitor != null) {
monitor.corruption(bytes, reason);
}
} | java | private void reportCorruption(long bytes, String reason)
{
if (monitor != null) {
monitor.corruption(bytes, reason);
}
} | [
"private",
"void",
"reportCorruption",
"(",
"long",
"bytes",
",",
"String",
"reason",
")",
"{",
"if",
"(",
"monitor",
"!=",
"null",
")",
"{",
"monitor",
".",
"corruption",
"(",
"bytes",
",",
"reason",
")",
";",
"}",
"}"
] | Reports corruption to the monitor.
The buffer must be updated to remove the dropped bytes prior to invocation. | [
"Reports",
"corruption",
"to",
"the",
"monitor",
".",
"The",
"buffer",
"must",
"be",
"updated",
"to",
"remove",
"the",
"dropped",
"bytes",
"prior",
"to",
"invocation",
"."
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/impl/LogReader.java#L337-L342 | train |
dain/leveldb | leveldb/src/main/java/org/iq80/leveldb/impl/LogReader.java | LogReader.reportDrop | private void reportDrop(long bytes, Throwable reason)
{
if (monitor != null) {
monitor.corruption(bytes, reason);
}
} | java | private void reportDrop(long bytes, Throwable reason)
{
if (monitor != null) {
monitor.corruption(bytes, reason);
}
} | [
"private",
"void",
"reportDrop",
"(",
"long",
"bytes",
",",
"Throwable",
"reason",
")",
"{",
"if",
"(",
"monitor",
"!=",
"null",
")",
"{",
"monitor",
".",
"corruption",
"(",
"bytes",
",",
"reason",
")",
";",
"}",
"}"
] | Reports dropped bytes to the monitor.
The buffer must be updated to remove the dropped bytes prior to invocation. | [
"Reports",
"dropped",
"bytes",
"to",
"the",
"monitor",
".",
"The",
"buffer",
"must",
"be",
"updated",
"to",
"remove",
"the",
"dropped",
"bytes",
"prior",
"to",
"invocation",
"."
] | 7994065b48eada2ef29e7fefd172c2ad1e0110eb | https://github.com/dain/leveldb/blob/7994065b48eada2ef29e7fefd172c2ad1e0110eb/leveldb/src/main/java/org/iq80/leveldb/impl/LogReader.java#L348-L353 | train |
spockframework/spock | spock-core/src/main/java/spock/util/concurrent/BlockingVariable.java | BlockingVariable.get | public T get() throws InterruptedException {
if (!valueReady.await((long) (timeout * 1000), TimeUnit.MILLISECONDS)) {
String msg = String.format("BlockingVariable.get() timed out after %1.2f seconds", timeout);
throw new SpockTimeoutError(timeout, msg);
}
return value;
} | java | public T get() throws InterruptedException {
if (!valueReady.await((long) (timeout * 1000), TimeUnit.MILLISECONDS)) {
String msg = String.format("BlockingVariable.get() timed out after %1.2f seconds", timeout);
throw new SpockTimeoutError(timeout, msg);
}
return value;
} | [
"public",
"T",
"get",
"(",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"!",
"valueReady",
".",
"await",
"(",
"(",
"long",
")",
"(",
"timeout",
"*",
"1000",
")",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
")",
"{",
"String",
"msg",
"=",
"St... | Blocks until a value has been set for this variable, or a timeout expires.
@return the variable's value
@throws InterruptedException if the calling thread is interrupted | [
"Blocks",
"until",
"a",
"value",
"has",
"been",
"set",
"for",
"this",
"variable",
"or",
"a",
"timeout",
"expires",
"."
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/spock/util/concurrent/BlockingVariable.java#L110-L116 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java | SpecRewriter.handleWhereBlock | private void handleWhereBlock(Method method) {
Block block = method.getLastBlock();
if (!(block instanceof WhereBlock)) return;
new DeepBlockRewriter(this).visit(block);
WhereBlockRewriter.rewrite((WhereBlock) block, this);
} | java | private void handleWhereBlock(Method method) {
Block block = method.getLastBlock();
if (!(block instanceof WhereBlock)) return;
new DeepBlockRewriter(this).visit(block);
WhereBlockRewriter.rewrite((WhereBlock) block, this);
} | [
"private",
"void",
"handleWhereBlock",
"(",
"Method",
"method",
")",
"{",
"Block",
"block",
"=",
"method",
".",
"getLastBlock",
"(",
")",
";",
"if",
"(",
"!",
"(",
"block",
"instanceof",
"WhereBlock",
")",
")",
"return",
";",
"new",
"DeepBlockRewriter",
"(... | will then be used by DeepBlockRewriter | [
"will",
"then",
"be",
"used",
"by",
"DeepBlockRewriter"
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java#L285-L291 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/runtime/extension/builtin/IncludeExcludeExtension.java | IncludeExcludeExtension.handleFeatureIncludes | private void handleFeatureIncludes(SpecInfo spec, IncludeExcludeCriteria criteria) {
if (criteria.isEmpty()) return;
for (FeatureInfo feature : spec.getAllFeatures())
if (hasAnyAnnotation(feature.getFeatureMethod(), criteria.annotations))
feature.setExcluded(false);
} | java | private void handleFeatureIncludes(SpecInfo spec, IncludeExcludeCriteria criteria) {
if (criteria.isEmpty()) return;
for (FeatureInfo feature : spec.getAllFeatures())
if (hasAnyAnnotation(feature.getFeatureMethod(), criteria.annotations))
feature.setExcluded(false);
} | [
"private",
"void",
"handleFeatureIncludes",
"(",
"SpecInfo",
"spec",
",",
"IncludeExcludeCriteria",
"criteria",
")",
"{",
"if",
"(",
"criteria",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"for",
"(",
"FeatureInfo",
"feature",
":",
"spec",
".",
"getAllFeatur... | in contrast to the three other handleXXX methods, this one includes nodes | [
"in",
"contrast",
"to",
"the",
"three",
"other",
"handleXXX",
"methods",
"this",
"one",
"includes",
"nodes"
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/runtime/extension/builtin/IncludeExcludeExtension.java#L58-L64 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/compiler/SpecParser.java | SpecParser.visitField | @Override
public void visitField(FieldNode gField) {
PropertyNode owner = spec.getAst().getProperty(gField.getName());
if (gField.isStatic()) return;
Field field = new Field(spec, gField, fieldCount++);
field.setShared(AstUtil.hasAnnotation(gField, Shared.class));
field.setOwner(owner);
spec.getFields().add(field);
} | java | @Override
public void visitField(FieldNode gField) {
PropertyNode owner = spec.getAst().getProperty(gField.getName());
if (gField.isStatic()) return;
Field field = new Field(spec, gField, fieldCount++);
field.setShared(AstUtil.hasAnnotation(gField, Shared.class));
field.setOwner(owner);
spec.getFields().add(field);
} | [
"@",
"Override",
"public",
"void",
"visitField",
"(",
"FieldNode",
"gField",
")",
"{",
"PropertyNode",
"owner",
"=",
"spec",
".",
"getAst",
"(",
")",
".",
"getProperty",
"(",
"gField",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"gField",
".",
"isSt... | although it IS related to a user-provided definition | [
"although",
"it",
"IS",
"related",
"to",
"a",
"user",
"-",
"provided",
"definition"
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/compiler/SpecParser.java#L62-L71 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/compiler/SpecParser.java | SpecParser.constructorMayHaveBeenAddedByCompiler | private boolean constructorMayHaveBeenAddedByCompiler(ConstructorNode constructor) {
Parameter[] params = constructor.getParameters();
Statement firstStat = constructor.getFirstStatement();
return AstUtil.isJointCompiled(spec.getAst()) && constructor.isPublic()
&& params != null && params.length == 0 && firstStat == null;
} | java | private boolean constructorMayHaveBeenAddedByCompiler(ConstructorNode constructor) {
Parameter[] params = constructor.getParameters();
Statement firstStat = constructor.getFirstStatement();
return AstUtil.isJointCompiled(spec.getAst()) && constructor.isPublic()
&& params != null && params.length == 0 && firstStat == null;
} | [
"private",
"boolean",
"constructorMayHaveBeenAddedByCompiler",
"(",
"ConstructorNode",
"constructor",
")",
"{",
"Parameter",
"[",
"]",
"params",
"=",
"constructor",
".",
"getParameters",
"(",
")",
";",
"Statement",
"firstStat",
"=",
"constructor",
".",
"getFirstStatem... | to add special logic to detect this case. | [
"to",
"add",
"special",
"logic",
"to",
"detect",
"this",
"case",
"."
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/compiler/SpecParser.java#L89-L94 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/compiler/InteractionRewriter.java | InteractionRewriter.rewrite | @Nullable
public ExpressionStatement rewrite(ExpressionStatement stat) {
try {
if (!isInteraction(stat)) return null;
createBuilder();
setCount();
setCall();
addResponses();
build();
return register();
} catch (InvalidSpecCompileException e) {
resources.getErrorReporter().error(e);
return null;
}
} | java | @Nullable
public ExpressionStatement rewrite(ExpressionStatement stat) {
try {
if (!isInteraction(stat)) return null;
createBuilder();
setCount();
setCall();
addResponses();
build();
return register();
} catch (InvalidSpecCompileException e) {
resources.getErrorReporter().error(e);
return null;
}
} | [
"@",
"Nullable",
"public",
"ExpressionStatement",
"rewrite",
"(",
"ExpressionStatement",
"stat",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"isInteraction",
"(",
"stat",
")",
")",
"return",
"null",
";",
"createBuilder",
"(",
")",
";",
"setCount",
"(",
")",
";",... | If the given statement is a valid interaction definition, returns the rewritten statement.
If the given statement is not an interaction definition, returns null.
If the given statement is an invalid interaction definition, records a compile error
and returns null. | [
"If",
"the",
"given",
"statement",
"is",
"a",
"valid",
"interaction",
"definition",
"returns",
"the",
"rewritten",
"statement",
".",
"If",
"the",
"given",
"statement",
"is",
"not",
"an",
"interaction",
"definition",
"returns",
"null",
".",
"If",
"the",
"given"... | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/compiler/InteractionRewriter.java#L62-L77 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/mock/EmptyOrDummyResponse.java | EmptyOrDummyResponse.createEmptyWrapper | private Object createEmptyWrapper(Class<?> type) {
if (Number.class.isAssignableFrom(type)) {
Method method = ReflectionUtil.getDeclaredMethodBySignature(type, "valueOf", String.class);
if (method != null && method.getReturnType() == type) {
return ReflectionUtil.invokeMethod(type, method, "0");
}
if (type == BigInteger.class) return BigInteger.ZERO;
if (type == BigDecimal.class) return BigDecimal.ZERO;
return null;
}
if (type == Boolean.class) return false;
if (type == Character.class) return (char) 0; // better return something else?
return null;
} | java | private Object createEmptyWrapper(Class<?> type) {
if (Number.class.isAssignableFrom(type)) {
Method method = ReflectionUtil.getDeclaredMethodBySignature(type, "valueOf", String.class);
if (method != null && method.getReturnType() == type) {
return ReflectionUtil.invokeMethod(type, method, "0");
}
if (type == BigInteger.class) return BigInteger.ZERO;
if (type == BigDecimal.class) return BigDecimal.ZERO;
return null;
}
if (type == Boolean.class) return false;
if (type == Character.class) return (char) 0; // better return something else?
return null;
} | [
"private",
"Object",
"createEmptyWrapper",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"if",
"(",
"Number",
".",
"class",
".",
"isAssignableFrom",
"(",
"type",
")",
")",
"{",
"Method",
"method",
"=",
"ReflectionUtil",
".",
"getDeclaredMethodBySignature",
... | also handles some numeric types which aren't primitive wrapper types | [
"also",
"handles",
"some",
"numeric",
"types",
"which",
"aren",
"t",
"primitive",
"wrapper",
"types"
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/mock/EmptyOrDummyResponse.java#L129-L142 | train |
spockframework/spock | spock-core/src/main/java/spock/util/concurrent/AsyncConditions.java | AsyncConditions.await | @Deprecated
public void await(int value, TimeUnit unit) throws Throwable {
await(TimeUtil.toSeconds(value, unit));
} | java | @Deprecated
public void await(int value, TimeUnit unit) throws Throwable {
await(TimeUtil.toSeconds(value, unit));
} | [
"@",
"Deprecated",
"public",
"void",
"await",
"(",
"int",
"value",
",",
"TimeUnit",
"unit",
")",
"throws",
"Throwable",
"{",
"await",
"(",
"TimeUtil",
".",
"toSeconds",
"(",
"value",
",",
"unit",
")",
")",
";",
"}"
] | Waits until all evaluate blocks have completed or the specified timeout
expires. If one of the evaluate blocks throws an exception, it is rethrown
from this method.
@throws InterruptedException if the calling thread is interrupted
@throws Throwable the first exception thrown by an evaluate block
@deprecated use {@link #await(double)} instead | [
"Waits",
"until",
"all",
"evaluate",
"blocks",
"have",
"completed",
"or",
"the",
"specified",
"timeout",
"expires",
".",
"If",
"one",
"of",
"the",
"evaluate",
"blocks",
"throws",
"an",
"exception",
"it",
"is",
"rethrown",
"from",
"this",
"method",
"."
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/spock/util/concurrent/AsyncConditions.java#L158-L161 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/runtime/RunContext.java | RunContext.createBottomContext | private static RunContext createBottomContext() {
File spockUserHome = SpockUserHomeUtil.getSpockUserHome();
DelegatingScript script = new ConfigurationScriptLoader(spockUserHome).loadAutoDetectedScript();
List<Class<?>> classes = new ExtensionClassesLoader().loadClassesFromDefaultLocation();
return new RunContext("default", spockUserHome, script, classes);
} | java | private static RunContext createBottomContext() {
File spockUserHome = SpockUserHomeUtil.getSpockUserHome();
DelegatingScript script = new ConfigurationScriptLoader(spockUserHome).loadAutoDetectedScript();
List<Class<?>> classes = new ExtensionClassesLoader().loadClassesFromDefaultLocation();
return new RunContext("default", spockUserHome, script, classes);
} | [
"private",
"static",
"RunContext",
"createBottomContext",
"(",
")",
"{",
"File",
"spockUserHome",
"=",
"SpockUserHomeUtil",
".",
"getSpockUserHome",
"(",
")",
";",
"DelegatingScript",
"script",
"=",
"new",
"ConfigurationScriptLoader",
"(",
"spockUserHome",
")",
".",
... | this shouldn't be much of a problem in practice. | [
"this",
"shouldn",
"t",
"be",
"much",
"of",
"a",
"problem",
"in",
"practice",
"."
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/runtime/RunContext.java#L182-L187 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/util/IoUtil.java | IoUtil.closeQuietly | public static void closeQuietly(@Nullable final Socket... sockets) {
if (sockets == null) return;
for (Socket socket : sockets) {
if (socket == null) return;
try {
socket.close();
} catch (IOException ignored) {}
}
} | java | public static void closeQuietly(@Nullable final Socket... sockets) {
if (sockets == null) return;
for (Socket socket : sockets) {
if (socket == null) return;
try {
socket.close();
} catch (IOException ignored) {}
}
} | [
"public",
"static",
"void",
"closeQuietly",
"(",
"@",
"Nullable",
"final",
"Socket",
"...",
"sockets",
")",
"{",
"if",
"(",
"sockets",
"==",
"null",
")",
"return",
";",
"for",
"(",
"Socket",
"socket",
":",
"sockets",
")",
"{",
"if",
"(",
"socket",
"=="... | In JDK 1.6, java.net.Socket doesn't implement Closeable, so we have this overload. | [
"In",
"JDK",
"1",
".",
"6",
"java",
".",
"net",
".",
"Socket",
"doesn",
"t",
"implement",
"Closeable",
"so",
"we",
"have",
"this",
"overload",
"."
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/util/IoUtil.java#L35-L45 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/util/IoUtil.java | IoUtil.getText | public static String getText(Reader reader) throws IOException {
try {
StringBuilder source = new StringBuilder();
BufferedReader buffered = new BufferedReader(reader);
String line = buffered.readLine();
while (line != null) {
source.append(line);
source.append('\n');
line = buffered.readLine();
}
return source.toString();
} finally {
closeQuietly(reader);
}
} | java | public static String getText(Reader reader) throws IOException {
try {
StringBuilder source = new StringBuilder();
BufferedReader buffered = new BufferedReader(reader);
String line = buffered.readLine();
while (line != null) {
source.append(line);
source.append('\n');
line = buffered.readLine();
}
return source.toString();
} finally {
closeQuietly(reader);
}
} | [
"public",
"static",
"String",
"getText",
"(",
"Reader",
"reader",
")",
"throws",
"IOException",
"{",
"try",
"{",
"StringBuilder",
"source",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"BufferedReader",
"buffered",
"=",
"new",
"BufferedReader",
"(",
"reader",
"... | Returns the text read from the given reader as a String.
Closes the given reader upon return. | [
"Returns",
"the",
"text",
"read",
"from",
"the",
"given",
"reader",
"as",
"a",
"String",
".",
"Closes",
"the",
"given",
"reader",
"upon",
"return",
"."
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/util/IoUtil.java#L63-L79 | train |
spockframework/spock | spock-core/src/main/java/spock/util/environment/OperatingSystem.java | OperatingSystem.getCurrent | public static OperatingSystem getCurrent() {
String name = System.getProperty("os.name");
String version = System.getProperty("os.version");
String lowerName = name.toLowerCase();
if (lowerName.contains("linux")) return new OperatingSystem(name, version, Family.LINUX);
if (lowerName.contains("mac os") || lowerName.contains("darwin")) return new OperatingSystem(name, version, Family.MAC_OS);
if (lowerName.contains("windows")) return new OperatingSystem(name, version, Family.WINDOWS);
if (lowerName.contains("sunos")) return new OperatingSystem(name, version, Family.SOLARIS);
return new OperatingSystem(name, version, Family.OTHER);
} | java | public static OperatingSystem getCurrent() {
String name = System.getProperty("os.name");
String version = System.getProperty("os.version");
String lowerName = name.toLowerCase();
if (lowerName.contains("linux")) return new OperatingSystem(name, version, Family.LINUX);
if (lowerName.contains("mac os") || lowerName.contains("darwin")) return new OperatingSystem(name, version, Family.MAC_OS);
if (lowerName.contains("windows")) return new OperatingSystem(name, version, Family.WINDOWS);
if (lowerName.contains("sunos")) return new OperatingSystem(name, version, Family.SOLARIS);
return new OperatingSystem(name, version, Family.OTHER);
} | [
"public",
"static",
"OperatingSystem",
"getCurrent",
"(",
")",
"{",
"String",
"name",
"=",
"System",
".",
"getProperty",
"(",
"\"os.name\"",
")",
";",
"String",
"version",
"=",
"System",
".",
"getProperty",
"(",
"\"os.version\"",
")",
";",
"String",
"lowerName... | Returns the current operating system.
@return the current operating system | [
"Returns",
"the",
"current",
"operating",
"system",
"."
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/spock/util/environment/OperatingSystem.java#L140-L149 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/compiler/DeepBlockRewriter.java | DeepBlockRewriter.forbidUseOfSuperInFixtureMethod | private boolean forbidUseOfSuperInFixtureMethod(MethodCallExpression expr) {
Method currMethod = resources.getCurrentMethod();
Expression target = expr.getObjectExpression();
if (currMethod instanceof FixtureMethod
&& target instanceof VariableExpression
&& ((VariableExpression)target).isSuperExpression()
&& currMethod.getName().equals(expr.getMethodAsString())) {
resources.getErrorReporter().error(expr,
"A base class fixture method should not be called explicitly " +
"because it is always invoked automatically by the framework");
return true;
}
return false;
} | java | private boolean forbidUseOfSuperInFixtureMethod(MethodCallExpression expr) {
Method currMethod = resources.getCurrentMethod();
Expression target = expr.getObjectExpression();
if (currMethod instanceof FixtureMethod
&& target instanceof VariableExpression
&& ((VariableExpression)target).isSuperExpression()
&& currMethod.getName().equals(expr.getMethodAsString())) {
resources.getErrorReporter().error(expr,
"A base class fixture method should not be called explicitly " +
"because it is always invoked automatically by the framework");
return true;
}
return false;
} | [
"private",
"boolean",
"forbidUseOfSuperInFixtureMethod",
"(",
"MethodCallExpression",
"expr",
")",
"{",
"Method",
"currMethod",
"=",
"resources",
".",
"getCurrentMethod",
"(",
")",
";",
"Expression",
"target",
"=",
"expr",
".",
"getObjectExpression",
"(",
")",
";",
... | the base method and doesn't know that it will be run automatically) | [
"the",
"base",
"method",
"and",
"doesn",
"t",
"know",
"that",
"it",
"will",
"be",
"run",
"automatically",
")"
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/compiler/DeepBlockRewriter.java#L300-L315 | train |
spockframework/spock | spock-core/src/main/groovy/spock/util/Exceptions.java | Exceptions.getRootCause | public static Throwable getRootCause(Throwable exception) {
Assert.notNull(exception);
return exception.getCause() == null ? exception : getRootCause(exception.getCause());
} | java | public static Throwable getRootCause(Throwable exception) {
Assert.notNull(exception);
return exception.getCause() == null ? exception : getRootCause(exception.getCause());
} | [
"public",
"static",
"Throwable",
"getRootCause",
"(",
"Throwable",
"exception",
")",
"{",
"Assert",
".",
"notNull",
"(",
"exception",
")",
";",
"return",
"exception",
".",
"getCause",
"(",
")",
"==",
"null",
"?",
"exception",
":",
"getRootCause",
"(",
"excep... | Returns the innermost cause of the specified exception. If the specified exception
has no cause, the exception itself is returned.
@param exception an exception
@return the root cause of the exception | [
"Returns",
"the",
"innermost",
"cause",
"of",
"the",
"specified",
"exception",
".",
"If",
"the",
"specified",
"exception",
"has",
"no",
"cause",
"the",
"exception",
"itself",
"is",
"returned",
"."
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/groovy/spock/util/Exceptions.java#L29-L32 | train |
spockframework/spock | spock-core/src/main/groovy/spock/util/Exceptions.java | Exceptions.getCauseChain | public static List<Throwable> getCauseChain(Throwable exception) {
Assert.notNull(exception);
List<Throwable> result = new ArrayList<>();
collectCauseChain(exception, result);
return result;
} | java | public static List<Throwable> getCauseChain(Throwable exception) {
Assert.notNull(exception);
List<Throwable> result = new ArrayList<>();
collectCauseChain(exception, result);
return result;
} | [
"public",
"static",
"List",
"<",
"Throwable",
">",
"getCauseChain",
"(",
"Throwable",
"exception",
")",
"{",
"Assert",
".",
"notNull",
"(",
"exception",
")",
";",
"List",
"<",
"Throwable",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"col... | Returns a list of all causes of the specified exception. The first element of the
returned list is the specified exception itself; the last element is its root cause.
@param exception an exception
@return the exception's cause chain | [
"Returns",
"a",
"list",
"of",
"all",
"causes",
"of",
"the",
"specified",
"exception",
".",
"The",
"first",
"element",
"of",
"the",
"returned",
"list",
"is",
"the",
"specified",
"exception",
"itself",
";",
"the",
"last",
"element",
"is",
"its",
"root",
"cau... | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/groovy/spock/util/Exceptions.java#L42-L47 | train |
spockframework/spock | spock-core/src/main/java/org/spockframework/gentyref/GenericTypeReflector.java | GenericTypeReflector.getArrayComponentType | public static Type getArrayComponentType(Type type) {
if (type instanceof Class) {
Class<?> clazz = (Class<?>)type;
return clazz.getComponentType();
} else if (type instanceof GenericArrayType) {
GenericArrayType aType = (GenericArrayType) type;
return aType.getGenericComponentType();
} else {
return null;
}
} | java | public static Type getArrayComponentType(Type type) {
if (type instanceof Class) {
Class<?> clazz = (Class<?>)type;
return clazz.getComponentType();
} else if (type instanceof GenericArrayType) {
GenericArrayType aType = (GenericArrayType) type;
return aType.getGenericComponentType();
} else {
return null;
}
} | [
"public",
"static",
"Type",
"getArrayComponentType",
"(",
"Type",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"Class",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"(",
"Class",
"<",
"?",
">",
")",
"type",
";",
"return",
"clazz",
".",
"getC... | If type is an array type, returns the type of the component of the array.
Otherwise, returns null. | [
"If",
"type",
"is",
"an",
"array",
"type",
"returns",
"the",
"type",
"of",
"the",
"component",
"of",
"the",
"array",
".",
"Otherwise",
"returns",
"null",
"."
] | d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9 | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/gentyref/GenericTypeReflector.java#L221-L231 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.