id
int32
0
165k
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
12,500
googleapis/google-cloud-java
google-cloud-clients/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyFactory.java
KeyFactory.reset
public KeyFactory reset() { setProjectId(pi); setNamespace(ns); kind = null; ancestors.clear(); return this; }
java
public KeyFactory reset() { setProjectId(pi); setNamespace(ns); kind = null; ancestors.clear(); return this; }
[ "public", "KeyFactory", "reset", "(", ")", "{", "setProjectId", "(", "pi", ")", ";", "setNamespace", "(", "ns", ")", ";", "kind", "=", "null", ";", "ancestors", ".", "clear", "(", ")", ";", "return", "this", ";", "}" ]
Resets the KeyFactory to its initial state. @return {@code this} for chaining
[ "Resets", "the", "KeyFactory", "to", "its", "initial", "state", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyFactory.java#L70-L76
12,501
googleapis/google-cloud-java
google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Cors.java
Cors.toBuilder
public Builder toBuilder() { return newBuilder() .setMaxAgeSeconds(maxAgeSeconds) .setMethods(methods) .setOrigins(origins) .setResponseHeaders(responseHeaders); }
java
public Builder toBuilder() { return newBuilder() .setMaxAgeSeconds(maxAgeSeconds) .setMethods(methods) .setOrigins(origins) .setResponseHeaders(responseHeaders); }
[ "public", "Builder", "toBuilder", "(", ")", "{", "return", "newBuilder", "(", ")", ".", "setMaxAgeSeconds", "(", "maxAgeSeconds", ")", ".", "setMethods", "(", "methods", ")", ".", "setOrigins", "(", "origins", ")", ".", "setResponseHeaders", "(", "responseHeaders", ")", ";", "}" ]
Returns a builder for this CORS configuration.
[ "Returns", "a", "builder", "for", "this", "CORS", "configuration", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Cors.java#L196-L202
12,502
googleapis/google-cloud-java
google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendBucketClient.java
BackendBucketClient.deleteSignedUrlKeyBackendBucket
@BetaApi public final Operation deleteSignedUrlKeyBackendBucket( ProjectGlobalBackendBucketName backendBucket, String keyName) { DeleteSignedUrlKeyBackendBucketHttpRequest request = DeleteSignedUrlKeyBackendBucketHttpRequest.newBuilder() .setBackendBucket(backendBucket == null ? null : backendBucket.toString()) .setKeyName(keyName) .build(); return deleteSignedUrlKeyBackendBucket(request); }
java
@BetaApi public final Operation deleteSignedUrlKeyBackendBucket( ProjectGlobalBackendBucketName backendBucket, String keyName) { DeleteSignedUrlKeyBackendBucketHttpRequest request = DeleteSignedUrlKeyBackendBucketHttpRequest.newBuilder() .setBackendBucket(backendBucket == null ? null : backendBucket.toString()) .setKeyName(keyName) .build(); return deleteSignedUrlKeyBackendBucket(request); }
[ "@", "BetaApi", "public", "final", "Operation", "deleteSignedUrlKeyBackendBucket", "(", "ProjectGlobalBackendBucketName", "backendBucket", ",", "String", "keyName", ")", "{", "DeleteSignedUrlKeyBackendBucketHttpRequest", "request", "=", "DeleteSignedUrlKeyBackendBucketHttpRequest", ".", "newBuilder", "(", ")", ".", "setBackendBucket", "(", "backendBucket", "==", "null", "?", "null", ":", "backendBucket", ".", "toString", "(", ")", ")", ".", "setKeyName", "(", "keyName", ")", ".", "build", "(", ")", ";", "return", "deleteSignedUrlKeyBackendBucket", "(", "request", ")", ";", "}" ]
Deletes a key for validating requests with signed URLs for this backend bucket. <p>Sample code: <pre><code> try (BackendBucketClient backendBucketClient = BackendBucketClient.create()) { ProjectGlobalBackendBucketName backendBucket = ProjectGlobalBackendBucketName.of("[PROJECT]", "[BACKEND_BUCKET]"); String keyName = ""; Operation response = backendBucketClient.deleteSignedUrlKeyBackendBucket(backendBucket, keyName); } </code></pre> @param backendBucket Name of the BackendBucket resource to which the Signed URL Key should be added. The name should conform to RFC1035. @param keyName The name of the Signed URL Key to delete. @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Deletes", "a", "key", "for", "validating", "requests", "with", "signed", "URLs", "for", "this", "backend", "bucket", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendBucketClient.java#L391-L401
12,503
googleapis/google-cloud-java
google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendBucketClient.java
BackendBucketClient.updateBackendBucket
@BetaApi public final Operation updateBackendBucket( String backendBucket, BackendBucket backendBucketResource, List<String> fieldMask) { UpdateBackendBucketHttpRequest request = UpdateBackendBucketHttpRequest.newBuilder() .setBackendBucket(backendBucket) .setBackendBucketResource(backendBucketResource) .addAllFieldMask(fieldMask) .build(); return updateBackendBucket(request); }
java
@BetaApi public final Operation updateBackendBucket( String backendBucket, BackendBucket backendBucketResource, List<String> fieldMask) { UpdateBackendBucketHttpRequest request = UpdateBackendBucketHttpRequest.newBuilder() .setBackendBucket(backendBucket) .setBackendBucketResource(backendBucketResource) .addAllFieldMask(fieldMask) .build(); return updateBackendBucket(request); }
[ "@", "BetaApi", "public", "final", "Operation", "updateBackendBucket", "(", "String", "backendBucket", ",", "BackendBucket", "backendBucketResource", ",", "List", "<", "String", ">", "fieldMask", ")", "{", "UpdateBackendBucketHttpRequest", "request", "=", "UpdateBackendBucketHttpRequest", ".", "newBuilder", "(", ")", ".", "setBackendBucket", "(", "backendBucket", ")", ".", "setBackendBucketResource", "(", "backendBucketResource", ")", ".", "addAllFieldMask", "(", "fieldMask", ")", ".", "build", "(", ")", ";", "return", "updateBackendBucket", "(", "request", ")", ";", "}" ]
Updates the specified BackendBucket resource with the data included in the request. <p>Sample code: <pre><code> try (BackendBucketClient backendBucketClient = BackendBucketClient.create()) { ProjectGlobalBackendBucketName backendBucket = ProjectGlobalBackendBucketName.of("[PROJECT]", "[BACKEND_BUCKET]"); BackendBucket backendBucketResource = BackendBucket.newBuilder().build(); List&lt;String&gt; fieldMask = new ArrayList&lt;&gt;(); Operation response = backendBucketClient.updateBackendBucket(backendBucket.toString(), backendBucketResource, fieldMask); } </code></pre> @param backendBucket Name of the BackendBucket resource to update. @param backendBucketResource A BackendBucket resource. This resource defines a Cloud Storage bucket. @param fieldMask The fields that should be serialized (even if they have empty values). If the containing message object has a non-null fieldmask, then all the fields in the field mask (and only those fields in the field mask) will be serialized. If the containing object does not have a fieldmask, then only non-empty fields will be serialized. @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Updates", "the", "specified", "BackendBucket", "resource", "with", "the", "data", "included", "in", "the", "request", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/BackendBucketClient.java#L1042-L1053
12,504
googleapis/google-cloud-java
google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java
Table.list
public TableResult list(Schema schema, TableDataListOption... options) throws BigQueryException { return bigquery.listTableData(getTableId(), schema, options); }
java
public TableResult list(Schema schema, TableDataListOption... options) throws BigQueryException { return bigquery.listTableData(getTableId(), schema, options); }
[ "public", "TableResult", "list", "(", "Schema", "schema", ",", "TableDataListOption", "...", "options", ")", "throws", "BigQueryException", "{", "return", "bigquery", ".", "listTableData", "(", "getTableId", "(", ")", ",", "schema", ",", "options", ")", ";", "}" ]
Returns the paginated list rows in this table. <p>Example of listing rows in the table given a schema. <pre>{@code Schema schema = ...; String field = "my_field"; Page<FieldValueList> page = table.list(schema); for (FieldValueList row : page.iterateAll()) { row.get(field); } }</pre> @param options table data list options @throws BigQueryException upon failure
[ "Returns", "the", "paginated", "list", "rows", "in", "this", "table", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Table.java#L369-L371
12,505
googleapis/google-cloud-java
google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/Role.java
Role.of
public static Role of(String value) { checkNotNull(value); if (!value.contains("/")) { value = ROLE_PREFIX + value; } return new Role(value); }
java
public static Role of(String value) { checkNotNull(value); if (!value.contains("/")) { value = ROLE_PREFIX + value; } return new Role(value); }
[ "public", "static", "Role", "of", "(", "String", "value", ")", "{", "checkNotNull", "(", "value", ")", ";", "if", "(", "!", "value", ".", "contains", "(", "\"/\"", ")", ")", "{", "value", "=", "ROLE_PREFIX", "+", "value", ";", "}", "return", "new", "Role", "(", "value", ")", ";", "}" ]
Returns a new role given its string value. <p>If the value contains no slash character ({@code '/'}), the prefix {@code "roles/""} is prepended. This slightly simplifies usage for <a href="https://cloud.google.com/iam/docs/understanding-roles">predefined roles</a>. For <a href="https://cloud.google.com/iam/docs/creating-custom-roles">custom roles</a>, call this method with the fully-qualified name, eg {@code "projects/XXX/roles/YYY"}. @param value the string value for the role @see <a href="https://cloud.google.com/iam/docs/viewing-grantable-roles">Viewing the Grantable Roles on Resources</a>
[ "Returns", "a", "new", "role", "given", "its", "string", "value", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-core/src/main/java/com/google/cloud/Role.java#L94-L100
12,506
googleapis/google-cloud-java
google-cloud-clients/google-cloud-redis/src/main/java/com/google/cloud/redis/v1/CloudRedisClient.java
CloudRedisClient.createInstanceAsync
@BetaApi( "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Instance, OperationMetadata> createInstanceAsync( LocationName parent, String instanceId, Instance instance) { CreateInstanceRequest request = CreateInstanceRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setInstanceId(instanceId) .setInstance(instance) .build(); return createInstanceAsync(request); }
java
@BetaApi( "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Instance, OperationMetadata> createInstanceAsync( LocationName parent, String instanceId, Instance instance) { CreateInstanceRequest request = CreateInstanceRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setInstanceId(instanceId) .setInstance(instance) .build(); return createInstanceAsync(request); }
[ "@", "BetaApi", "(", "\"The surface for long-running operations is not stable yet and may change in the future.\"", ")", "public", "final", "OperationFuture", "<", "Instance", ",", "OperationMetadata", ">", "createInstanceAsync", "(", "LocationName", "parent", ",", "String", "instanceId", ",", "Instance", "instance", ")", "{", "CreateInstanceRequest", "request", "=", "CreateInstanceRequest", ".", "newBuilder", "(", ")", ".", "setParent", "(", "parent", "==", "null", "?", "null", ":", "parent", ".", "toString", "(", ")", ")", ".", "setInstanceId", "(", "instanceId", ")", ".", "setInstance", "(", "instance", ")", ".", "build", "(", ")", ";", "return", "createInstanceAsync", "(", "request", ")", ";", "}" ]
Creates a Redis instance based on the specified tier and memory size. <p>By default, the instance is accessible from the project's [default network](/compute/docs/networks-and-firewalls#networks). <p>The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field. <p>The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation. <p>Sample code: <pre><code> try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) { LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); String instanceId = "test_instance"; Instance.Tier tier = Instance.Tier.BASIC; int memorySizeGb = 1; Instance instance = Instance.newBuilder() .setTier(tier) .setMemorySizeGb(memorySizeGb) .build(); Instance response = cloudRedisClient.createInstanceAsync(parent, instanceId, instance).get(); } </code></pre> @param parent Required. The resource name of the instance location using the form: `projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region @param instanceId Required. The logical name of the Redis instance in the customer project with the following restrictions: <p>&#42; Must contain only lowercase letters, numbers, and hyphens. &#42; Must start with a letter. &#42; Must be between 1-40 characters. &#42; Must end with a number or a letter. &#42; Must be unique within the customer project / location @param instance Required. A Redis [Instance] resource @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Creates", "a", "Redis", "instance", "based", "on", "the", "specified", "tier", "and", "memory", "size", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-redis/src/main/java/com/google/cloud/redis/v1/CloudRedisClient.java#L487-L499
12,507
googleapis/google-cloud-java
google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/ZoneOperationId.java
ZoneOperationId.of
public static ZoneOperationId of(ZoneId zoneId, String operation) { return new ZoneOperationId(zoneId.getProject(), zoneId.getZone(), operation); }
java
public static ZoneOperationId of(ZoneId zoneId, String operation) { return new ZoneOperationId(zoneId.getProject(), zoneId.getZone(), operation); }
[ "public", "static", "ZoneOperationId", "of", "(", "ZoneId", "zoneId", ",", "String", "operation", ")", "{", "return", "new", "ZoneOperationId", "(", "zoneId", ".", "getProject", "(", ")", ",", "zoneId", ".", "getZone", "(", ")", ",", "operation", ")", ";", "}" ]
Returns a zone operation identity given the zone identity and the operation name.
[ "Returns", "a", "zone", "operation", "identity", "given", "the", "zone", "identity", "and", "the", "operation", "name", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/ZoneOperationId.java#L91-L93
12,508
googleapis/google-cloud-java
google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/ZoneOperationId.java
ZoneOperationId.of
public static ZoneOperationId of(String zone, String operation) { return new ZoneOperationId(null, zone, operation); }
java
public static ZoneOperationId of(String zone, String operation) { return new ZoneOperationId(null, zone, operation); }
[ "public", "static", "ZoneOperationId", "of", "(", "String", "zone", ",", "String", "operation", ")", "{", "return", "new", "ZoneOperationId", "(", "null", ",", "zone", ",", "operation", ")", ";", "}" ]
Returns a zone operation identity given the zone and operation names.
[ "Returns", "a", "zone", "operation", "identity", "given", "the", "zone", "and", "operation", "names", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/ZoneOperationId.java#L96-L98
12,509
googleapis/google-cloud-java
google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/ZoneOperationId.java
ZoneOperationId.of
public static ZoneOperationId of(String project, String zone, String operation) { return new ZoneOperationId(project, zone, operation); }
java
public static ZoneOperationId of(String project, String zone, String operation) { return new ZoneOperationId(project, zone, operation); }
[ "public", "static", "ZoneOperationId", "of", "(", "String", "project", ",", "String", "zone", ",", "String", "operation", ")", "{", "return", "new", "ZoneOperationId", "(", "project", ",", "zone", ",", "operation", ")", ";", "}" ]
Returns a zone operation identity given project, zone and operation names.
[ "Returns", "a", "zone", "operation", "identity", "given", "project", "zone", "and", "operation", "names", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/ZoneOperationId.java#L101-L103
12,510
googleapis/google-cloud-java
google-cloud-clients/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java
DeviceManagerClient.updateDeviceRegistry
public final DeviceRegistry updateDeviceRegistry( DeviceRegistry deviceRegistry, FieldMask updateMask) { UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.newBuilder() .setDeviceRegistry(deviceRegistry) .setUpdateMask(updateMask) .build(); return updateDeviceRegistry(request); }
java
public final DeviceRegistry updateDeviceRegistry( DeviceRegistry deviceRegistry, FieldMask updateMask) { UpdateDeviceRegistryRequest request = UpdateDeviceRegistryRequest.newBuilder() .setDeviceRegistry(deviceRegistry) .setUpdateMask(updateMask) .build(); return updateDeviceRegistry(request); }
[ "public", "final", "DeviceRegistry", "updateDeviceRegistry", "(", "DeviceRegistry", "deviceRegistry", ",", "FieldMask", "updateMask", ")", "{", "UpdateDeviceRegistryRequest", "request", "=", "UpdateDeviceRegistryRequest", ".", "newBuilder", "(", ")", ".", "setDeviceRegistry", "(", "deviceRegistry", ")", ".", "setUpdateMask", "(", "updateMask", ")", ".", "build", "(", ")", ";", "return", "updateDeviceRegistry", "(", "request", ")", ";", "}" ]
Updates a device registry configuration. <p>Sample code: <pre><code> try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { DeviceRegistry deviceRegistry = DeviceRegistry.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); DeviceRegistry response = deviceManagerClient.updateDeviceRegistry(deviceRegistry, updateMask); } </code></pre> @param deviceRegistry The new values for the device registry. The `id` field must be empty, and the `name` field must indicate the path of the resource. For example, `projects/example-project/locations/us-central1/registries/my-registry`. @param updateMask Only updates the `device_registry` fields indicated by this mask. The field mask must not be empty, and it must not contain fields that are immutable or only set by the server. Mutable top-level fields: `event_notification_config`, `http_config`, `mqtt_config`, and `state_notification_config`. @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Updates", "a", "device", "registry", "configuration", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java#L393-L402
12,511
googleapis/google-cloud-java
google-cloud-clients/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java
DeviceManagerClient.updateDevice
public final Device updateDevice(Device device, FieldMask updateMask) { UpdateDeviceRequest request = UpdateDeviceRequest.newBuilder().setDevice(device).setUpdateMask(updateMask).build(); return updateDevice(request); }
java
public final Device updateDevice(Device device, FieldMask updateMask) { UpdateDeviceRequest request = UpdateDeviceRequest.newBuilder().setDevice(device).setUpdateMask(updateMask).build(); return updateDevice(request); }
[ "public", "final", "Device", "updateDevice", "(", "Device", "device", ",", "FieldMask", "updateMask", ")", "{", "UpdateDeviceRequest", "request", "=", "UpdateDeviceRequest", ".", "newBuilder", "(", ")", ".", "setDevice", "(", "device", ")", ".", "setUpdateMask", "(", "updateMask", ")", ".", "build", "(", ")", ";", "return", "updateDevice", "(", "request", ")", ";", "}" ]
Updates a device. <p>Sample code: <pre><code> try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { Device device = Device.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); Device response = deviceManagerClient.updateDevice(device, updateMask); } </code></pre> @param device The new values for the device. The `id` and `num_id` fields must be empty, and the field `name` must specify the name path. For example, `projects/p0/locations/us-central1/registries/registry0/devices/device0`or `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. @param updateMask Only updates the `device` fields indicated by this mask. The field mask must not be empty, and it must not contain fields that are immutable or only set by the server. Mutable top-level fields: `credentials`, `blocked`, and `metadata` @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Updates", "a", "device", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java#L907-L912
12,512
googleapis/google-cloud-java
google-cloud-clients/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java
DeviceManagerClient.bindDeviceToGateway
public final BindDeviceToGatewayResponse bindDeviceToGateway( String parent, String gatewayId, String deviceId) { BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.newBuilder() .setParent(parent) .setGatewayId(gatewayId) .setDeviceId(deviceId) .build(); return bindDeviceToGateway(request); }
java
public final BindDeviceToGatewayResponse bindDeviceToGateway( String parent, String gatewayId, String deviceId) { BindDeviceToGatewayRequest request = BindDeviceToGatewayRequest.newBuilder() .setParent(parent) .setGatewayId(gatewayId) .setDeviceId(deviceId) .build(); return bindDeviceToGateway(request); }
[ "public", "final", "BindDeviceToGatewayResponse", "bindDeviceToGateway", "(", "String", "parent", ",", "String", "gatewayId", ",", "String", "deviceId", ")", "{", "BindDeviceToGatewayRequest", "request", "=", "BindDeviceToGatewayRequest", ".", "newBuilder", "(", ")", ".", "setParent", "(", "parent", ")", ".", "setGatewayId", "(", "gatewayId", ")", ".", "setDeviceId", "(", "deviceId", ")", ".", "build", "(", ")", ";", "return", "bindDeviceToGateway", "(", "request", ")", ";", "}" ]
Associates the device with the gateway. <p>Sample code: <pre><code> try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); String gatewayId = ""; String deviceId = ""; BindDeviceToGatewayResponse response = deviceManagerClient.bindDeviceToGateway(parent.toString(), gatewayId, deviceId); } </code></pre> @param parent The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`. @param gatewayId The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier. @param deviceId The device to associate with the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier. @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Associates", "the", "device", "with", "the", "gateway", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java#L2051-L2061
12,513
googleapis/google-cloud-java
google-cloud-clients/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java
DeviceManagerClient.unbindDeviceFromGateway
public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway( RegistryName parent, String gatewayId, String deviceId) { UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setGatewayId(gatewayId) .setDeviceId(deviceId) .build(); return unbindDeviceFromGateway(request); }
java
public final UnbindDeviceFromGatewayResponse unbindDeviceFromGateway( RegistryName parent, String gatewayId, String deviceId) { UnbindDeviceFromGatewayRequest request = UnbindDeviceFromGatewayRequest.newBuilder() .setParent(parent == null ? null : parent.toString()) .setGatewayId(gatewayId) .setDeviceId(deviceId) .build(); return unbindDeviceFromGateway(request); }
[ "public", "final", "UnbindDeviceFromGatewayResponse", "unbindDeviceFromGateway", "(", "RegistryName", "parent", ",", "String", "gatewayId", ",", "String", "deviceId", ")", "{", "UnbindDeviceFromGatewayRequest", "request", "=", "UnbindDeviceFromGatewayRequest", ".", "newBuilder", "(", ")", ".", "setParent", "(", "parent", "==", "null", "?", "null", ":", "parent", ".", "toString", "(", ")", ")", ".", "setGatewayId", "(", "gatewayId", ")", ".", "setDeviceId", "(", "deviceId", ")", ".", "build", "(", ")", ";", "return", "unbindDeviceFromGateway", "(", "request", ")", ";", "}" ]
Deletes the association between the device and the gateway. <p>Sample code: <pre><code> try (DeviceManagerClient deviceManagerClient = DeviceManagerClient.create()) { RegistryName parent = RegistryName.of("[PROJECT]", "[LOCATION]", "[REGISTRY]"); String gatewayId = ""; String deviceId = ""; UnbindDeviceFromGatewayResponse response = deviceManagerClient.unbindDeviceFromGateway(parent, gatewayId, deviceId); } </code></pre> @param parent The name of the registry. For example, `projects/example-project/locations/us-central1/registries/my-registry`. @param gatewayId The value of `gateway_id` can be either the device numeric ID or the user-defined device identifier. @param deviceId The device to disassociate from the specified gateway. The value of `device_id` can be either the device numeric ID or the user-defined device identifier. @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Deletes", "the", "association", "between", "the", "device", "and", "the", "gateway", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-iot/src/main/java/com/google/cloud/iot/v1/DeviceManagerClient.java#L2140-L2150
12,514
googleapis/google-cloud-java
google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java
SessionPool.releaseSession
private void releaseSession(PooledSession session) { Preconditions.checkNotNull(session); synchronized (lock) { if (closureFuture != null) { return; } if (readWaiters.size() == 0 && numSessionsBeingPrepared >= readWriteWaiters.size()) { // No pending waiters if (shouldPrepareSession()) { prepareSession(session); } else { readSessions.add(session); } } else if (shouldUnblockReader()) { readWaiters.poll().put(session); } else { prepareSession(session); } } }
java
private void releaseSession(PooledSession session) { Preconditions.checkNotNull(session); synchronized (lock) { if (closureFuture != null) { return; } if (readWaiters.size() == 0 && numSessionsBeingPrepared >= readWriteWaiters.size()) { // No pending waiters if (shouldPrepareSession()) { prepareSession(session); } else { readSessions.add(session); } } else if (shouldUnblockReader()) { readWaiters.poll().put(session); } else { prepareSession(session); } } }
[ "private", "void", "releaseSession", "(", "PooledSession", "session", ")", "{", "Preconditions", ".", "checkNotNull", "(", "session", ")", ";", "synchronized", "(", "lock", ")", "{", "if", "(", "closureFuture", "!=", "null", ")", "{", "return", ";", "}", "if", "(", "readWaiters", ".", "size", "(", ")", "==", "0", "&&", "numSessionsBeingPrepared", ">=", "readWriteWaiters", ".", "size", "(", ")", ")", "{", "// No pending waiters", "if", "(", "shouldPrepareSession", "(", ")", ")", "{", "prepareSession", "(", "session", ")", ";", "}", "else", "{", "readSessions", ".", "add", "(", "session", ")", ";", "}", "}", "else", "if", "(", "shouldUnblockReader", "(", ")", ")", "{", "readWaiters", ".", "poll", "(", ")", ".", "put", "(", "session", ")", ";", "}", "else", "{", "prepareSession", "(", "session", ")", ";", "}", "}", "}" ]
Releases a session back to the pool. This might cause one of the waiters to be unblocked. <p>Implementation note: <ol> <li>If there are no pending waiters, either add to the read sessions queue or start preparing for write depending on what fraction of sessions are already prepared for writes. <li>Otherwise either unblock a waiting reader or start preparing for a write. Exact strategy on which option we chose, in case there are both waiting readers and writers, is implemented in {@link #shouldUnblockReader} </ol>
[ "Releases", "a", "session", "back", "to", "the", "pool", ".", "This", "might", "cause", "one", "of", "the", "waiters", "to", "be", "unblocked", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java#L968-L987
12,515
googleapis/google-cloud-java
google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java
UptimeCheckServiceClient.listUptimeCheckConfigs
public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(String parent) { ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder().setParent(parent).build(); return listUptimeCheckConfigs(request); }
java
public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(String parent) { ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder().setParent(parent).build(); return listUptimeCheckConfigs(request); }
[ "public", "final", "ListUptimeCheckConfigsPagedResponse", "listUptimeCheckConfigs", "(", "String", "parent", ")", "{", "ListUptimeCheckConfigsRequest", "request", "=", "ListUptimeCheckConfigsRequest", ".", "newBuilder", "(", ")", ".", "setParent", "(", "parent", ")", ".", "build", "(", ")", ";", "return", "listUptimeCheckConfigs", "(", "request", ")", ";", "}" ]
Lists the existing valid uptime check configurations for the project, leaving out any invalid configurations. <p>Sample code: <pre><code> try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) { String formattedParent = ProjectName.format("[PROJECT]"); for (UptimeCheckConfig element : uptimeCheckServiceClient.listUptimeCheckConfigs(formattedParent).iterateAll()) { // doThingsWith(element); } } </code></pre> @param parent The project whose uptime check configurations are listed. The format is `projects/[PROJECT_ID]`. @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Lists", "the", "existing", "valid", "uptime", "check", "configurations", "for", "the", "project", "leaving", "out", "any", "invalid", "configurations", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java#L193-L197
12,516
googleapis/google-cloud-java
google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java
UptimeCheckServiceClient.createUptimeCheckConfig
public final UptimeCheckConfig createUptimeCheckConfig( String parent, UptimeCheckConfig uptimeCheckConfig) { CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder() .setParent(parent) .setUptimeCheckConfig(uptimeCheckConfig) .build(); return createUptimeCheckConfig(request); }
java
public final UptimeCheckConfig createUptimeCheckConfig( String parent, UptimeCheckConfig uptimeCheckConfig) { CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder() .setParent(parent) .setUptimeCheckConfig(uptimeCheckConfig) .build(); return createUptimeCheckConfig(request); }
[ "public", "final", "UptimeCheckConfig", "createUptimeCheckConfig", "(", "String", "parent", ",", "UptimeCheckConfig", "uptimeCheckConfig", ")", "{", "CreateUptimeCheckConfigRequest", "request", "=", "CreateUptimeCheckConfigRequest", ".", "newBuilder", "(", ")", ".", "setParent", "(", "parent", ")", ".", "setUptimeCheckConfig", "(", "uptimeCheckConfig", ")", ".", "build", "(", ")", ";", "return", "createUptimeCheckConfig", "(", "request", ")", ";", "}" ]
Creates a new uptime check configuration. <p>Sample code: <pre><code> try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) { String formattedParent = ProjectName.format("[PROJECT]"); UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); UptimeCheckConfig response = uptimeCheckServiceClient.createUptimeCheckConfig(formattedParent, uptimeCheckConfig); } </code></pre> @param parent The project in which to create the uptime check. The format is `projects/[PROJECT_ID]`. @param uptimeCheckConfig The new uptime check configuration. @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Creates", "a", "new", "uptime", "check", "configuration", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java#L400-L409
12,517
googleapis/google-cloud-java
google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java
UptimeCheckServiceClient.updateUptimeCheckConfig
public final UptimeCheckConfig updateUptimeCheckConfig(UptimeCheckConfig uptimeCheckConfig) { UpdateUptimeCheckConfigRequest request = UpdateUptimeCheckConfigRequest.newBuilder().setUptimeCheckConfig(uptimeCheckConfig).build(); return updateUptimeCheckConfig(request); }
java
public final UptimeCheckConfig updateUptimeCheckConfig(UptimeCheckConfig uptimeCheckConfig) { UpdateUptimeCheckConfigRequest request = UpdateUptimeCheckConfigRequest.newBuilder().setUptimeCheckConfig(uptimeCheckConfig).build(); return updateUptimeCheckConfig(request); }
[ "public", "final", "UptimeCheckConfig", "updateUptimeCheckConfig", "(", "UptimeCheckConfig", "uptimeCheckConfig", ")", "{", "UpdateUptimeCheckConfigRequest", "request", "=", "UpdateUptimeCheckConfigRequest", ".", "newBuilder", "(", ")", ".", "setUptimeCheckConfig", "(", "uptimeCheckConfig", ")", ".", "build", "(", ")", ";", "return", "updateUptimeCheckConfig", "(", "request", ")", ";", "}" ]
Updates an uptime check configuration. You can either replace the entire configuration with a new one or replace only certain fields in the current configuration by specifying the fields to be updated via `"updateMask"`. Returns the updated configuration. <p>Sample code: <pre><code> try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) { UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); UptimeCheckConfig response = uptimeCheckServiceClient.updateUptimeCheckConfig(uptimeCheckConfig); } </code></pre> @param uptimeCheckConfig Required. If an `"updateMask"` has been specified, this field gives the values for the set of fields mentioned in the `"updateMask"`. If an `"updateMask"` has not been given, this uptime check configuration replaces the current configuration. If a field is mentioned in `"updateMask"` but the corresonding field is omitted in this partial uptime check configuration, it has the effect of deleting/clearing the field from the configuration on the server. <p>The following fields can be updated: `display_name`, `http_check`, `tcp_check`, `timeout`, `content_matchers`, and `selected_regions`. @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Updates", "an", "uptime", "check", "configuration", ".", "You", "can", "either", "replace", "the", "entire", "configuration", "with", "a", "new", "one", "or", "replace", "only", "certain", "fields", "in", "the", "current", "configuration", "by", "specifying", "the", "fields", "to", "be", "updated", "via", "updateMask", ".", "Returns", "the", "updated", "configuration", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java#L486-L491
12,518
googleapis/google-cloud-java
google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java
TopicAdminClientSnippets.listTopics
public ListTopicsPagedResponse listTopics() throws Exception { // [START pubsub_list_topics] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ListTopicsRequest listTopicsRequest = ListTopicsRequest.newBuilder().setProject(ProjectName.format(projectId)).build(); ListTopicsPagedResponse response = topicAdminClient.listTopics(listTopicsRequest); Iterable<Topic> topics = response.iterateAll(); for (Topic topic : topics) { // do something with the topic } return response; } // [END pubsub_list_topics] }
java
public ListTopicsPagedResponse listTopics() throws Exception { // [START pubsub_list_topics] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ListTopicsRequest listTopicsRequest = ListTopicsRequest.newBuilder().setProject(ProjectName.format(projectId)).build(); ListTopicsPagedResponse response = topicAdminClient.listTopics(listTopicsRequest); Iterable<Topic> topics = response.iterateAll(); for (Topic topic : topics) { // do something with the topic } return response; } // [END pubsub_list_topics] }
[ "public", "ListTopicsPagedResponse", "listTopics", "(", ")", "throws", "Exception", "{", "// [START pubsub_list_topics]", "try", "(", "TopicAdminClient", "topicAdminClient", "=", "TopicAdminClient", ".", "create", "(", ")", ")", "{", "ListTopicsRequest", "listTopicsRequest", "=", "ListTopicsRequest", ".", "newBuilder", "(", ")", ".", "setProject", "(", "ProjectName", ".", "format", "(", "projectId", ")", ")", ".", "build", "(", ")", ";", "ListTopicsPagedResponse", "response", "=", "topicAdminClient", ".", "listTopics", "(", "listTopicsRequest", ")", ";", "Iterable", "<", "Topic", ">", "topics", "=", "response", ".", "iterateAll", "(", ")", ";", "for", "(", "Topic", "topic", ":", "topics", ")", "{", "// do something with the topic", "}", "return", "response", ";", "}", "// [END pubsub_list_topics]", "}" ]
Example of listing topics.
[ "Example", "of", "listing", "topics", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java#L63-L76
12,519
googleapis/google-cloud-java
google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java
TopicAdminClientSnippets.listTopicSubscriptions
public ListTopicSubscriptionsPagedResponse listTopicSubscriptions(String topicId) throws Exception { // [START pubsub_list_topic_subscriptions] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); ListTopicSubscriptionsRequest request = ListTopicSubscriptionsRequest.newBuilder().setTopic(topicName.toString()).build(); ListTopicSubscriptionsPagedResponse response = topicAdminClient.listTopicSubscriptions(request); Iterable<String> subscriptionNames = response.iterateAll(); for (String subscriptionName : subscriptionNames) { // do something with the subscription name } return response; } // [END pubsub_list_topic_subscriptions] }
java
public ListTopicSubscriptionsPagedResponse listTopicSubscriptions(String topicId) throws Exception { // [START pubsub_list_topic_subscriptions] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); ListTopicSubscriptionsRequest request = ListTopicSubscriptionsRequest.newBuilder().setTopic(topicName.toString()).build(); ListTopicSubscriptionsPagedResponse response = topicAdminClient.listTopicSubscriptions(request); Iterable<String> subscriptionNames = response.iterateAll(); for (String subscriptionName : subscriptionNames) { // do something with the subscription name } return response; } // [END pubsub_list_topic_subscriptions] }
[ "public", "ListTopicSubscriptionsPagedResponse", "listTopicSubscriptions", "(", "String", "topicId", ")", "throws", "Exception", "{", "// [START pubsub_list_topic_subscriptions]", "try", "(", "TopicAdminClient", "topicAdminClient", "=", "TopicAdminClient", ".", "create", "(", ")", ")", "{", "ProjectTopicName", "topicName", "=", "ProjectTopicName", ".", "of", "(", "projectId", ",", "topicId", ")", ";", "ListTopicSubscriptionsRequest", "request", "=", "ListTopicSubscriptionsRequest", ".", "newBuilder", "(", ")", ".", "setTopic", "(", "topicName", ".", "toString", "(", ")", ")", ".", "build", "(", ")", ";", "ListTopicSubscriptionsPagedResponse", "response", "=", "topicAdminClient", ".", "listTopicSubscriptions", "(", "request", ")", ";", "Iterable", "<", "String", ">", "subscriptionNames", "=", "response", ".", "iterateAll", "(", ")", ";", "for", "(", "String", "subscriptionName", ":", "subscriptionNames", ")", "{", "// do something with the subscription name", "}", "return", "response", ";", "}", "// [END pubsub_list_topic_subscriptions]", "}" ]
Example of listing subscriptions for a topic.
[ "Example", "of", "listing", "subscriptions", "for", "a", "topic", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java#L79-L95
12,520
googleapis/google-cloud-java
google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java
TopicAdminClientSnippets.deleteTopic
public ProjectTopicName deleteTopic(String topicId) throws Exception { // [START pubsub_delete_topic] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); topicAdminClient.deleteTopic(topicName); return topicName; } // [END pubsub_delete_topic] }
java
public ProjectTopicName deleteTopic(String topicId) throws Exception { // [START pubsub_delete_topic] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); topicAdminClient.deleteTopic(topicName); return topicName; } // [END pubsub_delete_topic] }
[ "public", "ProjectTopicName", "deleteTopic", "(", "String", "topicId", ")", "throws", "Exception", "{", "// [START pubsub_delete_topic]", "try", "(", "TopicAdminClient", "topicAdminClient", "=", "TopicAdminClient", ".", "create", "(", ")", ")", "{", "ProjectTopicName", "topicName", "=", "ProjectTopicName", ".", "of", "(", "projectId", ",", "topicId", ")", ";", "topicAdminClient", ".", "deleteTopic", "(", "topicName", ")", ";", "return", "topicName", ";", "}", "// [END pubsub_delete_topic]", "}" ]
Example of deleting a topic.
[ "Example", "of", "deleting", "a", "topic", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java#L98-L106
12,521
googleapis/google-cloud-java
google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java
TopicAdminClientSnippets.getTopicPolicy
public Policy getTopicPolicy(String topicId) throws Exception { // [START pubsub_get_topic_policy] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); Policy policy = topicAdminClient.getIamPolicy(topicName.toString()); if (policy == null) { // topic iam policy was not found } return policy; } // [END pubsub_get_topic_policy] }
java
public Policy getTopicPolicy(String topicId) throws Exception { // [START pubsub_get_topic_policy] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); Policy policy = topicAdminClient.getIamPolicy(topicName.toString()); if (policy == null) { // topic iam policy was not found } return policy; } // [END pubsub_get_topic_policy] }
[ "public", "Policy", "getTopicPolicy", "(", "String", "topicId", ")", "throws", "Exception", "{", "// [START pubsub_get_topic_policy]", "try", "(", "TopicAdminClient", "topicAdminClient", "=", "TopicAdminClient", ".", "create", "(", ")", ")", "{", "ProjectTopicName", "topicName", "=", "ProjectTopicName", ".", "of", "(", "projectId", ",", "topicId", ")", ";", "Policy", "policy", "=", "topicAdminClient", ".", "getIamPolicy", "(", "topicName", ".", "toString", "(", ")", ")", ";", "if", "(", "policy", "==", "null", ")", "{", "// topic iam policy was not found", "}", "return", "policy", ";", "}", "// [END pubsub_get_topic_policy]", "}" ]
Example of getting a topic policy.
[ "Example", "of", "getting", "a", "topic", "policy", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java#L109-L120
12,522
googleapis/google-cloud-java
google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java
TopicAdminClientSnippets.replaceTopicPolicy
public Policy replaceTopicPolicy(String topicId) throws Exception { // [START pubsub_set_topic_policy] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { String topicName = ProjectTopicName.format(projectId, topicId); Policy policy = topicAdminClient.getIamPolicy(topicName); // add role -> members binding Binding binding = Binding.newBuilder() .setRole(Role.viewer().toString()) .addMembers(Identity.allAuthenticatedUsers().toString()) .build(); // create updated policy Policy updatedPolicy = Policy.newBuilder(policy).addBindings(binding).build(); updatedPolicy = topicAdminClient.setIamPolicy(topicName, updatedPolicy); return updatedPolicy; } // [END pubsub_set_topic_policy] }
java
public Policy replaceTopicPolicy(String topicId) throws Exception { // [START pubsub_set_topic_policy] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { String topicName = ProjectTopicName.format(projectId, topicId); Policy policy = topicAdminClient.getIamPolicy(topicName); // add role -> members binding Binding binding = Binding.newBuilder() .setRole(Role.viewer().toString()) .addMembers(Identity.allAuthenticatedUsers().toString()) .build(); // create updated policy Policy updatedPolicy = Policy.newBuilder(policy).addBindings(binding).build(); updatedPolicy = topicAdminClient.setIamPolicy(topicName, updatedPolicy); return updatedPolicy; } // [END pubsub_set_topic_policy] }
[ "public", "Policy", "replaceTopicPolicy", "(", "String", "topicId", ")", "throws", "Exception", "{", "// [START pubsub_set_topic_policy]", "try", "(", "TopicAdminClient", "topicAdminClient", "=", "TopicAdminClient", ".", "create", "(", ")", ")", "{", "String", "topicName", "=", "ProjectTopicName", ".", "format", "(", "projectId", ",", "topicId", ")", ";", "Policy", "policy", "=", "topicAdminClient", ".", "getIamPolicy", "(", "topicName", ")", ";", "// add role -> members binding", "Binding", "binding", "=", "Binding", ".", "newBuilder", "(", ")", ".", "setRole", "(", "Role", ".", "viewer", "(", ")", ".", "toString", "(", ")", ")", ".", "addMembers", "(", "Identity", ".", "allAuthenticatedUsers", "(", ")", ".", "toString", "(", ")", ")", ".", "build", "(", ")", ";", "// create updated policy", "Policy", "updatedPolicy", "=", "Policy", ".", "newBuilder", "(", "policy", ")", ".", "addBindings", "(", "binding", ")", ".", "build", "(", ")", ";", "updatedPolicy", "=", "topicAdminClient", ".", "setIamPolicy", "(", "topicName", ",", "updatedPolicy", ")", ";", "return", "updatedPolicy", ";", "}", "// [END pubsub_set_topic_policy]", "}" ]
Example of replacing a topic policy.
[ "Example", "of", "replacing", "a", "topic", "policy", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java#L123-L140
12,523
googleapis/google-cloud-java
google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java
TopicAdminClientSnippets.getTopic
public Topic getTopic(String topicId) throws Exception { // [START pubsub_get_topic] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); Topic topic = topicAdminClient.getTopic(topicName); return topic; } // [END pubsub_get_topic] }
java
public Topic getTopic(String topicId) throws Exception { // [START pubsub_get_topic] try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); Topic topic = topicAdminClient.getTopic(topicName); return topic; } // [END pubsub_get_topic] }
[ "public", "Topic", "getTopic", "(", "String", "topicId", ")", "throws", "Exception", "{", "// [START pubsub_get_topic]", "try", "(", "TopicAdminClient", "topicAdminClient", "=", "TopicAdminClient", ".", "create", "(", ")", ")", "{", "ProjectTopicName", "topicName", "=", "ProjectTopicName", ".", "of", "(", "projectId", ",", "topicId", ")", ";", "Topic", "topic", "=", "topicAdminClient", ".", "getTopic", "(", "topicName", ")", ";", "return", "topic", ";", "}", "// [END pubsub_get_topic]", "}" ]
Example of getting a topic.
[ "Example", "of", "getting", "a", "topic", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java#L160-L168
12,524
googleapis/google-cloud-java
google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/HttpsHealthCheckClient.java
HttpsHealthCheckClient.updateHttpsHealthCheck
@BetaApi public final Operation updateHttpsHealthCheck( ProjectGlobalHttpsHealthCheckName httpsHealthCheck, HttpsHealthCheck2 httpsHealthCheckResource, List<String> fieldMask) { UpdateHttpsHealthCheckHttpRequest request = UpdateHttpsHealthCheckHttpRequest.newBuilder() .setHttpsHealthCheck(httpsHealthCheck == null ? null : httpsHealthCheck.toString()) .setHttpsHealthCheckResource(httpsHealthCheckResource) .addAllFieldMask(fieldMask) .build(); return updateHttpsHealthCheck(request); }
java
@BetaApi public final Operation updateHttpsHealthCheck( ProjectGlobalHttpsHealthCheckName httpsHealthCheck, HttpsHealthCheck2 httpsHealthCheckResource, List<String> fieldMask) { UpdateHttpsHealthCheckHttpRequest request = UpdateHttpsHealthCheckHttpRequest.newBuilder() .setHttpsHealthCheck(httpsHealthCheck == null ? null : httpsHealthCheck.toString()) .setHttpsHealthCheckResource(httpsHealthCheckResource) .addAllFieldMask(fieldMask) .build(); return updateHttpsHealthCheck(request); }
[ "@", "BetaApi", "public", "final", "Operation", "updateHttpsHealthCheck", "(", "ProjectGlobalHttpsHealthCheckName", "httpsHealthCheck", ",", "HttpsHealthCheck2", "httpsHealthCheckResource", ",", "List", "<", "String", ">", "fieldMask", ")", "{", "UpdateHttpsHealthCheckHttpRequest", "request", "=", "UpdateHttpsHealthCheckHttpRequest", ".", "newBuilder", "(", ")", ".", "setHttpsHealthCheck", "(", "httpsHealthCheck", "==", "null", "?", "null", ":", "httpsHealthCheck", ".", "toString", "(", ")", ")", ".", "setHttpsHealthCheckResource", "(", "httpsHealthCheckResource", ")", ".", "addAllFieldMask", "(", "fieldMask", ")", ".", "build", "(", ")", ";", "return", "updateHttpsHealthCheck", "(", "request", ")", ";", "}" ]
Updates a HttpsHealthCheck resource in the specified project using the data included in the request. <p>Sample code: <pre><code> try (HttpsHealthCheckClient httpsHealthCheckClient = HttpsHealthCheckClient.create()) { ProjectGlobalHttpsHealthCheckName httpsHealthCheck = ProjectGlobalHttpsHealthCheckName.of("[PROJECT]", "[HTTPS_HEALTH_CHECK]"); HttpsHealthCheck2 httpsHealthCheckResource = HttpsHealthCheck2.newBuilder().build(); List&lt;String&gt; fieldMask = new ArrayList&lt;&gt;(); Operation response = httpsHealthCheckClient.updateHttpsHealthCheck(httpsHealthCheck, httpsHealthCheckResource, fieldMask); } </code></pre> @param httpsHealthCheck Name of the HttpsHealthCheck resource to update. @param httpsHealthCheckResource An HttpsHealthCheck resource. This resource defines a template for how individual instances should be checked for health, via HTTPS. @param fieldMask The fields that should be serialized (even if they have empty values). If the containing message object has a non-null fieldmask, then all the fields in the field mask (and only those fields in the field mask) will be serialized. If the containing object does not have a fieldmask, then only non-empty fields will be serialized. @throws com.google.api.gax.rpc.ApiException if the remote call fails
[ "Updates", "a", "HttpsHealthCheck", "resource", "in", "the", "specified", "project", "using", "the", "data", "included", "in", "the", "request", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/HttpsHealthCheckClient.java#L782-L795
12,525
googleapis/google-cloud-java
google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java
HttpStorageRpc.startSpan
private Span startSpan(String spanName) { return tracer .spanBuilder(spanName) .setRecordEvents(censusHttpModule.isRecordEvents()) .startSpan(); }
java
private Span startSpan(String spanName) { return tracer .spanBuilder(spanName) .setRecordEvents(censusHttpModule.isRecordEvents()) .startSpan(); }
[ "private", "Span", "startSpan", "(", "String", "spanName", ")", "{", "return", "tracer", ".", "spanBuilder", "(", "spanName", ")", ".", "setRecordEvents", "(", "censusHttpModule", ".", "isRecordEvents", "(", ")", ")", ".", "startSpan", "(", ")", ";", "}" ]
Helper method to start a span.
[ "Helper", "method", "to", "start", "a", "span", "." ]
d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java#L249-L254
12,526
apache/groovy
subprojects/groovy-servlet/src/main/java/groovy/servlet/TemplateServlet.java
TemplateServlet.createAndStoreTemplate
private Template createAndStoreTemplate(String key, InputStream inputStream, File file) throws Exception { if (verbose) { log("Creating new template from " + key + "..."); } Reader reader = null; try { String fileEncoding = (fileEncodingParamVal != null) ? fileEncodingParamVal : System.getProperty(GROOVY_SOURCE_ENCODING); reader = fileEncoding == null ? new InputStreamReader(inputStream) : new InputStreamReader(inputStream, fileEncoding); Template template = engine.createTemplate(reader); cache.put(key, new TemplateCacheEntry(file, template, verbose)); if (verbose) { log("Created and added template to cache. [key=" + key + "] " + cache.get(key)); } // // Last sanity check. // if (template == null) { throw new ServletException("Template is null? Should not happen here!"); } return template; } finally { if (reader != null) { reader.close(); } else if (inputStream != null) { inputStream.close(); } } }
java
private Template createAndStoreTemplate(String key, InputStream inputStream, File file) throws Exception { if (verbose) { log("Creating new template from " + key + "..."); } Reader reader = null; try { String fileEncoding = (fileEncodingParamVal != null) ? fileEncodingParamVal : System.getProperty(GROOVY_SOURCE_ENCODING); reader = fileEncoding == null ? new InputStreamReader(inputStream) : new InputStreamReader(inputStream, fileEncoding); Template template = engine.createTemplate(reader); cache.put(key, new TemplateCacheEntry(file, template, verbose)); if (verbose) { log("Created and added template to cache. [key=" + key + "] " + cache.get(key)); } // // Last sanity check. // if (template == null) { throw new ServletException("Template is null? Should not happen here!"); } return template; } finally { if (reader != null) { reader.close(); } else if (inputStream != null) { inputStream.close(); } } }
[ "private", "Template", "createAndStoreTemplate", "(", "String", "key", ",", "InputStream", "inputStream", ",", "File", "file", ")", "throws", "Exception", "{", "if", "(", "verbose", ")", "{", "log", "(", "\"Creating new template from \"", "+", "key", "+", "\"...\"", ")", ";", "}", "Reader", "reader", "=", "null", ";", "try", "{", "String", "fileEncoding", "=", "(", "fileEncodingParamVal", "!=", "null", ")", "?", "fileEncodingParamVal", ":", "System", ".", "getProperty", "(", "GROOVY_SOURCE_ENCODING", ")", ";", "reader", "=", "fileEncoding", "==", "null", "?", "new", "InputStreamReader", "(", "inputStream", ")", ":", "new", "InputStreamReader", "(", "inputStream", ",", "fileEncoding", ")", ";", "Template", "template", "=", "engine", ".", "createTemplate", "(", "reader", ")", ";", "cache", ".", "put", "(", "key", ",", "new", "TemplateCacheEntry", "(", "file", ",", "template", ",", "verbose", ")", ")", ";", "if", "(", "verbose", ")", "{", "log", "(", "\"Created and added template to cache. [key=\"", "+", "key", "+", "\"] \"", "+", "cache", ".", "get", "(", "key", ")", ")", ";", "}", "//", "// Last sanity check.", "//", "if", "(", "template", "==", "null", ")", "{", "throw", "new", "ServletException", "(", "\"Template is null? Should not happen here!\"", ")", ";", "}", "return", "template", ";", "}", "finally", "{", "if", "(", "reader", "!=", "null", ")", "{", "reader", ".", "close", "(", ")", ";", "}", "else", "if", "(", "inputStream", "!=", "null", ")", "{", "inputStream", ".", "close", "(", ")", ";", "}", "}", "}" ]
Compile the template and store it in the cache. @param key a unique key for the template, such as a file's absolutePath or a URL. @param inputStream an InputStream for the template's source. @param file a file to be used to determine if the cached template is stale. May be null. @return the created template. @throws Exception Any exception when creating the template.
[ "Compile", "the", "template", "and", "store", "it", "in", "the", "cache", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-servlet/src/main/java/groovy/servlet/TemplateServlet.java#L241-L276
12,527
apache/groovy
src/main/java/org/codehaus/groovy/ast/tools/ParameterUtils.java
ParameterUtils.parametersCompatible
public static boolean parametersCompatible(Parameter[] source, Parameter[] target) { return parametersMatch(source, target, t -> ClassHelper.getWrapper(t.getV2()).getTypeClass() .isAssignableFrom(ClassHelper.getWrapper(t.getV1()).getTypeClass()) ); }
java
public static boolean parametersCompatible(Parameter[] source, Parameter[] target) { return parametersMatch(source, target, t -> ClassHelper.getWrapper(t.getV2()).getTypeClass() .isAssignableFrom(ClassHelper.getWrapper(t.getV1()).getTypeClass()) ); }
[ "public", "static", "boolean", "parametersCompatible", "(", "Parameter", "[", "]", "source", ",", "Parameter", "[", "]", "target", ")", "{", "return", "parametersMatch", "(", "source", ",", "target", ",", "t", "->", "ClassHelper", ".", "getWrapper", "(", "t", ".", "getV2", "(", ")", ")", ".", "getTypeClass", "(", ")", ".", "isAssignableFrom", "(", "ClassHelper", ".", "getWrapper", "(", "t", ".", "getV1", "(", ")", ")", ".", "getTypeClass", "(", ")", ")", ")", ";", "}" ]
check whether parameters type are compatible each parameter should match the following condition: {@code targetParameter.getType().getTypeClass().isAssignableFrom(sourceParameter.getType().getTypeClass())} @param source source parameters @param target target parameters @return the check result @since 3.0.0
[ "check", "whether", "parameters", "type", "are", "compatible" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/ast/tools/ParameterUtils.java#L51-L56
12,528
apache/groovy
src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java
StaticImportVisitor.setSourcePosition
private static void setSourcePosition(Expression toSet, Expression origNode) { toSet.setSourcePosition(origNode); if (toSet instanceof PropertyExpression) { ((PropertyExpression) toSet).getProperty().setSourcePosition(origNode); } }
java
private static void setSourcePosition(Expression toSet, Expression origNode) { toSet.setSourcePosition(origNode); if (toSet instanceof PropertyExpression) { ((PropertyExpression) toSet).getProperty().setSourcePosition(origNode); } }
[ "private", "static", "void", "setSourcePosition", "(", "Expression", "toSet", ",", "Expression", "origNode", ")", "{", "toSet", ".", "setSourcePosition", "(", "origNode", ")", ";", "if", "(", "toSet", "instanceof", "PropertyExpression", ")", "{", "(", "(", "PropertyExpression", ")", "toSet", ")", ".", "getProperty", "(", ")", ".", "setSourcePosition", "(", "origNode", ")", ";", "}", "}" ]
Set the source position of toSet including its property expression if it has one. @param toSet resulting node @param origNode original node
[ "Set", "the", "source", "position", "of", "toSet", "including", "its", "property", "expression", "if", "it", "has", "one", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/StaticImportVisitor.java#L232-L237
12,529
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java
XmlSlurper.parse
public GPathResult parse(final InputSource input) throws IOException, SAXException { reader.setContentHandler(this); reader.parse(input); return getDocument(); }
java
public GPathResult parse(final InputSource input) throws IOException, SAXException { reader.setContentHandler(this); reader.parse(input); return getDocument(); }
[ "public", "GPathResult", "parse", "(", "final", "InputSource", "input", ")", "throws", "IOException", ",", "SAXException", "{", "reader", ".", "setContentHandler", "(", "this", ")", ";", "reader", ".", "parse", "(", "input", ")", ";", "return", "getDocument", "(", ")", ";", "}" ]
Parse the content of the specified input source into a GPathResult object @param input the InputSource to parse @return An object which supports GPath expressions @throws SAXException Any SAX exception, possibly wrapping another exception. @throws IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
[ "Parse", "the", "content", "of", "the", "specified", "input", "source", "into", "a", "GPathResult", "object" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java#L199-L203
12,530
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java
XmlSlurper.parse
public GPathResult parse(final File file) throws IOException, SAXException { final FileInputStream fis = new FileInputStream(file); final InputSource input = new InputSource(fis); input.setSystemId("file://" + file.getAbsolutePath()); try { return parse(input); } finally { fis.close(); } }
java
public GPathResult parse(final File file) throws IOException, SAXException { final FileInputStream fis = new FileInputStream(file); final InputSource input = new InputSource(fis); input.setSystemId("file://" + file.getAbsolutePath()); try { return parse(input); } finally { fis.close(); } }
[ "public", "GPathResult", "parse", "(", "final", "File", "file", ")", "throws", "IOException", ",", "SAXException", "{", "final", "FileInputStream", "fis", "=", "new", "FileInputStream", "(", "file", ")", ";", "final", "InputSource", "input", "=", "new", "InputSource", "(", "fis", ")", ";", "input", ".", "setSystemId", "(", "\"file://\"", "+", "file", ".", "getAbsolutePath", "(", ")", ")", ";", "try", "{", "return", "parse", "(", "input", ")", ";", "}", "finally", "{", "fis", ".", "close", "(", ")", ";", "}", "}" ]
Parses the content of the given file as XML turning it into a GPathResult object @param file the File to parse @return An object which supports GPath expressions @throws SAXException Any SAX exception, possibly wrapping another exception. @throws IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
[ "Parses", "the", "content", "of", "the", "given", "file", "as", "XML", "turning", "it", "into", "a", "GPathResult", "object" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java#L214-L223
12,531
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java
XmlSlurper.setEntityBaseUrl
public void setEntityBaseUrl(final URL base) { reader.setEntityResolver(new EntityResolver() { public InputSource resolveEntity(final String publicId, final String systemId) throws IOException { return new InputSource(new URL(base, systemId).openStream()); } }); }
java
public void setEntityBaseUrl(final URL base) { reader.setEntityResolver(new EntityResolver() { public InputSource resolveEntity(final String publicId, final String systemId) throws IOException { return new InputSource(new URL(base, systemId).openStream()); } }); }
[ "public", "void", "setEntityBaseUrl", "(", "final", "URL", "base", ")", "{", "reader", ".", "setEntityResolver", "(", "new", "EntityResolver", "(", ")", "{", "public", "InputSource", "resolveEntity", "(", "final", "String", "publicId", ",", "final", "String", "systemId", ")", "throws", "IOException", "{", "return", "new", "InputSource", "(", "new", "URL", "(", "base", ",", "systemId", ")", ".", "openStream", "(", ")", ")", ";", "}", "}", ")", ";", "}" ]
Resolves entities against using the supplied URL as the base for relative URLs @param base The URL used to resolve relative URLs
[ "Resolves", "entities", "against", "using", "the", "supplied", "URL", "as", "the", "base", "for", "relative", "URLs" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java#L340-L346
12,532
apache/groovy
src/main/java/org/codehaus/groovy/transform/AbstractInterruptibleASTTransformation.java
AbstractInterruptibleASTTransformation.wrapBlock
protected final Statement wrapBlock(Statement statement) { BlockStatement stmt = new BlockStatement(); stmt.addStatement(createInterruptStatement()); stmt.addStatement(statement); return stmt; }
java
protected final Statement wrapBlock(Statement statement) { BlockStatement stmt = new BlockStatement(); stmt.addStatement(createInterruptStatement()); stmt.addStatement(statement); return stmt; }
[ "protected", "final", "Statement", "wrapBlock", "(", "Statement", "statement", ")", "{", "BlockStatement", "stmt", "=", "new", "BlockStatement", "(", ")", ";", "stmt", ".", "addStatement", "(", "createInterruptStatement", "(", ")", ")", ";", "stmt", ".", "addStatement", "(", "statement", ")", ";", "return", "stmt", ";", "}" ]
Takes a statement and wraps it into a block statement which first element is the interruption check statement. @param statement the statement to be wrapped @return a {@link BlockStatement block statement} which first element is for checking interruption, and the second one the statement to be wrapped.
[ "Takes", "a", "statement", "and", "wraps", "it", "into", "a", "block", "statement", "which", "first", "element", "is", "the", "interruption", "check", "statement", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/AbstractInterruptibleASTTransformation.java#L199-L204
12,533
apache/groovy
src/main/java/org/codehaus/groovy/transform/AbstractInterruptibleASTTransformation.java
AbstractInterruptibleASTTransformation.visitLoop
private void visitLoop(LoopingStatement loopStatement) { Statement statement = loopStatement.getLoopBlock(); loopStatement.setLoopBlock(wrapBlock(statement)); }
java
private void visitLoop(LoopingStatement loopStatement) { Statement statement = loopStatement.getLoopBlock(); loopStatement.setLoopBlock(wrapBlock(statement)); }
[ "private", "void", "visitLoop", "(", "LoopingStatement", "loopStatement", ")", "{", "Statement", "statement", "=", "loopStatement", ".", "getLoopBlock", "(", ")", ";", "loopStatement", ".", "setLoopBlock", "(", "wrapBlock", "(", "statement", ")", ")", ";", "}" ]
Shortcut method which avoids duplicating code for every type of loop. Actually wraps the loopBlock of different types of loop statements.
[ "Shortcut", "method", "which", "avoids", "duplicating", "code", "for", "every", "type", "of", "loop", ".", "Actually", "wraps", "the", "loopBlock", "of", "different", "types", "of", "loop", "statements", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/AbstractInterruptibleASTTransformation.java#L216-L219
12,534
apache/groovy
src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
MetaClassRegistryImpl.installMetaClassCreationHandle
private void installMetaClassCreationHandle() { try { final Class customMetaClassHandle = Class.forName("groovy.runtime.metaclass.CustomMetaClassCreationHandle"); final Constructor customMetaClassHandleConstructor = customMetaClassHandle.getConstructor(); this.metaClassCreationHandle = (MetaClassCreationHandle)customMetaClassHandleConstructor.newInstance(); } catch (final ClassNotFoundException e) { this.metaClassCreationHandle = new MetaClassCreationHandle(); } catch (final Exception e) { throw new GroovyRuntimeException("Could not instantiate custom Metaclass creation handle: "+ e, e); } }
java
private void installMetaClassCreationHandle() { try { final Class customMetaClassHandle = Class.forName("groovy.runtime.metaclass.CustomMetaClassCreationHandle"); final Constructor customMetaClassHandleConstructor = customMetaClassHandle.getConstructor(); this.metaClassCreationHandle = (MetaClassCreationHandle)customMetaClassHandleConstructor.newInstance(); } catch (final ClassNotFoundException e) { this.metaClassCreationHandle = new MetaClassCreationHandle(); } catch (final Exception e) { throw new GroovyRuntimeException("Could not instantiate custom Metaclass creation handle: "+ e, e); } }
[ "private", "void", "installMetaClassCreationHandle", "(", ")", "{", "try", "{", "final", "Class", "customMetaClassHandle", "=", "Class", ".", "forName", "(", "\"groovy.runtime.metaclass.CustomMetaClassCreationHandle\"", ")", ";", "final", "Constructor", "customMetaClassHandleConstructor", "=", "customMetaClassHandle", ".", "getConstructor", "(", ")", ";", "this", ".", "metaClassCreationHandle", "=", "(", "MetaClassCreationHandle", ")", "customMetaClassHandleConstructor", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "final", "ClassNotFoundException", "e", ")", "{", "this", ".", "metaClassCreationHandle", "=", "new", "MetaClassCreationHandle", "(", ")", ";", "}", "catch", "(", "final", "Exception", "e", ")", "{", "throw", "new", "GroovyRuntimeException", "(", "\"Could not instantiate custom Metaclass creation handle: \"", "+", "e", ",", "e", ")", ";", "}", "}" ]
Looks for a class called 'groovy.runtime.metaclass.CustomMetaClassCreationHandle' and if it exists uses it as the MetaClassCreationHandle otherwise uses the default @see groovy.lang.MetaClassRegistry.MetaClassCreationHandle
[ "Looks", "for", "a", "class", "called", "groovy", ".", "runtime", ".", "metaclass", ".", "CustomMetaClassCreationHandle", "and", "if", "it", "exists", "uses", "it", "as", "the", "MetaClassCreationHandle", "otherwise", "uses", "the", "default" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java#L182-L192
12,535
apache/groovy
src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
MetaClassRegistryImpl.setMetaClass
private void setMetaClass(Class theClass, MetaClass oldMc, MetaClass newMc) { final ClassInfo info = ClassInfo.getClassInfo(theClass); MetaClass mc = null; info.lock(); try { mc = info.getStrongMetaClass(); info.setStrongMetaClass(newMc); } finally { info.unlock(); } if ((oldMc == null && mc != newMc) || (oldMc != null && mc != newMc && mc != oldMc)) { fireConstantMetaClassUpdate(null, theClass, mc, newMc); } }
java
private void setMetaClass(Class theClass, MetaClass oldMc, MetaClass newMc) { final ClassInfo info = ClassInfo.getClassInfo(theClass); MetaClass mc = null; info.lock(); try { mc = info.getStrongMetaClass(); info.setStrongMetaClass(newMc); } finally { info.unlock(); } if ((oldMc == null && mc != newMc) || (oldMc != null && mc != newMc && mc != oldMc)) { fireConstantMetaClassUpdate(null, theClass, mc, newMc); } }
[ "private", "void", "setMetaClass", "(", "Class", "theClass", ",", "MetaClass", "oldMc", ",", "MetaClass", "newMc", ")", "{", "final", "ClassInfo", "info", "=", "ClassInfo", ".", "getClassInfo", "(", "theClass", ")", ";", "MetaClass", "mc", "=", "null", ";", "info", ".", "lock", "(", ")", ";", "try", "{", "mc", "=", "info", ".", "getStrongMetaClass", "(", ")", ";", "info", ".", "setStrongMetaClass", "(", "newMc", ")", ";", "}", "finally", "{", "info", ".", "unlock", "(", ")", ";", "}", "if", "(", "(", "oldMc", "==", "null", "&&", "mc", "!=", "newMc", ")", "||", "(", "oldMc", "!=", "null", "&&", "mc", "!=", "newMc", "&&", "mc", "!=", "oldMc", ")", ")", "{", "fireConstantMetaClassUpdate", "(", "null", ",", "theClass", ",", "mc", ",", "newMc", ")", ";", "}", "}" ]
if oldMc is null, newMc will replace whatever meta class was used before. if oldMc is not null, then newMc will be used only if he stored mc is the same as oldMc
[ "if", "oldMc", "is", "null", "newMc", "will", "replace", "whatever", "meta", "class", "was", "used", "before", ".", "if", "oldMc", "is", "not", "null", "then", "newMc", "will", "be", "used", "only", "if", "he", "stored", "mc", "is", "the", "same", "as", "oldMc" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java#L283-L297
12,536
apache/groovy
src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
MetaClassRegistryImpl.fireConstantMetaClassUpdate
protected void fireConstantMetaClassUpdate(Object obj, Class c, final MetaClass oldMC, MetaClass newMc) { MetaClassRegistryChangeEventListener[] listener = getMetaClassRegistryChangeEventListeners(); MetaClassRegistryChangeEvent cmcu = new MetaClassRegistryChangeEvent(this, obj, c, oldMC, newMc); for (int i = 0; i<listener.length; i++) { listener[i].updateConstantMetaClass(cmcu); } }
java
protected void fireConstantMetaClassUpdate(Object obj, Class c, final MetaClass oldMC, MetaClass newMc) { MetaClassRegistryChangeEventListener[] listener = getMetaClassRegistryChangeEventListeners(); MetaClassRegistryChangeEvent cmcu = new MetaClassRegistryChangeEvent(this, obj, c, oldMC, newMc); for (int i = 0; i<listener.length; i++) { listener[i].updateConstantMetaClass(cmcu); } }
[ "protected", "void", "fireConstantMetaClassUpdate", "(", "Object", "obj", ",", "Class", "c", ",", "final", "MetaClass", "oldMC", ",", "MetaClass", "newMc", ")", "{", "MetaClassRegistryChangeEventListener", "[", "]", "listener", "=", "getMetaClassRegistryChangeEventListeners", "(", ")", ";", "MetaClassRegistryChangeEvent", "cmcu", "=", "new", "MetaClassRegistryChangeEvent", "(", "this", ",", "obj", ",", "c", ",", "oldMC", ",", "newMc", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listener", ".", "length", ";", "i", "++", ")", "{", "listener", "[", "i", "]", ".", "updateConstantMetaClass", "(", "cmcu", ")", ";", "}", "}" ]
Causes the execution of all registered listeners. This method is used mostly internal to kick of the listener notification. It can also be used by subclasses to achieve the same. @param obj object instance if the MetaClass change is on a per-instance metaclass (or null if global) @param c the class @param oldMC the old MetaClass @param newMc the new MetaClass
[ "Causes", "the", "execution", "of", "all", "registered", "listeners", ".", "This", "method", "is", "used", "mostly", "internal", "to", "kick", "of", "the", "listener", "notification", ".", "It", "can", "also", "be", "used", "by", "subclasses", "to", "achieve", "the", "same", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java#L402-L408
12,537
apache/groovy
src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
MetaClassRegistryImpl.iterator
public Iterator iterator() { final MetaClass[] refs = metaClassInfo.toArray(EMPTY_METACLASS_ARRAY); return new Iterator() { // index in the ref array private int index = 0; // the current meta class private MetaClass currentMeta; // used to ensure that hasNext has been called private boolean hasNextCalled = false; // the cached hasNext call value private boolean hasNext = false; public boolean hasNext() { if (hasNextCalled) return hasNext; hasNextCalled = true; if(index < refs.length) { hasNext = true; currentMeta = refs[index]; index++; } else { hasNext = false; } return hasNext; } private void ensureNext() { // we ensure that hasNext has been called before // next is called hasNext(); hasNextCalled = false; } public Object next() { ensureNext(); return currentMeta; } public void remove() { ensureNext(); setMetaClass(currentMeta.getTheClass(), currentMeta, null); currentMeta = null; } }; }
java
public Iterator iterator() { final MetaClass[] refs = metaClassInfo.toArray(EMPTY_METACLASS_ARRAY); return new Iterator() { // index in the ref array private int index = 0; // the current meta class private MetaClass currentMeta; // used to ensure that hasNext has been called private boolean hasNextCalled = false; // the cached hasNext call value private boolean hasNext = false; public boolean hasNext() { if (hasNextCalled) return hasNext; hasNextCalled = true; if(index < refs.length) { hasNext = true; currentMeta = refs[index]; index++; } else { hasNext = false; } return hasNext; } private void ensureNext() { // we ensure that hasNext has been called before // next is called hasNext(); hasNextCalled = false; } public Object next() { ensureNext(); return currentMeta; } public void remove() { ensureNext(); setMetaClass(currentMeta.getTheClass(), currentMeta, null); currentMeta = null; } }; }
[ "public", "Iterator", "iterator", "(", ")", "{", "final", "MetaClass", "[", "]", "refs", "=", "metaClassInfo", ".", "toArray", "(", "EMPTY_METACLASS_ARRAY", ")", ";", "return", "new", "Iterator", "(", ")", "{", "// index in the ref array", "private", "int", "index", "=", "0", ";", "// the current meta class", "private", "MetaClass", "currentMeta", ";", "// used to ensure that hasNext has been called", "private", "boolean", "hasNextCalled", "=", "false", ";", "// the cached hasNext call value", "private", "boolean", "hasNext", "=", "false", ";", "public", "boolean", "hasNext", "(", ")", "{", "if", "(", "hasNextCalled", ")", "return", "hasNext", ";", "hasNextCalled", "=", "true", ";", "if", "(", "index", "<", "refs", ".", "length", ")", "{", "hasNext", "=", "true", ";", "currentMeta", "=", "refs", "[", "index", "]", ";", "index", "++", ";", "}", "else", "{", "hasNext", "=", "false", ";", "}", "return", "hasNext", ";", "}", "private", "void", "ensureNext", "(", ")", "{", "// we ensure that hasNext has been called before ", "// next is called", "hasNext", "(", ")", ";", "hasNextCalled", "=", "false", ";", "}", "public", "Object", "next", "(", ")", "{", "ensureNext", "(", ")", ";", "return", "currentMeta", ";", "}", "public", "void", "remove", "(", ")", "{", "ensureNext", "(", ")", ";", "setMetaClass", "(", "currentMeta", ".", "getTheClass", "(", ")", ",", "currentMeta", ",", "null", ")", ";", "currentMeta", "=", "null", ";", "}", "}", ";", "}" ]
Returns an iterator to iterate over all constant meta classes. This iterator can be seen as making a snapshot of the current state of the registry. The snapshot will include all meta classes that has been used unless they are already collected. Collected meta classes will be skipped automatically, so you can expect that each element of the iteration is not null. Calling this method is thread safe, the usage of the iterator is not. @return the iterator.
[ "Returns", "an", "iterator", "to", "iterate", "over", "all", "constant", "meta", "classes", ".", "This", "iterator", "can", "be", "seen", "as", "making", "a", "snapshot", "of", "the", "current", "state", "of", "the", "registry", ".", "The", "snapshot", "will", "include", "all", "meta", "classes", "that", "has", "been", "used", "unless", "they", "are", "already", "collected", ".", "Collected", "meta", "classes", "will", "be", "skipped", "automatically", "so", "you", "can", "expect", "that", "each", "element", "of", "the", "iteration", "is", "not", "null", ".", "Calling", "this", "method", "is", "thread", "safe", "the", "usage", "of", "the", "iterator", "is", "not", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java#L462-L506
12,538
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.checkValueIsType
public static boolean checkValueIsType(Object value, Object name, Class type) { if (value != null) { if (type.isAssignableFrom(value.getClass())) { return true; } else { throw new RuntimeException("The value argument of '" + name + "' must be of type " + type.getName() + ". Found: " + value.getClass()); } } else { return false; } }
java
public static boolean checkValueIsType(Object value, Object name, Class type) { if (value != null) { if (type.isAssignableFrom(value.getClass())) { return true; } else { throw new RuntimeException("The value argument of '" + name + "' must be of type " + type.getName() + ". Found: " + value.getClass()); } } else { return false; } }
[ "public", "static", "boolean", "checkValueIsType", "(", "Object", "value", ",", "Object", "name", ",", "Class", "type", ")", "{", "if", "(", "value", "!=", "null", ")", "{", "if", "(", "type", ".", "isAssignableFrom", "(", "value", ".", "getClass", "(", ")", ")", ")", "{", "return", "true", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"The value argument of '\"", "+", "name", "+", "\"' must be of type \"", "+", "type", ".", "getName", "(", ")", "+", "\". Found: \"", "+", "value", ".", "getClass", "(", ")", ")", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Checks type of value against builder type @param value the node's value @param name the node's name @param type a Class that may be assignable to the value's class @return true if type is assignable to the value's class, false if value is null.
[ "Checks", "type", "of", "value", "against", "builder", "type" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L104-L115
12,539
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.autoRegisterNodes
public void autoRegisterNodes() { // if java did atomic blocks, this would be one synchronized (this) { if (autoRegistrationRunning || autoRegistrationComplete) { // registration already done or in process, abort return; } } autoRegistrationRunning = true; try { callAutoRegisterMethods(getClass()); } finally { autoRegistrationComplete = true; autoRegistrationRunning = false; } }
java
public void autoRegisterNodes() { // if java did atomic blocks, this would be one synchronized (this) { if (autoRegistrationRunning || autoRegistrationComplete) { // registration already done or in process, abort return; } } autoRegistrationRunning = true; try { callAutoRegisterMethods(getClass()); } finally { autoRegistrationComplete = true; autoRegistrationRunning = false; } }
[ "public", "void", "autoRegisterNodes", "(", ")", "{", "// if java did atomic blocks, this would be one", "synchronized", "(", "this", ")", "{", "if", "(", "autoRegistrationRunning", "||", "autoRegistrationComplete", ")", "{", "// registration already done or in process, abort", "return", ";", "}", "}", "autoRegistrationRunning", "=", "true", ";", "try", "{", "callAutoRegisterMethods", "(", "getClass", "(", ")", ")", ";", "}", "finally", "{", "autoRegistrationComplete", "=", "true", ";", "autoRegistrationRunning", "=", "false", ";", "}", "}" ]
Ask the nodes to be registered
[ "Ask", "the", "nodes", "to", "be", "registered" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L185-L200
12,540
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.registerFactory
public void registerFactory(String name, String groupName, Factory factory) { getProxyBuilder().factories.put(name, factory); getRegistrationGroup(groupName).add(name); factory.onFactoryRegistration(this, name, groupName); }
java
public void registerFactory(String name, String groupName, Factory factory) { getProxyBuilder().factories.put(name, factory); getRegistrationGroup(groupName).add(name); factory.onFactoryRegistration(this, name, groupName); }
[ "public", "void", "registerFactory", "(", "String", "name", ",", "String", "groupName", ",", "Factory", "factory", ")", "{", "getProxyBuilder", "(", ")", ".", "factories", ".", "put", "(", "name", ",", "factory", ")", ";", "getRegistrationGroup", "(", "groupName", ")", ".", "add", "(", "name", ")", ";", "factory", ".", "onFactoryRegistration", "(", "this", ",", "name", ",", "groupName", ")", ";", "}" ]
Registers a factory for a node name. @param name the name of the node @param groupName thr group to register this node in @param factory the factory to return the values
[ "Registers", "a", "factory", "for", "a", "node", "name", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L690-L694
12,541
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.createNode
protected Object createNode(Object name, Map attributes, Object value) { Object node; Factory factory = getProxyBuilder().resolveFactory(name, attributes, value); if (factory == null) { LOG.log(Level.WARNING, "Could not find match for name '" + name + "'"); throw new MissingMethodExceptionNoStack((String) name, Object.class, new Object[]{attributes, value}); //return null; } getProxyBuilder().getContext().put(CURRENT_FACTORY, factory); getProxyBuilder().getContext().put(CURRENT_NAME, String.valueOf(name)); getProxyBuilder().preInstantiate(name, attributes, value); try { node = factory.newInstance(getProxyBuilder().getChildBuilder(), name, value, attributes); if (node == null) { LOG.log(Level.WARNING, "Factory for name '" + name + "' returned null"); return null; } if (LOG.isLoggable(Level.FINE)) { LOG.fine("For name: " + name + " created node: " + node); } } catch (Exception e) { throw new RuntimeException("Failed to create component for '" + name + "' reason: " + e, e); } getProxyBuilder().postInstantiate(name, attributes, node); getProxyBuilder().handleNodeAttributes(node, attributes); return node; }
java
protected Object createNode(Object name, Map attributes, Object value) { Object node; Factory factory = getProxyBuilder().resolveFactory(name, attributes, value); if (factory == null) { LOG.log(Level.WARNING, "Could not find match for name '" + name + "'"); throw new MissingMethodExceptionNoStack((String) name, Object.class, new Object[]{attributes, value}); //return null; } getProxyBuilder().getContext().put(CURRENT_FACTORY, factory); getProxyBuilder().getContext().put(CURRENT_NAME, String.valueOf(name)); getProxyBuilder().preInstantiate(name, attributes, value); try { node = factory.newInstance(getProxyBuilder().getChildBuilder(), name, value, attributes); if (node == null) { LOG.log(Level.WARNING, "Factory for name '" + name + "' returned null"); return null; } if (LOG.isLoggable(Level.FINE)) { LOG.fine("For name: " + name + " created node: " + node); } } catch (Exception e) { throw new RuntimeException("Failed to create component for '" + name + "' reason: " + e, e); } getProxyBuilder().postInstantiate(name, attributes, node); getProxyBuilder().handleNodeAttributes(node, attributes); return node; }
[ "protected", "Object", "createNode", "(", "Object", "name", ",", "Map", "attributes", ",", "Object", "value", ")", "{", "Object", "node", ";", "Factory", "factory", "=", "getProxyBuilder", "(", ")", ".", "resolveFactory", "(", "name", ",", "attributes", ",", "value", ")", ";", "if", "(", "factory", "==", "null", ")", "{", "LOG", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Could not find match for name '\"", "+", "name", "+", "\"'\"", ")", ";", "throw", "new", "MissingMethodExceptionNoStack", "(", "(", "String", ")", "name", ",", "Object", ".", "class", ",", "new", "Object", "[", "]", "{", "attributes", ",", "value", "}", ")", ";", "//return null;", "}", "getProxyBuilder", "(", ")", ".", "getContext", "(", ")", ".", "put", "(", "CURRENT_FACTORY", ",", "factory", ")", ";", "getProxyBuilder", "(", ")", ".", "getContext", "(", ")", ".", "put", "(", "CURRENT_NAME", ",", "String", ".", "valueOf", "(", "name", ")", ")", ";", "getProxyBuilder", "(", ")", ".", "preInstantiate", "(", "name", ",", "attributes", ",", "value", ")", ";", "try", "{", "node", "=", "factory", ".", "newInstance", "(", "getProxyBuilder", "(", ")", ".", "getChildBuilder", "(", ")", ",", "name", ",", "value", ",", "attributes", ")", ";", "if", "(", "node", "==", "null", ")", "{", "LOG", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Factory for name '\"", "+", "name", "+", "\"' returned null\"", ")", ";", "return", "null", ";", "}", "if", "(", "LOG", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "{", "LOG", ".", "fine", "(", "\"For name: \"", "+", "name", "+", "\" created node: \"", "+", "node", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to create component for '\"", "+", "name", "+", "\"' reason: \"", "+", "e", ",", "e", ")", ";", "}", "getProxyBuilder", "(", ")", ".", "postInstantiate", "(", "name", ",", "attributes", ",", "node", ")", ";", "getProxyBuilder", "(", ")", ".", "handleNodeAttributes", "(", "node", ",", "attributes", ")", ";", "return", "node", ";", "}" ]
This method is responsible for instantiating a node and configure its properties. @param name the name of the node @param attributes the attributes for the node @param value the value arguments for the node @return the object return from the factory
[ "This", "method", "is", "responsible", "for", "instantiating", "a", "node", "and", "configure", "its", "properties", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L705-L734
12,542
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.resolveFactory
protected Factory resolveFactory(Object name, Map attributes, Object value) { getProxyBuilder().getContext().put(CHILD_BUILDER, getProxyBuilder()); return getProxyBuilder().getFactories().get(name); }
java
protected Factory resolveFactory(Object name, Map attributes, Object value) { getProxyBuilder().getContext().put(CHILD_BUILDER, getProxyBuilder()); return getProxyBuilder().getFactories().get(name); }
[ "protected", "Factory", "resolveFactory", "(", "Object", "name", ",", "Map", "attributes", ",", "Object", "value", ")", "{", "getProxyBuilder", "(", ")", ".", "getContext", "(", ")", ".", "put", "(", "CHILD_BUILDER", ",", "getProxyBuilder", "(", ")", ")", ";", "return", "getProxyBuilder", "(", ")", ".", "getFactories", "(", ")", ".", "get", "(", "name", ")", ";", "}" ]
This is a hook for subclasses to plugin a custom strategy for mapping names to factories. @param name the name of the factory @param attributes the attributes from the node @param value value arguments from te node @return the Factory associated with name.<br>
[ "This", "is", "a", "hook", "for", "subclasses", "to", "plugin", "a", "custom", "strategy", "for", "mapping", "names", "to", "factories", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L745-L748
12,543
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.resolveExplicitMethod
@SuppressWarnings({"UnusedDeclaration"}) protected Closure resolveExplicitMethod(String methodName, Object args) { return getExplicitMethods().get(methodName); }
java
@SuppressWarnings({"UnusedDeclaration"}) protected Closure resolveExplicitMethod(String methodName, Object args) { return getExplicitMethods().get(methodName); }
[ "@", "SuppressWarnings", "(", "{", "\"UnusedDeclaration\"", "}", ")", "protected", "Closure", "resolveExplicitMethod", "(", "String", "methodName", ",", "Object", "args", ")", "{", "return", "getExplicitMethods", "(", ")", ".", "get", "(", "methodName", ")", ";", "}" ]
This is a hook for subclasses to plugin a custom strategy for mapping names to explicit methods. @param methodName the name of the explicit method @param args the arguments for the method @return the closure for the matched explicit method.<br>
[ "This", "is", "a", "hook", "for", "subclasses", "to", "plugin", "a", "custom", "strategy", "for", "mapping", "names", "to", "explicit", "methods", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L758-L761
12,544
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.doInvokeMethod
private Object doInvokeMethod(String methodName, Object name, Object args) { Reference explicitResult = new Reference(); if (checkExplicitMethod(methodName, args, explicitResult)) { return explicitResult.get(); } else { try { return dispatchNodeCall(name, args); } catch(MissingMethodException mme) { if(mme.getMethod().equals(methodName) && methodMissingDelegate != null) { return methodMissingDelegate.call(methodName, args); } throw mme; } } }
java
private Object doInvokeMethod(String methodName, Object name, Object args) { Reference explicitResult = new Reference(); if (checkExplicitMethod(methodName, args, explicitResult)) { return explicitResult.get(); } else { try { return dispatchNodeCall(name, args); } catch(MissingMethodException mme) { if(mme.getMethod().equals(methodName) && methodMissingDelegate != null) { return methodMissingDelegate.call(methodName, args); } throw mme; } } }
[ "private", "Object", "doInvokeMethod", "(", "String", "methodName", ",", "Object", "name", ",", "Object", "args", ")", "{", "Reference", "explicitResult", "=", "new", "Reference", "(", ")", ";", "if", "(", "checkExplicitMethod", "(", "methodName", ",", "args", ",", "explicitResult", ")", ")", "{", "return", "explicitResult", ".", "get", "(", ")", ";", "}", "else", "{", "try", "{", "return", "dispatchNodeCall", "(", "name", ",", "args", ")", ";", "}", "catch", "(", "MissingMethodException", "mme", ")", "{", "if", "(", "mme", ".", "getMethod", "(", ")", ".", "equals", "(", "methodName", ")", "&&", "methodMissingDelegate", "!=", "null", ")", "{", "return", "methodMissingDelegate", ".", "call", "(", "methodName", ",", "args", ")", ";", "}", "throw", "mme", ";", "}", "}", "}" ]
This method is the workhorse of the builder. @param methodName the name of the method being invoked @param name the name of the node @param args the arguments passed into the node @return the object from the factory
[ "This", "method", "is", "the", "workhorse", "of", "the", "builder", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L782-L796
12,545
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.getName
public Object getName(String methodName) { if (getProxyBuilder().nameMappingClosure != null) { return getProxyBuilder().nameMappingClosure.call(methodName); } return methodName; }
java
public Object getName(String methodName) { if (getProxyBuilder().nameMappingClosure != null) { return getProxyBuilder().nameMappingClosure.call(methodName); } return methodName; }
[ "public", "Object", "getName", "(", "String", "methodName", ")", "{", "if", "(", "getProxyBuilder", "(", ")", ".", "nameMappingClosure", "!=", "null", ")", "{", "return", "getProxyBuilder", "(", ")", ".", "nameMappingClosure", ".", "call", "(", "methodName", ")", ";", "}", "return", "methodName", ";", "}" ]
A hook to allow names to be converted into some other object such as a QName in XML or ObjectName in JMX. @param methodName the name of the desired method @return the object representing the name
[ "A", "hook", "to", "allow", "names", "to", "be", "converted", "into", "some", "other", "object", "such", "as", "a", "QName", "in", "XML", "or", "ObjectName", "in", "JMX", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L921-L926
12,546
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.getProxyBuilder
protected FactoryBuilderSupport getProxyBuilder() { FactoryBuilderSupport proxy = localProxyBuilder.get(); if (proxy == null) { return globalProxyBuilder; } else { return proxy; } }
java
protected FactoryBuilderSupport getProxyBuilder() { FactoryBuilderSupport proxy = localProxyBuilder.get(); if (proxy == null) { return globalProxyBuilder; } else { return proxy; } }
[ "protected", "FactoryBuilderSupport", "getProxyBuilder", "(", ")", "{", "FactoryBuilderSupport", "proxy", "=", "localProxyBuilder", ".", "get", "(", ")", ";", "if", "(", "proxy", "==", "null", ")", "{", "return", "globalProxyBuilder", ";", "}", "else", "{", "return", "proxy", ";", "}", "}" ]
Proxy builders are useful for changing the building context, thus enabling mix &amp; match builders. @return the current builder that serves as a proxy.<br>
[ "Proxy", "builders", "are", "useful", "for", "changing", "the", "building", "context", "thus", "enabling", "mix", "&amp", ";", "match", "builders", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L934-L941
12,547
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.nodeCompleted
protected void nodeCompleted(Object parent, Object node) { getProxyBuilder().getCurrentFactory().onNodeCompleted(getProxyBuilder().getChildBuilder(), parent, node); }
java
protected void nodeCompleted(Object parent, Object node) { getProxyBuilder().getCurrentFactory().onNodeCompleted(getProxyBuilder().getChildBuilder(), parent, node); }
[ "protected", "void", "nodeCompleted", "(", "Object", "parent", ",", "Object", "node", ")", "{", "getProxyBuilder", "(", ")", ".", "getCurrentFactory", "(", ")", ".", "onNodeCompleted", "(", "getProxyBuilder", "(", ")", ".", "getChildBuilder", "(", ")", ",", "parent", ",", "node", ")", ";", "}" ]
A hook to allow nodes to be processed once they have had all of their children applied. @param node the current node being processed @param parent the parent of the node being processed
[ "A", "hook", "to", "allow", "nodes", "to", "be", "processed", "once", "they", "have", "had", "all", "of", "their", "children", "applied", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L1004-L1006
12,548
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.popContext
protected Map<String, Object> popContext() { if (!getProxyBuilder().getContexts().isEmpty()) { return getProxyBuilder().getContexts().removeFirst(); } return null; }
java
protected Map<String, Object> popContext() { if (!getProxyBuilder().getContexts().isEmpty()) { return getProxyBuilder().getContexts().removeFirst(); } return null; }
[ "protected", "Map", "<", "String", ",", "Object", ">", "popContext", "(", ")", "{", "if", "(", "!", "getProxyBuilder", "(", ")", ".", "getContexts", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "getProxyBuilder", "(", ")", ".", "getContexts", "(", ")", ".", "removeFirst", "(", ")", ";", "}", "return", "null", ";", "}" ]
Removes the last context from the stack. @return the content just removed
[ "Removes", "the", "last", "context", "from", "the", "stack", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L1013-L1018
12,549
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.getContinuationData
protected Map<String, Object> getContinuationData() { Map<String, Object> data = new HashMap<String, Object>(); data.put("proxyBuilder", localProxyBuilder.get()); data.put("contexts", contexts.get()); return data; }
java
protected Map<String, Object> getContinuationData() { Map<String, Object> data = new HashMap<String, Object>(); data.put("proxyBuilder", localProxyBuilder.get()); data.put("contexts", contexts.get()); return data; }
[ "protected", "Map", "<", "String", ",", "Object", ">", "getContinuationData", "(", ")", "{", "Map", "<", "String", ",", "Object", ">", "data", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "data", ".", "put", "(", "\"proxyBuilder\"", ",", "localProxyBuilder", ".", "get", "(", ")", ")", ";", "data", ".", "put", "(", "\"contexts\"", ",", "contexts", ".", "get", "(", ")", ")", ";", "return", "data", ";", "}" ]
Stores the thread local states in a Map that can be passed across threads @return the map
[ "Stores", "the", "thread", "local", "states", "in", "a", "Map", "that", "can", "be", "passed", "across", "threads" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L1138-L1143
12,550
apache/groovy
src/main/groovy/groovy/util/FactoryBuilderSupport.java
FactoryBuilderSupport.restoreFromContinuationData
protected void restoreFromContinuationData(Map<String, Object> data) { //noinspection unchecked localProxyBuilder.set((FactoryBuilderSupport) data.get("proxyBuilder")); //noinspection unchecked contexts.set((LinkedList<Map<String, Object>>) data.get("contexts")); }
java
protected void restoreFromContinuationData(Map<String, Object> data) { //noinspection unchecked localProxyBuilder.set((FactoryBuilderSupport) data.get("proxyBuilder")); //noinspection unchecked contexts.set((LinkedList<Map<String, Object>>) data.get("contexts")); }
[ "protected", "void", "restoreFromContinuationData", "(", "Map", "<", "String", ",", "Object", ">", "data", ")", "{", "//noinspection unchecked", "localProxyBuilder", ".", "set", "(", "(", "FactoryBuilderSupport", ")", "data", ".", "get", "(", "\"proxyBuilder\"", ")", ")", ";", "//noinspection unchecked", "contexts", ".", "set", "(", "(", "LinkedList", "<", "Map", "<", "String", ",", "Object", ">", ">", ")", "data", ".", "get", "(", "\"contexts\"", ")", ")", ";", "}" ]
Restores the state of the current builder to the same state as an older build. Caution, this will destroy rather than merge the current build context if there is any, @param data the data retrieved from a compatible getContinuationData call
[ "Restores", "the", "state", "of", "the", "current", "builder", "to", "the", "same", "state", "as", "an", "older", "build", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L1151-L1156
12,551
apache/groovy
src/main/java/org/codehaus/groovy/tools/Utilities.java
Utilities.repeatString
public static String repeatString( String pattern, int repeats ) { StringBuilder buffer = new StringBuilder( pattern.length() * repeats ); for( int i = 0; i < repeats; i++ ) { buffer.append( pattern ); } return new String( buffer ); }
java
public static String repeatString( String pattern, int repeats ) { StringBuilder buffer = new StringBuilder( pattern.length() * repeats ); for( int i = 0; i < repeats; i++ ) { buffer.append( pattern ); } return new String( buffer ); }
[ "public", "static", "String", "repeatString", "(", "String", "pattern", ",", "int", "repeats", ")", "{", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", "pattern", ".", "length", "(", ")", "*", "repeats", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "repeats", ";", "i", "++", ")", "{", "buffer", ".", "append", "(", "pattern", ")", ";", "}", "return", "new", "String", "(", "buffer", ")", ";", "}" ]
Returns a string made up of repetitions of the specified string.
[ "Returns", "a", "string", "made", "up", "of", "repetitions", "of", "the", "specified", "string", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/tools/Utilities.java#L41-L50
12,552
apache/groovy
src/main/java/org/codehaus/groovy/tools/Utilities.java
Utilities.isJavaIdentifier
public static boolean isJavaIdentifier(String name) { if (name.length() == 0 || INVALID_JAVA_IDENTIFIERS.contains(name)) return false; char[] chars = name.toCharArray(); if (!Character.isJavaIdentifierStart(chars[0])) return false; for (int i = 1; i < chars.length; i++ ) { if (!Character.isJavaIdentifierPart(chars[i])) return false; } return true; }
java
public static boolean isJavaIdentifier(String name) { if (name.length() == 0 || INVALID_JAVA_IDENTIFIERS.contains(name)) return false; char[] chars = name.toCharArray(); if (!Character.isJavaIdentifierStart(chars[0])) return false; for (int i = 1; i < chars.length; i++ ) { if (!Character.isJavaIdentifierPart(chars[i])) return false; } return true; }
[ "public", "static", "boolean", "isJavaIdentifier", "(", "String", "name", ")", "{", "if", "(", "name", ".", "length", "(", ")", "==", "0", "||", "INVALID_JAVA_IDENTIFIERS", ".", "contains", "(", "name", ")", ")", "return", "false", ";", "char", "[", "]", "chars", "=", "name", ".", "toCharArray", "(", ")", ";", "if", "(", "!", "Character", ".", "isJavaIdentifierStart", "(", "chars", "[", "0", "]", ")", ")", "return", "false", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "chars", ".", "length", ";", "i", "++", ")", "{", "if", "(", "!", "Character", ".", "isJavaIdentifierPart", "(", "chars", "[", "i", "]", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}" ]
Tells if the given string is a valid Java identifier.
[ "Tells", "if", "the", "given", "string", "is", "a", "valid", "Java", "identifier", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/tools/Utilities.java#L65-L73
12,553
apache/groovy
subprojects/groovy-swing/src/main/java/groovy/inspect/swingui/TableSorter.java
TableSorter.shuttlesort
public void shuttlesort(int from[], int to[], int low, int high) { if (high - low < 2) { return; } int middle = (low + high) / 2; shuttlesort(to, from, low, middle); shuttlesort(to, from, middle, high); int p = low; int q = middle; /* This is an optional short-cut; at each recursive call, check to see if the elements in this subset are already ordered. If so, no further comparisons are needed; the sub-array can just be copied. The array must be copied rather than assigned otherwise sister calls in the recursion might get out of sync. When the number of elements is three they are partitioned so that the first set, [low, mid), has one element and and the second, [mid, high), has two. We skip the optimisation when the number of elements is three or less as the first compare in the normal merge will produce the same sequence of steps. This optimisation seems to be worthwhile for partially ordered lists but some analysis is needed to find out how the performance drops to Nlog(N) as the initial order diminishes - it may drop very quickly. */ if (high - low >= 4 && compare(from[middle - 1], from[middle]) <= 0) { System.arraycopy(from, low, to, low, high - low); return; } // A normal merge. for (int i = low; i < high; i++) { if (q >= high || (p < middle && compare(from[p], from[q]) <= 0)) { to[i] = from[p++]; } else { to[i] = from[q++]; } } }
java
public void shuttlesort(int from[], int to[], int low, int high) { if (high - low < 2) { return; } int middle = (low + high) / 2; shuttlesort(to, from, low, middle); shuttlesort(to, from, middle, high); int p = low; int q = middle; /* This is an optional short-cut; at each recursive call, check to see if the elements in this subset are already ordered. If so, no further comparisons are needed; the sub-array can just be copied. The array must be copied rather than assigned otherwise sister calls in the recursion might get out of sync. When the number of elements is three they are partitioned so that the first set, [low, mid), has one element and and the second, [mid, high), has two. We skip the optimisation when the number of elements is three or less as the first compare in the normal merge will produce the same sequence of steps. This optimisation seems to be worthwhile for partially ordered lists but some analysis is needed to find out how the performance drops to Nlog(N) as the initial order diminishes - it may drop very quickly. */ if (high - low >= 4 && compare(from[middle - 1], from[middle]) <= 0) { System.arraycopy(from, low, to, low, high - low); return; } // A normal merge. for (int i = low; i < high; i++) { if (q >= high || (p < middle && compare(from[p], from[q]) <= 0)) { to[i] = from[p++]; } else { to[i] = from[q++]; } } }
[ "public", "void", "shuttlesort", "(", "int", "from", "[", "]", ",", "int", "to", "[", "]", ",", "int", "low", ",", "int", "high", ")", "{", "if", "(", "high", "-", "low", "<", "2", ")", "{", "return", ";", "}", "int", "middle", "=", "(", "low", "+", "high", ")", "/", "2", ";", "shuttlesort", "(", "to", ",", "from", ",", "low", ",", "middle", ")", ";", "shuttlesort", "(", "to", ",", "from", ",", "middle", ",", "high", ")", ";", "int", "p", "=", "low", ";", "int", "q", "=", "middle", ";", "/* This is an optional short-cut; at each recursive call,\n check to see if the elements in this subset are already\n ordered. If so, no further comparisons are needed; the\n sub-array can just be copied. The array must be copied rather\n than assigned otherwise sister calls in the recursion might\n get out of sync. When the number of elements is three they\n are partitioned so that the first set, [low, mid), has one\n element and and the second, [mid, high), has two. We skip the\n optimisation when the number of elements is three or less as\n the first compare in the normal merge will produce the same\n sequence of steps. This optimisation seems to be worthwhile\n for partially ordered lists but some analysis is needed to\n find out how the performance drops to Nlog(N) as the initial\n order diminishes - it may drop very quickly. */", "if", "(", "high", "-", "low", ">=", "4", "&&", "compare", "(", "from", "[", "middle", "-", "1", "]", ",", "from", "[", "middle", "]", ")", "<=", "0", ")", "{", "System", ".", "arraycopy", "(", "from", ",", "low", ",", "to", ",", "low", ",", "high", "-", "low", ")", ";", "return", ";", "}", "// A normal merge.", "for", "(", "int", "i", "=", "low", ";", "i", "<", "high", ";", "i", "++", ")", "{", "if", "(", "q", ">=", "high", "||", "(", "p", "<", "middle", "&&", "compare", "(", "from", "[", "p", "]", ",", "from", "[", "q", "]", ")", "<=", "0", ")", ")", "{", "to", "[", "i", "]", "=", "from", "[", "p", "++", "]", ";", "}", "else", "{", "to", "[", "i", "]", "=", "from", "[", "q", "++", "]", ";", "}", "}", "}" ]
using it here is that, unlike qsort, it is stable.
[ "using", "it", "here", "is", "that", "unlike", "qsort", "it", "is", "stable", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-swing/src/main/java/groovy/inspect/swingui/TableSorter.java#L228-L268
12,554
apache/groovy
subprojects/groovy-swing/src/main/java/groovy/inspect/swingui/TableSorter.java
TableSorter.addMouseListenerToHeaderInTable
public void addMouseListenerToHeaderInTable(JTable table) { final TableSorter sorter = this; final JTable tableView = table; tableView.setColumnSelectionAllowed(false); MouseAdapter listMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { if (lastSortedColumn == column) ascending = !ascending; sorter.sortByColumn(column, ascending); lastSortedColumn = column; } } }; JTableHeader th = tableView.getTableHeader(); th.addMouseListener(listMouseListener); }
java
public void addMouseListenerToHeaderInTable(JTable table) { final TableSorter sorter = this; final JTable tableView = table; tableView.setColumnSelectionAllowed(false); MouseAdapter listMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = tableView.convertColumnIndexToModel(viewColumn); if (e.getClickCount() == 1 && column != -1) { if (lastSortedColumn == column) ascending = !ascending; sorter.sortByColumn(column, ascending); lastSortedColumn = column; } } }; JTableHeader th = tableView.getTableHeader(); th.addMouseListener(listMouseListener); }
[ "public", "void", "addMouseListenerToHeaderInTable", "(", "JTable", "table", ")", "{", "final", "TableSorter", "sorter", "=", "this", ";", "final", "JTable", "tableView", "=", "table", ";", "tableView", ".", "setColumnSelectionAllowed", "(", "false", ")", ";", "MouseAdapter", "listMouseListener", "=", "new", "MouseAdapter", "(", ")", "{", "public", "void", "mouseClicked", "(", "MouseEvent", "e", ")", "{", "TableColumnModel", "columnModel", "=", "tableView", ".", "getColumnModel", "(", ")", ";", "int", "viewColumn", "=", "columnModel", ".", "getColumnIndexAtX", "(", "e", ".", "getX", "(", ")", ")", ";", "int", "column", "=", "tableView", ".", "convertColumnIndexToModel", "(", "viewColumn", ")", ";", "if", "(", "e", ".", "getClickCount", "(", ")", "==", "1", "&&", "column", "!=", "-", "1", ")", "{", "if", "(", "lastSortedColumn", "==", "column", ")", "ascending", "=", "!", "ascending", ";", "sorter", ".", "sortByColumn", "(", "column", ",", "ascending", ")", ";", "lastSortedColumn", "=", "column", ";", "}", "}", "}", ";", "JTableHeader", "th", "=", "tableView", ".", "getTableHeader", "(", ")", ";", "th", ".", "addMouseListener", "(", "listMouseListener", ")", ";", "}" ]
when a column heading is clicked in the JTable.
[ "when", "a", "column", "heading", "is", "clicked", "in", "the", "JTable", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-swing/src/main/java/groovy/inspect/swingui/TableSorter.java#L304-L322
12,555
apache/groovy
src/main/java/org/codehaus/groovy/control/messages/ExceptionMessage.java
ExceptionMessage.write
public void write(PrintWriter output, Janitor janitor) { String description = "General error during " + owner.getPhaseDescription() + ": "; String message = cause.getMessage(); if (message != null) { output.println(description + message); } else { output.println(description + cause); } output.println(); //if (verbose) { cause.printStackTrace(output); //} }
java
public void write(PrintWriter output, Janitor janitor) { String description = "General error during " + owner.getPhaseDescription() + ": "; String message = cause.getMessage(); if (message != null) { output.println(description + message); } else { output.println(description + cause); } output.println(); //if (verbose) { cause.printStackTrace(output); //} }
[ "public", "void", "write", "(", "PrintWriter", "output", ",", "Janitor", "janitor", ")", "{", "String", "description", "=", "\"General error during \"", "+", "owner", ".", "getPhaseDescription", "(", ")", "+", "\": \"", ";", "String", "message", "=", "cause", ".", "getMessage", "(", ")", ";", "if", "(", "message", "!=", "null", ")", "{", "output", ".", "println", "(", "description", "+", "message", ")", ";", "}", "else", "{", "output", ".", "println", "(", "description", "+", "cause", ")", ";", "}", "output", ".", "println", "(", ")", ";", "//if (verbose) {", "cause", ".", "printStackTrace", "(", "output", ")", ";", "//}", "}" ]
Writes out a nicely formatted summary of the exception.
[ "Writes", "out", "a", "nicely", "formatted", "summary", "of", "the", "exception", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/messages/ExceptionMessage.java#L54-L68
12,556
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.appendNode
public Node appendNode(Object name, Map attributes, Object value) { return new Node(this, name, attributes, value); }
java
public Node appendNode(Object name, Map attributes, Object value) { return new Node(this, name, attributes, value); }
[ "public", "Node", "appendNode", "(", "Object", "name", ",", "Map", "attributes", ",", "Object", "value", ")", "{", "return", "new", "Node", "(", "this", ",", "name", ",", "attributes", ",", "value", ")", ";", "}" ]
Creates a new node as a child of the current node. @param name the name of the new node @param attributes the attributes of the new node @param value the value of the new node @return the newly created <code>Node</code>
[ "Creates", "a", "new", "node", "as", "a", "child", "of", "the", "current", "node", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L218-L220
12,557
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.replaceNode
public Node replaceNode(Closure c) { if (parent() == null) { throw new UnsupportedOperationException("Replacing the root node is not supported"); } appendNodes(c); getParentList(parent()).remove(this); this.setParent(null); return this; }
java
public Node replaceNode(Closure c) { if (parent() == null) { throw new UnsupportedOperationException("Replacing the root node is not supported"); } appendNodes(c); getParentList(parent()).remove(this); this.setParent(null); return this; }
[ "public", "Node", "replaceNode", "(", "Closure", "c", ")", "{", "if", "(", "parent", "(", ")", "==", "null", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Replacing the root node is not supported\"", ")", ";", "}", "appendNodes", "(", "c", ")", ";", "getParentList", "(", "parent", "(", ")", ")", ".", "remove", "(", "this", ")", ";", "this", ".", "setParent", "(", "null", ")", ";", "return", "this", ";", "}" ]
Replaces the current node with nodes defined using builder-style notation via a Closure. @param c A Closure defining the new nodes using builder-style notation. @return the original now replaced node
[ "Replaces", "the", "current", "node", "with", "nodes", "defined", "using", "builder", "-", "style", "notation", "via", "a", "Closure", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L228-L236
12,558
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.replaceNode
public Node replaceNode(Node n) { if (parent() == null) { throw new UnsupportedOperationException("Replacing the root node is not supported"); } List tail = getTail(); parent().appendNode(n.name(), n.attributes(), n.value()); parent().children().addAll(tail); getParentList(parent()).remove(this); this.setParent(null); return this; }
java
public Node replaceNode(Node n) { if (parent() == null) { throw new UnsupportedOperationException("Replacing the root node is not supported"); } List tail = getTail(); parent().appendNode(n.name(), n.attributes(), n.value()); parent().children().addAll(tail); getParentList(parent()).remove(this); this.setParent(null); return this; }
[ "public", "Node", "replaceNode", "(", "Node", "n", ")", "{", "if", "(", "parent", "(", ")", "==", "null", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"Replacing the root node is not supported\"", ")", ";", "}", "List", "tail", "=", "getTail", "(", ")", ";", "parent", "(", ")", ".", "appendNode", "(", "n", ".", "name", "(", ")", ",", "n", ".", "attributes", "(", ")", ",", "n", ".", "value", "(", ")", ")", ";", "parent", "(", ")", ".", "children", "(", ")", ".", "addAll", "(", "tail", ")", ";", "getParentList", "(", "parent", "(", ")", ")", ".", "remove", "(", "this", ")", ";", "this", ".", "setParent", "(", "null", ")", ";", "return", "this", ";", "}" ]
Replaces the current node with the supplied node. @param n the new Node @return the original now replaced node
[ "Replaces", "the", "current", "node", "with", "the", "supplied", "node", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L244-L254
12,559
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.text
public String text() { if (value instanceof String) { return (String) value; } if (value instanceof NodeList) { return ((NodeList) value).text(); } if (value instanceof Collection) { Collection coll = (Collection) value; String previousText = null; StringBuilder sb = null; for (Object child : coll) { String childText = null; if (child instanceof String) { childText = (String) child; } else if (child instanceof Node) { childText = ((Node) child).text(); } if (childText != null) { if (previousText == null) { previousText = childText; } else { if (sb == null) { sb = new StringBuilder(); sb.append(previousText); } sb.append(childText); } } } if (sb != null) { return sb.toString(); } else { if (previousText != null) { return previousText; } return ""; } } return "" + value; }
java
public String text() { if (value instanceof String) { return (String) value; } if (value instanceof NodeList) { return ((NodeList) value).text(); } if (value instanceof Collection) { Collection coll = (Collection) value; String previousText = null; StringBuilder sb = null; for (Object child : coll) { String childText = null; if (child instanceof String) { childText = (String) child; } else if (child instanceof Node) { childText = ((Node) child).text(); } if (childText != null) { if (previousText == null) { previousText = childText; } else { if (sb == null) { sb = new StringBuilder(); sb.append(previousText); } sb.append(childText); } } } if (sb != null) { return sb.toString(); } else { if (previousText != null) { return previousText; } return ""; } } return "" + value; }
[ "public", "String", "text", "(", ")", "{", "if", "(", "value", "instanceof", "String", ")", "{", "return", "(", "String", ")", "value", ";", "}", "if", "(", "value", "instanceof", "NodeList", ")", "{", "return", "(", "(", "NodeList", ")", "value", ")", ".", "text", "(", ")", ";", "}", "if", "(", "value", "instanceof", "Collection", ")", "{", "Collection", "coll", "=", "(", "Collection", ")", "value", ";", "String", "previousText", "=", "null", ";", "StringBuilder", "sb", "=", "null", ";", "for", "(", "Object", "child", ":", "coll", ")", "{", "String", "childText", "=", "null", ";", "if", "(", "child", "instanceof", "String", ")", "{", "childText", "=", "(", "String", ")", "child", ";", "}", "else", "if", "(", "child", "instanceof", "Node", ")", "{", "childText", "=", "(", "(", "Node", ")", "child", ")", ".", "text", "(", ")", ";", "}", "if", "(", "childText", "!=", "null", ")", "{", "if", "(", "previousText", "==", "null", ")", "{", "previousText", "=", "childText", ";", "}", "else", "{", "if", "(", "sb", "==", "null", ")", "{", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "previousText", ")", ";", "}", "sb", ".", "append", "(", "childText", ")", ";", "}", "}", "}", "if", "(", "sb", "!=", "null", ")", "{", "return", "sb", ".", "toString", "(", ")", ";", "}", "else", "{", "if", "(", "previousText", "!=", "null", ")", "{", "return", "previousText", ";", "}", "return", "\"\"", ";", "}", "}", "return", "\"\"", "+", "value", ";", "}" ]
Returns the textual representation of the current node and all its child nodes. @return the text value of the node including child text
[ "Returns", "the", "textual", "representation", "of", "the", "current", "node", "and", "all", "its", "child", "nodes", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L340-L380
12,560
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.attribute
public Object attribute(Object key) { return (attributes != null) ? attributes.get(key) : null; }
java
public Object attribute(Object key) { return (attributes != null) ? attributes.get(key) : null; }
[ "public", "Object", "attribute", "(", "Object", "key", ")", "{", "return", "(", "attributes", "!=", "null", ")", "?", "attributes", ".", "get", "(", "key", ")", ":", "null", ";", "}" ]
Provides lookup of attributes by key. @param key the key of interest @return the attribute matching the key or <code>null</code> if no match exists
[ "Provides", "lookup", "of", "attributes", "by", "key", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L425-L427
12,561
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.get
public Object get(String key) { if (key != null && key.charAt(0) == '@') { String attributeName = key.substring(1); return attributes().get(attributeName); } if ("..".equals(key)) { return parent(); } if ("*".equals(key)) { return children(); } if ("**".equals(key)) { return depthFirst(); } return getByName(key); }
java
public Object get(String key) { if (key != null && key.charAt(0) == '@') { String attributeName = key.substring(1); return attributes().get(attributeName); } if ("..".equals(key)) { return parent(); } if ("*".equals(key)) { return children(); } if ("**".equals(key)) { return depthFirst(); } return getByName(key); }
[ "public", "Object", "get", "(", "String", "key", ")", "{", "if", "(", "key", "!=", "null", "&&", "key", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "String", "attributeName", "=", "key", ".", "substring", "(", "1", ")", ";", "return", "attributes", "(", ")", ".", "get", "(", "attributeName", ")", ";", "}", "if", "(", "\"..\"", ".", "equals", "(", "key", ")", ")", "{", "return", "parent", "(", ")", ";", "}", "if", "(", "\"*\"", ".", "equals", "(", "key", ")", ")", "{", "return", "children", "(", ")", ";", "}", "if", "(", "\"**\"", ".", "equals", "(", "key", ")", ")", "{", "return", "depthFirst", "(", ")", ";", "}", "return", "getByName", "(", "key", ")", ";", "}" ]
Provides lookup of elements by non-namespaced name @param key the name (or shortcut key) of the node(s) of interest @return the nodes which match key
[ "Provides", "lookup", "of", "elements", "by", "non", "-", "namespaced", "name" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L480-L495
12,562
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.getByName
private NodeList getByName(String name) { NodeList answer = new NodeList(); for (Object child : children()) { if (child instanceof Node) { Node childNode = (Node) child; Object childNodeName = childNode.name(); if (childNodeName instanceof QName) { QName qn = (QName) childNodeName; if (qn.matches(name)) { answer.add(childNode); } } else if (name.equals(childNodeName)) { answer.add(childNode); } } } return answer; }
java
private NodeList getByName(String name) { NodeList answer = new NodeList(); for (Object child : children()) { if (child instanceof Node) { Node childNode = (Node) child; Object childNodeName = childNode.name(); if (childNodeName instanceof QName) { QName qn = (QName) childNodeName; if (qn.matches(name)) { answer.add(childNode); } } else if (name.equals(childNodeName)) { answer.add(childNode); } } } return answer; }
[ "private", "NodeList", "getByName", "(", "String", "name", ")", "{", "NodeList", "answer", "=", "new", "NodeList", "(", ")", ";", "for", "(", "Object", "child", ":", "children", "(", ")", ")", "{", "if", "(", "child", "instanceof", "Node", ")", "{", "Node", "childNode", "=", "(", "Node", ")", "child", ";", "Object", "childNodeName", "=", "childNode", ".", "name", "(", ")", ";", "if", "(", "childNodeName", "instanceof", "QName", ")", "{", "QName", "qn", "=", "(", "QName", ")", "childNodeName", ";", "if", "(", "qn", ".", "matches", "(", "name", ")", ")", "{", "answer", ".", "add", "(", "childNode", ")", ";", "}", "}", "else", "if", "(", "name", ".", "equals", "(", "childNodeName", ")", ")", "{", "answer", ".", "add", "(", "childNode", ")", ";", "}", "}", "}", "return", "answer", ";", "}" ]
Provides lookup of elements by name. @param name the name of interest @return the nodes matching name
[ "Provides", "lookup", "of", "elements", "by", "name", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L523-L540
12,563
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.depthFirst
public List depthFirst(boolean preorder) { List answer = new NodeList(); if (preorder) answer.add(this); answer.addAll(depthFirstRest(preorder)); if (!preorder) answer.add(this); return answer; }
java
public List depthFirst(boolean preorder) { List answer = new NodeList(); if (preorder) answer.add(this); answer.addAll(depthFirstRest(preorder)); if (!preorder) answer.add(this); return answer; }
[ "public", "List", "depthFirst", "(", "boolean", "preorder", ")", "{", "List", "answer", "=", "new", "NodeList", "(", ")", ";", "if", "(", "preorder", ")", "answer", ".", "add", "(", "this", ")", ";", "answer", ".", "addAll", "(", "depthFirstRest", "(", "preorder", ")", ")", ";", "if", "(", "!", "preorder", ")", "answer", ".", "add", "(", "this", ")", ";", "return", "answer", ";", "}" ]
Provides a collection of all the nodes in the tree using a depth-first traversal. @param preorder if false, a postorder depth-first traversal will be performed @return the list of (depth-first) ordered nodes @since 2.5.0
[ "Provides", "a", "collection", "of", "all", "the", "nodes", "in", "the", "tree", "using", "a", "depth", "-", "first", "traversal", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L560-L566
12,564
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.depthFirst
public void depthFirst(Closure c) { Map<String, Object> options = new ListHashMap<String, Object>(); options.put("preorder", true); depthFirst(options, c); }
java
public void depthFirst(Closure c) { Map<String, Object> options = new ListHashMap<String, Object>(); options.put("preorder", true); depthFirst(options, c); }
[ "public", "void", "depthFirst", "(", "Closure", "c", ")", "{", "Map", "<", "String", ",", "Object", ">", "options", "=", "new", "ListHashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "options", ".", "put", "(", "\"preorder\"", ",", "true", ")", ";", "depthFirst", "(", "options", ",", "c", ")", ";", "}" ]
Provides a collection of all the nodes in the tree using a depth-first preorder traversal. @param c the closure to run for each node (a one or two parameter can be used; if one parameter is given the closure will be passed the node, for a two param closure the second parameter will be the level). @since 2.5.0
[ "Provides", "a", "collection", "of", "all", "the", "nodes", "in", "the", "tree", "using", "a", "depth", "-", "first", "preorder", "traversal", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L593-L597
12,565
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.depthFirst
public void depthFirst(Map<String, Object> options, Closure c) { boolean preorder = Boolean.valueOf(options.get("preorder").toString()); if (preorder) callClosureForNode(c, this, 1); depthFirstRest(preorder, 2, c); if (!preorder) callClosureForNode(c, this, 1); }
java
public void depthFirst(Map<String, Object> options, Closure c) { boolean preorder = Boolean.valueOf(options.get("preorder").toString()); if (preorder) callClosureForNode(c, this, 1); depthFirstRest(preorder, 2, c); if (!preorder) callClosureForNode(c, this, 1); }
[ "public", "void", "depthFirst", "(", "Map", "<", "String", ",", "Object", ">", "options", ",", "Closure", "c", ")", "{", "boolean", "preorder", "=", "Boolean", ".", "valueOf", "(", "options", ".", "get", "(", "\"preorder\"", ")", ".", "toString", "(", ")", ")", ";", "if", "(", "preorder", ")", "callClosureForNode", "(", "c", ",", "this", ",", "1", ")", ";", "depthFirstRest", "(", "preorder", ",", "2", ",", "c", ")", ";", "if", "(", "!", "preorder", ")", "callClosureForNode", "(", "c", ",", "this", ",", "1", ")", ";", "}" ]
Provides a collection of all the nodes in the tree using a depth-first traversal. A boolean 'preorder' options is supported. @param options map containing options @param c the closure to run for each node (a one or two parameter can be used; if one parameter is given the closure will be passed the node, for a two param closure the second parameter will be the level). @since 2.5.0
[ "Provides", "a", "collection", "of", "all", "the", "nodes", "in", "the", "tree", "using", "a", "depth", "-", "first", "traversal", ".", "A", "boolean", "preorder", "options", "is", "supported", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L609-L614
12,566
apache/groovy
src/main/groovy/groovy/util/Node.java
Node.breadthFirst
public void breadthFirst(Map<String, Object> options, Closure c) { boolean preorder = Boolean.valueOf(options.get("preorder").toString()); if (preorder) callClosureForNode(c, this, 1); breadthFirstRest(preorder, 2, c); if (!preorder) callClosureForNode(c, this, 1); }
java
public void breadthFirst(Map<String, Object> options, Closure c) { boolean preorder = Boolean.valueOf(options.get("preorder").toString()); if (preorder) callClosureForNode(c, this, 1); breadthFirstRest(preorder, 2, c); if (!preorder) callClosureForNode(c, this, 1); }
[ "public", "void", "breadthFirst", "(", "Map", "<", "String", ",", "Object", ">", "options", ",", "Closure", "c", ")", "{", "boolean", "preorder", "=", "Boolean", ".", "valueOf", "(", "options", ".", "get", "(", "\"preorder\"", ")", ".", "toString", "(", ")", ")", ";", "if", "(", "preorder", ")", "callClosureForNode", "(", "c", ",", "this", ",", "1", ")", ";", "breadthFirstRest", "(", "preorder", ",", "2", ",", "c", ")", ";", "if", "(", "!", "preorder", ")", "callClosureForNode", "(", "c", ",", "this", ",", "1", ")", ";", "}" ]
Calls the provided closure for all the nodes in the tree using a breadth-first traversal. A boolean 'preorder' options is supported. @param options map containing options @param c the closure to run for each node (a one or two parameter can be used; if one parameter is given the closure will be passed the node, for a two param closure the second parameter will be the level). @since 2.5.0
[ "Calls", "the", "provided", "closure", "for", "all", "the", "nodes", "in", "the", "tree", "using", "a", "breadth", "-", "first", "traversal", ".", "A", "boolean", "preorder", "options", "is", "supported", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/Node.java#L711-L716
12,567
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
GPathResult.setMetaClass
@Override public void setMetaClass(final MetaClass metaClass) { final MetaClass newMetaClass = new DelegatingMetaClass(metaClass) { @Override public Object getAttribute(final Object object, final String attribute) { return GPathResult.this.getProperty("@" + attribute); } @Override public void setAttribute(final Object object, final String attribute, final Object newValue) { GPathResult.this.setProperty("@" + attribute, newValue); } }; super.setMetaClass(newMetaClass); }
java
@Override public void setMetaClass(final MetaClass metaClass) { final MetaClass newMetaClass = new DelegatingMetaClass(metaClass) { @Override public Object getAttribute(final Object object, final String attribute) { return GPathResult.this.getProperty("@" + attribute); } @Override public void setAttribute(final Object object, final String attribute, final Object newValue) { GPathResult.this.setProperty("@" + attribute, newValue); } }; super.setMetaClass(newMetaClass); }
[ "@", "Override", "public", "void", "setMetaClass", "(", "final", "MetaClass", "metaClass", ")", "{", "final", "MetaClass", "newMetaClass", "=", "new", "DelegatingMetaClass", "(", "metaClass", ")", "{", "@", "Override", "public", "Object", "getAttribute", "(", "final", "Object", "object", ",", "final", "String", "attribute", ")", "{", "return", "GPathResult", ".", "this", ".", "getProperty", "(", "\"@\"", "+", "attribute", ")", ";", "}", "@", "Override", "public", "void", "setAttribute", "(", "final", "Object", "object", ",", "final", "String", "attribute", ",", "final", "Object", "newValue", ")", "{", "GPathResult", ".", "this", ".", "setProperty", "(", "\"@\"", "+", "attribute", ",", "newValue", ")", ";", "}", "}", ";", "super", ".", "setMetaClass", "(", "newMetaClass", ")", ";", "}" ]
Replaces the MetaClass of this GPathResult. @param metaClass the new MetaClass
[ "Replaces", "the", "MetaClass", "of", "this", "GPathResult", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java#L89-L103
12,568
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
GPathResult.setProperty
public void setProperty(final String property, final Object newValue) { if (property.startsWith("@")) { if (newValue instanceof String || newValue instanceof GString) { final Iterator iter = iterator(); while (iter.hasNext()) { final NodeChild child = (NodeChild) iter.next(); child.attributes().put(property.substring(1), newValue); } } } else { final GPathResult result = new NodeChildren(this, property, this.namespaceTagHints); if (newValue instanceof Map) { for (Object o : ((Map) newValue).entrySet()) { final Map.Entry entry = (Map.Entry) o; result.setProperty("@" + entry.getKey(), entry.getValue()); } } else { if (newValue instanceof Closure) { result.replaceNode((Closure) newValue); } else { result.replaceBody(newValue); } } } }
java
public void setProperty(final String property, final Object newValue) { if (property.startsWith("@")) { if (newValue instanceof String || newValue instanceof GString) { final Iterator iter = iterator(); while (iter.hasNext()) { final NodeChild child = (NodeChild) iter.next(); child.attributes().put(property.substring(1), newValue); } } } else { final GPathResult result = new NodeChildren(this, property, this.namespaceTagHints); if (newValue instanceof Map) { for (Object o : ((Map) newValue).entrySet()) { final Map.Entry entry = (Map.Entry) o; result.setProperty("@" + entry.getKey(), entry.getValue()); } } else { if (newValue instanceof Closure) { result.replaceNode((Closure) newValue); } else { result.replaceBody(newValue); } } } }
[ "public", "void", "setProperty", "(", "final", "String", "property", ",", "final", "Object", "newValue", ")", "{", "if", "(", "property", ".", "startsWith", "(", "\"@\"", ")", ")", "{", "if", "(", "newValue", "instanceof", "String", "||", "newValue", "instanceof", "GString", ")", "{", "final", "Iterator", "iter", "=", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "final", "NodeChild", "child", "=", "(", "NodeChild", ")", "iter", ".", "next", "(", ")", ";", "child", ".", "attributes", "(", ")", ".", "put", "(", "property", ".", "substring", "(", "1", ")", ",", "newValue", ")", ";", "}", "}", "}", "else", "{", "final", "GPathResult", "result", "=", "new", "NodeChildren", "(", "this", ",", "property", ",", "this", ".", "namespaceTagHints", ")", ";", "if", "(", "newValue", "instanceof", "Map", ")", "{", "for", "(", "Object", "o", ":", "(", "(", "Map", ")", "newValue", ")", ".", "entrySet", "(", ")", ")", "{", "final", "Map", ".", "Entry", "entry", "=", "(", "Map", ".", "Entry", ")", "o", ";", "result", ".", "setProperty", "(", "\"@\"", "+", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}", "else", "{", "if", "(", "newValue", "instanceof", "Closure", ")", "{", "result", ".", "replaceNode", "(", "(", "Closure", ")", "newValue", ")", ";", "}", "else", "{", "result", ".", "replaceBody", "(", "newValue", ")", ";", "}", "}", "}", "}" ]
Replaces the specified property of this GPathResult with a new value. @param property the property of this GPathResult to replace @param newValue the new value of the property
[ "Replaces", "the", "specified", "property", "of", "this", "GPathResult", "with", "a", "new", "value", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java#L147-L174
12,569
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
GPathResult.plus
public Object plus(final Object newValue) { this.replaceNode(new Closure(this) { public void doCall(Object[] args) { final GroovyObject delegate = (GroovyObject) getDelegate(); delegate.getProperty("mkp"); delegate.invokeMethod("yield", args); delegate.getProperty("mkp"); delegate.invokeMethod("yield", new Object[]{newValue}); } }); return this; }
java
public Object plus(final Object newValue) { this.replaceNode(new Closure(this) { public void doCall(Object[] args) { final GroovyObject delegate = (GroovyObject) getDelegate(); delegate.getProperty("mkp"); delegate.invokeMethod("yield", args); delegate.getProperty("mkp"); delegate.invokeMethod("yield", new Object[]{newValue}); } }); return this; }
[ "public", "Object", "plus", "(", "final", "Object", "newValue", ")", "{", "this", ".", "replaceNode", "(", "new", "Closure", "(", "this", ")", "{", "public", "void", "doCall", "(", "Object", "[", "]", "args", ")", "{", "final", "GroovyObject", "delegate", "=", "(", "GroovyObject", ")", "getDelegate", "(", ")", ";", "delegate", ".", "getProperty", "(", "\"mkp\"", ")", ";", "delegate", ".", "invokeMethod", "(", "\"yield\"", ",", "args", ")", ";", "delegate", ".", "getProperty", "(", "\"mkp\"", ")", ";", "delegate", ".", "invokeMethod", "(", "\"yield\"", ",", "new", "Object", "[", "]", "{", "newValue", "}", ")", ";", "}", "}", ")", ";", "return", "this", ";", "}" ]
Lazily adds the specified Object to this GPathResult. @param newValue the Object to add @return <code>this</code>
[ "Lazily", "adds", "the", "specified", "Object", "to", "this", "GPathResult", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java#L194-L206
12,570
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
GPathResult.putAt
public void putAt(final int index, final Object newValue) { final GPathResult result = (GPathResult)getAt(index); if (newValue instanceof Closure) { result.replaceNode((Closure)newValue); } else { result.replaceBody(newValue); } }
java
public void putAt(final int index, final Object newValue) { final GPathResult result = (GPathResult)getAt(index); if (newValue instanceof Closure) { result.replaceNode((Closure)newValue); } else { result.replaceBody(newValue); } }
[ "public", "void", "putAt", "(", "final", "int", "index", ",", "final", "Object", "newValue", ")", "{", "final", "GPathResult", "result", "=", "(", "GPathResult", ")", "getAt", "(", "index", ")", ";", "if", "(", "newValue", "instanceof", "Closure", ")", "{", "result", ".", "replaceNode", "(", "(", "Closure", ")", "newValue", ")", ";", "}", "else", "{", "result", ".", "replaceBody", "(", "newValue", ")", ";", "}", "}" ]
A helper method to allow GPathResults to work with subscript operators @param index an index @param newValue the value to put at the given index
[ "A", "helper", "method", "to", "allow", "GPathResults", "to", "work", "with", "subscript", "operators" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java#L477-L484
12,571
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
GPathResult.depthFirst
public Iterator depthFirst() { return new Iterator() { private final List list = new LinkedList(); private final Stack stack = new Stack(); private Iterator iter = iterator(); private GPathResult next = getNextByDepth(); public boolean hasNext() { return this.next != null; } public Object next() { try { return this.next; } finally { this.next = getNextByDepth(); } } public void remove() { throw new UnsupportedOperationException(); } private GPathResult getNextByDepth() { while (this.iter.hasNext()) { final GPathResult node = (GPathResult) this.iter.next(); this.list.add(node); this.stack.push(this.iter); this.iter = node.children().iterator(); } if (this.list.isEmpty()) { return null; } else { GPathResult result = (GPathResult) this.list.get(0); this.list.remove(0); this.iter = (Iterator) this.stack.pop(); return result; } } }; }
java
public Iterator depthFirst() { return new Iterator() { private final List list = new LinkedList(); private final Stack stack = new Stack(); private Iterator iter = iterator(); private GPathResult next = getNextByDepth(); public boolean hasNext() { return this.next != null; } public Object next() { try { return this.next; } finally { this.next = getNextByDepth(); } } public void remove() { throw new UnsupportedOperationException(); } private GPathResult getNextByDepth() { while (this.iter.hasNext()) { final GPathResult node = (GPathResult) this.iter.next(); this.list.add(node); this.stack.push(this.iter); this.iter = node.children().iterator(); } if (this.list.isEmpty()) { return null; } else { GPathResult result = (GPathResult) this.list.get(0); this.list.remove(0); this.iter = (Iterator) this.stack.pop(); return result; } } }; }
[ "public", "Iterator", "depthFirst", "(", ")", "{", "return", "new", "Iterator", "(", ")", "{", "private", "final", "List", "list", "=", "new", "LinkedList", "(", ")", ";", "private", "final", "Stack", "stack", "=", "new", "Stack", "(", ")", ";", "private", "Iterator", "iter", "=", "iterator", "(", ")", ";", "private", "GPathResult", "next", "=", "getNextByDepth", "(", ")", ";", "public", "boolean", "hasNext", "(", ")", "{", "return", "this", ".", "next", "!=", "null", ";", "}", "public", "Object", "next", "(", ")", "{", "try", "{", "return", "this", ".", "next", ";", "}", "finally", "{", "this", ".", "next", "=", "getNextByDepth", "(", ")", ";", "}", "}", "public", "void", "remove", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "private", "GPathResult", "getNextByDepth", "(", ")", "{", "while", "(", "this", ".", "iter", ".", "hasNext", "(", ")", ")", "{", "final", "GPathResult", "node", "=", "(", "GPathResult", ")", "this", ".", "iter", ".", "next", "(", ")", ";", "this", ".", "list", ".", "add", "(", "node", ")", ";", "this", ".", "stack", ".", "push", "(", "this", ".", "iter", ")", ";", "this", ".", "iter", "=", "node", ".", "children", "(", ")", ".", "iterator", "(", ")", ";", "}", "if", "(", "this", ".", "list", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "GPathResult", "result", "=", "(", "GPathResult", ")", "this", ".", "list", ".", "get", "(", "0", ")", ";", "this", ".", "list", ".", "remove", "(", "0", ")", ";", "this", ".", "iter", "=", "(", "Iterator", ")", "this", ".", "stack", ".", "pop", "(", ")", ";", "return", "result", ";", "}", "}", "}", ";", "}" ]
Provides an Iterator over all the nodes of this GPathResult using a depth-first traversal. @return the <code>Iterator</code> of (depth-first) ordered GPathResults
[ "Provides", "an", "Iterator", "over", "all", "the", "nodes", "of", "this", "GPathResult", "using", "a", "depth", "-", "first", "traversal", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java#L491-L532
12,572
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
GPathResult.breadthFirst
public Iterator breadthFirst() { return new Iterator() { private final List list = new LinkedList(); private Iterator iter = iterator(); private GPathResult next = getNextByBreadth(); public boolean hasNext() { return this.next != null; } public Object next() { try { return this.next; } finally { this.next = getNextByBreadth(); } } public void remove() { throw new UnsupportedOperationException(); } private GPathResult getNextByBreadth() { List children = new ArrayList(); while (this.iter.hasNext() || !children.isEmpty()) { if (this.iter.hasNext()) { final GPathResult node = (GPathResult) this.iter.next(); this.list.add(node); this.list.add(this.iter); children.add(node.children()); } else { List nextLevel = new ArrayList(); for (Object child : children) { GPathResult next = (GPathResult) child; Iterator iterator = next.iterator(); while (iterator.hasNext()) { nextLevel.add(iterator.next()); } } this.iter = nextLevel.iterator(); children = new ArrayList(); } } if (this.list.isEmpty()) { return null; } else { GPathResult result = (GPathResult) this.list.get(0); this.list.remove(0); this.iter = (Iterator) this.list.get(0); this.list.remove(0); return result; } } }; }
java
public Iterator breadthFirst() { return new Iterator() { private final List list = new LinkedList(); private Iterator iter = iterator(); private GPathResult next = getNextByBreadth(); public boolean hasNext() { return this.next != null; } public Object next() { try { return this.next; } finally { this.next = getNextByBreadth(); } } public void remove() { throw new UnsupportedOperationException(); } private GPathResult getNextByBreadth() { List children = new ArrayList(); while (this.iter.hasNext() || !children.isEmpty()) { if (this.iter.hasNext()) { final GPathResult node = (GPathResult) this.iter.next(); this.list.add(node); this.list.add(this.iter); children.add(node.children()); } else { List nextLevel = new ArrayList(); for (Object child : children) { GPathResult next = (GPathResult) child; Iterator iterator = next.iterator(); while (iterator.hasNext()) { nextLevel.add(iterator.next()); } } this.iter = nextLevel.iterator(); children = new ArrayList(); } } if (this.list.isEmpty()) { return null; } else { GPathResult result = (GPathResult) this.list.get(0); this.list.remove(0); this.iter = (Iterator) this.list.get(0); this.list.remove(0); return result; } } }; }
[ "public", "Iterator", "breadthFirst", "(", ")", "{", "return", "new", "Iterator", "(", ")", "{", "private", "final", "List", "list", "=", "new", "LinkedList", "(", ")", ";", "private", "Iterator", "iter", "=", "iterator", "(", ")", ";", "private", "GPathResult", "next", "=", "getNextByBreadth", "(", ")", ";", "public", "boolean", "hasNext", "(", ")", "{", "return", "this", ".", "next", "!=", "null", ";", "}", "public", "Object", "next", "(", ")", "{", "try", "{", "return", "this", ".", "next", ";", "}", "finally", "{", "this", ".", "next", "=", "getNextByBreadth", "(", ")", ";", "}", "}", "public", "void", "remove", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "private", "GPathResult", "getNextByBreadth", "(", ")", "{", "List", "children", "=", "new", "ArrayList", "(", ")", ";", "while", "(", "this", ".", "iter", ".", "hasNext", "(", ")", "||", "!", "children", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "this", ".", "iter", ".", "hasNext", "(", ")", ")", "{", "final", "GPathResult", "node", "=", "(", "GPathResult", ")", "this", ".", "iter", ".", "next", "(", ")", ";", "this", ".", "list", ".", "add", "(", "node", ")", ";", "this", ".", "list", ".", "add", "(", "this", ".", "iter", ")", ";", "children", ".", "add", "(", "node", ".", "children", "(", ")", ")", ";", "}", "else", "{", "List", "nextLevel", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Object", "child", ":", "children", ")", "{", "GPathResult", "next", "=", "(", "GPathResult", ")", "child", ";", "Iterator", "iterator", "=", "next", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "nextLevel", ".", "add", "(", "iterator", ".", "next", "(", ")", ")", ";", "}", "}", "this", ".", "iter", "=", "nextLevel", ".", "iterator", "(", ")", ";", "children", "=", "new", "ArrayList", "(", ")", ";", "}", "}", "if", "(", "this", ".", "list", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "GPathResult", "result", "=", "(", "GPathResult", ")", "this", ".", "list", ".", "get", "(", "0", ")", ";", "this", ".", "list", ".", "remove", "(", "0", ")", ";", "this", ".", "iter", "=", "(", "Iterator", ")", "this", ".", "list", ".", "get", "(", "0", ")", ";", "this", ".", "list", ".", "remove", "(", "0", ")", ";", "return", "result", ";", "}", "}", "}", ";", "}" ]
Provides an Iterator over all the nodes of this GPathResult using a breadth-first traversal. @return the <code>Iterator</code> of (breadth-first) ordered GPathResults
[ "Provides", "an", "Iterator", "over", "all", "the", "nodes", "of", "this", "GPathResult", "using", "a", "breadth", "-", "first", "traversal", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java#L539-L593
12,573
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
GPathResult.list
public List list() { final Iterator iter = nodeIterator(); final List result = new LinkedList(); while (iter.hasNext()) { result.add(new NodeChild((Node) iter.next(), this.parent, this.namespacePrefix, this.namespaceTagHints)); } return result; }
java
public List list() { final Iterator iter = nodeIterator(); final List result = new LinkedList(); while (iter.hasNext()) { result.add(new NodeChild((Node) iter.next(), this.parent, this.namespacePrefix, this.namespaceTagHints)); } return result; }
[ "public", "List", "list", "(", ")", "{", "final", "Iterator", "iter", "=", "nodeIterator", "(", ")", ";", "final", "List", "result", "=", "new", "LinkedList", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "result", ".", "add", "(", "new", "NodeChild", "(", "(", "Node", ")", "iter", ".", "next", "(", ")", ",", "this", ".", "parent", ",", "this", ".", "namespacePrefix", ",", "this", ".", "namespaceTagHints", ")", ")", ";", "}", "return", "result", ";", "}" ]
Creates a list of objects representing this GPathResult. @return a list representing of this GPathResult
[ "Creates", "a", "list", "of", "objects", "representing", "this", "GPathResult", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java#L600-L607
12,574
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java
GPathResult.getBody
public Closure getBody() { return new Closure(this.parent,this) { public void doCall(Object[] args) { final GroovyObject delegate = (GroovyObject)getDelegate(); final GPathResult thisObject = (GPathResult)getThisObject(); Node node = (Node)thisObject.getAt(0); List children = node.children(); for (Object child : children) { delegate.getProperty("mkp"); if (child instanceof Node) { delegate.invokeMethod("yield", new Object[]{new NodeChild((Node) child, thisObject, "*", null)}); } else { delegate.invokeMethod("yield", new Object[]{child}); } } } }; }
java
public Closure getBody() { return new Closure(this.parent,this) { public void doCall(Object[] args) { final GroovyObject delegate = (GroovyObject)getDelegate(); final GPathResult thisObject = (GPathResult)getThisObject(); Node node = (Node)thisObject.getAt(0); List children = node.children(); for (Object child : children) { delegate.getProperty("mkp"); if (child instanceof Node) { delegate.invokeMethod("yield", new Object[]{new NodeChild((Node) child, thisObject, "*", null)}); } else { delegate.invokeMethod("yield", new Object[]{child}); } } } }; }
[ "public", "Closure", "getBody", "(", ")", "{", "return", "new", "Closure", "(", "this", ".", "parent", ",", "this", ")", "{", "public", "void", "doCall", "(", "Object", "[", "]", "args", ")", "{", "final", "GroovyObject", "delegate", "=", "(", "GroovyObject", ")", "getDelegate", "(", ")", ";", "final", "GPathResult", "thisObject", "=", "(", "GPathResult", ")", "getThisObject", "(", ")", ";", "Node", "node", "=", "(", "Node", ")", "thisObject", ".", "getAt", "(", "0", ")", ";", "List", "children", "=", "node", ".", "children", "(", ")", ";", "for", "(", "Object", "child", ":", "children", ")", "{", "delegate", ".", "getProperty", "(", "\"mkp\"", ")", ";", "if", "(", "child", "instanceof", "Node", ")", "{", "delegate", ".", "invokeMethod", "(", "\"yield\"", ",", "new", "Object", "[", "]", "{", "new", "NodeChild", "(", "(", "Node", ")", "child", ",", "thisObject", ",", "\"*\"", ",", "null", ")", "}", ")", ";", "}", "else", "{", "delegate", ".", "invokeMethod", "(", "\"yield\"", ",", "new", "Object", "[", "]", "{", "child", "}", ")", ";", "}", "}", "}", "}", ";", "}" ]
Creates a Closure representing the body of this GPathResult. @return the body of this GPathResult, converted to a <code>Closure</code>
[ "Creates", "a", "Closure", "representing", "the", "body", "of", "this", "GPathResult", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/GPathResult.java#L623-L642
12,575
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ArrayTypeUtils.java
ArrayTypeUtils.dimension
public static int dimension(Class clazz) { checkArrayType(clazz); int result = 0; while (clazz.isArray()) { result++; clazz = clazz.getComponentType(); } return result; }
java
public static int dimension(Class clazz) { checkArrayType(clazz); int result = 0; while (clazz.isArray()) { result++; clazz = clazz.getComponentType(); } return result; }
[ "public", "static", "int", "dimension", "(", "Class", "clazz", ")", "{", "checkArrayType", "(", "clazz", ")", ";", "int", "result", "=", "0", ";", "while", "(", "clazz", ".", "isArray", "(", ")", ")", "{", "result", "++", ";", "clazz", "=", "clazz", ".", "getComponentType", "(", ")", ";", "}", "return", "result", ";", "}" ]
Calculate the dimension of array @param clazz the type of array @return the dimension of array
[ "Calculate", "the", "dimension", "of", "array" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ArrayTypeUtils.java#L33-L43
12,576
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ArrayTypeUtils.java
ArrayTypeUtils.elementType
public static Class elementType(Class clazz) { checkArrayType(clazz); while (clazz.isArray()) { clazz = clazz.getComponentType(); } return clazz; }
java
public static Class elementType(Class clazz) { checkArrayType(clazz); while (clazz.isArray()) { clazz = clazz.getComponentType(); } return clazz; }
[ "public", "static", "Class", "elementType", "(", "Class", "clazz", ")", "{", "checkArrayType", "(", "clazz", ")", ";", "while", "(", "clazz", ".", "isArray", "(", ")", ")", "{", "clazz", "=", "clazz", ".", "getComponentType", "(", ")", ";", "}", "return", "clazz", ";", "}" ]
Get the type of array elements @param clazz the type of array @return the type of elements
[ "Get", "the", "type", "of", "array", "elements" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ArrayTypeUtils.java#L51-L59
12,577
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ArrayTypeUtils.java
ArrayTypeUtils.elementType
public static Class elementType(Class clazz, int dim) { checkArrayType(clazz); if (dim < 0) { throw new IllegalArgumentException("The target dimension should not be less than zero: " + dim); } while (clazz.isArray() && dimension(clazz) > dim) { clazz = clazz.getComponentType(); } return clazz; }
java
public static Class elementType(Class clazz, int dim) { checkArrayType(clazz); if (dim < 0) { throw new IllegalArgumentException("The target dimension should not be less than zero: " + dim); } while (clazz.isArray() && dimension(clazz) > dim) { clazz = clazz.getComponentType(); } return clazz; }
[ "public", "static", "Class", "elementType", "(", "Class", "clazz", ",", "int", "dim", ")", "{", "checkArrayType", "(", "clazz", ")", ";", "if", "(", "dim", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The target dimension should not be less than zero: \"", "+", "dim", ")", ";", "}", "while", "(", "clazz", ".", "isArray", "(", ")", "&&", "dimension", "(", "clazz", ")", ">", "dim", ")", "{", "clazz", "=", "clazz", ".", "getComponentType", "(", ")", ";", "}", "return", "clazz", ";", "}" ]
Get the type of array elements by the dimension @param clazz the type of array @param dim the target dimension @return the result array
[ "Get", "the", "type", "of", "array", "elements", "by", "the", "dimension" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ArrayTypeUtils.java#L68-L80
12,578
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ArrayTypeUtils.java
ArrayTypeUtils.checkArrayType
private static void checkArrayType(Class clazz) { if (null == clazz) { throw new IllegalArgumentException("clazz can not be null"); } if (!clazz.isArray()) { throw new IllegalArgumentException(clazz.getCanonicalName() + " is not array type"); } }
java
private static void checkArrayType(Class clazz) { if (null == clazz) { throw new IllegalArgumentException("clazz can not be null"); } if (!clazz.isArray()) { throw new IllegalArgumentException(clazz.getCanonicalName() + " is not array type"); } }
[ "private", "static", "void", "checkArrayType", "(", "Class", "clazz", ")", "{", "if", "(", "null", "==", "clazz", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"clazz can not be null\"", ")", ";", "}", "if", "(", "!", "clazz", ".", "isArray", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "clazz", ".", "getCanonicalName", "(", ")", "+", "\" is not array type\"", ")", ";", "}", "}" ]
Check whether the type passed in is array type. If the type is not array type, throw IllegalArgumentException.
[ "Check", "whether", "the", "type", "passed", "in", "is", "array", "type", ".", "If", "the", "type", "is", "not", "array", "type", "throw", "IllegalArgumentException", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ArrayTypeUtils.java#L86-L94
12,579
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.getText
public static String getText(Process self) throws IOException { String text = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(self.getInputStream()))); closeStreams(self); return text; }
java
public static String getText(Process self) throws IOException { String text = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(self.getInputStream()))); closeStreams(self); return text; }
[ "public", "static", "String", "getText", "(", "Process", "self", ")", "throws", "IOException", "{", "String", "text", "=", "IOGroovyMethods", ".", "getText", "(", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "self", ".", "getInputStream", "(", ")", ")", ")", ")", ";", "closeStreams", "(", "self", ")", ";", "return", "text", ";", "}" ]
Read the text of the output stream of the Process. Closes all the streams associated with the process after retrieving the text. @param self a Process instance @return the text of the output @throws java.io.IOException if an IOException occurs. @since 1.0
[ "Read", "the", "text", "of", "the", "output", "stream", "of", "the", "Process", ".", "Closes", "all", "the", "streams", "associated", "with", "the", "process", "after", "retrieving", "the", "text", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L74-L78
12,580
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.leftShift
public static OutputStream leftShift(Process self, byte[] value) throws IOException { return IOGroovyMethods.leftShift(self.getOutputStream(), value); }
java
public static OutputStream leftShift(Process self, byte[] value) throws IOException { return IOGroovyMethods.leftShift(self.getOutputStream(), value); }
[ "public", "static", "OutputStream", "leftShift", "(", "Process", "self", ",", "byte", "[", "]", "value", ")", "throws", "IOException", "{", "return", "IOGroovyMethods", ".", "leftShift", "(", "self", ".", "getOutputStream", "(", ")", ",", "value", ")", ";", "}" ]
Overloads the left shift operator to provide an append mechanism to pipe into a Process @param self a Process instance @param value data to append @return an OutputStream @throws java.io.IOException if an IOException occurs. @since 1.0
[ "Overloads", "the", "left", "shift", "operator", "to", "provide", "an", "append", "mechanism", "to", "pipe", "into", "a", "Process" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L128-L130
12,581
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.waitForOrKill
public static void waitForOrKill(Process self, long numberOfMillis) { ProcessRunner runnable = new ProcessRunner(self); Thread thread = new Thread(runnable); thread.start(); runnable.waitForOrKill(numberOfMillis); }
java
public static void waitForOrKill(Process self, long numberOfMillis) { ProcessRunner runnable = new ProcessRunner(self); Thread thread = new Thread(runnable); thread.start(); runnable.waitForOrKill(numberOfMillis); }
[ "public", "static", "void", "waitForOrKill", "(", "Process", "self", ",", "long", "numberOfMillis", ")", "{", "ProcessRunner", "runnable", "=", "new", "ProcessRunner", "(", "self", ")", ";", "Thread", "thread", "=", "new", "Thread", "(", "runnable", ")", ";", "thread", ".", "start", "(", ")", ";", "runnable", ".", "waitForOrKill", "(", "numberOfMillis", ")", ";", "}" ]
Wait for the process to finish during a certain amount of time, otherwise stops the process. @param self a Process @param numberOfMillis the number of milliseconds to wait before stopping the process @since 1.0
[ "Wait", "for", "the", "process", "to", "finish", "during", "a", "certain", "amount", "of", "time", "otherwise", "stops", "the", "process", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L139-L144
12,582
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.consumeProcessErrorStream
public static Thread consumeProcessErrorStream(Process self, OutputStream err) { Thread thread = new Thread(new ByteDumper(self.getErrorStream(), err)); thread.start(); return thread; }
java
public static Thread consumeProcessErrorStream(Process self, OutputStream err) { Thread thread = new Thread(new ByteDumper(self.getErrorStream(), err)); thread.start(); return thread; }
[ "public", "static", "Thread", "consumeProcessErrorStream", "(", "Process", "self", ",", "OutputStream", "err", ")", "{", "Thread", "thread", "=", "new", "Thread", "(", "new", "ByteDumper", "(", "self", ".", "getErrorStream", "(", ")", ",", "err", ")", ")", ";", "thread", ".", "start", "(", ")", ";", "return", "thread", ";", "}" ]
Gets the error stream from a process and reads it to keep the process from blocking due to a full buffer. The processed stream data is appended to the supplied OutputStream. A new Thread is started, so this method will return immediately. @param self a Process @param err an OutputStream to capture the process stderr @return the Thread @since 1.5.2
[ "Gets", "the", "error", "stream", "from", "a", "process", "and", "reads", "it", "to", "keep", "the", "process", "from", "blocking", "due", "to", "a", "full", "buffer", ".", "The", "processed", "stream", "data", "is", "appended", "to", "the", "supplied", "OutputStream", ".", "A", "new", "Thread", "is", "started", "so", "this", "method", "will", "return", "immediately", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L283-L287
12,583
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.consumeProcessErrorStream
public static Thread consumeProcessErrorStream(Process self, Appendable error) { Thread thread = new Thread(new TextDumper(self.getErrorStream(), error)); thread.start(); return thread; }
java
public static Thread consumeProcessErrorStream(Process self, Appendable error) { Thread thread = new Thread(new TextDumper(self.getErrorStream(), error)); thread.start(); return thread; }
[ "public", "static", "Thread", "consumeProcessErrorStream", "(", "Process", "self", ",", "Appendable", "error", ")", "{", "Thread", "thread", "=", "new", "Thread", "(", "new", "TextDumper", "(", "self", ".", "getErrorStream", "(", ")", ",", "error", ")", ")", ";", "thread", ".", "start", "(", ")", ";", "return", "thread", ";", "}" ]
Gets the error stream from a process and reads it to keep the process from blocking due to a full buffer. The processed stream data is appended to the supplied Appendable. A new Thread is started, so this method will return immediately. @param self a Process @param error an Appendable to capture the process stderr @return the Thread @since 1.7.5
[ "Gets", "the", "error", "stream", "from", "a", "process", "and", "reads", "it", "to", "keep", "the", "process", "from", "blocking", "due", "to", "a", "full", "buffer", ".", "The", "processed", "stream", "data", "is", "appended", "to", "the", "supplied", "Appendable", ".", "A", "new", "Thread", "is", "started", "so", "this", "method", "will", "return", "immediately", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L300-L304
12,584
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.consumeProcessOutputStream
public static Thread consumeProcessOutputStream(Process self, Appendable output) { Thread thread = new Thread(new TextDumper(self.getInputStream(), output)); thread.start(); return thread; }
java
public static Thread consumeProcessOutputStream(Process self, Appendable output) { Thread thread = new Thread(new TextDumper(self.getInputStream(), output)); thread.start(); return thread; }
[ "public", "static", "Thread", "consumeProcessOutputStream", "(", "Process", "self", ",", "Appendable", "output", ")", "{", "Thread", "thread", "=", "new", "Thread", "(", "new", "TextDumper", "(", "self", ".", "getInputStream", "(", ")", ",", "output", ")", ")", ";", "thread", ".", "start", "(", ")", ";", "return", "thread", ";", "}" ]
Gets the output stream from a process and reads it to keep the process from blocking due to a full output buffer. The processed stream data is appended to the supplied Appendable. A new Thread is started, so this method will return immediately. @param self a Process @param output an Appendable to capture the process stdout @return the Thread @since 1.7.5
[ "Gets", "the", "output", "stream", "from", "a", "process", "and", "reads", "it", "to", "keep", "the", "process", "from", "blocking", "due", "to", "a", "full", "output", "buffer", ".", "The", "processed", "stream", "data", "is", "appended", "to", "the", "supplied", "Appendable", ".", "A", "new", "Thread", "is", "started", "so", "this", "method", "will", "return", "immediately", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L317-L321
12,585
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.consumeProcessOutputStream
public static Thread consumeProcessOutputStream(Process self, OutputStream output) { Thread thread = new Thread(new ByteDumper(self.getInputStream(), output)); thread.start(); return thread; }
java
public static Thread consumeProcessOutputStream(Process self, OutputStream output) { Thread thread = new Thread(new ByteDumper(self.getInputStream(), output)); thread.start(); return thread; }
[ "public", "static", "Thread", "consumeProcessOutputStream", "(", "Process", "self", ",", "OutputStream", "output", ")", "{", "Thread", "thread", "=", "new", "Thread", "(", "new", "ByteDumper", "(", "self", ".", "getInputStream", "(", ")", ",", "output", ")", ")", ";", "thread", ".", "start", "(", ")", ";", "return", "thread", ";", "}" ]
Gets the output stream from a process and reads it to keep the process from blocking due to a full output buffer. The processed stream data is appended to the supplied OutputStream. A new Thread is started, so this method will return immediately. @param self a Process @param output an OutputStream to capture the process stdout @return the Thread @since 1.5.2
[ "Gets", "the", "output", "stream", "from", "a", "process", "and", "reads", "it", "to", "keep", "the", "process", "from", "blocking", "due", "to", "a", "full", "output", "buffer", ".", "The", "processed", "stream", "data", "is", "appended", "to", "the", "supplied", "OutputStream", ".", "A", "new", "Thread", "is", "started", "so", "this", "method", "will", "return", "immediately", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L334-L338
12,586
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.withWriter
public static void withWriter(final Process self, final Closure closure) { new Thread(new Runnable() { public void run() { try { IOGroovyMethods.withWriter(new BufferedOutputStream(getOut(self)), closure); } catch (IOException e) { throw new GroovyRuntimeException("exception while reading process stream", e); } } }).start(); }
java
public static void withWriter(final Process self, final Closure closure) { new Thread(new Runnable() { public void run() { try { IOGroovyMethods.withWriter(new BufferedOutputStream(getOut(self)), closure); } catch (IOException e) { throw new GroovyRuntimeException("exception while reading process stream", e); } } }).start(); }
[ "public", "static", "void", "withWriter", "(", "final", "Process", "self", ",", "final", "Closure", "closure", ")", "{", "new", "Thread", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "IOGroovyMethods", ".", "withWriter", "(", "new", "BufferedOutputStream", "(", "getOut", "(", "self", ")", ")", ",", "closure", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "GroovyRuntimeException", "(", "\"exception while reading process stream\"", ",", "e", ")", ";", "}", "}", "}", ")", ".", "start", "(", ")", ";", "}" ]
Creates a new BufferedWriter as stdin for this process, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. A new Thread is started, so this method will return immediately. @param self a Process @param closure a closure @since 1.5.2
[ "Creates", "a", "new", "BufferedWriter", "as", "stdin", "for", "this", "process", "passes", "it", "to", "the", "closure", "and", "ensures", "the", "stream", "is", "flushed", "and", "closed", "after", "the", "closure", "returns", ".", "A", "new", "Thread", "is", "started", "so", "this", "method", "will", "return", "immediately", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L350-L360
12,587
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.pipeTo
public static Process pipeTo(final Process left, final Process right) throws IOException { new Thread(new Runnable() { public void run() { InputStream in = new BufferedInputStream(getIn(left)); OutputStream out = new BufferedOutputStream(getOut(right)); byte[] buf = new byte[8192]; int next; try { while ((next = in.read(buf)) != -1) { out.write(buf, 0, next); } } catch (IOException e) { throw new GroovyRuntimeException("exception while reading process stream", e); } finally { closeWithWarning(out); closeWithWarning(in); } } }).start(); return right; }
java
public static Process pipeTo(final Process left, final Process right) throws IOException { new Thread(new Runnable() { public void run() { InputStream in = new BufferedInputStream(getIn(left)); OutputStream out = new BufferedOutputStream(getOut(right)); byte[] buf = new byte[8192]; int next; try { while ((next = in.read(buf)) != -1) { out.write(buf, 0, next); } } catch (IOException e) { throw new GroovyRuntimeException("exception while reading process stream", e); } finally { closeWithWarning(out); closeWithWarning(in); } } }).start(); return right; }
[ "public", "static", "Process", "pipeTo", "(", "final", "Process", "left", ",", "final", "Process", "right", ")", "throws", "IOException", "{", "new", "Thread", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "InputStream", "in", "=", "new", "BufferedInputStream", "(", "getIn", "(", "left", ")", ")", ";", "OutputStream", "out", "=", "new", "BufferedOutputStream", "(", "getOut", "(", "right", ")", ")", ";", "byte", "[", "]", "buf", "=", "new", "byte", "[", "8192", "]", ";", "int", "next", ";", "try", "{", "while", "(", "(", "next", "=", "in", ".", "read", "(", "buf", ")", ")", "!=", "-", "1", ")", "{", "out", ".", "write", "(", "buf", ",", "0", ",", "next", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "GroovyRuntimeException", "(", "\"exception while reading process stream\"", ",", "e", ")", ";", "}", "finally", "{", "closeWithWarning", "(", "out", ")", ";", "closeWithWarning", "(", "in", ")", ";", "}", "}", "}", ")", ".", "start", "(", ")", ";", "return", "right", ";", "}" ]
Allows one Process to asynchronously pipe data to another Process. @param left a Process instance @param right a Process to pipe output to @return the second Process to allow chaining @throws java.io.IOException if an IOException occurs. @since 1.5.2
[ "Allows", "one", "Process", "to", "asynchronously", "pipe", "data", "to", "another", "Process", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L393-L413
12,588
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java
ProcessGroovyMethods.or
public static Process or(final Process left, final Process right) throws IOException { return pipeTo(left, right); }
java
public static Process or(final Process left, final Process right) throws IOException { return pipeTo(left, right); }
[ "public", "static", "Process", "or", "(", "final", "Process", "left", ",", "final", "Process", "right", ")", "throws", "IOException", "{", "return", "pipeTo", "(", "left", ",", "right", ")", ";", "}" ]
Overrides the or operator to allow one Process to asynchronously pipe data to another Process. @param left a Process instance @param right a Process to pipe output to @return the second Process to allow chaining @throws java.io.IOException if an IOException occurs. @since 1.5.1
[ "Overrides", "the", "or", "operator", "to", "allow", "one", "Process", "to", "asynchronously", "pipe", "data", "to", "another", "Process", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java#L425-L427
12,589
apache/groovy
src/main/java/org/codehaus/groovy/ast/MethodInvocationTrap.java
MethodInvocationTrap.visitMethodCallExpression
public void visitMethodCallExpression(MethodCallExpression call) { boolean shouldContinueWalking = true; if (isBuildInvocation(call)) { shouldContinueWalking = handleTargetMethodCallExpression(call); } if (shouldContinueWalking) { // continue normal tree walking call.getObjectExpression().visit(this); call.getMethod().visit(this); call.getArguments().visit(this); } }
java
public void visitMethodCallExpression(MethodCallExpression call) { boolean shouldContinueWalking = true; if (isBuildInvocation(call)) { shouldContinueWalking = handleTargetMethodCallExpression(call); } if (shouldContinueWalking) { // continue normal tree walking call.getObjectExpression().visit(this); call.getMethod().visit(this); call.getArguments().visit(this); } }
[ "public", "void", "visitMethodCallExpression", "(", "MethodCallExpression", "call", ")", "{", "boolean", "shouldContinueWalking", "=", "true", ";", "if", "(", "isBuildInvocation", "(", "call", ")", ")", "{", "shouldContinueWalking", "=", "handleTargetMethodCallExpression", "(", "call", ")", ";", "}", "if", "(", "shouldContinueWalking", ")", "{", "// continue normal tree walking", "call", ".", "getObjectExpression", "(", ")", ".", "visit", "(", "this", ")", ";", "call", ".", "getMethod", "(", ")", ".", "visit", "(", "this", ")", ";", "call", ".", "getArguments", "(", ")", ".", "visit", "(", "this", ")", ";", "}", "}" ]
Attempts to find AstBuilder 'from code' invocations. When found, converts them into calls to the 'from string' approach. @param call the method call expression that may or may not be an AstBuilder 'from code' invocation.
[ "Attempts", "to", "find", "AstBuilder", "from", "code", "invocations", ".", "When", "found", "converts", "them", "into", "calls", "to", "the", "from", "string", "approach", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/ast/MethodInvocationTrap.java#L47-L60
12,590
apache/groovy
subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetProxy.java
GroovyResultSetProxy.invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (method.getDeclaringClass() == GroovyObject.class) { if (name.equals("getMetaClass")) { return getMetaClass(); } else if (name.equals("setMetaClass")) { return setMetaClass((MetaClass) args[0]); } } return InvokerHelper.invokeMethod(extension, method.getName(), args); }
java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); if (method.getDeclaringClass() == GroovyObject.class) { if (name.equals("getMetaClass")) { return getMetaClass(); } else if (name.equals("setMetaClass")) { return setMetaClass((MetaClass) args[0]); } } return InvokerHelper.invokeMethod(extension, method.getName(), args); }
[ "public", "Object", "invoke", "(", "Object", "proxy", ",", "Method", "method", ",", "Object", "[", "]", "args", ")", "throws", "Throwable", "{", "String", "name", "=", "method", ".", "getName", "(", ")", ";", "if", "(", "method", ".", "getDeclaringClass", "(", ")", "==", "GroovyObject", ".", "class", ")", "{", "if", "(", "name", ".", "equals", "(", "\"getMetaClass\"", ")", ")", "{", "return", "getMetaClass", "(", ")", ";", "}", "else", "if", "(", "name", ".", "equals", "(", "\"setMetaClass\"", ")", ")", "{", "return", "setMetaClass", "(", "(", "MetaClass", ")", "args", "[", "0", "]", ")", ";", "}", "}", "return", "InvokerHelper", ".", "invokeMethod", "(", "extension", ",", "method", ".", "getName", "(", ")", ",", "args", ")", ";", "}" ]
Invokes a method for the GroovyResultSet. This will try to invoke the given method first on the extension and then on the result set given as proxy parameter. @param proxy the result set @param method the method name of this method will be used to make a call on the extension. If this fails the call will be done on the proxy instead @param args for the call @see ResultSet @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
[ "Invokes", "a", "method", "for", "the", "GroovyResultSet", ".", "This", "will", "try", "to", "invoke", "the", "given", "method", "first", "on", "the", "extension", "and", "then", "on", "the", "result", "set", "given", "as", "proxy", "parameter", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetProxy.java#L80-L91
12,591
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/xml/DOMBuilder.java
DOMBuilder.parse
public static Document parse(Reader reader) throws SAXException, IOException, ParserConfigurationException { return parse(reader, false, true); }
java
public static Document parse(Reader reader) throws SAXException, IOException, ParserConfigurationException { return parse(reader, false, true); }
[ "public", "static", "Document", "parse", "(", "Reader", "reader", ")", "throws", "SAXException", ",", "IOException", ",", "ParserConfigurationException", "{", "return", "parse", "(", "reader", ",", "false", ",", "true", ")", ";", "}" ]
Creates a DocumentBuilder and uses it to parse the XML text read from the given reader. A non-validating, namespace aware parser which does not allow DOCTYPE declarations is used. @param reader the reader to read the XML text from @return the root node of the parsed tree of Nodes @throws SAXException Any SAX exception, possibly wrapping another exception. @throws IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. @throws ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested. @see #parse(Reader, boolean, boolean)
[ "Creates", "a", "DocumentBuilder", "and", "uses", "it", "to", "parse", "the", "XML", "text", "read", "from", "the", "given", "reader", ".", "A", "non", "-", "validating", "namespace", "aware", "parser", "which", "does", "not", "allow", "DOCTYPE", "declarations", "is", "used", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/xml/DOMBuilder.java#L70-L72
12,592
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/xml/DOMBuilder.java
DOMBuilder.parse
public static Document parse(Reader reader, boolean validating, boolean namespaceAware) throws SAXException, IOException, ParserConfigurationException { return parse(reader, validating, namespaceAware, false); }
java
public static Document parse(Reader reader, boolean validating, boolean namespaceAware) throws SAXException, IOException, ParserConfigurationException { return parse(reader, validating, namespaceAware, false); }
[ "public", "static", "Document", "parse", "(", "Reader", "reader", ",", "boolean", "validating", ",", "boolean", "namespaceAware", ")", "throws", "SAXException", ",", "IOException", ",", "ParserConfigurationException", "{", "return", "parse", "(", "reader", ",", "validating", ",", "namespaceAware", ",", "false", ")", ";", "}" ]
Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation and namespace awareness to be controlled. Documents are not allowed to contain DOCYTYPE declarations. @param reader the reader to read the XML text from @param validating whether to validate the XML @param namespaceAware whether the parser should be namespace aware @return the root node of the parsed tree of Nodes @throws SAXException Any SAX exception, possibly wrapping another exception. @throws IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. @throws ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested.
[ "Creates", "a", "DocumentBuilder", "and", "uses", "it", "to", "parse", "the", "XML", "text", "read", "from", "the", "given", "reader", "allowing", "parser", "validation", "and", "namespace", "awareness", "to", "be", "controlled", ".", "Documents", "are", "not", "allowed", "to", "contain", "DOCYTYPE", "declarations", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/xml/DOMBuilder.java#L89-L92
12,593
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/xml/DOMBuilder.java
DOMBuilder.parse
public static Document parse(Reader reader, boolean validating, boolean namespaceAware, boolean allowDocTypeDeclaration) throws SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory factory = FactorySupport.createDocumentBuilderFactory(); factory.setNamespaceAware(namespaceAware); factory.setValidating(validating); setQuietly(factory, XMLConstants.FEATURE_SECURE_PROCESSING, true); setQuietly(factory, "http://apache.org/xml/features/disallow-doctype-decl", !allowDocTypeDeclaration); DocumentBuilder documentBuilder = factory.newDocumentBuilder(); return documentBuilder.parse(new InputSource(reader)); }
java
public static Document parse(Reader reader, boolean validating, boolean namespaceAware, boolean allowDocTypeDeclaration) throws SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory factory = FactorySupport.createDocumentBuilderFactory(); factory.setNamespaceAware(namespaceAware); factory.setValidating(validating); setQuietly(factory, XMLConstants.FEATURE_SECURE_PROCESSING, true); setQuietly(factory, "http://apache.org/xml/features/disallow-doctype-decl", !allowDocTypeDeclaration); DocumentBuilder documentBuilder = factory.newDocumentBuilder(); return documentBuilder.parse(new InputSource(reader)); }
[ "public", "static", "Document", "parse", "(", "Reader", "reader", ",", "boolean", "validating", ",", "boolean", "namespaceAware", ",", "boolean", "allowDocTypeDeclaration", ")", "throws", "SAXException", ",", "IOException", ",", "ParserConfigurationException", "{", "DocumentBuilderFactory", "factory", "=", "FactorySupport", ".", "createDocumentBuilderFactory", "(", ")", ";", "factory", ".", "setNamespaceAware", "(", "namespaceAware", ")", ";", "factory", ".", "setValidating", "(", "validating", ")", ";", "setQuietly", "(", "factory", ",", "XMLConstants", ".", "FEATURE_SECURE_PROCESSING", ",", "true", ")", ";", "setQuietly", "(", "factory", ",", "\"http://apache.org/xml/features/disallow-doctype-decl\"", ",", "!", "allowDocTypeDeclaration", ")", ";", "DocumentBuilder", "documentBuilder", "=", "factory", ".", "newDocumentBuilder", "(", ")", ";", "return", "documentBuilder", ".", "parse", "(", "new", "InputSource", "(", "reader", ")", ")", ";", "}" ]
Creates a DocumentBuilder and uses it to parse the XML text read from the given reader, allowing parser validation, namespace awareness and permission of DOCTYPE declarations to be controlled. @param reader the reader to read the XML text from @param validating whether to validate the XML @param namespaceAware whether the parser should be namespace aware @param allowDocTypeDeclaration whether the parser should allow DOCTYPE declarations @return the root node of the parsed tree of Nodes @throws SAXException Any SAX exception, possibly wrapping another exception. @throws IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. @throws ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested.
[ "Creates", "a", "DocumentBuilder", "and", "uses", "it", "to", "parse", "the", "XML", "text", "read", "from", "the", "given", "reader", "allowing", "parser", "validation", "namespace", "awareness", "and", "permission", "of", "DOCTYPE", "declarations", "to", "be", "controlled", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/xml/DOMBuilder.java#L109-L118
12,594
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/xml/DOMBuilder.java
DOMBuilder.parseText
public Document parseText(String text) throws SAXException, IOException, ParserConfigurationException { return parse(new StringReader(text)); }
java
public Document parseText(String text) throws SAXException, IOException, ParserConfigurationException { return parse(new StringReader(text)); }
[ "public", "Document", "parseText", "(", "String", "text", ")", "throws", "SAXException", ",", "IOException", ",", "ParserConfigurationException", "{", "return", "parse", "(", "new", "StringReader", "(", "text", ")", ")", ";", "}" ]
A helper method to parse the given text as XML. @param text the XML text to parse @return the root node of the parsed tree of Nodes @throws SAXException Any SAX exception, possibly wrapping another exception. @throws IOException An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. @throws ParserConfigurationException if a DocumentBuilder cannot be created which satisfies the configuration requested. @see #parse(Reader)
[ "A", "helper", "method", "to", "parse", "the", "given", "text", "as", "XML", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/xml/DOMBuilder.java#L139-L141
12,595
apache/groovy
subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
AstBuilder.visit
@Override public Object visit(ParseTree tree) { if (!asBoolean(tree)) { return null; } return super.visit(tree); }
java
@Override public Object visit(ParseTree tree) { if (!asBoolean(tree)) { return null; } return super.visit(tree); }
[ "@", "Override", "public", "Object", "visit", "(", "ParseTree", "tree", ")", "{", "if", "(", "!", "asBoolean", "(", "tree", ")", ")", "{", "return", "null", ";", "}", "return", "super", ".", "visit", "(", "tree", ")", ";", "}" ]
Visit tree safely, no NPE occurred when the tree is null. @param tree an AST node @return the visiting result
[ "Visit", "tree", "safely", "no", "NPE", "occurred", "when", "the", "tree", "is", "null", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java#L4306-L4313
12,596
apache/groovy
subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
AstBuilder.configureScriptClassNode
private void configureScriptClassNode() { ClassNode scriptClassNode = moduleNode.getScriptClassDummy(); if (!asBoolean(scriptClassNode)) { return; } List<Statement> statements = moduleNode.getStatementBlock().getStatements(); if (!statements.isEmpty()) { Statement firstStatement = statements.get(0); Statement lastStatement = statements.get(statements.size() - 1); scriptClassNode.setSourcePosition(firstStatement); scriptClassNode.setLastColumnNumber(lastStatement.getLastColumnNumber()); scriptClassNode.setLastLineNumber(lastStatement.getLastLineNumber()); } }
java
private void configureScriptClassNode() { ClassNode scriptClassNode = moduleNode.getScriptClassDummy(); if (!asBoolean(scriptClassNode)) { return; } List<Statement> statements = moduleNode.getStatementBlock().getStatements(); if (!statements.isEmpty()) { Statement firstStatement = statements.get(0); Statement lastStatement = statements.get(statements.size() - 1); scriptClassNode.setSourcePosition(firstStatement); scriptClassNode.setLastColumnNumber(lastStatement.getLastColumnNumber()); scriptClassNode.setLastLineNumber(lastStatement.getLastLineNumber()); } }
[ "private", "void", "configureScriptClassNode", "(", ")", "{", "ClassNode", "scriptClassNode", "=", "moduleNode", ".", "getScriptClassDummy", "(", ")", ";", "if", "(", "!", "asBoolean", "(", "scriptClassNode", ")", ")", "{", "return", ";", "}", "List", "<", "Statement", ">", "statements", "=", "moduleNode", ".", "getStatementBlock", "(", ")", ".", "getStatements", "(", ")", ";", "if", "(", "!", "statements", ".", "isEmpty", "(", ")", ")", "{", "Statement", "firstStatement", "=", "statements", ".", "get", "(", "0", ")", ";", "Statement", "lastStatement", "=", "statements", ".", "get", "(", "statements", ".", "size", "(", ")", "-", "1", ")", ";", "scriptClassNode", ".", "setSourcePosition", "(", "firstStatement", ")", ";", "scriptClassNode", ".", "setLastColumnNumber", "(", "lastStatement", ".", "getLastColumnNumber", "(", ")", ")", ";", "scriptClassNode", ".", "setLastLineNumber", "(", "lastStatement", ".", "getLastLineNumber", "(", ")", ")", ";", "}", "}" ]
set the script source position
[ "set", "the", "script", "source", "position" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java#L4591-L4608
12,597
apache/groovy
src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
Selector.getSelector
public static Selector getSelector(MutableCallSite callSite, Class sender, String methodName, int callID, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments) { CALL_TYPES callType = CALL_TYPES_VALUES[callID]; switch (callType) { case INIT: return new InitSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments); case METHOD: return new MethodSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments); case GET: return new PropertySelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments); case SET: throw new GroovyBugError("your call tried to do a property set, which is not supported."); case CAST: return new CastSelector(callSite, arguments); default: throw new GroovyBugError("unexpected call type"); } }
java
public static Selector getSelector(MutableCallSite callSite, Class sender, String methodName, int callID, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments) { CALL_TYPES callType = CALL_TYPES_VALUES[callID]; switch (callType) { case INIT: return new InitSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments); case METHOD: return new MethodSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments); case GET: return new PropertySelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments); case SET: throw new GroovyBugError("your call tried to do a property set, which is not supported."); case CAST: return new CastSelector(callSite, arguments); default: throw new GroovyBugError("unexpected call type"); } }
[ "public", "static", "Selector", "getSelector", "(", "MutableCallSite", "callSite", ",", "Class", "sender", ",", "String", "methodName", ",", "int", "callID", ",", "boolean", "safeNavigation", ",", "boolean", "thisCall", ",", "boolean", "spreadCall", ",", "Object", "[", "]", "arguments", ")", "{", "CALL_TYPES", "callType", "=", "CALL_TYPES_VALUES", "[", "callID", "]", ";", "switch", "(", "callType", ")", "{", "case", "INIT", ":", "return", "new", "InitSelector", "(", "callSite", ",", "sender", ",", "methodName", ",", "callType", ",", "safeNavigation", ",", "thisCall", ",", "spreadCall", ",", "arguments", ")", ";", "case", "METHOD", ":", "return", "new", "MethodSelector", "(", "callSite", ",", "sender", ",", "methodName", ",", "callType", ",", "safeNavigation", ",", "thisCall", ",", "spreadCall", ",", "arguments", ")", ";", "case", "GET", ":", "return", "new", "PropertySelector", "(", "callSite", ",", "sender", ",", "methodName", ",", "callType", ",", "safeNavigation", ",", "thisCall", ",", "spreadCall", ",", "arguments", ")", ";", "case", "SET", ":", "throw", "new", "GroovyBugError", "(", "\"your call tried to do a property set, which is not supported.\"", ")", ";", "case", "CAST", ":", "return", "new", "CastSelector", "(", "callSite", ",", "arguments", ")", ";", "default", ":", "throw", "new", "GroovyBugError", "(", "\"unexpected call type\"", ")", ";", "}", "}" ]
Returns the Selector
[ "Returns", "the", "Selector" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java#L123-L135
12,598
apache/groovy
src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
Selector.getMetaClassImpl
private static MetaClassImpl getMetaClassImpl(MetaClass mc, boolean includeEMC) { Class mcc = mc.getClass(); boolean valid = mcc == MetaClassImpl.class || mcc == AdaptingMetaClass.class || mcc == ClosureMetaClass.class || (includeEMC && mcc == ExpandoMetaClass.class); if (!valid) { if (LOG_ENABLED) LOG.info("meta class is neither MetaClassImpl, nor AdoptingMetaClass, nor ClosureMetaClass, normal method selection path disabled."); return null; } if (LOG_ENABLED) LOG.info("meta class is a recognized MetaClassImpl"); return (MetaClassImpl) mc; }
java
private static MetaClassImpl getMetaClassImpl(MetaClass mc, boolean includeEMC) { Class mcc = mc.getClass(); boolean valid = mcc == MetaClassImpl.class || mcc == AdaptingMetaClass.class || mcc == ClosureMetaClass.class || (includeEMC && mcc == ExpandoMetaClass.class); if (!valid) { if (LOG_ENABLED) LOG.info("meta class is neither MetaClassImpl, nor AdoptingMetaClass, nor ClosureMetaClass, normal method selection path disabled."); return null; } if (LOG_ENABLED) LOG.info("meta class is a recognized MetaClassImpl"); return (MetaClassImpl) mc; }
[ "private", "static", "MetaClassImpl", "getMetaClassImpl", "(", "MetaClass", "mc", ",", "boolean", "includeEMC", ")", "{", "Class", "mcc", "=", "mc", ".", "getClass", "(", ")", ";", "boolean", "valid", "=", "mcc", "==", "MetaClassImpl", ".", "class", "||", "mcc", "==", "AdaptingMetaClass", ".", "class", "||", "mcc", "==", "ClosureMetaClass", ".", "class", "||", "(", "includeEMC", "&&", "mcc", "==", "ExpandoMetaClass", ".", "class", ")", ";", "if", "(", "!", "valid", ")", "{", "if", "(", "LOG_ENABLED", ")", "LOG", ".", "info", "(", "\"meta class is neither MetaClassImpl, nor AdoptingMetaClass, nor ClosureMetaClass, normal method selection path disabled.\"", ")", ";", "return", "null", ";", "}", "if", "(", "LOG_ENABLED", ")", "LOG", ".", "info", "(", "\"meta class is a recognized MetaClassImpl\"", ")", ";", "return", "(", "MetaClassImpl", ")", "mc", ";", "}" ]
Returns the MetaClassImpl if the given MetaClass is one of MetaClassImpl, AdaptingMetaClass or ClosureMetaClass. If none of these cases matches, this method returns null.
[ "Returns", "the", "MetaClassImpl", "if", "the", "given", "MetaClass", "is", "one", "of", "MetaClassImpl", "AdaptingMetaClass", "or", "ClosureMetaClass", ".", "If", "none", "of", "these", "cases", "matches", "this", "method", "returns", "null", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java#L1045-L1057
12,599
apache/groovy
src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
Selector.removeRealReceiver
private static Object[] removeRealReceiver(Object[] args) { Object[] ar = new Object[args.length-1]; System.arraycopy(args, 1, ar, 0, args.length - 1); return ar; }
java
private static Object[] removeRealReceiver(Object[] args) { Object[] ar = new Object[args.length-1]; System.arraycopy(args, 1, ar, 0, args.length - 1); return ar; }
[ "private", "static", "Object", "[", "]", "removeRealReceiver", "(", "Object", "[", "]", "args", ")", "{", "Object", "[", "]", "ar", "=", "new", "Object", "[", "args", ".", "length", "-", "1", "]", ";", "System", ".", "arraycopy", "(", "args", ",", "1", ",", "ar", ",", "0", ",", "args", ".", "length", "-", "1", ")", ";", "return", "ar", ";", "}" ]
Helper method to remove the receiver from the argument array by producing a new array.
[ "Helper", "method", "to", "remove", "the", "receiver", "from", "the", "argument", "array", "by", "producing", "a", "new", "array", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java#L1063-L1067