repository_name
stringlengths 7
58
| func_path_in_repository
stringlengths 11
218
| func_name
stringlengths 4
140
| whole_func_string
stringlengths 153
5.32k
| language
stringclasses 1
value | func_code_string
stringlengths 72
4k
| func_code_tokens
sequencelengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
sequencelengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
geomajas/geomajas-project-client-gwt2 | plugin/tilebasedlayer/impl/src/main/java/org/geomajas/gwt2/plugin/tilebasedlayer/client/TileBasedLayerClient.java | TileBasedLayerClient.createOsmMap | public MapConfiguration createOsmMap(int nrOfLevels) {
"""
Create an OSM compliant map configuration with this number of zoom levels.
@param nrOfLevels
@return
"""
MapConfiguration configuration = new MapConfigurationImpl();
Bbox bounds = new Bbox(-OSM_HALF_WIDTH, -OSM_HALF_WIDTH, 2 * OSM_HALF_WIDTH, 2 * OSM_HALF_WIDTH);
configuration.setCrs(OSM_EPSG, CrsType.METRIC);
configuration.setHintValue(MapConfiguration.INITIAL_BOUNDS, bounds);
configuration.setMaxBounds(Bbox.ALL);
List<Double> resolutions = new ArrayList<Double>();
for (int i = 0; i < nrOfLevels; i++) {
resolutions.add(OSM_HALF_WIDTH / (OSM_TILE_SIZE * Math.pow(2, i - 1)));
}
configuration.setResolutions(resolutions);
return configuration;
} | java | public MapConfiguration createOsmMap(int nrOfLevels) {
MapConfiguration configuration = new MapConfigurationImpl();
Bbox bounds = new Bbox(-OSM_HALF_WIDTH, -OSM_HALF_WIDTH, 2 * OSM_HALF_WIDTH, 2 * OSM_HALF_WIDTH);
configuration.setCrs(OSM_EPSG, CrsType.METRIC);
configuration.setHintValue(MapConfiguration.INITIAL_BOUNDS, bounds);
configuration.setMaxBounds(Bbox.ALL);
List<Double> resolutions = new ArrayList<Double>();
for (int i = 0; i < nrOfLevels; i++) {
resolutions.add(OSM_HALF_WIDTH / (OSM_TILE_SIZE * Math.pow(2, i - 1)));
}
configuration.setResolutions(resolutions);
return configuration;
} | [
"public",
"MapConfiguration",
"createOsmMap",
"(",
"int",
"nrOfLevels",
")",
"{",
"MapConfiguration",
"configuration",
"=",
"new",
"MapConfigurationImpl",
"(",
")",
";",
"Bbox",
"bounds",
"=",
"new",
"Bbox",
"(",
"-",
"OSM_HALF_WIDTH",
",",
"-",
"OSM_HALF_WIDTH",
",",
"2",
"*",
"OSM_HALF_WIDTH",
",",
"2",
"*",
"OSM_HALF_WIDTH",
")",
";",
"configuration",
".",
"setCrs",
"(",
"OSM_EPSG",
",",
"CrsType",
".",
"METRIC",
")",
";",
"configuration",
".",
"setHintValue",
"(",
"MapConfiguration",
".",
"INITIAL_BOUNDS",
",",
"bounds",
")",
";",
"configuration",
".",
"setMaxBounds",
"(",
"Bbox",
".",
"ALL",
")",
";",
"List",
"<",
"Double",
">",
"resolutions",
"=",
"new",
"ArrayList",
"<",
"Double",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nrOfLevels",
";",
"i",
"++",
")",
"{",
"resolutions",
".",
"add",
"(",
"OSM_HALF_WIDTH",
"/",
"(",
"OSM_TILE_SIZE",
"*",
"Math",
".",
"pow",
"(",
"2",
",",
"i",
"-",
"1",
")",
")",
")",
";",
"}",
"configuration",
".",
"setResolutions",
"(",
"resolutions",
")",
";",
"return",
"configuration",
";",
"}"
] | Create an OSM compliant map configuration with this number of zoom levels.
@param nrOfLevels
@return | [
"Create",
"an",
"OSM",
"compliant",
"map",
"configuration",
"with",
"this",
"number",
"of",
"zoom",
"levels",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt2/blob/bd8d7904e861fa80522eed7b83c4ea99844180c7/plugin/tilebasedlayer/impl/src/main/java/org/geomajas/gwt2/plugin/tilebasedlayer/client/TileBasedLayerClient.java#L94-L106 |
jbundle/jbundle | base/remote/src/main/java/org/jbundle/base/remote/message/ReceiveQueueSession.java | ReceiveQueueSession.updateRemoteFilterProperties | public void updateRemoteFilterProperties(BaseMessageFilter messageFilter, Object[][] mxProperties, Map<String,Object> propFilter) throws RemoteException {
"""
Update this filter with this new information.
@param messageFilter The message filter I am updating.
@param properties New filter information (ie, bookmark=345).
"""
Utility.getLogger().info("EJB updateRemoteFilter properties: " + mxProperties);
// Give the filter the remote environment
MessageManager messageManager = ((Application)this.getTask().getApplication()).getMessageManager();
messageFilter = ((BaseMessageReceiver)messageManager.getMessageQueue(messageFilter.getQueueName(), messageFilter.getQueueType()).getMessageReceiver()).getMessageFilter(messageFilter.getRemoteFilterID()); // Must look it up
if (messageFilter != null) // Always
{
if (mxProperties != null)
messageFilter.setFilterTree(mxProperties);
if (propFilter != null)
{
propFilter = messageFilter.handleUpdateFilterMap(propFilter); // Update this object's local filter.
messageFilter.setFilterMap(propFilter); // Update any remote copy of this.
}
}
} | java | public void updateRemoteFilterProperties(BaseMessageFilter messageFilter, Object[][] mxProperties, Map<String,Object> propFilter) throws RemoteException
{
Utility.getLogger().info("EJB updateRemoteFilter properties: " + mxProperties);
// Give the filter the remote environment
MessageManager messageManager = ((Application)this.getTask().getApplication()).getMessageManager();
messageFilter = ((BaseMessageReceiver)messageManager.getMessageQueue(messageFilter.getQueueName(), messageFilter.getQueueType()).getMessageReceiver()).getMessageFilter(messageFilter.getRemoteFilterID()); // Must look it up
if (messageFilter != null) // Always
{
if (mxProperties != null)
messageFilter.setFilterTree(mxProperties);
if (propFilter != null)
{
propFilter = messageFilter.handleUpdateFilterMap(propFilter); // Update this object's local filter.
messageFilter.setFilterMap(propFilter); // Update any remote copy of this.
}
}
} | [
"public",
"void",
"updateRemoteFilterProperties",
"(",
"BaseMessageFilter",
"messageFilter",
",",
"Object",
"[",
"]",
"[",
"]",
"mxProperties",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"propFilter",
")",
"throws",
"RemoteException",
"{",
"Utility",
".",
"getLogger",
"(",
")",
".",
"info",
"(",
"\"EJB updateRemoteFilter properties: \"",
"+",
"mxProperties",
")",
";",
"// Give the filter the remote environment",
"MessageManager",
"messageManager",
"=",
"(",
"(",
"Application",
")",
"this",
".",
"getTask",
"(",
")",
".",
"getApplication",
"(",
")",
")",
".",
"getMessageManager",
"(",
")",
";",
"messageFilter",
"=",
"(",
"(",
"BaseMessageReceiver",
")",
"messageManager",
".",
"getMessageQueue",
"(",
"messageFilter",
".",
"getQueueName",
"(",
")",
",",
"messageFilter",
".",
"getQueueType",
"(",
")",
")",
".",
"getMessageReceiver",
"(",
")",
")",
".",
"getMessageFilter",
"(",
"messageFilter",
".",
"getRemoteFilterID",
"(",
")",
")",
";",
"// Must look it up",
"if",
"(",
"messageFilter",
"!=",
"null",
")",
"// Always",
"{",
"if",
"(",
"mxProperties",
"!=",
"null",
")",
"messageFilter",
".",
"setFilterTree",
"(",
"mxProperties",
")",
";",
"if",
"(",
"propFilter",
"!=",
"null",
")",
"{",
"propFilter",
"=",
"messageFilter",
".",
"handleUpdateFilterMap",
"(",
"propFilter",
")",
";",
"// Update this object's local filter.",
"messageFilter",
".",
"setFilterMap",
"(",
"propFilter",
")",
";",
"// Update any remote copy of this.",
"}",
"}",
"}"
] | Update this filter with this new information.
@param messageFilter The message filter I am updating.
@param properties New filter information (ie, bookmark=345). | [
"Update",
"this",
"filter",
"with",
"this",
"new",
"information",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/remote/src/main/java/org/jbundle/base/remote/message/ReceiveQueueSession.java#L199-L215 |
jtablesaw/tablesaw | core/src/main/java/tech/tablesaw/api/Table.java | Table.first | private static Sort first(String columnName, Sort.Order order) {
"""
Returns a sort Key that can be used for simple or chained comparator sorting
<p>
You can extend the sort key by using .next() to fill more columns to the sort order
"""
return Sort.on(columnName, order);
} | java | private static Sort first(String columnName, Sort.Order order) {
return Sort.on(columnName, order);
} | [
"private",
"static",
"Sort",
"first",
"(",
"String",
"columnName",
",",
"Sort",
".",
"Order",
"order",
")",
"{",
"return",
"Sort",
".",
"on",
"(",
"columnName",
",",
"order",
")",
";",
"}"
] | Returns a sort Key that can be used for simple or chained comparator sorting
<p>
You can extend the sort key by using .next() to fill more columns to the sort order | [
"Returns",
"a",
"sort",
"Key",
"that",
"can",
"be",
"used",
"for",
"simple",
"or",
"chained",
"comparator",
"sorting",
"<p",
">",
"You",
"can",
"extend",
"the",
"sort",
"key",
"by",
"using",
".",
"next",
"()",
"to",
"fill",
"more",
"columns",
"to",
"the",
"sort",
"order"
] | train | https://github.com/jtablesaw/tablesaw/blob/68a75b4098ac677e9486df5572cf13ec39f9f701/core/src/main/java/tech/tablesaw/api/Table.java#L171-L173 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/VersionsImpl.java | VersionsImpl.cloneWithServiceResponseAsync | public Observable<ServiceResponse<String>> cloneWithServiceResponseAsync(UUID appId, String versionId, CloneOptionalParameter cloneOptionalParameter) {
"""
Creates a new version using the current snapshot of the selected application version.
@param appId The application ID.
@param versionId The version ID.
@param cloneOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the String object
"""
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
final String version = cloneOptionalParameter != null ? cloneOptionalParameter.version() : null;
return cloneWithServiceResponseAsync(appId, versionId, version);
} | java | public Observable<ServiceResponse<String>> cloneWithServiceResponseAsync(UUID appId, String versionId, CloneOptionalParameter cloneOptionalParameter) {
if (this.client.endpoint() == null) {
throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null.");
}
if (appId == null) {
throw new IllegalArgumentException("Parameter appId is required and cannot be null.");
}
if (versionId == null) {
throw new IllegalArgumentException("Parameter versionId is required and cannot be null.");
}
final String version = cloneOptionalParameter != null ? cloneOptionalParameter.version() : null;
return cloneWithServiceResponseAsync(appId, versionId, version);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"String",
">",
">",
"cloneWithServiceResponseAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"CloneOptionalParameter",
"cloneOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"endpoint",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.endpoint() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"appId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter appId is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"versionId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter versionId is required and cannot be null.\"",
")",
";",
"}",
"final",
"String",
"version",
"=",
"cloneOptionalParameter",
"!=",
"null",
"?",
"cloneOptionalParameter",
".",
"version",
"(",
")",
":",
"null",
";",
"return",
"cloneWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"version",
")",
";",
"}"
] | Creates a new version using the current snapshot of the selected application version.
@param appId The application ID.
@param versionId The version ID.
@param cloneOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the String object | [
"Creates",
"a",
"new",
"version",
"using",
"the",
"current",
"snapshot",
"of",
"the",
"selected",
"application",
"version",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/VersionsImpl.java#L162-L175 |
Scout24/appmon4j | core/src/main/java/de/is24/util/monitoring/InApplicationMonitor.java | InApplicationMonitor.incrementCounter | public void incrementCounter(String name, int increment) {
"""
<p>Increase the specified counter by a variable amount.</p>
@param name
the name of the {@code Counter} to increase
@param increment
the added to add
"""
if (monitorActive) {
String escapedName = keyHandler.handle(name);
for (MonitorPlugin p : getPlugins()) {
p.incrementCounter(escapedName, increment);
}
}
} | java | public void incrementCounter(String name, int increment) {
if (monitorActive) {
String escapedName = keyHandler.handle(name);
for (MonitorPlugin p : getPlugins()) {
p.incrementCounter(escapedName, increment);
}
}
} | [
"public",
"void",
"incrementCounter",
"(",
"String",
"name",
",",
"int",
"increment",
")",
"{",
"if",
"(",
"monitorActive",
")",
"{",
"String",
"escapedName",
"=",
"keyHandler",
".",
"handle",
"(",
"name",
")",
";",
"for",
"(",
"MonitorPlugin",
"p",
":",
"getPlugins",
"(",
")",
")",
"{",
"p",
".",
"incrementCounter",
"(",
"escapedName",
",",
"increment",
")",
";",
"}",
"}",
"}"
] | <p>Increase the specified counter by a variable amount.</p>
@param name
the name of the {@code Counter} to increase
@param increment
the added to add | [
"<p",
">",
"Increase",
"the",
"specified",
"counter",
"by",
"a",
"variable",
"amount",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/Scout24/appmon4j/blob/a662e5123805ea455cfd01e1b9ae5d808f83529c/core/src/main/java/de/is24/util/monitoring/InApplicationMonitor.java#L197-L204 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/JSField.java | JSField.estimateSizeOfUnassembledValue | public int estimateSizeOfUnassembledValue(byte[] frame, int offset, int indirect) {
"""
estimateSizeOfUnassembledValue
Return the estimated size of the value if unassembled.
This size includes a guess at the heap overhead of the object(s) which
would be created.
@param frame the byte array from which the object would be deserialized.
@param offset the byte at which to start in frame
@param indirect the list indirection that applies to the object or -1 if the
JSField's maximum list indirection (based on the number of JSRepeated nodes that
dominate it in the schema) is to be used: this, of course, includes the possibility
that it isn't a list at all.
@return int the estimated size of the unassembled object in the heap.
"""
if (indirect == 0)
return estimateUnassembledSize(frame, offset);
else
return coder.estimateUnassembledSize(frame, offset);
} | java | public int estimateSizeOfUnassembledValue(byte[] frame, int offset, int indirect) {
if (indirect == 0)
return estimateUnassembledSize(frame, offset);
else
return coder.estimateUnassembledSize(frame, offset);
} | [
"public",
"int",
"estimateSizeOfUnassembledValue",
"(",
"byte",
"[",
"]",
"frame",
",",
"int",
"offset",
",",
"int",
"indirect",
")",
"{",
"if",
"(",
"indirect",
"==",
"0",
")",
"return",
"estimateUnassembledSize",
"(",
"frame",
",",
"offset",
")",
";",
"else",
"return",
"coder",
".",
"estimateUnassembledSize",
"(",
"frame",
",",
"offset",
")",
";",
"}"
] | estimateSizeOfUnassembledValue
Return the estimated size of the value if unassembled.
This size includes a guess at the heap overhead of the object(s) which
would be created.
@param frame the byte array from which the object would be deserialized.
@param offset the byte at which to start in frame
@param indirect the list indirection that applies to the object or -1 if the
JSField's maximum list indirection (based on the number of JSRepeated nodes that
dominate it in the schema) is to be used: this, of course, includes the possibility
that it isn't a list at all.
@return int the estimated size of the unassembled object in the heap. | [
"estimateSizeOfUnassembledValue",
"Return",
"the",
"estimated",
"size",
"of",
"the",
"value",
"if",
"unassembled",
".",
"This",
"size",
"includes",
"a",
"guess",
"at",
"the",
"heap",
"overhead",
"of",
"the",
"object",
"(",
"s",
")",
"which",
"would",
"be",
"created",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/jmf/impl/JSField.java#L222-L227 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/fastpath/Fastpath.java | Fastpath.getID | public int getID(String name) throws SQLException {
"""
<p>This returns the function id associated by its name.</p>
<p>If addFunction() or addFunctions() have not been called for this name, then an SQLException is
thrown.</p>
@param name Function name to lookup
@return Function ID for fastpath call
@throws SQLException is function is unknown.
"""
Integer id = func.get(name);
// may be we could add a lookup to the database here, and store the result
// in our lookup table, throwing the exception if that fails.
// We must, however, ensure that if we do, any existing ResultSet is
// unaffected, otherwise we could break user code.
//
// so, until we know we can do this (needs testing, on the TODO list)
// for now, we throw the exception and do no lookups.
if (id == null) {
throw new PSQLException(GT.tr("The fastpath function {0} is unknown.", name),
PSQLState.UNEXPECTED_ERROR);
}
return id;
} | java | public int getID(String name) throws SQLException {
Integer id = func.get(name);
// may be we could add a lookup to the database here, and store the result
// in our lookup table, throwing the exception if that fails.
// We must, however, ensure that if we do, any existing ResultSet is
// unaffected, otherwise we could break user code.
//
// so, until we know we can do this (needs testing, on the TODO list)
// for now, we throw the exception and do no lookups.
if (id == null) {
throw new PSQLException(GT.tr("The fastpath function {0} is unknown.", name),
PSQLState.UNEXPECTED_ERROR);
}
return id;
} | [
"public",
"int",
"getID",
"(",
"String",
"name",
")",
"throws",
"SQLException",
"{",
"Integer",
"id",
"=",
"func",
".",
"get",
"(",
"name",
")",
";",
"// may be we could add a lookup to the database here, and store the result",
"// in our lookup table, throwing the exception if that fails.",
"// We must, however, ensure that if we do, any existing ResultSet is",
"// unaffected, otherwise we could break user code.",
"//",
"// so, until we know we can do this (needs testing, on the TODO list)",
"// for now, we throw the exception and do no lookups.",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"throw",
"new",
"PSQLException",
"(",
"GT",
".",
"tr",
"(",
"\"The fastpath function {0} is unknown.\"",
",",
"name",
")",
",",
"PSQLState",
".",
"UNEXPECTED_ERROR",
")",
";",
"}",
"return",
"id",
";",
"}"
] | <p>This returns the function id associated by its name.</p>
<p>If addFunction() or addFunctions() have not been called for this name, then an SQLException is
thrown.</p>
@param name Function name to lookup
@return Function ID for fastpath call
@throws SQLException is function is unknown. | [
"<p",
">",
"This",
"returns",
"the",
"function",
"id",
"associated",
"by",
"its",
"name",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/fastpath/Fastpath.java#L286-L302 |
soabase/exhibitor | exhibitor-core/src/main/java/com/netflix/exhibitor/core/Exhibitor.java | Exhibitor.getLocalConnection | public synchronized CuratorFramework getLocalConnection() throws IOException {
"""
Return a connection ot the ZK instance (creating it if needed)
@return connection
@throws IOException errors
"""
if ( localConnection == null )
{
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
.connectString("localhost:" + configManager.getConfig().getInt(IntConfigs.CLIENT_PORT))
.sessionTimeoutMs(arguments.connectionTimeOutMs * 10)
.connectionTimeoutMs(arguments.connectionTimeOutMs)
.retryPolicy(new ExponentialBackoffRetry(1000, 3));
if ( arguments.aclProvider != null )
{
builder = builder.aclProvider(arguments.aclProvider);
}
localConnection = builder.build();
localConnection.start();
}
return localConnection;
} | java | public synchronized CuratorFramework getLocalConnection() throws IOException
{
if ( localConnection == null )
{
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
.connectString("localhost:" + configManager.getConfig().getInt(IntConfigs.CLIENT_PORT))
.sessionTimeoutMs(arguments.connectionTimeOutMs * 10)
.connectionTimeoutMs(arguments.connectionTimeOutMs)
.retryPolicy(new ExponentialBackoffRetry(1000, 3));
if ( arguments.aclProvider != null )
{
builder = builder.aclProvider(arguments.aclProvider);
}
localConnection = builder.build();
localConnection.start();
}
return localConnection;
} | [
"public",
"synchronized",
"CuratorFramework",
"getLocalConnection",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"localConnection",
"==",
"null",
")",
"{",
"CuratorFrameworkFactory",
".",
"Builder",
"builder",
"=",
"CuratorFrameworkFactory",
".",
"builder",
"(",
")",
".",
"connectString",
"(",
"\"localhost:\"",
"+",
"configManager",
".",
"getConfig",
"(",
")",
".",
"getInt",
"(",
"IntConfigs",
".",
"CLIENT_PORT",
")",
")",
".",
"sessionTimeoutMs",
"(",
"arguments",
".",
"connectionTimeOutMs",
"*",
"10",
")",
".",
"connectionTimeoutMs",
"(",
"arguments",
".",
"connectionTimeOutMs",
")",
".",
"retryPolicy",
"(",
"new",
"ExponentialBackoffRetry",
"(",
"1000",
",",
"3",
")",
")",
";",
"if",
"(",
"arguments",
".",
"aclProvider",
"!=",
"null",
")",
"{",
"builder",
"=",
"builder",
".",
"aclProvider",
"(",
"arguments",
".",
"aclProvider",
")",
";",
"}",
"localConnection",
"=",
"builder",
".",
"build",
"(",
")",
";",
"localConnection",
".",
"start",
"(",
")",
";",
"}",
"return",
"localConnection",
";",
"}"
] | Return a connection ot the ZK instance (creating it if needed)
@return connection
@throws IOException errors | [
"Return",
"a",
"connection",
"ot",
"the",
"ZK",
"instance",
"(",
"creating",
"it",
"if",
"needed",
")"
] | train | https://github.com/soabase/exhibitor/blob/d345d2d45c75b0694b562b6c346f8594f3a5d166/exhibitor-core/src/main/java/com/netflix/exhibitor/core/Exhibitor.java#L305-L324 |
aws/aws-sdk-java | aws-java-sdk-clouddirectory/src/main/java/com/amazonaws/services/clouddirectory/model/ListObjectChildrenResult.java | ListObjectChildrenResult.withChildren | public ListObjectChildrenResult withChildren(java.util.Map<String, String> children) {
"""
<p>
Children structure, which is a map with key as the <code>LinkName</code> and <code>ObjectIdentifier</code> as the
value.
</p>
@param children
Children structure, which is a map with key as the <code>LinkName</code> and <code>ObjectIdentifier</code>
as the value.
@return Returns a reference to this object so that method calls can be chained together.
"""
setChildren(children);
return this;
} | java | public ListObjectChildrenResult withChildren(java.util.Map<String, String> children) {
setChildren(children);
return this;
} | [
"public",
"ListObjectChildrenResult",
"withChildren",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"children",
")",
"{",
"setChildren",
"(",
"children",
")",
";",
"return",
"this",
";",
"}"
] | <p>
Children structure, which is a map with key as the <code>LinkName</code> and <code>ObjectIdentifier</code> as the
value.
</p>
@param children
Children structure, which is a map with key as the <code>LinkName</code> and <code>ObjectIdentifier</code>
as the value.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Children",
"structure",
"which",
"is",
"a",
"map",
"with",
"key",
"as",
"the",
"<code",
">",
"LinkName<",
"/",
"code",
">",
"and",
"<code",
">",
"ObjectIdentifier<",
"/",
"code",
">",
"as",
"the",
"value",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-clouddirectory/src/main/java/com/amazonaws/services/clouddirectory/model/ListObjectChildrenResult.java#L81-L84 |
dwdyer/watchmaker | swing/src/java/main/org/uncommons/watchmaker/swing/evolutionmonitor/EvolutionMonitor.java | EvolutionMonitor.showInDialog | public void showInDialog(final JFrame owner,
final String title,
final boolean modal) {
"""
Displays the evolution monitor component in a new {@link JDialog}. There is no
need to make sure this method is invoked from the Event Dispatch Thread, the
method itself ensures that the window is created and displayed from the EDT.
@param owner The owning frame for the new dialog.
@param title The title for the new dialog.
@param modal Whether the
"""
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
JDialog dialog = new JDialog(owner, title, modal);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
showWindow(dialog);
}
});
} | java | public void showInDialog(final JFrame owner,
final String title,
final boolean modal)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
JDialog dialog = new JDialog(owner, title, modal);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
showWindow(dialog);
}
});
} | [
"public",
"void",
"showInDialog",
"(",
"final",
"JFrame",
"owner",
",",
"final",
"String",
"title",
",",
"final",
"boolean",
"modal",
")",
"{",
"SwingUtilities",
".",
"invokeLater",
"(",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"JDialog",
"dialog",
"=",
"new",
"JDialog",
"(",
"owner",
",",
"title",
",",
"modal",
")",
";",
"dialog",
".",
"setDefaultCloseOperation",
"(",
"JDialog",
".",
"DISPOSE_ON_CLOSE",
")",
";",
"showWindow",
"(",
"dialog",
")",
";",
"}",
"}",
")",
";",
"}"
] | Displays the evolution monitor component in a new {@link JDialog}. There is no
need to make sure this method is invoked from the Event Dispatch Thread, the
method itself ensures that the window is created and displayed from the EDT.
@param owner The owning frame for the new dialog.
@param title The title for the new dialog.
@param modal Whether the | [
"Displays",
"the",
"evolution",
"monitor",
"component",
"in",
"a",
"new",
"{"
] | train | https://github.com/dwdyer/watchmaker/blob/33d942350e6bf7d9a17b9262a4f898158530247e/swing/src/java/main/org/uncommons/watchmaker/swing/evolutionmonitor/EvolutionMonitor.java#L216-L229 |
graknlabs/grakn | server/src/graql/executor/ComputeExecutor.java | ComputeExecutor.initStatisticsVertexProgram | private VertexProgram initStatisticsVertexProgram(GraqlCompute query, Set<LabelId> targetTypes, AttributeType.DataType<?> targetDataType) {
"""
Helper method to intialise the vertex program for compute statistics queries
@param query representing the compute query
@param targetTypes representing the attribute types in which the statistics computation is targeted for
@param targetDataType representing the data type of the target attribute types
@return an object which is a subclass of VertexProgram
"""
if (query.method().equals(MEDIAN)) return new MedianVertexProgram(targetTypes, targetDataType);
else return new DegreeStatisticsVertexProgram(targetTypes);
} | java | private VertexProgram initStatisticsVertexProgram(GraqlCompute query, Set<LabelId> targetTypes, AttributeType.DataType<?> targetDataType) {
if (query.method().equals(MEDIAN)) return new MedianVertexProgram(targetTypes, targetDataType);
else return new DegreeStatisticsVertexProgram(targetTypes);
} | [
"private",
"VertexProgram",
"initStatisticsVertexProgram",
"(",
"GraqlCompute",
"query",
",",
"Set",
"<",
"LabelId",
">",
"targetTypes",
",",
"AttributeType",
".",
"DataType",
"<",
"?",
">",
"targetDataType",
")",
"{",
"if",
"(",
"query",
".",
"method",
"(",
")",
".",
"equals",
"(",
"MEDIAN",
")",
")",
"return",
"new",
"MedianVertexProgram",
"(",
"targetTypes",
",",
"targetDataType",
")",
";",
"else",
"return",
"new",
"DegreeStatisticsVertexProgram",
"(",
"targetTypes",
")",
";",
"}"
] | Helper method to intialise the vertex program for compute statistics queries
@param query representing the compute query
@param targetTypes representing the attribute types in which the statistics computation is targeted for
@param targetDataType representing the data type of the target attribute types
@return an object which is a subclass of VertexProgram | [
"Helper",
"method",
"to",
"intialise",
"the",
"vertex",
"program",
"for",
"compute",
"statistics",
"queries"
] | train | https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/server/src/graql/executor/ComputeExecutor.java#L263-L266 |
alexvasilkov/AndroidCommons | library/src/main/java/com/alexvasilkov/android/commons/texts/Fonts.java | Fonts.apply | public static void apply(@NonNull TextView textView, @NonNull String fontPath) {
"""
Applies font to provided TextView.<br/>
Note: this class will only accept fonts under <code>fonts/</code> directory
and fonts starting with <code>font:</code> prefix.
"""
if (!textView.isInEditMode()) {
setTypeface(textView, getFontFromString
(textView.getContext().getAssets(), fontPath, true));
}
} | java | public static void apply(@NonNull TextView textView, @NonNull String fontPath) {
if (!textView.isInEditMode()) {
setTypeface(textView, getFontFromString
(textView.getContext().getAssets(), fontPath, true));
}
} | [
"public",
"static",
"void",
"apply",
"(",
"@",
"NonNull",
"TextView",
"textView",
",",
"@",
"NonNull",
"String",
"fontPath",
")",
"{",
"if",
"(",
"!",
"textView",
".",
"isInEditMode",
"(",
")",
")",
"{",
"setTypeface",
"(",
"textView",
",",
"getFontFromString",
"(",
"textView",
".",
"getContext",
"(",
")",
".",
"getAssets",
"(",
")",
",",
"fontPath",
",",
"true",
")",
")",
";",
"}",
"}"
] | Applies font to provided TextView.<br/>
Note: this class will only accept fonts under <code>fonts/</code> directory
and fonts starting with <code>font:</code> prefix. | [
"Applies",
"font",
"to",
"provided",
"TextView",
".",
"<br",
"/",
">",
"Note",
":",
"this",
"class",
"will",
"only",
"accept",
"fonts",
"under",
"<code",
">",
"fonts",
"/",
"<",
"/",
"code",
">",
"directory",
"and",
"fonts",
"starting",
"with",
"<code",
">",
"font",
":",
"<",
"/",
"code",
">",
"prefix",
"."
] | train | https://github.com/alexvasilkov/AndroidCommons/blob/aca9f6d5acfc6bd3694984b7f89956e1a0146ddb/library/src/main/java/com/alexvasilkov/android/commons/texts/Fonts.java#L102-L107 |
jenkinsci/jenkins | core/src/main/java/hudson/model/AbstractItem.java | AbstractItem.onLoad | public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
"""
Called right after when a {@link Item} is loaded from disk.
This is an opportunity to do a post load processing.
"""
this.parent = parent;
doSetName(name);
} | java | public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
this.parent = parent;
doSetName(name);
} | [
"public",
"void",
"onLoad",
"(",
"ItemGroup",
"<",
"?",
"extends",
"Item",
">",
"parent",
",",
"String",
"name",
")",
"throws",
"IOException",
"{",
"this",
".",
"parent",
"=",
"parent",
";",
"doSetName",
"(",
"name",
")",
";",
"}"
] | Called right after when a {@link Item} is loaded from disk.
This is an opportunity to do a post load processing. | [
"Called",
"right",
"after",
"when",
"a",
"{"
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/model/AbstractItem.java#L505-L508 |
joniles/mpxj | src/main/java/net/sf/mpxj/sample/MpxjConvert.java | MpxjConvert.process | public void process(String inputFile, String outputFile) throws Exception {
"""
Convert one project file format to another.
@param inputFile input file
@param outputFile output file
@throws Exception
"""
System.out.println("Reading input file started.");
long start = System.currentTimeMillis();
ProjectFile projectFile = readFile(inputFile);
long elapsed = System.currentTimeMillis() - start;
System.out.println("Reading input file completed in " + elapsed + "ms.");
System.out.println("Writing output file started.");
start = System.currentTimeMillis();
ProjectWriter writer = ProjectWriterUtility.getProjectWriter(outputFile);
writer.write(projectFile, outputFile);
elapsed = System.currentTimeMillis() - start;
System.out.println("Writing output completed in " + elapsed + "ms.");
} | java | public void process(String inputFile, String outputFile) throws Exception
{
System.out.println("Reading input file started.");
long start = System.currentTimeMillis();
ProjectFile projectFile = readFile(inputFile);
long elapsed = System.currentTimeMillis() - start;
System.out.println("Reading input file completed in " + elapsed + "ms.");
System.out.println("Writing output file started.");
start = System.currentTimeMillis();
ProjectWriter writer = ProjectWriterUtility.getProjectWriter(outputFile);
writer.write(projectFile, outputFile);
elapsed = System.currentTimeMillis() - start;
System.out.println("Writing output completed in " + elapsed + "ms.");
} | [
"public",
"void",
"process",
"(",
"String",
"inputFile",
",",
"String",
"outputFile",
")",
"throws",
"Exception",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Reading input file started.\"",
")",
";",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"ProjectFile",
"projectFile",
"=",
"readFile",
"(",
"inputFile",
")",
";",
"long",
"elapsed",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Reading input file completed in \"",
"+",
"elapsed",
"+",
"\"ms.\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Writing output file started.\"",
")",
";",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"ProjectWriter",
"writer",
"=",
"ProjectWriterUtility",
".",
"getProjectWriter",
"(",
"outputFile",
")",
";",
"writer",
".",
"write",
"(",
"projectFile",
",",
"outputFile",
")",
";",
"elapsed",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Writing output completed in \"",
"+",
"elapsed",
"+",
"\"ms.\"",
")",
";",
"}"
] | Convert one project file format to another.
@param inputFile input file
@param outputFile output file
@throws Exception | [
"Convert",
"one",
"project",
"file",
"format",
"to",
"another",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/sample/MpxjConvert.java#L80-L94 |
alipay/sofa-rpc | core/api/src/main/java/com/alipay/sofa/rpc/config/RegistryConfig.java | RegistryConfig.setParameters | public RegistryConfig setParameters(Map<String, String> parameters) {
"""
Sets parameters.
@param parameters the parameters
@return the RegistryConfig
"""
if (this.parameters == null) {
this.parameters = new ConcurrentHashMap<String, String>();
this.parameters.putAll(parameters);
}
return this;
} | java | public RegistryConfig setParameters(Map<String, String> parameters) {
if (this.parameters == null) {
this.parameters = new ConcurrentHashMap<String, String>();
this.parameters.putAll(parameters);
}
return this;
} | [
"public",
"RegistryConfig",
"setParameters",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"if",
"(",
"this",
".",
"parameters",
"==",
"null",
")",
"{",
"this",
".",
"parameters",
"=",
"new",
"ConcurrentHashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"this",
".",
"parameters",
".",
"putAll",
"(",
"parameters",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Sets parameters.
@param parameters the parameters
@return the RegistryConfig | [
"Sets",
"parameters",
"."
] | train | https://github.com/alipay/sofa-rpc/blob/a31406410291e56696185a29c3ba4bd1f54488fd/core/api/src/main/java/com/alipay/sofa/rpc/config/RegistryConfig.java#L368-L374 |
apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/ConcurrentBoundedWorkUnitList.java | ConcurrentBoundedWorkUnitList.addFileSet | public boolean addFileSet(FileSet<CopyEntity> fileSet, List<WorkUnit> workUnits) {
"""
Add a file set to the container.
@param fileSet File set, expressed as a {@link org.apache.gobblin.data.management.partition.FileSet} of {@link CopyEntity}s.
@param workUnits List of {@link WorkUnit}s corresponding to this file set.
@return true if the file set was added to the container, false otherwise (i.e. has reached max size).
"""
boolean addedWorkunits = addFileSetImpl(fileSet, workUnits);
if (!addedWorkunits) {
this.rejectedFileSet = true;
}
return addedWorkunits;
} | java | public boolean addFileSet(FileSet<CopyEntity> fileSet, List<WorkUnit> workUnits) {
boolean addedWorkunits = addFileSetImpl(fileSet, workUnits);
if (!addedWorkunits) {
this.rejectedFileSet = true;
}
return addedWorkunits;
} | [
"public",
"boolean",
"addFileSet",
"(",
"FileSet",
"<",
"CopyEntity",
">",
"fileSet",
",",
"List",
"<",
"WorkUnit",
">",
"workUnits",
")",
"{",
"boolean",
"addedWorkunits",
"=",
"addFileSetImpl",
"(",
"fileSet",
",",
"workUnits",
")",
";",
"if",
"(",
"!",
"addedWorkunits",
")",
"{",
"this",
".",
"rejectedFileSet",
"=",
"true",
";",
"}",
"return",
"addedWorkunits",
";",
"}"
] | Add a file set to the container.
@param fileSet File set, expressed as a {@link org.apache.gobblin.data.management.partition.FileSet} of {@link CopyEntity}s.
@param workUnits List of {@link WorkUnit}s corresponding to this file set.
@return true if the file set was added to the container, false otherwise (i.e. has reached max size). | [
"Add",
"a",
"file",
"set",
"to",
"the",
"container",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/ConcurrentBoundedWorkUnitList.java#L108-L114 |
apache/groovy | src/main/groovy/groovy/lang/BenchmarkInterceptor.java | BenchmarkInterceptor.beforeInvoke | public Object beforeInvoke(Object object, String methodName, Object[] arguments) {
"""
This code is executed before the method is called.
@param object receiver object for the method call
@param methodName name of the method to call
@param arguments arguments to the method call
@return null
relays this result.
"""
if (!calls.containsKey(methodName)) calls.put(methodName, new LinkedList());
((List) calls.get(methodName)).add(System.currentTimeMillis());
return null;
} | java | public Object beforeInvoke(Object object, String methodName, Object[] arguments) {
if (!calls.containsKey(methodName)) calls.put(methodName, new LinkedList());
((List) calls.get(methodName)).add(System.currentTimeMillis());
return null;
} | [
"public",
"Object",
"beforeInvoke",
"(",
"Object",
"object",
",",
"String",
"methodName",
",",
"Object",
"[",
"]",
"arguments",
")",
"{",
"if",
"(",
"!",
"calls",
".",
"containsKey",
"(",
"methodName",
")",
")",
"calls",
".",
"put",
"(",
"methodName",
",",
"new",
"LinkedList",
"(",
")",
")",
";",
"(",
"(",
"List",
")",
"calls",
".",
"get",
"(",
"methodName",
")",
")",
".",
"add",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"return",
"null",
";",
"}"
] | This code is executed before the method is called.
@param object receiver object for the method call
@param methodName name of the method to call
@param arguments arguments to the method call
@return null
relays this result. | [
"This",
"code",
"is",
"executed",
"before",
"the",
"method",
"is",
"called",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/BenchmarkInterceptor.java#L75-L80 |
aalmiray/Json-lib | src/main/java/net/sf/json/JSONObject.java | JSONObject.element | public JSONObject element( String key, Object value, JsonConfig jsonConfig ) {
"""
Put a key/value pair in the JSONObject. If the value is null, then the key
will be removed from the JSONObject if it is present.<br>
If there is a previous value assigned to the key, it will call accumulate.
@param key A key string.
@param value An object which is the value. It should be of one of these
types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
String, or the JSONNull object.
@return this.
@throws JSONException If the value is non-finite number or if the key is
null.
"""
verifyIsNull();
if( key == null ){
throw new JSONException( "Null key." );
}
if( value != null ){
value = processValue( key, value, jsonConfig );
_setInternal( key, value, jsonConfig );
}else{
remove( key );
}
return this;
} | java | public JSONObject element( String key, Object value, JsonConfig jsonConfig ) {
verifyIsNull();
if( key == null ){
throw new JSONException( "Null key." );
}
if( value != null ){
value = processValue( key, value, jsonConfig );
_setInternal( key, value, jsonConfig );
}else{
remove( key );
}
return this;
} | [
"public",
"JSONObject",
"element",
"(",
"String",
"key",
",",
"Object",
"value",
",",
"JsonConfig",
"jsonConfig",
")",
"{",
"verifyIsNull",
"(",
")",
";",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"\"Null key.\"",
")",
";",
"}",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"value",
"=",
"processValue",
"(",
"key",
",",
"value",
",",
"jsonConfig",
")",
";",
"_setInternal",
"(",
"key",
",",
"value",
",",
"jsonConfig",
")",
";",
"}",
"else",
"{",
"remove",
"(",
"key",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Put a key/value pair in the JSONObject. If the value is null, then the key
will be removed from the JSONObject if it is present.<br>
If there is a previous value assigned to the key, it will call accumulate.
@param key A key string.
@param value An object which is the value. It should be of one of these
types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
String, or the JSONNull object.
@return this.
@throws JSONException If the value is non-finite number or if the key is
null. | [
"Put",
"a",
"key",
"/",
"value",
"pair",
"in",
"the",
"JSONObject",
".",
"If",
"the",
"value",
"is",
"null",
"then",
"the",
"key",
"will",
"be",
"removed",
"from",
"the",
"JSONObject",
"if",
"it",
"is",
"present",
".",
"<br",
">",
"If",
"there",
"is",
"a",
"previous",
"value",
"assigned",
"to",
"the",
"key",
"it",
"will",
"call",
"accumulate",
"."
] | train | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONObject.java#L1706-L1718 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/db/QueryRecord.java | QueryRecord.addRelationship | public void addRelationship(int iLinkType, Record recLeft, Record recRight, int ifldLeft1, int ifldRight1) {
"""
Add this table link to this query.
Creates a new tablelink and adds it to the link list.
"""
String fldLeft1 = recLeft.getField(ifldLeft1).getFieldName();
String fldRight1 = recRight.getField(ifldRight1).getFieldName();
this.addRelationship(iLinkType, recLeft, recRight, fldLeft1, fldRight1);
} | java | public void addRelationship(int iLinkType, Record recLeft, Record recRight, int ifldLeft1, int ifldRight1)
{
String fldLeft1 = recLeft.getField(ifldLeft1).getFieldName();
String fldRight1 = recRight.getField(ifldRight1).getFieldName();
this.addRelationship(iLinkType, recLeft, recRight, fldLeft1, fldRight1);
} | [
"public",
"void",
"addRelationship",
"(",
"int",
"iLinkType",
",",
"Record",
"recLeft",
",",
"Record",
"recRight",
",",
"int",
"ifldLeft1",
",",
"int",
"ifldRight1",
")",
"{",
"String",
"fldLeft1",
"=",
"recLeft",
".",
"getField",
"(",
"ifldLeft1",
")",
".",
"getFieldName",
"(",
")",
";",
"String",
"fldRight1",
"=",
"recRight",
".",
"getField",
"(",
"ifldRight1",
")",
".",
"getFieldName",
"(",
")",
";",
"this",
".",
"addRelationship",
"(",
"iLinkType",
",",
"recLeft",
",",
"recRight",
",",
"fldLeft1",
",",
"fldRight1",
")",
";",
"}"
] | Add this table link to this query.
Creates a new tablelink and adds it to the link list. | [
"Add",
"this",
"table",
"link",
"to",
"this",
"query",
".",
"Creates",
"a",
"new",
"tablelink",
"and",
"adds",
"it",
"to",
"the",
"link",
"list",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/QueryRecord.java#L144-L149 |
tvesalainen/util | util/src/main/java/org/vesalainen/bean/BeanHelper.java | BeanHelper.applyList | public static final <T> T applyList(Object bean, String property, BiFunction<Class<T>,String,T> factory) {
"""
Applies bean action by using given factory
<p>Bean actions are:
<p>List item property remove by adding '#' to the end of pattern.
<p>E.g. list.3- - list.remove(3)
<p>List item creation to the end of the list.
<p>E.g. list+ - add(factory.get(cls, null))
<p>E.g. list+hint - add(factory.get(cls, hint))
@param <T>
@param bean
@param property
@param factory
@return true if pattern was applied
"""
int addIdx = property.lastIndexOf(Add);
if (addIdx != -1)
{
String hint = property.substring(addIdx+1);
return addList(bean, property.substring(0, addIdx), hint, factory);
}
else
{
int assignIdx = property.lastIndexOf(Assign);
if (assignIdx != -1)
{
String hint = property.substring(assignIdx+1);
return assignList(bean, property.substring(0, assignIdx), hint, factory);
}
else
{
if (property.endsWith(Remove))
{
return (T)removeList(bean, property.substring(0, property.length()-1));
}
else
{
return null;
}
}
}
} | java | public static final <T> T applyList(Object bean, String property, BiFunction<Class<T>,String,T> factory)
{
int addIdx = property.lastIndexOf(Add);
if (addIdx != -1)
{
String hint = property.substring(addIdx+1);
return addList(bean, property.substring(0, addIdx), hint, factory);
}
else
{
int assignIdx = property.lastIndexOf(Assign);
if (assignIdx != -1)
{
String hint = property.substring(assignIdx+1);
return assignList(bean, property.substring(0, assignIdx), hint, factory);
}
else
{
if (property.endsWith(Remove))
{
return (T)removeList(bean, property.substring(0, property.length()-1));
}
else
{
return null;
}
}
}
} | [
"public",
"static",
"final",
"<",
"T",
">",
"T",
"applyList",
"(",
"Object",
"bean",
",",
"String",
"property",
",",
"BiFunction",
"<",
"Class",
"<",
"T",
">",
",",
"String",
",",
"T",
">",
"factory",
")",
"{",
"int",
"addIdx",
"=",
"property",
".",
"lastIndexOf",
"(",
"Add",
")",
";",
"if",
"(",
"addIdx",
"!=",
"-",
"1",
")",
"{",
"String",
"hint",
"=",
"property",
".",
"substring",
"(",
"addIdx",
"+",
"1",
")",
";",
"return",
"addList",
"(",
"bean",
",",
"property",
".",
"substring",
"(",
"0",
",",
"addIdx",
")",
",",
"hint",
",",
"factory",
")",
";",
"}",
"else",
"{",
"int",
"assignIdx",
"=",
"property",
".",
"lastIndexOf",
"(",
"Assign",
")",
";",
"if",
"(",
"assignIdx",
"!=",
"-",
"1",
")",
"{",
"String",
"hint",
"=",
"property",
".",
"substring",
"(",
"assignIdx",
"+",
"1",
")",
";",
"return",
"assignList",
"(",
"bean",
",",
"property",
".",
"substring",
"(",
"0",
",",
"assignIdx",
")",
",",
"hint",
",",
"factory",
")",
";",
"}",
"else",
"{",
"if",
"(",
"property",
".",
"endsWith",
"(",
"Remove",
")",
")",
"{",
"return",
"(",
"T",
")",
"removeList",
"(",
"bean",
",",
"property",
".",
"substring",
"(",
"0",
",",
"property",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"}",
"}"
] | Applies bean action by using given factory
<p>Bean actions are:
<p>List item property remove by adding '#' to the end of pattern.
<p>E.g. list.3- - list.remove(3)
<p>List item creation to the end of the list.
<p>E.g. list+ - add(factory.get(cls, null))
<p>E.g. list+hint - add(factory.get(cls, hint))
@param <T>
@param bean
@param property
@param factory
@return true if pattern was applied | [
"Applies",
"bean",
"action",
"by",
"using",
"given",
"factory",
"<p",
">",
"Bean",
"actions",
"are",
":",
"<p",
">",
"List",
"item",
"property",
"remove",
"by",
"adding",
"#",
"to",
"the",
"end",
"of",
"pattern",
".",
"<p",
">",
"E",
".",
"g",
".",
"list",
".",
"3",
"-",
"-",
"list",
".",
"remove",
"(",
"3",
")",
"<p",
">",
"List",
"item",
"creation",
"to",
"the",
"end",
"of",
"the",
"list",
".",
"<p",
">",
"E",
".",
"g",
".",
"list",
"+",
"-",
"add",
"(",
"factory",
".",
"get",
"(",
"cls",
"null",
"))",
"<p",
">",
"E",
".",
"g",
".",
"list",
"+",
"hint",
"-",
"add",
"(",
"factory",
".",
"get",
"(",
"cls",
"hint",
"))"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/bean/BeanHelper.java#L461-L489 |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/model/monitor/ServiceLevelAgreement.java | ServiceLevelAgreement.unitsToSeconds | public static int unitsToSeconds(String interval, String unit) {
"""
Convert interval of specified unit to seconds
@param interval
@param unit
@return
"""
if (interval == null || interval.isEmpty()) return 0;
else if (unit == null) return (int)(Double.parseDouble(interval));
else if (unit.equals(INTERVAL_DAYS)) return (int)(Double.parseDouble(interval)*86400);
else if (unit.equals(INTERVAL_HOURS)) return (int)(Double.parseDouble(interval)*3600);
else if (unit.equals(INTERVAL_MINUTES)) return (int)(Double.parseDouble(interval)*60);
else return (int)(Double.parseDouble(interval));
} | java | public static int unitsToSeconds(String interval, String unit) {
if (interval == null || interval.isEmpty()) return 0;
else if (unit == null) return (int)(Double.parseDouble(interval));
else if (unit.equals(INTERVAL_DAYS)) return (int)(Double.parseDouble(interval)*86400);
else if (unit.equals(INTERVAL_HOURS)) return (int)(Double.parseDouble(interval)*3600);
else if (unit.equals(INTERVAL_MINUTES)) return (int)(Double.parseDouble(interval)*60);
else return (int)(Double.parseDouble(interval));
} | [
"public",
"static",
"int",
"unitsToSeconds",
"(",
"String",
"interval",
",",
"String",
"unit",
")",
"{",
"if",
"(",
"interval",
"==",
"null",
"||",
"interval",
".",
"isEmpty",
"(",
")",
")",
"return",
"0",
";",
"else",
"if",
"(",
"unit",
"==",
"null",
")",
"return",
"(",
"int",
")",
"(",
"Double",
".",
"parseDouble",
"(",
"interval",
")",
")",
";",
"else",
"if",
"(",
"unit",
".",
"equals",
"(",
"INTERVAL_DAYS",
")",
")",
"return",
"(",
"int",
")",
"(",
"Double",
".",
"parseDouble",
"(",
"interval",
")",
"*",
"86400",
")",
";",
"else",
"if",
"(",
"unit",
".",
"equals",
"(",
"INTERVAL_HOURS",
")",
")",
"return",
"(",
"int",
")",
"(",
"Double",
".",
"parseDouble",
"(",
"interval",
")",
"*",
"3600",
")",
";",
"else",
"if",
"(",
"unit",
".",
"equals",
"(",
"INTERVAL_MINUTES",
")",
")",
"return",
"(",
"int",
")",
"(",
"Double",
".",
"parseDouble",
"(",
"interval",
")",
"*",
"60",
")",
";",
"else",
"return",
"(",
"int",
")",
"(",
"Double",
".",
"parseDouble",
"(",
"interval",
")",
")",
";",
"}"
] | Convert interval of specified unit to seconds
@param interval
@param unit
@return | [
"Convert",
"interval",
"of",
"specified",
"unit",
"to",
"seconds"
] | train | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/model/monitor/ServiceLevelAgreement.java#L68-L75 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/utils/ByteUtils.java | ByteUtils.intToBytes | public static final void intToBytes( int i, byte[] data, int[] offset ) {
"""
Write the bytes representing <code>i</code> into the byte array
<code>data</code>, starting at index <code>offset [0]</code>, and
increment <code>offset [0]</code> by the number of bytes written; if
<code>data == null</code>, increment <code>offset [0]</code> by the
number of bytes that would have been written otherwise.
@param i the <code>int</code> to encode
@param data The byte array to store into, or <code>null</code>.
@param offset A single element array whose first element is the index in
data to begin writing at on function entry, and which on
function exit has been incremented by the number of bytes
written.
"""
/**
* TODO: We use network-order within OceanStore, but temporarily
* supporting intel-order to work with some JNI code until JNI code is
* set to interoperate with network-order.
*/
if (data != null) {
for( int j = (offset[0] + SIZE_INT) - 1; j >= offset[0]; --j ) {
data[j] = (byte) i;
i >>= 8;
}
}
offset[0] += SIZE_INT;
} | java | public static final void intToBytes( int i, byte[] data, int[] offset ) {
/**
* TODO: We use network-order within OceanStore, but temporarily
* supporting intel-order to work with some JNI code until JNI code is
* set to interoperate with network-order.
*/
if (data != null) {
for( int j = (offset[0] + SIZE_INT) - 1; j >= offset[0]; --j ) {
data[j] = (byte) i;
i >>= 8;
}
}
offset[0] += SIZE_INT;
} | [
"public",
"static",
"final",
"void",
"intToBytes",
"(",
"int",
"i",
",",
"byte",
"[",
"]",
"data",
",",
"int",
"[",
"]",
"offset",
")",
"{",
"/**\n * TODO: We use network-order within OceanStore, but temporarily\n * supporting intel-order to work with some JNI code until JNI code is\n * set to interoperate with network-order.\n */",
"if",
"(",
"data",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"(",
"offset",
"[",
"0",
"]",
"+",
"SIZE_INT",
")",
"-",
"1",
";",
"j",
">=",
"offset",
"[",
"0",
"]",
";",
"--",
"j",
")",
"{",
"data",
"[",
"j",
"]",
"=",
"(",
"byte",
")",
"i",
";",
"i",
">>=",
"8",
";",
"}",
"}",
"offset",
"[",
"0",
"]",
"+=",
"SIZE_INT",
";",
"}"
] | Write the bytes representing <code>i</code> into the byte array
<code>data</code>, starting at index <code>offset [0]</code>, and
increment <code>offset [0]</code> by the number of bytes written; if
<code>data == null</code>, increment <code>offset [0]</code> by the
number of bytes that would have been written otherwise.
@param i the <code>int</code> to encode
@param data The byte array to store into, or <code>null</code>.
@param offset A single element array whose first element is the index in
data to begin writing at on function entry, and which on
function exit has been incremented by the number of bytes
written. | [
"Write",
"the",
"bytes",
"representing",
"<code",
">",
"i<",
"/",
"code",
">",
"into",
"the",
"byte",
"array",
"<code",
">",
"data<",
"/",
"code",
">",
"starting",
"at",
"index",
"<code",
">",
"offset",
"[",
"0",
"]",
"<",
"/",
"code",
">",
"and",
"increment",
"<code",
">",
"offset",
"[",
"0",
"]",
"<",
"/",
"code",
">",
"by",
"the",
"number",
"of",
"bytes",
"written",
";",
"if",
"<code",
">",
"data",
"==",
"null<",
"/",
"code",
">",
"increment",
"<code",
">",
"offset",
"[",
"0",
"]",
"<",
"/",
"code",
">",
"by",
"the",
"number",
"of",
"bytes",
"that",
"would",
"have",
"been",
"written",
"otherwise",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/io/dxfdwg/libs/dwg/utils/ByteUtils.java#L79-L93 |
kobakei/Android-RateThisApp | ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java | RateThisApp.storeInstallDate | private static void storeInstallDate(final Context context, SharedPreferences.Editor editor) {
"""
Store install date.
Install date is retrieved from package manager if possible.
@param context
@param editor
"""
Date installDate = new Date();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
PackageManager packMan = context.getPackageManager();
try {
PackageInfo pkgInfo = packMan.getPackageInfo(context.getPackageName(), 0);
installDate = new Date(pkgInfo.firstInstallTime);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
editor.putLong(KEY_INSTALL_DATE, installDate.getTime());
log("First install: " + installDate.toString());
} | java | private static void storeInstallDate(final Context context, SharedPreferences.Editor editor) {
Date installDate = new Date();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
PackageManager packMan = context.getPackageManager();
try {
PackageInfo pkgInfo = packMan.getPackageInfo(context.getPackageName(), 0);
installDate = new Date(pkgInfo.firstInstallTime);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
editor.putLong(KEY_INSTALL_DATE, installDate.getTime());
log("First install: " + installDate.toString());
} | [
"private",
"static",
"void",
"storeInstallDate",
"(",
"final",
"Context",
"context",
",",
"SharedPreferences",
".",
"Editor",
"editor",
")",
"{",
"Date",
"installDate",
"=",
"new",
"Date",
"(",
")",
";",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"GINGERBREAD",
")",
"{",
"PackageManager",
"packMan",
"=",
"context",
".",
"getPackageManager",
"(",
")",
";",
"try",
"{",
"PackageInfo",
"pkgInfo",
"=",
"packMan",
".",
"getPackageInfo",
"(",
"context",
".",
"getPackageName",
"(",
")",
",",
"0",
")",
";",
"installDate",
"=",
"new",
"Date",
"(",
"pkgInfo",
".",
"firstInstallTime",
")",
";",
"}",
"catch",
"(",
"PackageManager",
".",
"NameNotFoundException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"editor",
".",
"putLong",
"(",
"KEY_INSTALL_DATE",
",",
"installDate",
".",
"getTime",
"(",
")",
")",
";",
"log",
"(",
"\"First install: \"",
"+",
"installDate",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Store install date.
Install date is retrieved from package manager if possible.
@param context
@param editor | [
"Store",
"install",
"date",
".",
"Install",
"date",
"is",
"retrieved",
"from",
"package",
"manager",
"if",
"possible",
"."
] | train | https://github.com/kobakei/Android-RateThisApp/blob/c3d007c8c02beb6ff196745c2310c259737f5c81/ratethisapp/src/main/java/com/kobakei/ratethisapp/RateThisApp.java#L338-L351 |
snowflakedb/snowflake-jdbc | src/main/java/net/snowflake/client/core/SFTrustManager.java | SFTrustManager.validateRevocationStatus | void validateRevocationStatus(X509Certificate[] chain, String peerHost) throws CertificateException {
"""
Certificate Revocation checks
@param chain chain of certificates attached.
@param peerHost Hostname of the server
@throws CertificateException if any certificate validation fails
"""
final List<Certificate> bcChain = convertToBouncyCastleCertificate(chain);
final List<SFPair<Certificate, Certificate>> pairIssuerSubjectList =
getPairIssuerSubject(bcChain);
if (peerHost.startsWith("ocspssd"))
{
return;
}
if (ocspCacheServer.new_endpoint_enabled)
{
ocspCacheServer.resetOCSPResponseCacheServer(peerHost);
}
synchronized (OCSP_RESPONSE_CACHE_LOCK)
{
boolean isCached = isCached(pairIssuerSubjectList);
if (this.useOcspResponseCacheServer && !isCached)
{
if (!ocspCacheServer.new_endpoint_enabled)
{
LOGGER.debug(
"Downloading OCSP response cache from the server. URL: {}",
SF_OCSP_RESPONSE_CACHE_SERVER_URL);
}
else
{
LOGGER.debug(
"Downloading OCSP response cache from the server. URL: {}",
ocspCacheServer.SF_OCSP_RESPONSE_CACHE_SERVER);
}
readOcspResponseCacheServer();
// if the cache is downloaded from the server, it should be written
// to the file cache at all times.
WAS_CACHE_UPDATED = true;
}
executeRevocationStatusChecks(pairIssuerSubjectList, peerHost);
if (WAS_CACHE_UPDATED)
{
JsonNode input = encodeCacheToJSON();
fileCacheManager.writeCacheFile(input);
WAS_CACHE_UPDATED = false;
}
}
} | java | void validateRevocationStatus(X509Certificate[] chain, String peerHost) throws CertificateException
{
final List<Certificate> bcChain = convertToBouncyCastleCertificate(chain);
final List<SFPair<Certificate, Certificate>> pairIssuerSubjectList =
getPairIssuerSubject(bcChain);
if (peerHost.startsWith("ocspssd"))
{
return;
}
if (ocspCacheServer.new_endpoint_enabled)
{
ocspCacheServer.resetOCSPResponseCacheServer(peerHost);
}
synchronized (OCSP_RESPONSE_CACHE_LOCK)
{
boolean isCached = isCached(pairIssuerSubjectList);
if (this.useOcspResponseCacheServer && !isCached)
{
if (!ocspCacheServer.new_endpoint_enabled)
{
LOGGER.debug(
"Downloading OCSP response cache from the server. URL: {}",
SF_OCSP_RESPONSE_CACHE_SERVER_URL);
}
else
{
LOGGER.debug(
"Downloading OCSP response cache from the server. URL: {}",
ocspCacheServer.SF_OCSP_RESPONSE_CACHE_SERVER);
}
readOcspResponseCacheServer();
// if the cache is downloaded from the server, it should be written
// to the file cache at all times.
WAS_CACHE_UPDATED = true;
}
executeRevocationStatusChecks(pairIssuerSubjectList, peerHost);
if (WAS_CACHE_UPDATED)
{
JsonNode input = encodeCacheToJSON();
fileCacheManager.writeCacheFile(input);
WAS_CACHE_UPDATED = false;
}
}
} | [
"void",
"validateRevocationStatus",
"(",
"X509Certificate",
"[",
"]",
"chain",
",",
"String",
"peerHost",
")",
"throws",
"CertificateException",
"{",
"final",
"List",
"<",
"Certificate",
">",
"bcChain",
"=",
"convertToBouncyCastleCertificate",
"(",
"chain",
")",
";",
"final",
"List",
"<",
"SFPair",
"<",
"Certificate",
",",
"Certificate",
">",
">",
"pairIssuerSubjectList",
"=",
"getPairIssuerSubject",
"(",
"bcChain",
")",
";",
"if",
"(",
"peerHost",
".",
"startsWith",
"(",
"\"ocspssd\"",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"ocspCacheServer",
".",
"new_endpoint_enabled",
")",
"{",
"ocspCacheServer",
".",
"resetOCSPResponseCacheServer",
"(",
"peerHost",
")",
";",
"}",
"synchronized",
"(",
"OCSP_RESPONSE_CACHE_LOCK",
")",
"{",
"boolean",
"isCached",
"=",
"isCached",
"(",
"pairIssuerSubjectList",
")",
";",
"if",
"(",
"this",
".",
"useOcspResponseCacheServer",
"&&",
"!",
"isCached",
")",
"{",
"if",
"(",
"!",
"ocspCacheServer",
".",
"new_endpoint_enabled",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Downloading OCSP response cache from the server. URL: {}\"",
",",
"SF_OCSP_RESPONSE_CACHE_SERVER_URL",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Downloading OCSP response cache from the server. URL: {}\"",
",",
"ocspCacheServer",
".",
"SF_OCSP_RESPONSE_CACHE_SERVER",
")",
";",
"}",
"readOcspResponseCacheServer",
"(",
")",
";",
"// if the cache is downloaded from the server, it should be written",
"// to the file cache at all times.",
"WAS_CACHE_UPDATED",
"=",
"true",
";",
"}",
"executeRevocationStatusChecks",
"(",
"pairIssuerSubjectList",
",",
"peerHost",
")",
";",
"if",
"(",
"WAS_CACHE_UPDATED",
")",
"{",
"JsonNode",
"input",
"=",
"encodeCacheToJSON",
"(",
")",
";",
"fileCacheManager",
".",
"writeCacheFile",
"(",
"input",
")",
";",
"WAS_CACHE_UPDATED",
"=",
"false",
";",
"}",
"}",
"}"
] | Certificate Revocation checks
@param chain chain of certificates attached.
@param peerHost Hostname of the server
@throws CertificateException if any certificate validation fails | [
"Certificate",
"Revocation",
"checks"
] | train | https://github.com/snowflakedb/snowflake-jdbc/blob/98567b5a57753f29d51446809640b969a099658f/src/main/java/net/snowflake/client/core/SFTrustManager.java#L585-L631 |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/summary/InternalResultSummary.java | InternalResultSummary.resolvePlan | private static Plan resolvePlan( Plan plan, ProfiledPlan profiledPlan ) {
"""
Profiled plan is a superset of plan. This method returns profiled plan if plan is {@code null}.
@param plan the given plan, possibly {@code null}.
@param profiledPlan the given profiled plan, possibly {@code null}.
@return available plan.
"""
return plan == null ? profiledPlan : plan;
} | java | private static Plan resolvePlan( Plan plan, ProfiledPlan profiledPlan )
{
return plan == null ? profiledPlan : plan;
} | [
"private",
"static",
"Plan",
"resolvePlan",
"(",
"Plan",
"plan",
",",
"ProfiledPlan",
"profiledPlan",
")",
"{",
"return",
"plan",
"==",
"null",
"?",
"profiledPlan",
":",
"plan",
";",
"}"
] | Profiled plan is a superset of plan. This method returns profiled plan if plan is {@code null}.
@param plan the given plan, possibly {@code null}.
@param profiledPlan the given profiled plan, possibly {@code null}.
@return available plan. | [
"Profiled",
"plan",
"is",
"a",
"superset",
"of",
"plan",
".",
"This",
"method",
"returns",
"profiled",
"plan",
"if",
"plan",
"is",
"{",
"@code",
"null",
"}",
"."
] | train | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/summary/InternalResultSummary.java#L183-L186 |
Azure/azure-sdk-for-java | eventgrid/resource-manager/v2018_09_15_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_09_15_preview/implementation/DomainsInner.java | DomainsInner.beginCreateOrUpdateAsync | public Observable<DomainInner> beginCreateOrUpdateAsync(String resourceGroupName, String domainName, DomainInner domainInfo) {
"""
Create a domain.
Asynchronously creates a new domain with the specified parameters.
@param resourceGroupName The name of the resource group within the user's subscription.
@param domainName Name of the domain
@param domainInfo Domain information
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DomainInner object
"""
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, domainName, domainInfo).map(new Func1<ServiceResponse<DomainInner>, DomainInner>() {
@Override
public DomainInner call(ServiceResponse<DomainInner> response) {
return response.body();
}
});
} | java | public Observable<DomainInner> beginCreateOrUpdateAsync(String resourceGroupName, String domainName, DomainInner domainInfo) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, domainName, domainInfo).map(new Func1<ServiceResponse<DomainInner>, DomainInner>() {
@Override
public DomainInner call(ServiceResponse<DomainInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"DomainInner",
">",
"beginCreateOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"domainName",
",",
"DomainInner",
"domainInfo",
")",
"{",
"return",
"beginCreateOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"domainName",
",",
"domainInfo",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"DomainInner",
">",
",",
"DomainInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DomainInner",
"call",
"(",
"ServiceResponse",
"<",
"DomainInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Create a domain.
Asynchronously creates a new domain with the specified parameters.
@param resourceGroupName The name of the resource group within the user's subscription.
@param domainName Name of the domain
@param domainInfo Domain information
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the DomainInner object | [
"Create",
"a",
"domain",
".",
"Asynchronously",
"creates",
"a",
"new",
"domain",
"with",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/resource-manager/v2018_09_15_preview/src/main/java/com/microsoft/azure/management/eventgrid/v2018_09_15_preview/implementation/DomainsInner.java#L327-L334 |
openengsb/openengsb | components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/PropertyConnectionCalculator.java | PropertyConnectionCalculator.resolveTemporaryProperties | private void resolveTemporaryProperties(Map<String, Set<String>> map) {
"""
Resolves the temporary properties of the given property map. It replaces the temporary properties in the values
of the given map with the values of the temporary property it replaces. This procedure is done until there are no
more temporary fields present in the values of the map.
"""
boolean temporaryPresent = false;
do {
temporaryPresent = false;
for (Map.Entry<String, Set<String>> entry : map.entrySet()) {
Set<String> newProperties = new HashSet<String>();
Iterator<String> properties = entry.getValue().iterator();
while (properties.hasNext()) {
String property = properties.next();
if (isTemporaryProperty(property)) {
LOGGER.debug("Resolve temporary field {} for property {}", entry.getKey(), property);
temporaryPresent = true;
newProperties.addAll(map.get(property));
properties.remove();
}
}
entry.getValue().addAll(newProperties);
}
} while (temporaryPresent);
} | java | private void resolveTemporaryProperties(Map<String, Set<String>> map) {
boolean temporaryPresent = false;
do {
temporaryPresent = false;
for (Map.Entry<String, Set<String>> entry : map.entrySet()) {
Set<String> newProperties = new HashSet<String>();
Iterator<String> properties = entry.getValue().iterator();
while (properties.hasNext()) {
String property = properties.next();
if (isTemporaryProperty(property)) {
LOGGER.debug("Resolve temporary field {} for property {}", entry.getKey(), property);
temporaryPresent = true;
newProperties.addAll(map.get(property));
properties.remove();
}
}
entry.getValue().addAll(newProperties);
}
} while (temporaryPresent);
} | [
"private",
"void",
"resolveTemporaryProperties",
"(",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"map",
")",
"{",
"boolean",
"temporaryPresent",
"=",
"false",
";",
"do",
"{",
"temporaryPresent",
"=",
"false",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"Set",
"<",
"String",
">",
"newProperties",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"Iterator",
"<",
"String",
">",
"properties",
"=",
"entry",
".",
"getValue",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"properties",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"property",
"=",
"properties",
".",
"next",
"(",
")",
";",
"if",
"(",
"isTemporaryProperty",
"(",
"property",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Resolve temporary field {} for property {}\"",
",",
"entry",
".",
"getKey",
"(",
")",
",",
"property",
")",
";",
"temporaryPresent",
"=",
"true",
";",
"newProperties",
".",
"addAll",
"(",
"map",
".",
"get",
"(",
"property",
")",
")",
";",
"properties",
".",
"remove",
"(",
")",
";",
"}",
"}",
"entry",
".",
"getValue",
"(",
")",
".",
"addAll",
"(",
"newProperties",
")",
";",
"}",
"}",
"while",
"(",
"temporaryPresent",
")",
";",
"}"
] | Resolves the temporary properties of the given property map. It replaces the temporary properties in the values
of the given map with the values of the temporary property it replaces. This procedure is done until there are no
more temporary fields present in the values of the map. | [
"Resolves",
"the",
"temporary",
"properties",
"of",
"the",
"given",
"property",
"map",
".",
"It",
"replaces",
"the",
"temporary",
"properties",
"in",
"the",
"values",
"of",
"the",
"given",
"map",
"with",
"the",
"values",
"of",
"the",
"temporary",
"property",
"it",
"replaces",
".",
"This",
"procedure",
"is",
"done",
"until",
"there",
"are",
"no",
"more",
"temporary",
"fields",
"present",
"in",
"the",
"values",
"of",
"the",
"map",
"."
] | train | https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/components/ekb/transformation-wonderland/src/main/java/org/openengsb/core/ekb/transformation/wonderland/internal/PropertyConnectionCalculator.java#L119-L138 |
gallandarakhneorg/afc | core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java | XMLUtil.getAttributeURLWithDefault | @Pure
public static URL getAttributeURLWithDefault(Node document, boolean caseSensitive, URL defaultValue, String... path) {
"""
Replies the URL that corresponds to the specified attribute's path.
<p>The path is an ordered list of tag's names and ended by the name of
the attribute.
@param document is the XML document to explore.
@param caseSensitive indicates of the {@code path}'s components are case sensitive.
@param defaultValue is the default value to reply.
@param path is the list of and ended by the attribute's name.
@return the URL in the specified attribute or <code>null</code> if
it was node found in the document
"""
assert document != null : AssertMessages.notNullParameter(0);
final String v = getAttributeValue(document, caseSensitive, 0, path);
if (v != null && !v.isEmpty()) {
final URL url = FileSystem.convertStringToURL(v, true);
if (url != null) {
return url;
}
}
return defaultValue;
} | java | @Pure
public static URL getAttributeURLWithDefault(Node document, boolean caseSensitive, URL defaultValue, String... path) {
assert document != null : AssertMessages.notNullParameter(0);
final String v = getAttributeValue(document, caseSensitive, 0, path);
if (v != null && !v.isEmpty()) {
final URL url = FileSystem.convertStringToURL(v, true);
if (url != null) {
return url;
}
}
return defaultValue;
} | [
"@",
"Pure",
"public",
"static",
"URL",
"getAttributeURLWithDefault",
"(",
"Node",
"document",
",",
"boolean",
"caseSensitive",
",",
"URL",
"defaultValue",
",",
"String",
"...",
"path",
")",
"{",
"assert",
"document",
"!=",
"null",
":",
"AssertMessages",
".",
"notNullParameter",
"(",
"0",
")",
";",
"final",
"String",
"v",
"=",
"getAttributeValue",
"(",
"document",
",",
"caseSensitive",
",",
"0",
",",
"path",
")",
";",
"if",
"(",
"v",
"!=",
"null",
"&&",
"!",
"v",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"URL",
"url",
"=",
"FileSystem",
".",
"convertStringToURL",
"(",
"v",
",",
"true",
")",
";",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
"return",
"url",
";",
"}",
"}",
"return",
"defaultValue",
";",
"}"
] | Replies the URL that corresponds to the specified attribute's path.
<p>The path is an ordered list of tag's names and ended by the name of
the attribute.
@param document is the XML document to explore.
@param caseSensitive indicates of the {@code path}'s components are case sensitive.
@param defaultValue is the default value to reply.
@param path is the list of and ended by the attribute's name.
@return the URL in the specified attribute or <code>null</code> if
it was node found in the document | [
"Replies",
"the",
"URL",
"that",
"corresponds",
"to",
"the",
"specified",
"attribute",
"s",
"path",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/inputoutput/src/main/java/org/arakhne/afc/inputoutput/xml/XMLUtil.java#L997-L1008 |
jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/Sources.java | Sources.asProperties | public static Properties asProperties(Class<?> contextClass, String resourceName) throws IOException {
"""
Returns the given source as a {@link Properties}
@param contextClass
@param resourceName
@return
@throws IOException
"""
Closer closer = Closer.create();
try {
Properties p = new Properties();
p.load(closer.register(asCharSource(contextClass, resourceName).openStream()));
return p;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
} | java | public static Properties asProperties(Class<?> contextClass, String resourceName) throws IOException {
Closer closer = Closer.create();
try {
Properties p = new Properties();
p.load(closer.register(asCharSource(contextClass, resourceName).openStream()));
return p;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
} | [
"public",
"static",
"Properties",
"asProperties",
"(",
"Class",
"<",
"?",
">",
"contextClass",
",",
"String",
"resourceName",
")",
"throws",
"IOException",
"{",
"Closer",
"closer",
"=",
"Closer",
".",
"create",
"(",
")",
";",
"try",
"{",
"Properties",
"p",
"=",
"new",
"Properties",
"(",
")",
";",
"p",
".",
"load",
"(",
"closer",
".",
"register",
"(",
"asCharSource",
"(",
"contextClass",
",",
"resourceName",
")",
".",
"openStream",
"(",
")",
")",
")",
";",
"return",
"p",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"throw",
"closer",
".",
"rethrow",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closer",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Returns the given source as a {@link Properties}
@param contextClass
@param resourceName
@return
@throws IOException | [
"Returns",
"the",
"given",
"source",
"as",
"a",
"{",
"@link",
"Properties",
"}"
] | train | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/Sources.java#L43-L54 |
MenoData/Time4J | base/src/main/java/net/time4j/format/expert/AttributeSet.java | AttributeSet.withAttributes | AttributeSet withAttributes(Attributes attributes) {
"""
<p>Setzt die Attribute neu. </p>
@param attributes new format attributes
"""
return new AttributeSet(attributes, this.locale, this.level, this.section, this.printCondition, this.internals);
} | java | AttributeSet withAttributes(Attributes attributes) {
return new AttributeSet(attributes, this.locale, this.level, this.section, this.printCondition, this.internals);
} | [
"AttributeSet",
"withAttributes",
"(",
"Attributes",
"attributes",
")",
"{",
"return",
"new",
"AttributeSet",
"(",
"attributes",
",",
"this",
".",
"locale",
",",
"this",
".",
"level",
",",
"this",
".",
"section",
",",
"this",
".",
"printCondition",
",",
"this",
".",
"internals",
")",
";",
"}"
] | <p>Setzt die Attribute neu. </p>
@param attributes new format attributes | [
"<p",
">",
"Setzt",
"die",
"Attribute",
"neu",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/format/expert/AttributeSet.java#L314-L318 |
google/j2objc | jre_emul/android/platform/libcore/luni/src/objc/java/libcore/icu/TimeZoneNames.java | TimeZoneNames.fillZoneStrings | private static void fillZoneStrings(String localeId, String[][] result) {
"""
/* J2ObjC: unused.
public static native String getExemplarLocation(String locale, String tz);
"""
for (int i = 0; i < result.length; i++) {
fillZoneStringNames(localeId, result[i]);
}
} | java | private static void fillZoneStrings(String localeId, String[][] result) {
for (int i = 0; i < result.length; i++) {
fillZoneStringNames(localeId, result[i]);
}
} | [
"private",
"static",
"void",
"fillZoneStrings",
"(",
"String",
"localeId",
",",
"String",
"[",
"]",
"[",
"]",
"result",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"fillZoneStringNames",
"(",
"localeId",
",",
"result",
"[",
"i",
"]",
")",
";",
"}",
"}"
] | /* J2ObjC: unused.
public static native String getExemplarLocation(String locale, String tz); | [
"/",
"*",
"J2ObjC",
":",
"unused",
".",
"public",
"static",
"native",
"String",
"getExemplarLocation",
"(",
"String",
"locale",
"String",
"tz",
")",
";"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/luni/src/objc/java/libcore/icu/TimeZoneNames.java#L164-L168 |
OpenLiberty/open-liberty | dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/ReferrerURLCookieHandler.java | ReferrerURLCookieHandler.clearReferrerURLCookie | public void clearReferrerURLCookie(HttpServletRequest req, HttpServletResponse res, String cookieName) {
"""
Removes the referrer URL cookie from the HttpServletResponse if set in the
HttpServletRequest.
@param req
@param res
"""
String url = CookieHelper.getCookieValue(req.getCookies(), cookieName);
if (url != null && url.length() > 0) {
invalidateReferrerURLCookie(req, res, cookieName);
}
} | java | public void clearReferrerURLCookie(HttpServletRequest req, HttpServletResponse res, String cookieName) {
String url = CookieHelper.getCookieValue(req.getCookies(), cookieName);
if (url != null && url.length() > 0) {
invalidateReferrerURLCookie(req, res, cookieName);
}
} | [
"public",
"void",
"clearReferrerURLCookie",
"(",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"res",
",",
"String",
"cookieName",
")",
"{",
"String",
"url",
"=",
"CookieHelper",
".",
"getCookieValue",
"(",
"req",
".",
"getCookies",
"(",
")",
",",
"cookieName",
")",
";",
"if",
"(",
"url",
"!=",
"null",
"&&",
"url",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"invalidateReferrerURLCookie",
"(",
"req",
",",
"res",
",",
"cookieName",
")",
";",
"}",
"}"
] | Removes the referrer URL cookie from the HttpServletResponse if set in the
HttpServletRequest.
@param req
@param res | [
"Removes",
"the",
"referrer",
"URL",
"cookie",
"from",
"the",
"HttpServletResponse",
"if",
"set",
"in",
"the",
"HttpServletRequest",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.webcontainer.security/src/com/ibm/ws/webcontainer/security/ReferrerURLCookieHandler.java#L154-L160 |
igniterealtime/Smack | smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java | MamManager.retrieveFormFields | public List<FormField> retrieveFormFields(String node)
throws NoResponseException, XMPPErrorException, NotConnectedException,
InterruptedException, NotLoggedInException {
"""
Get the form fields supported by the server.
@param node The PubSub node name, can be null
@return the list of form fields.
@throws NoResponseException
@throws XMPPErrorException
@throws NotConnectedException
@throws InterruptedException
@throws NotLoggedInException
"""
String queryId = UUID.randomUUID().toString();
MamQueryIQ mamQueryIq = new MamQueryIQ(queryId, node, null);
mamQueryIq.setTo(archiveAddress);
MamQueryIQ mamResponseQueryIq = connection().createStanzaCollectorAndSend(mamQueryIq).nextResultOrThrow();
return mamResponseQueryIq.getDataForm().getFields();
} | java | public List<FormField> retrieveFormFields(String node)
throws NoResponseException, XMPPErrorException, NotConnectedException,
InterruptedException, NotLoggedInException {
String queryId = UUID.randomUUID().toString();
MamQueryIQ mamQueryIq = new MamQueryIQ(queryId, node, null);
mamQueryIq.setTo(archiveAddress);
MamQueryIQ mamResponseQueryIq = connection().createStanzaCollectorAndSend(mamQueryIq).nextResultOrThrow();
return mamResponseQueryIq.getDataForm().getFields();
} | [
"public",
"List",
"<",
"FormField",
">",
"retrieveFormFields",
"(",
"String",
"node",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
",",
"NotLoggedInException",
"{",
"String",
"queryId",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"MamQueryIQ",
"mamQueryIq",
"=",
"new",
"MamQueryIQ",
"(",
"queryId",
",",
"node",
",",
"null",
")",
";",
"mamQueryIq",
".",
"setTo",
"(",
"archiveAddress",
")",
";",
"MamQueryIQ",
"mamResponseQueryIq",
"=",
"connection",
"(",
")",
".",
"createStanzaCollectorAndSend",
"(",
"mamQueryIq",
")",
".",
"nextResultOrThrow",
"(",
")",
";",
"return",
"mamResponseQueryIq",
".",
"getDataForm",
"(",
")",
".",
"getFields",
"(",
")",
";",
"}"
] | Get the form fields supported by the server.
@param node The PubSub node name, can be null
@return the list of form fields.
@throws NoResponseException
@throws XMPPErrorException
@throws NotConnectedException
@throws InterruptedException
@throws NotLoggedInException | [
"Get",
"the",
"form",
"fields",
"supported",
"by",
"the",
"server",
"."
] | train | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java#L524-L534 |
the-fascinator/plugin-indexer-solr | src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java | SolrIndexer.cacheConfig | private void cacheConfig(String oid, JsonSimpleConfig config) {
"""
Add a config class to the cache if caching if configured
@param oid
: The config OID to use as an index
@param config
: The instantiated JsonConfigHelper to cache
"""
if (useCache && config != null) {
configCache.put(oid, config);
}
} | java | private void cacheConfig(String oid, JsonSimpleConfig config) {
if (useCache && config != null) {
configCache.put(oid, config);
}
} | [
"private",
"void",
"cacheConfig",
"(",
"String",
"oid",
",",
"JsonSimpleConfig",
"config",
")",
"{",
"if",
"(",
"useCache",
"&&",
"config",
"!=",
"null",
")",
"{",
"configCache",
".",
"put",
"(",
"oid",
",",
"config",
")",
";",
"}",
"}"
] | Add a config class to the cache if caching if configured
@param oid
: The config OID to use as an index
@param config
: The instantiated JsonConfigHelper to cache | [
"Add",
"a",
"config",
"class",
"to",
"the",
"cache",
"if",
"caching",
"if",
"configured"
] | train | https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrIndexer.java#L1163-L1167 |
nominanuda/zen-project | zen-dataobject/src/main/java/com/nominanuda/dataobject/DataStructHelper.java | DataStructHelper.sort | @SuppressWarnings("unchecked")
public <T> void sort(Arr arr, Comparator<T> c) {
"""
can lead to classcastexception if comparator is not of the right type
"""
int l = arr.getLength();
Object[] objs = new Object[l];
for (int i=0; i<l; i++) {
objs[i] = arr.get(i);
}
Arrays.sort((T[])objs, c);
for (int i=0; i<l; i++) {
arr.put(i, objs[i]);
}
} | java | @SuppressWarnings("unchecked")
public <T> void sort(Arr arr, Comparator<T> c) {
int l = arr.getLength();
Object[] objs = new Object[l];
for (int i=0; i<l; i++) {
objs[i] = arr.get(i);
}
Arrays.sort((T[])objs, c);
for (int i=0; i<l; i++) {
arr.put(i, objs[i]);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
">",
"void",
"sort",
"(",
"Arr",
"arr",
",",
"Comparator",
"<",
"T",
">",
"c",
")",
"{",
"int",
"l",
"=",
"arr",
".",
"getLength",
"(",
")",
";",
"Object",
"[",
"]",
"objs",
"=",
"new",
"Object",
"[",
"l",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"objs",
"[",
"i",
"]",
"=",
"arr",
".",
"get",
"(",
"i",
")",
";",
"}",
"Arrays",
".",
"sort",
"(",
"(",
"T",
"[",
"]",
")",
"objs",
",",
"c",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"arr",
".",
"put",
"(",
"i",
",",
"objs",
"[",
"i",
"]",
")",
";",
"}",
"}"
] | can lead to classcastexception if comparator is not of the right type | [
"can",
"lead",
"to",
"classcastexception",
"if",
"comparator",
"is",
"not",
"of",
"the",
"right",
"type"
] | train | https://github.com/nominanuda/zen-project/blob/fe48ae8da198eb7066c2b56bf2ffafe4cdfc451d/zen-dataobject/src/main/java/com/nominanuda/dataobject/DataStructHelper.java#L859-L870 |
alkacon/opencms-core | src/org/opencms/xml/CmsXmlUtils.java | CmsXmlUtils.createXpath | public static String createXpath(String path, int index) {
"""
Translates a simple lookup path to the simplified Xpath format used for
the internal bookmarks.<p>
Examples:<br>
<code>title</code> becomes <code>title[1]</code><br>
<code>title[1]</code> is left untouched<br>
<code>title/subtitle</code> becomes <code>title[1]/subtitle[1]</code><br>
<code>title/subtitle[1]</code> becomes <code>title[1]/subtitle[1]</code><p>
Note: If the name already has the format <code>title[1]</code> then provided index parameter
is ignored.<p>
@param path the path to get the simplified Xpath for
@param index the index to append (if required)
@return the simplified Xpath for the given name
"""
if (path.indexOf('/') > -1) {
// this is a complex path over more then 1 node
StringBuffer result = new StringBuffer(path.length() + 32);
// split the path into sub elements
List<String> elements = CmsStringUtil.splitAsList(path, '/');
int end = elements.size() - 1;
for (int i = 0; i <= end; i++) {
// append [i] to path element if required
result.append(createXpathElementCheck(elements.get(i), (i == end) ? index : 1));
if (i < end) {
// append path delimiter if not final path element
result.append('/');
}
}
return result.toString();
}
// this path has only 1 node, append [index] if required
return createXpathElementCheck(path, index);
} | java | public static String createXpath(String path, int index) {
if (path.indexOf('/') > -1) {
// this is a complex path over more then 1 node
StringBuffer result = new StringBuffer(path.length() + 32);
// split the path into sub elements
List<String> elements = CmsStringUtil.splitAsList(path, '/');
int end = elements.size() - 1;
for (int i = 0; i <= end; i++) {
// append [i] to path element if required
result.append(createXpathElementCheck(elements.get(i), (i == end) ? index : 1));
if (i < end) {
// append path delimiter if not final path element
result.append('/');
}
}
return result.toString();
}
// this path has only 1 node, append [index] if required
return createXpathElementCheck(path, index);
} | [
"public",
"static",
"String",
"createXpath",
"(",
"String",
"path",
",",
"int",
"index",
")",
"{",
"if",
"(",
"path",
".",
"indexOf",
"(",
"'",
"'",
")",
">",
"-",
"1",
")",
"{",
"// this is a complex path over more then 1 node",
"StringBuffer",
"result",
"=",
"new",
"StringBuffer",
"(",
"path",
".",
"length",
"(",
")",
"+",
"32",
")",
";",
"// split the path into sub elements",
"List",
"<",
"String",
">",
"elements",
"=",
"CmsStringUtil",
".",
"splitAsList",
"(",
"path",
",",
"'",
"'",
")",
";",
"int",
"end",
"=",
"elements",
".",
"size",
"(",
")",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"end",
";",
"i",
"++",
")",
"{",
"// append [i] to path element if required",
"result",
".",
"append",
"(",
"createXpathElementCheck",
"(",
"elements",
".",
"get",
"(",
"i",
")",
",",
"(",
"i",
"==",
"end",
")",
"?",
"index",
":",
"1",
")",
")",
";",
"if",
"(",
"i",
"<",
"end",
")",
"{",
"// append path delimiter if not final path element",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}",
"// this path has only 1 node, append [index] if required",
"return",
"createXpathElementCheck",
"(",
"path",
",",
"index",
")",
";",
"}"
] | Translates a simple lookup path to the simplified Xpath format used for
the internal bookmarks.<p>
Examples:<br>
<code>title</code> becomes <code>title[1]</code><br>
<code>title[1]</code> is left untouched<br>
<code>title/subtitle</code> becomes <code>title[1]/subtitle[1]</code><br>
<code>title/subtitle[1]</code> becomes <code>title[1]/subtitle[1]</code><p>
Note: If the name already has the format <code>title[1]</code> then provided index parameter
is ignored.<p>
@param path the path to get the simplified Xpath for
@param index the index to append (if required)
@return the simplified Xpath for the given name | [
"Translates",
"a",
"simple",
"lookup",
"path",
"to",
"the",
"simplified",
"Xpath",
"format",
"used",
"for",
"the",
"internal",
"bookmarks",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/CmsXmlUtils.java#L177-L199 |
phax/ph-web | ph-httpclient/src/main/java/com/helger/httpclient/HttpDebugger.java | HttpDebugger.beforeRequest | public static void beforeRequest (@Nonnull final HttpUriRequest aRequest, @Nullable final HttpContext aHttpContext) {
"""
Call before an invocation
@param aRequest
The request to be executed. May not be <code>null</code>.
@param aHttpContext
The special HTTP content for this call. May be <code>null</code>.
"""
if (isEnabled ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Before HTTP call: " +
aRequest.getMethod () +
" " +
aRequest.getURI () +
(aHttpContext != null ? " (with special HTTP context)" : ""));
} | java | public static void beforeRequest (@Nonnull final HttpUriRequest aRequest, @Nullable final HttpContext aHttpContext)
{
if (isEnabled ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Before HTTP call: " +
aRequest.getMethod () +
" " +
aRequest.getURI () +
(aHttpContext != null ? " (with special HTTP context)" : ""));
} | [
"public",
"static",
"void",
"beforeRequest",
"(",
"@",
"Nonnull",
"final",
"HttpUriRequest",
"aRequest",
",",
"@",
"Nullable",
"final",
"HttpContext",
"aHttpContext",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
")",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
"(",
")",
")",
"LOGGER",
".",
"info",
"(",
"\"Before HTTP call: \"",
"+",
"aRequest",
".",
"getMethod",
"(",
")",
"+",
"\" \"",
"+",
"aRequest",
".",
"getURI",
"(",
")",
"+",
"(",
"aHttpContext",
"!=",
"null",
"?",
"\" (with special HTTP context)\"",
":",
"\"\"",
")",
")",
";",
"}"
] | Call before an invocation
@param aRequest
The request to be executed. May not be <code>null</code>.
@param aHttpContext
The special HTTP content for this call. May be <code>null</code>. | [
"Call",
"before",
"an",
"invocation"
] | train | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-httpclient/src/main/java/com/helger/httpclient/HttpDebugger.java#L66-L75 |
OpenLiberty/open-liberty | dev/com.ibm.ws.transport.http/src/com/ibm/ws/genericbnf/internal/BNFHeadersImpl.java | BNFHeadersImpl.removeHdrInstances | private void removeHdrInstances(HeaderElement root, boolean bFilter) {
"""
Remove all instances of this header.
@param root
@param bFilter
"""
if (null == root) {
return;
}
HeaderKeys key = root.getKey();
if (bFilter && key.useFilters()) {
filterRemove(key, null);
}
HeaderElement elem = root;
while (null != elem) {
elem.remove();
elem = elem.nextInstance;
}
} | java | private void removeHdrInstances(HeaderElement root, boolean bFilter) {
if (null == root) {
return;
}
HeaderKeys key = root.getKey();
if (bFilter && key.useFilters()) {
filterRemove(key, null);
}
HeaderElement elem = root;
while (null != elem) {
elem.remove();
elem = elem.nextInstance;
}
} | [
"private",
"void",
"removeHdrInstances",
"(",
"HeaderElement",
"root",
",",
"boolean",
"bFilter",
")",
"{",
"if",
"(",
"null",
"==",
"root",
")",
"{",
"return",
";",
"}",
"HeaderKeys",
"key",
"=",
"root",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"bFilter",
"&&",
"key",
".",
"useFilters",
"(",
")",
")",
"{",
"filterRemove",
"(",
"key",
",",
"null",
")",
";",
"}",
"HeaderElement",
"elem",
"=",
"root",
";",
"while",
"(",
"null",
"!=",
"elem",
")",
"{",
"elem",
".",
"remove",
"(",
")",
";",
"elem",
"=",
"elem",
".",
"nextInstance",
";",
"}",
"}"
] | Remove all instances of this header.
@param root
@param bFilter | [
"Remove",
"all",
"instances",
"of",
"this",
"header",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.transport.http/src/com/ibm/ws/genericbnf/internal/BNFHeadersImpl.java#L2290-L2303 |
VoltDB/voltdb | third_party/java/src/org/HdrHistogram_voltpatches/AtomicHistogram.java | AtomicHistogram.decodeFromCompressedByteBuffer | public static AtomicHistogram decodeFromCompressedByteBuffer(final ByteBuffer buffer,
final long minBarForHighestTrackableValue) throws DataFormatException {
"""
Construct a new histogram by decoding it from a compressed form in a ByteBuffer.
@param buffer The buffer to decode from
@param minBarForHighestTrackableValue Force highestTrackableValue to be set at least this high
@return The newly constructed histogram
@throws DataFormatException on error parsing/decompressing the buffer
"""
return decodeFromCompressedByteBuffer(buffer, AtomicHistogram.class, minBarForHighestTrackableValue);
} | java | public static AtomicHistogram decodeFromCompressedByteBuffer(final ByteBuffer buffer,
final long minBarForHighestTrackableValue) throws DataFormatException {
return decodeFromCompressedByteBuffer(buffer, AtomicHistogram.class, minBarForHighestTrackableValue);
} | [
"public",
"static",
"AtomicHistogram",
"decodeFromCompressedByteBuffer",
"(",
"final",
"ByteBuffer",
"buffer",
",",
"final",
"long",
"minBarForHighestTrackableValue",
")",
"throws",
"DataFormatException",
"{",
"return",
"decodeFromCompressedByteBuffer",
"(",
"buffer",
",",
"AtomicHistogram",
".",
"class",
",",
"minBarForHighestTrackableValue",
")",
";",
"}"
] | Construct a new histogram by decoding it from a compressed form in a ByteBuffer.
@param buffer The buffer to decode from
@param minBarForHighestTrackableValue Force highestTrackableValue to be set at least this high
@return The newly constructed histogram
@throws DataFormatException on error parsing/decompressing the buffer | [
"Construct",
"a",
"new",
"histogram",
"by",
"decoding",
"it",
"from",
"a",
"compressed",
"form",
"in",
"a",
"ByteBuffer",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/HdrHistogram_voltpatches/AtomicHistogram.java#L219-L222 |
apache/flink | flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java | MemorySegment.putLongLittleEndian | public final void putLongLittleEndian(int index, long value) {
"""
Writes the given long value (64bit, 8 bytes) to the given position in little endian
byte order. This method's speed depends on the system's native byte order, and it
is possibly slower than {@link #putLong(int, long)}. For most cases (such as
transient storage in memory or serialization for I/O and network),
it suffices to know that the byte order in which the value is written is the same as the
one in which it is read, and {@link #putLong(int, long)} is the preferable choice.
@param index The position at which the value will be written.
@param value The long value to be written.
@throws IndexOutOfBoundsException Thrown, if the index is negative, or larger than the segment
size minus 8.
"""
if (LITTLE_ENDIAN) {
putLong(index, value);
} else {
putLong(index, Long.reverseBytes(value));
}
} | java | public final void putLongLittleEndian(int index, long value) {
if (LITTLE_ENDIAN) {
putLong(index, value);
} else {
putLong(index, Long.reverseBytes(value));
}
} | [
"public",
"final",
"void",
"putLongLittleEndian",
"(",
"int",
"index",
",",
"long",
"value",
")",
"{",
"if",
"(",
"LITTLE_ENDIAN",
")",
"{",
"putLong",
"(",
"index",
",",
"value",
")",
";",
"}",
"else",
"{",
"putLong",
"(",
"index",
",",
"Long",
".",
"reverseBytes",
"(",
"value",
")",
")",
";",
"}",
"}"
] | Writes the given long value (64bit, 8 bytes) to the given position in little endian
byte order. This method's speed depends on the system's native byte order, and it
is possibly slower than {@link #putLong(int, long)}. For most cases (such as
transient storage in memory or serialization for I/O and network),
it suffices to know that the byte order in which the value is written is the same as the
one in which it is read, and {@link #putLong(int, long)} is the preferable choice.
@param index The position at which the value will be written.
@param value The long value to be written.
@throws IndexOutOfBoundsException Thrown, if the index is negative, or larger than the segment
size minus 8. | [
"Writes",
"the",
"given",
"long",
"value",
"(",
"64bit",
"8",
"bytes",
")",
"to",
"the",
"given",
"position",
"in",
"little",
"endian",
"byte",
"order",
".",
"This",
"method",
"s",
"speed",
"depends",
"on",
"the",
"system",
"s",
"native",
"byte",
"order",
"and",
"it",
"is",
"possibly",
"slower",
"than",
"{",
"@link",
"#putLong",
"(",
"int",
"long",
")",
"}",
".",
"For",
"most",
"cases",
"(",
"such",
"as",
"transient",
"storage",
"in",
"memory",
"or",
"serialization",
"for",
"I",
"/",
"O",
"and",
"network",
")",
"it",
"suffices",
"to",
"know",
"that",
"the",
"byte",
"order",
"in",
"which",
"the",
"value",
"is",
"written",
"is",
"the",
"same",
"as",
"the",
"one",
"in",
"which",
"it",
"is",
"read",
"and",
"{",
"@link",
"#putLong",
"(",
"int",
"long",
")",
"}",
"is",
"the",
"preferable",
"choice",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java#L934-L940 |
JodaOrg/joda-money | src/main/java/org/joda/money/BigMoney.java | BigMoney.minusRetainScale | public BigMoney minusRetainScale(BigMoneyProvider moneyToSubtract, RoundingMode roundingMode) {
"""
Returns a copy of this monetary value with the amount in the same currency subtracted
retaining the scale by rounding the result.
<p>
The scale of the result will be the same as the scale of this instance.
For example,'USD 25.95' minus 'USD 3.029' gives 'USD 22.92 with most rounding modes.
<p>
This instance is immutable and unaffected by this method.
@param moneyToSubtract the monetary value to add, not null
@param roundingMode the rounding mode to use to adjust the scale, not null
@return the new instance with the input amount subtracted, never null
"""
BigMoney toSubtract = checkCurrencyEqual(moneyToSubtract);
return minusRetainScale(toSubtract.getAmount(), roundingMode);
} | java | public BigMoney minusRetainScale(BigMoneyProvider moneyToSubtract, RoundingMode roundingMode) {
BigMoney toSubtract = checkCurrencyEqual(moneyToSubtract);
return minusRetainScale(toSubtract.getAmount(), roundingMode);
} | [
"public",
"BigMoney",
"minusRetainScale",
"(",
"BigMoneyProvider",
"moneyToSubtract",
",",
"RoundingMode",
"roundingMode",
")",
"{",
"BigMoney",
"toSubtract",
"=",
"checkCurrencyEqual",
"(",
"moneyToSubtract",
")",
";",
"return",
"minusRetainScale",
"(",
"toSubtract",
".",
"getAmount",
"(",
")",
",",
"roundingMode",
")",
";",
"}"
] | Returns a copy of this monetary value with the amount in the same currency subtracted
retaining the scale by rounding the result.
<p>
The scale of the result will be the same as the scale of this instance.
For example,'USD 25.95' minus 'USD 3.029' gives 'USD 22.92 with most rounding modes.
<p>
This instance is immutable and unaffected by this method.
@param moneyToSubtract the monetary value to add, not null
@param roundingMode the rounding mode to use to adjust the scale, not null
@return the new instance with the input amount subtracted, never null | [
"Returns",
"a",
"copy",
"of",
"this",
"monetary",
"value",
"with",
"the",
"amount",
"in",
"the",
"same",
"currency",
"subtracted",
"retaining",
"the",
"scale",
"by",
"rounding",
"the",
"result",
".",
"<p",
">",
"The",
"scale",
"of",
"the",
"result",
"will",
"be",
"the",
"same",
"as",
"the",
"scale",
"of",
"this",
"instance",
".",
"For",
"example",
"USD",
"25",
".",
"95",
"minus",
"USD",
"3",
".",
"029",
"gives",
"USD",
"22",
".",
"92",
"with",
"most",
"rounding",
"modes",
".",
"<p",
">",
"This",
"instance",
"is",
"immutable",
"and",
"unaffected",
"by",
"this",
"method",
"."
] | train | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/BigMoney.java#L1179-L1182 |
actorapp/actor-platform | actor-server/actor-frontend/src/main/java/im/actor/crypto/primitives/kuznechik/KuznechikCipher.java | KuznechikCipher.encryptBlock | public void encryptBlock(byte[] data, int offset, byte[] dest, int destOffset) {
"""
Encrypting Block with KuznechikImpl encryption
@param data 16-byte block for encryption
@param offset offset in block
@param dest destination array
@param destOffset destinaation offset
"""
// w128_t x;
// x.q[0] = ((uint64_t *) blk)[0];
// x.q[1] = ((uint64_t *) blk)[1];
Kuz128 x = new Kuz128();
x.setQ(0, ByteStrings.bytesToLong(data, offset));
x.setQ(1, ByteStrings.bytesToLong(data, offset + 8));
for (int i = 0; i < 9; i++) {
// x.q[0] ^= key->k[i].q[0];
// x.q[1] ^= key->k[i].q[1];
x.setQ(0, x.getQ(0) ^ key.getK()[i].getQ(0));
x.setQ(1, x.getQ(1) ^ key.getK()[i].getQ(1));
for (int j = 0; j < 16; j++) {
// x.b[j] = kuz_pi[x.b[j]];
x.getB()[j] = KuznechikTables.kuz_pi[(x.getB()[j] & 0xFF)];
}
// kuz_l(&x);
KuznechikMath.kuz_l(x);
}
// ((uint64_t *) blk)[0] = x.q[0] ^ key->k[9].q[0];
// ((uint64_t *) blk)[1] = x.q[1] ^ key->k[9].q[1];
ByteStrings.write(dest, destOffset, ByteStrings.longToBytes(x.getQ(0) ^ key.getK()[9].getQ(0)), 0, 8);
ByteStrings.write(dest, destOffset + 8, ByteStrings.longToBytes(x.getQ(1) ^ key.getK()[9].getQ(1)), 0, 8);
} | java | public void encryptBlock(byte[] data, int offset, byte[] dest, int destOffset) {
// w128_t x;
// x.q[0] = ((uint64_t *) blk)[0];
// x.q[1] = ((uint64_t *) blk)[1];
Kuz128 x = new Kuz128();
x.setQ(0, ByteStrings.bytesToLong(data, offset));
x.setQ(1, ByteStrings.bytesToLong(data, offset + 8));
for (int i = 0; i < 9; i++) {
// x.q[0] ^= key->k[i].q[0];
// x.q[1] ^= key->k[i].q[1];
x.setQ(0, x.getQ(0) ^ key.getK()[i].getQ(0));
x.setQ(1, x.getQ(1) ^ key.getK()[i].getQ(1));
for (int j = 0; j < 16; j++) {
// x.b[j] = kuz_pi[x.b[j]];
x.getB()[j] = KuznechikTables.kuz_pi[(x.getB()[j] & 0xFF)];
}
// kuz_l(&x);
KuznechikMath.kuz_l(x);
}
// ((uint64_t *) blk)[0] = x.q[0] ^ key->k[9].q[0];
// ((uint64_t *) blk)[1] = x.q[1] ^ key->k[9].q[1];
ByteStrings.write(dest, destOffset, ByteStrings.longToBytes(x.getQ(0) ^ key.getK()[9].getQ(0)), 0, 8);
ByteStrings.write(dest, destOffset + 8, ByteStrings.longToBytes(x.getQ(1) ^ key.getK()[9].getQ(1)), 0, 8);
} | [
"public",
"void",
"encryptBlock",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"byte",
"[",
"]",
"dest",
",",
"int",
"destOffset",
")",
"{",
"// w128_t x;",
"// x.q[0] = ((uint64_t *) blk)[0];",
"// x.q[1] = ((uint64_t *) blk)[1];",
"Kuz128",
"x",
"=",
"new",
"Kuz128",
"(",
")",
";",
"x",
".",
"setQ",
"(",
"0",
",",
"ByteStrings",
".",
"bytesToLong",
"(",
"data",
",",
"offset",
")",
")",
";",
"x",
".",
"setQ",
"(",
"1",
",",
"ByteStrings",
".",
"bytesToLong",
"(",
"data",
",",
"offset",
"+",
"8",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"9",
";",
"i",
"++",
")",
"{",
"// x.q[0] ^= key->k[i].q[0];",
"// x.q[1] ^= key->k[i].q[1];",
"x",
".",
"setQ",
"(",
"0",
",",
"x",
".",
"getQ",
"(",
"0",
")",
"^",
"key",
".",
"getK",
"(",
")",
"[",
"i",
"]",
".",
"getQ",
"(",
"0",
")",
")",
";",
"x",
".",
"setQ",
"(",
"1",
",",
"x",
".",
"getQ",
"(",
"1",
")",
"^",
"key",
".",
"getK",
"(",
")",
"[",
"i",
"]",
".",
"getQ",
"(",
"1",
")",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"16",
";",
"j",
"++",
")",
"{",
"// x.b[j] = kuz_pi[x.b[j]];",
"x",
".",
"getB",
"(",
")",
"[",
"j",
"]",
"=",
"KuznechikTables",
".",
"kuz_pi",
"[",
"(",
"x",
".",
"getB",
"(",
")",
"[",
"j",
"]",
"&",
"0xFF",
")",
"]",
";",
"}",
"// kuz_l(&x);",
"KuznechikMath",
".",
"kuz_l",
"(",
"x",
")",
";",
"}",
"// ((uint64_t *) blk)[0] = x.q[0] ^ key->k[9].q[0];",
"// ((uint64_t *) blk)[1] = x.q[1] ^ key->k[9].q[1];",
"ByteStrings",
".",
"write",
"(",
"dest",
",",
"destOffset",
",",
"ByteStrings",
".",
"longToBytes",
"(",
"x",
".",
"getQ",
"(",
"0",
")",
"^",
"key",
".",
"getK",
"(",
")",
"[",
"9",
"]",
".",
"getQ",
"(",
"0",
")",
")",
",",
"0",
",",
"8",
")",
";",
"ByteStrings",
".",
"write",
"(",
"dest",
",",
"destOffset",
"+",
"8",
",",
"ByteStrings",
".",
"longToBytes",
"(",
"x",
".",
"getQ",
"(",
"1",
")",
"^",
"key",
".",
"getK",
"(",
")",
"[",
"9",
"]",
".",
"getQ",
"(",
"1",
")",
")",
",",
"0",
",",
"8",
")",
";",
"}"
] | Encrypting Block with KuznechikImpl encryption
@param data 16-byte block for encryption
@param offset offset in block
@param dest destination array
@param destOffset destinaation offset | [
"Encrypting",
"Block",
"with",
"KuznechikImpl",
"encryption"
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-server/actor-frontend/src/main/java/im/actor/crypto/primitives/kuznechik/KuznechikCipher.java#L31-L57 |
infinispan/infinispan | client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transaction/entry/Modification.java | Modification.writeTo | public void writeTo(ByteBuf byteBuf, Codec codec) {
"""
Writes this modification to the {@link ByteBuf}.
@param byteBuf the {@link ByteBuf} to write to.
@param codec the {@link Codec} to use.
"""
writeArray(byteBuf, key);
byteBuf.writeByte(control);
if (!ControlByte.NON_EXISTING.hasFlag(control) && !ControlByte.NOT_READ.hasFlag(control)) {
byteBuf.writeLong(versionRead);
}
if (ControlByte.REMOVE_OP.hasFlag(control)) {
return;
}
codec.writeExpirationParams(byteBuf, lifespan, lifespanTimeUnit, maxIdle, maxIdleTimeUnit);
writeArray(byteBuf, value);
} | java | public void writeTo(ByteBuf byteBuf, Codec codec) {
writeArray(byteBuf, key);
byteBuf.writeByte(control);
if (!ControlByte.NON_EXISTING.hasFlag(control) && !ControlByte.NOT_READ.hasFlag(control)) {
byteBuf.writeLong(versionRead);
}
if (ControlByte.REMOVE_OP.hasFlag(control)) {
return;
}
codec.writeExpirationParams(byteBuf, lifespan, lifespanTimeUnit, maxIdle, maxIdleTimeUnit);
writeArray(byteBuf, value);
} | [
"public",
"void",
"writeTo",
"(",
"ByteBuf",
"byteBuf",
",",
"Codec",
"codec",
")",
"{",
"writeArray",
"(",
"byteBuf",
",",
"key",
")",
";",
"byteBuf",
".",
"writeByte",
"(",
"control",
")",
";",
"if",
"(",
"!",
"ControlByte",
".",
"NON_EXISTING",
".",
"hasFlag",
"(",
"control",
")",
"&&",
"!",
"ControlByte",
".",
"NOT_READ",
".",
"hasFlag",
"(",
"control",
")",
")",
"{",
"byteBuf",
".",
"writeLong",
"(",
"versionRead",
")",
";",
"}",
"if",
"(",
"ControlByte",
".",
"REMOVE_OP",
".",
"hasFlag",
"(",
"control",
")",
")",
"{",
"return",
";",
"}",
"codec",
".",
"writeExpirationParams",
"(",
"byteBuf",
",",
"lifespan",
",",
"lifespanTimeUnit",
",",
"maxIdle",
",",
"maxIdleTimeUnit",
")",
";",
"writeArray",
"(",
"byteBuf",
",",
"value",
")",
";",
"}"
] | Writes this modification to the {@link ByteBuf}.
@param byteBuf the {@link ByteBuf} to write to.
@param codec the {@link Codec} to use. | [
"Writes",
"this",
"modification",
"to",
"the",
"{",
"@link",
"ByteBuf",
"}",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transaction/entry/Modification.java#L47-L59 |
GenesysPureEngage/authentication-client-java | src/main/java/com/genesys/internal/authentication/api/AuthenticationApi.java | AuthenticationApi.retrieveTokenWithHttpInfo | public ApiResponse<DefaultOAuth2AccessToken> retrieveTokenWithHttpInfo(String grantType, String accept, String authorization, String clientId, String password, String refreshToken, String scope, String username) throws ApiException {
"""
Retrieve access token
Retrieve an access token based on the grant type &mdash; Authorization Code Grant, Resource Owner Password Credentials Grant or Client Credentials Grant. For more information, see [Token Endpoint](https://tools.ietf.org/html/rfc6749). **Note:** For the optional **scope** parameter, the Authentication API supports only the `*` value.
@param grantType The grant type you use to implement authentication. (required)
@param accept The media type the Authentication API should should use for the response. For example: 'Accept: application/x-www-form-urlencoded' (optional)
@param authorization Basic authorization. For example: 'Authorization: Basic Y3...MQ==' (optional)
@param clientId The ID of the application or service that is registered as the client. You'll need to get this value from your PureEngage Cloud representative. (optional)
@param password The agent's password. (optional)
@param refreshToken See [Refresh Token](https://tools.ietf.org/html/rfc6749#section-1.5) for details. (optional)
@param scope The scope of the access request. The Authentication API supports only the `*` value. (optional)
@param username The agent's username. (optional)
@return ApiResponse<DefaultOAuth2AccessToken>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
com.squareup.okhttp.Call call = retrieveTokenValidateBeforeCall(grantType, accept, authorization, clientId, password, refreshToken, scope, username, null, null);
Type localVarReturnType = new TypeToken<DefaultOAuth2AccessToken>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | java | public ApiResponse<DefaultOAuth2AccessToken> retrieveTokenWithHttpInfo(String grantType, String accept, String authorization, String clientId, String password, String refreshToken, String scope, String username) throws ApiException {
com.squareup.okhttp.Call call = retrieveTokenValidateBeforeCall(grantType, accept, authorization, clientId, password, refreshToken, scope, username, null, null);
Type localVarReturnType = new TypeToken<DefaultOAuth2AccessToken>(){}.getType();
return apiClient.execute(call, localVarReturnType);
} | [
"public",
"ApiResponse",
"<",
"DefaultOAuth2AccessToken",
">",
"retrieveTokenWithHttpInfo",
"(",
"String",
"grantType",
",",
"String",
"accept",
",",
"String",
"authorization",
",",
"String",
"clientId",
",",
"String",
"password",
",",
"String",
"refreshToken",
",",
"String",
"scope",
",",
"String",
"username",
")",
"throws",
"ApiException",
"{",
"com",
".",
"squareup",
".",
"okhttp",
".",
"Call",
"call",
"=",
"retrieveTokenValidateBeforeCall",
"(",
"grantType",
",",
"accept",
",",
"authorization",
",",
"clientId",
",",
"password",
",",
"refreshToken",
",",
"scope",
",",
"username",
",",
"null",
",",
"null",
")",
";",
"Type",
"localVarReturnType",
"=",
"new",
"TypeToken",
"<",
"DefaultOAuth2AccessToken",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"return",
"apiClient",
".",
"execute",
"(",
"call",
",",
"localVarReturnType",
")",
";",
"}"
] | Retrieve access token
Retrieve an access token based on the grant type &mdash; Authorization Code Grant, Resource Owner Password Credentials Grant or Client Credentials Grant. For more information, see [Token Endpoint](https://tools.ietf.org/html/rfc6749). **Note:** For the optional **scope** parameter, the Authentication API supports only the `*` value.
@param grantType The grant type you use to implement authentication. (required)
@param accept The media type the Authentication API should should use for the response. For example: 'Accept: application/x-www-form-urlencoded' (optional)
@param authorization Basic authorization. For example: 'Authorization: Basic Y3...MQ==' (optional)
@param clientId The ID of the application or service that is registered as the client. You'll need to get this value from your PureEngage Cloud representative. (optional)
@param password The agent's password. (optional)
@param refreshToken See [Refresh Token](https://tools.ietf.org/html/rfc6749#section-1.5) for details. (optional)
@param scope The scope of the access request. The Authentication API supports only the `*` value. (optional)
@param username The agent's username. (optional)
@return ApiResponse<DefaultOAuth2AccessToken>
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Retrieve",
"access",
"token",
"Retrieve",
"an",
"access",
"token",
"based",
"on",
"the",
"grant",
"type",
"&",
";",
"mdash",
";",
"Authorization",
"Code",
"Grant",
"Resource",
"Owner",
"Password",
"Credentials",
"Grant",
"or",
"Client",
"Credentials",
"Grant",
".",
"For",
"more",
"information",
"see",
"[",
"Token",
"Endpoint",
"]",
"(",
"https",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc6749",
")",
".",
"**",
"Note",
":",
"**",
"For",
"the",
"optional",
"**",
"scope",
"**",
"parameter",
"the",
"Authentication",
"API",
"supports",
"only",
"the",
"`",
";",
"*",
"`",
";",
"value",
"."
] | train | https://github.com/GenesysPureEngage/authentication-client-java/blob/eb0d58343ee42ebd3c037163c1137f611dfcbb3a/src/main/java/com/genesys/internal/authentication/api/AuthenticationApi.java#L1068-L1072 |
mpetazzoni/ttorrent | common/src/main/java/com/turn/ttorrent/common/protocol/http/HTTPAnnounceResponseMessage.java | HTTPAnnounceResponseMessage.toPeerList | private static List<Peer> toPeerList(byte[] data)
throws InvalidBEncodingException, UnknownHostException {
"""
Build a peer list as a list of {@link Peer}s from the
announce response's binary compact peer list.
@param data The bytes representing the compact peer list from the
announce response.
@return A {@link List} of {@link Peer}s representing the
peers' addresses. Peer IDs are lost, but they are not crucial.
"""
if (data.length % 6 != 0) {
throw new InvalidBEncodingException("Invalid peers " +
"binary information string!");
}
List<Peer> result = new LinkedList<Peer>();
ByteBuffer peers = ByteBuffer.wrap(data);
for (int i = 0; i < data.length / 6; i++) {
byte[] ipBytes = new byte[4];
peers.get(ipBytes);
InetAddress ip = InetAddress.getByAddress(ipBytes);
int port =
(0xFF & (int) peers.get()) << 8 |
(0xFF & (int) peers.get());
result.add(new Peer(new InetSocketAddress(ip, port)));
}
return result;
} | java | private static List<Peer> toPeerList(byte[] data)
throws InvalidBEncodingException, UnknownHostException {
if (data.length % 6 != 0) {
throw new InvalidBEncodingException("Invalid peers " +
"binary information string!");
}
List<Peer> result = new LinkedList<Peer>();
ByteBuffer peers = ByteBuffer.wrap(data);
for (int i = 0; i < data.length / 6; i++) {
byte[] ipBytes = new byte[4];
peers.get(ipBytes);
InetAddress ip = InetAddress.getByAddress(ipBytes);
int port =
(0xFF & (int) peers.get()) << 8 |
(0xFF & (int) peers.get());
result.add(new Peer(new InetSocketAddress(ip, port)));
}
return result;
} | [
"private",
"static",
"List",
"<",
"Peer",
">",
"toPeerList",
"(",
"byte",
"[",
"]",
"data",
")",
"throws",
"InvalidBEncodingException",
",",
"UnknownHostException",
"{",
"if",
"(",
"data",
".",
"length",
"%",
"6",
"!=",
"0",
")",
"{",
"throw",
"new",
"InvalidBEncodingException",
"(",
"\"Invalid peers \"",
"+",
"\"binary information string!\"",
")",
";",
"}",
"List",
"<",
"Peer",
">",
"result",
"=",
"new",
"LinkedList",
"<",
"Peer",
">",
"(",
")",
";",
"ByteBuffer",
"peers",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"data",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
"/",
"6",
";",
"i",
"++",
")",
"{",
"byte",
"[",
"]",
"ipBytes",
"=",
"new",
"byte",
"[",
"4",
"]",
";",
"peers",
".",
"get",
"(",
"ipBytes",
")",
";",
"InetAddress",
"ip",
"=",
"InetAddress",
".",
"getByAddress",
"(",
"ipBytes",
")",
";",
"int",
"port",
"=",
"(",
"0xFF",
"&",
"(",
"int",
")",
"peers",
".",
"get",
"(",
")",
")",
"<<",
"8",
"|",
"(",
"0xFF",
"&",
"(",
"int",
")",
"peers",
".",
"get",
"(",
")",
")",
";",
"result",
".",
"add",
"(",
"new",
"Peer",
"(",
"new",
"InetSocketAddress",
"(",
"ip",
",",
"port",
")",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Build a peer list as a list of {@link Peer}s from the
announce response's binary compact peer list.
@param data The bytes representing the compact peer list from the
announce response.
@return A {@link List} of {@link Peer}s representing the
peers' addresses. Peer IDs are lost, but they are not crucial. | [
"Build",
"a",
"peer",
"list",
"as",
"a",
"list",
"of",
"{",
"@link",
"Peer",
"}",
"s",
"from",
"the",
"announce",
"response",
"s",
"binary",
"compact",
"peer",
"list",
"."
] | train | https://github.com/mpetazzoni/ttorrent/blob/ecd0e6caf853b63393c4ab63cfd8f20114f73f70/common/src/main/java/com/turn/ttorrent/common/protocol/http/HTTPAnnounceResponseMessage.java#L167-L188 |
JodaOrg/joda-time | src/main/java/org/joda/time/chrono/BuddhistChronology.java | BuddhistChronology.getInstance | public static BuddhistChronology getInstance(DateTimeZone zone) {
"""
Standard instance of a Buddhist Chronology, that matches
Sun's BuddhistCalendar class. This means that it follows the
GregorianJulian calendar rules with a cutover date.
@param zone the time zone to use, null is default
"""
if (zone == null) {
zone = DateTimeZone.getDefault();
}
BuddhistChronology chrono = cCache.get(zone);
if (chrono == null) {
// First create without a lower limit.
chrono = new BuddhistChronology(GJChronology.getInstance(zone, null), null);
// Impose lower limit and make another BuddhistChronology.
DateTime lowerLimit = new DateTime(1, 1, 1, 0, 0, 0, 0, chrono);
chrono = new BuddhistChronology(LimitChronology.getInstance(chrono, lowerLimit, null), "");
BuddhistChronology oldChrono = cCache.putIfAbsent(zone, chrono);
if (oldChrono != null) {
chrono = oldChrono;
}
}
return chrono;
} | java | public static BuddhistChronology getInstance(DateTimeZone zone) {
if (zone == null) {
zone = DateTimeZone.getDefault();
}
BuddhistChronology chrono = cCache.get(zone);
if (chrono == null) {
// First create without a lower limit.
chrono = new BuddhistChronology(GJChronology.getInstance(zone, null), null);
// Impose lower limit and make another BuddhistChronology.
DateTime lowerLimit = new DateTime(1, 1, 1, 0, 0, 0, 0, chrono);
chrono = new BuddhistChronology(LimitChronology.getInstance(chrono, lowerLimit, null), "");
BuddhistChronology oldChrono = cCache.putIfAbsent(zone, chrono);
if (oldChrono != null) {
chrono = oldChrono;
}
}
return chrono;
} | [
"public",
"static",
"BuddhistChronology",
"getInstance",
"(",
"DateTimeZone",
"zone",
")",
"{",
"if",
"(",
"zone",
"==",
"null",
")",
"{",
"zone",
"=",
"DateTimeZone",
".",
"getDefault",
"(",
")",
";",
"}",
"BuddhistChronology",
"chrono",
"=",
"cCache",
".",
"get",
"(",
"zone",
")",
";",
"if",
"(",
"chrono",
"==",
"null",
")",
"{",
"// First create without a lower limit.",
"chrono",
"=",
"new",
"BuddhistChronology",
"(",
"GJChronology",
".",
"getInstance",
"(",
"zone",
",",
"null",
")",
",",
"null",
")",
";",
"// Impose lower limit and make another BuddhistChronology.",
"DateTime",
"lowerLimit",
"=",
"new",
"DateTime",
"(",
"1",
",",
"1",
",",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"chrono",
")",
";",
"chrono",
"=",
"new",
"BuddhistChronology",
"(",
"LimitChronology",
".",
"getInstance",
"(",
"chrono",
",",
"lowerLimit",
",",
"null",
")",
",",
"\"\"",
")",
";",
"BuddhistChronology",
"oldChrono",
"=",
"cCache",
".",
"putIfAbsent",
"(",
"zone",
",",
"chrono",
")",
";",
"if",
"(",
"oldChrono",
"!=",
"null",
")",
"{",
"chrono",
"=",
"oldChrono",
";",
"}",
"}",
"return",
"chrono",
";",
"}"
] | Standard instance of a Buddhist Chronology, that matches
Sun's BuddhistCalendar class. This means that it follows the
GregorianJulian calendar rules with a cutover date.
@param zone the time zone to use, null is default | [
"Standard",
"instance",
"of",
"a",
"Buddhist",
"Chronology",
"that",
"matches",
"Sun",
"s",
"BuddhistCalendar",
"class",
".",
"This",
"means",
"that",
"it",
"follows",
"the",
"GregorianJulian",
"calendar",
"rules",
"with",
"a",
"cutover",
"date",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BuddhistChronology.java#L104-L121 |
biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/RotationAxis.java | RotationAxis.getJmolScript | public String getJmolScript(Atom[] atoms, int axisID) {
"""
Returns a Jmol script which will display the axis of rotation. This
consists of a cyan arrow along the axis, plus an arc showing the angle
of rotation.
<p>
As the rotation angle gets smaller, the axis of rotation becomes poorly
defined and would need to get farther and farther away from the protein.
This is not particularly useful, so we arbitrarily draw it parallel to
the translation and omit the arc.
@param atoms Some atoms from the protein, used for determining the bounds
of the axis.
@param axisID in case of representing more than one axis in the same jmol
panel, indicate the ID number.
@return The Jmol script, suitable for calls to
{@link org.biojava.nbio.structure.align.gui.jmol.StructureAlignmentJmol#evalString() jmol.evalString()}
"""
final double width=.5;// width of JMol object
final String axisColor = "yellow"; //axis color
final String screwColor = "orange"; //screw translation color
Pair<Atom> endPoints = getAxisEnds(atoms);
Atom axisMin = endPoints.getFirst();
Atom axisMax = endPoints.getSecond();
StringWriter result = new StringWriter();
// set arrow heads to a reasonable length
result.append("set defaultDrawArrowScale 2.0;");
// draw axis of rotation
result.append(
String.format("draw ID rot"+axisID+" CYLINDER {%f,%f,%f} {%f,%f,%f} WIDTH %f COLOR %s ;",
axisMin.getX(),axisMin.getY(),axisMin.getZ(),
axisMax.getX(),axisMax.getY(),axisMax.getZ(), width, axisColor ));
// draw screw component
boolean positiveScrew = Math.signum(rotationAxis.getX()) == Math.signum(screwTranslation.getX());
if( positiveScrew ) {
// screw is in the same direction as the axis
result.append( String.format(
"draw ID screw"+axisID+" VECTOR {%f,%f,%f} {%f,%f,%f} WIDTH %f COLOR %s ;",
axisMax.getX(),axisMax.getY(),axisMax.getZ(),
screwTranslation.getX(),screwTranslation.getY(),screwTranslation.getZ(),
width, screwColor ));
} else {
// screw is in the opposite direction as the axis
result.append( String.format(
"draw ID screw"+axisID+" VECTOR {%f,%f,%f} {%f,%f,%f} WIDTH %f COLOR %s ;",
axisMin.getX(),axisMin.getY(),axisMin.getZ(),
screwTranslation.getX(),screwTranslation.getY(),screwTranslation.getZ(),
width, screwColor ));
}
// draw angle of rotation
if(rotationPos != null) {
result.append(System.getProperty("line.separator"));
result.append(String.format("draw ID rotArc"+axisID+" ARC {%f,%f,%f} {%f,%f,%f} {0,0,0} {0,%f,%d} SCALE 500 DIAMETER %f COLOR %s;",
axisMin.getX(),axisMin.getY(),axisMin.getZ(),
axisMax.getX(),axisMax.getY(),axisMax.getZ(),
Math.toDegrees(theta),
positiveScrew ? 0 : 1 , // draw at the opposite end from the screw arrow
width, axisColor ));
}
return result.toString();
} | java | public String getJmolScript(Atom[] atoms, int axisID){
final double width=.5;// width of JMol object
final String axisColor = "yellow"; //axis color
final String screwColor = "orange"; //screw translation color
Pair<Atom> endPoints = getAxisEnds(atoms);
Atom axisMin = endPoints.getFirst();
Atom axisMax = endPoints.getSecond();
StringWriter result = new StringWriter();
// set arrow heads to a reasonable length
result.append("set defaultDrawArrowScale 2.0;");
// draw axis of rotation
result.append(
String.format("draw ID rot"+axisID+" CYLINDER {%f,%f,%f} {%f,%f,%f} WIDTH %f COLOR %s ;",
axisMin.getX(),axisMin.getY(),axisMin.getZ(),
axisMax.getX(),axisMax.getY(),axisMax.getZ(), width, axisColor ));
// draw screw component
boolean positiveScrew = Math.signum(rotationAxis.getX()) == Math.signum(screwTranslation.getX());
if( positiveScrew ) {
// screw is in the same direction as the axis
result.append( String.format(
"draw ID screw"+axisID+" VECTOR {%f,%f,%f} {%f,%f,%f} WIDTH %f COLOR %s ;",
axisMax.getX(),axisMax.getY(),axisMax.getZ(),
screwTranslation.getX(),screwTranslation.getY(),screwTranslation.getZ(),
width, screwColor ));
} else {
// screw is in the opposite direction as the axis
result.append( String.format(
"draw ID screw"+axisID+" VECTOR {%f,%f,%f} {%f,%f,%f} WIDTH %f COLOR %s ;",
axisMin.getX(),axisMin.getY(),axisMin.getZ(),
screwTranslation.getX(),screwTranslation.getY(),screwTranslation.getZ(),
width, screwColor ));
}
// draw angle of rotation
if(rotationPos != null) {
result.append(System.getProperty("line.separator"));
result.append(String.format("draw ID rotArc"+axisID+" ARC {%f,%f,%f} {%f,%f,%f} {0,0,0} {0,%f,%d} SCALE 500 DIAMETER %f COLOR %s;",
axisMin.getX(),axisMin.getY(),axisMin.getZ(),
axisMax.getX(),axisMax.getY(),axisMax.getZ(),
Math.toDegrees(theta),
positiveScrew ? 0 : 1 , // draw at the opposite end from the screw arrow
width, axisColor ));
}
return result.toString();
} | [
"public",
"String",
"getJmolScript",
"(",
"Atom",
"[",
"]",
"atoms",
",",
"int",
"axisID",
")",
"{",
"final",
"double",
"width",
"=",
".5",
";",
"// width of JMol object",
"final",
"String",
"axisColor",
"=",
"\"yellow\"",
";",
"//axis color",
"final",
"String",
"screwColor",
"=",
"\"orange\"",
";",
"//screw translation color",
"Pair",
"<",
"Atom",
">",
"endPoints",
"=",
"getAxisEnds",
"(",
"atoms",
")",
";",
"Atom",
"axisMin",
"=",
"endPoints",
".",
"getFirst",
"(",
")",
";",
"Atom",
"axisMax",
"=",
"endPoints",
".",
"getSecond",
"(",
")",
";",
"StringWriter",
"result",
"=",
"new",
"StringWriter",
"(",
")",
";",
"// set arrow heads to a reasonable length",
"result",
".",
"append",
"(",
"\"set defaultDrawArrowScale 2.0;\"",
")",
";",
"// draw axis of rotation",
"result",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"draw ID rot\"",
"+",
"axisID",
"+",
"\" CYLINDER {%f,%f,%f} {%f,%f,%f} WIDTH %f COLOR %s ;\"",
",",
"axisMin",
".",
"getX",
"(",
")",
",",
"axisMin",
".",
"getY",
"(",
")",
",",
"axisMin",
".",
"getZ",
"(",
")",
",",
"axisMax",
".",
"getX",
"(",
")",
",",
"axisMax",
".",
"getY",
"(",
")",
",",
"axisMax",
".",
"getZ",
"(",
")",
",",
"width",
",",
"axisColor",
")",
")",
";",
"// draw screw component",
"boolean",
"positiveScrew",
"=",
"Math",
".",
"signum",
"(",
"rotationAxis",
".",
"getX",
"(",
")",
")",
"==",
"Math",
".",
"signum",
"(",
"screwTranslation",
".",
"getX",
"(",
")",
")",
";",
"if",
"(",
"positiveScrew",
")",
"{",
"// screw is in the same direction as the axis",
"result",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"draw ID screw\"",
"+",
"axisID",
"+",
"\" VECTOR {%f,%f,%f} {%f,%f,%f} WIDTH %f COLOR %s ;\"",
",",
"axisMax",
".",
"getX",
"(",
")",
",",
"axisMax",
".",
"getY",
"(",
")",
",",
"axisMax",
".",
"getZ",
"(",
")",
",",
"screwTranslation",
".",
"getX",
"(",
")",
",",
"screwTranslation",
".",
"getY",
"(",
")",
",",
"screwTranslation",
".",
"getZ",
"(",
")",
",",
"width",
",",
"screwColor",
")",
")",
";",
"}",
"else",
"{",
"// screw is in the opposite direction as the axis",
"result",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"draw ID screw\"",
"+",
"axisID",
"+",
"\" VECTOR {%f,%f,%f} {%f,%f,%f} WIDTH %f COLOR %s ;\"",
",",
"axisMin",
".",
"getX",
"(",
")",
",",
"axisMin",
".",
"getY",
"(",
")",
",",
"axisMin",
".",
"getZ",
"(",
")",
",",
"screwTranslation",
".",
"getX",
"(",
")",
",",
"screwTranslation",
".",
"getY",
"(",
")",
",",
"screwTranslation",
".",
"getZ",
"(",
")",
",",
"width",
",",
"screwColor",
")",
")",
";",
"}",
"// draw angle of rotation",
"if",
"(",
"rotationPos",
"!=",
"null",
")",
"{",
"result",
".",
"append",
"(",
"System",
".",
"getProperty",
"(",
"\"line.separator\"",
")",
")",
";",
"result",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"draw ID rotArc\"",
"+",
"axisID",
"+",
"\" ARC {%f,%f,%f} {%f,%f,%f} {0,0,0} {0,%f,%d} SCALE 500 DIAMETER %f COLOR %s;\"",
",",
"axisMin",
".",
"getX",
"(",
")",
",",
"axisMin",
".",
"getY",
"(",
")",
",",
"axisMin",
".",
"getZ",
"(",
")",
",",
"axisMax",
".",
"getX",
"(",
")",
",",
"axisMax",
".",
"getY",
"(",
")",
",",
"axisMax",
".",
"getZ",
"(",
")",
",",
"Math",
".",
"toDegrees",
"(",
"theta",
")",
",",
"positiveScrew",
"?",
"0",
":",
"1",
",",
"// draw at the opposite end from the screw arrow",
"width",
",",
"axisColor",
")",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Returns a Jmol script which will display the axis of rotation. This
consists of a cyan arrow along the axis, plus an arc showing the angle
of rotation.
<p>
As the rotation angle gets smaller, the axis of rotation becomes poorly
defined and would need to get farther and farther away from the protein.
This is not particularly useful, so we arbitrarily draw it parallel to
the translation and omit the arc.
@param atoms Some atoms from the protein, used for determining the bounds
of the axis.
@param axisID in case of representing more than one axis in the same jmol
panel, indicate the ID number.
@return The Jmol script, suitable for calls to
{@link org.biojava.nbio.structure.align.gui.jmol.StructureAlignmentJmol#evalString() jmol.evalString()} | [
"Returns",
"a",
"Jmol",
"script",
"which",
"will",
"display",
"the",
"axis",
"of",
"rotation",
".",
"This",
"consists",
"of",
"a",
"cyan",
"arrow",
"along",
"the",
"axis",
"plus",
"an",
"arc",
"showing",
"the",
"angle",
"of",
"rotation",
".",
"<p",
">",
"As",
"the",
"rotation",
"angle",
"gets",
"smaller",
"the",
"axis",
"of",
"rotation",
"becomes",
"poorly",
"defined",
"and",
"would",
"need",
"to",
"get",
"farther",
"and",
"farther",
"away",
"from",
"the",
"protein",
".",
"This",
"is",
"not",
"particularly",
"useful",
"so",
"we",
"arbitrarily",
"draw",
"it",
"parallel",
"to",
"the",
"translation",
"and",
"omit",
"the",
"arc",
".",
"@param",
"atoms",
"Some",
"atoms",
"from",
"the",
"protein",
"used",
"for",
"determining",
"the",
"bounds",
"of",
"the",
"axis",
".",
"@param",
"axisID",
"in",
"case",
"of",
"representing",
"more",
"than",
"one",
"axis",
"in",
"the",
"same",
"jmol",
"panel",
"indicate",
"the",
"ID",
"number",
"."
] | train | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/RotationAxis.java#L447-L497 |
mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java | LatLongUtils.parseCoordinateString | public static double[] parseCoordinateString(String coordinatesString, int numberOfCoordinates) {
"""
Parses a given number of comma-separated coordinate values from the supplied string.
@param coordinatesString a comma-separated string of coordinate values.
@param numberOfCoordinates the expected number of coordinate values in the string.
@return the coordinate values in the order they have been parsed from the string.
@throws IllegalArgumentException if the string is invalid or does not contain the given number of coordinate values.
"""
StringTokenizer stringTokenizer = new StringTokenizer(coordinatesString, DELIMITER, true);
boolean isDelimiter = true;
List<String> tokens = new ArrayList<>(numberOfCoordinates);
while (stringTokenizer.hasMoreTokens()) {
String token = stringTokenizer.nextToken();
isDelimiter = !isDelimiter;
if (isDelimiter) {
continue;
}
tokens.add(token);
}
if (isDelimiter) {
throw new IllegalArgumentException("invalid coordinate delimiter: " + coordinatesString);
} else if (tokens.size() != numberOfCoordinates) {
throw new IllegalArgumentException("invalid number of coordinate values: " + coordinatesString);
}
double[] coordinates = new double[numberOfCoordinates];
for (int i = 0; i < numberOfCoordinates; ++i) {
coordinates[i] = Double.parseDouble(tokens.get(i));
}
return coordinates;
} | java | public static double[] parseCoordinateString(String coordinatesString, int numberOfCoordinates) {
StringTokenizer stringTokenizer = new StringTokenizer(coordinatesString, DELIMITER, true);
boolean isDelimiter = true;
List<String> tokens = new ArrayList<>(numberOfCoordinates);
while (stringTokenizer.hasMoreTokens()) {
String token = stringTokenizer.nextToken();
isDelimiter = !isDelimiter;
if (isDelimiter) {
continue;
}
tokens.add(token);
}
if (isDelimiter) {
throw new IllegalArgumentException("invalid coordinate delimiter: " + coordinatesString);
} else if (tokens.size() != numberOfCoordinates) {
throw new IllegalArgumentException("invalid number of coordinate values: " + coordinatesString);
}
double[] coordinates = new double[numberOfCoordinates];
for (int i = 0; i < numberOfCoordinates; ++i) {
coordinates[i] = Double.parseDouble(tokens.get(i));
}
return coordinates;
} | [
"public",
"static",
"double",
"[",
"]",
"parseCoordinateString",
"(",
"String",
"coordinatesString",
",",
"int",
"numberOfCoordinates",
")",
"{",
"StringTokenizer",
"stringTokenizer",
"=",
"new",
"StringTokenizer",
"(",
"coordinatesString",
",",
"DELIMITER",
",",
"true",
")",
";",
"boolean",
"isDelimiter",
"=",
"true",
";",
"List",
"<",
"String",
">",
"tokens",
"=",
"new",
"ArrayList",
"<>",
"(",
"numberOfCoordinates",
")",
";",
"while",
"(",
"stringTokenizer",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"token",
"=",
"stringTokenizer",
".",
"nextToken",
"(",
")",
";",
"isDelimiter",
"=",
"!",
"isDelimiter",
";",
"if",
"(",
"isDelimiter",
")",
"{",
"continue",
";",
"}",
"tokens",
".",
"add",
"(",
"token",
")",
";",
"}",
"if",
"(",
"isDelimiter",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid coordinate delimiter: \"",
"+",
"coordinatesString",
")",
";",
"}",
"else",
"if",
"(",
"tokens",
".",
"size",
"(",
")",
"!=",
"numberOfCoordinates",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid number of coordinate values: \"",
"+",
"coordinatesString",
")",
";",
"}",
"double",
"[",
"]",
"coordinates",
"=",
"new",
"double",
"[",
"numberOfCoordinates",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numberOfCoordinates",
";",
"++",
"i",
")",
"{",
"coordinates",
"[",
"i",
"]",
"=",
"Double",
".",
"parseDouble",
"(",
"tokens",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"return",
"coordinates",
";",
"}"
] | Parses a given number of comma-separated coordinate values from the supplied string.
@param coordinatesString a comma-separated string of coordinate values.
@param numberOfCoordinates the expected number of coordinate values in the string.
@return the coordinate values in the order they have been parsed from the string.
@throws IllegalArgumentException if the string is invalid or does not contain the given number of coordinate values. | [
"Parses",
"a",
"given",
"number",
"of",
"comma",
"-",
"separated",
"coordinate",
"values",
"from",
"the",
"supplied",
"string",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java#L249-L275 |
netheosgithub/pcs_api | java/src/main/java/net/netheos/pcsapi/utils/URIBuilder.java | URIBuilder.addParameter | public URIBuilder addParameter( String key, String value ) {
"""
Add a single query parameter. Parameter is ignored if it has null value.
@param key The parameter key (not url encoded)
@param value The parameter value (not url encoded)
@return The builder
"""
if ( key != null && value != null ) {
queryParams.put( key, value );
}
return this;
} | java | public URIBuilder addParameter( String key, String value )
{
if ( key != null && value != null ) {
queryParams.put( key, value );
}
return this;
} | [
"public",
"URIBuilder",
"addParameter",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"key",
"!=",
"null",
"&&",
"value",
"!=",
"null",
")",
"{",
"queryParams",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Add a single query parameter. Parameter is ignored if it has null value.
@param key The parameter key (not url encoded)
@param value The parameter value (not url encoded)
@return The builder | [
"Add",
"a",
"single",
"query",
"parameter",
".",
"Parameter",
"is",
"ignored",
"if",
"it",
"has",
"null",
"value",
"."
] | train | https://github.com/netheosgithub/pcs_api/blob/20691e52e144014f99ca75cb7dedc7ba0c18586c/java/src/main/java/net/netheos/pcsapi/utils/URIBuilder.java#L115-L122 |
impossibl/stencil | engine/src/main/java/com/impossibl/stencil/engine/StencilEngine.java | StencilEngine.loadInline | public Template loadInline(String text) throws IOException, ParseException {
"""
Loads the given text as a template
@param text Template text
@return Loaded template
@throws IOException
@throws ParseException
"""
try(InlineTemplateSource templateSource = new InlineTemplateSource(text)) {
return load("inline", templateSource);
}
} | java | public Template loadInline(String text) throws IOException, ParseException {
try(InlineTemplateSource templateSource = new InlineTemplateSource(text)) {
return load("inline", templateSource);
}
} | [
"public",
"Template",
"loadInline",
"(",
"String",
"text",
")",
"throws",
"IOException",
",",
"ParseException",
"{",
"try",
"(",
"InlineTemplateSource",
"templateSource",
"=",
"new",
"InlineTemplateSource",
"(",
"text",
")",
")",
"{",
"return",
"load",
"(",
"\"inline\"",
",",
"templateSource",
")",
";",
"}",
"}"
] | Loads the given text as a template
@param text Template text
@return Loaded template
@throws IOException
@throws ParseException | [
"Loads",
"the",
"given",
"text",
"as",
"a",
"template"
] | train | https://github.com/impossibl/stencil/blob/4aac1be605542b4248be95bf8916be4e2f755d1c/engine/src/main/java/com/impossibl/stencil/engine/StencilEngine.java#L324-L331 |
jbundle/jbundle | thin/base/db/base/src/main/java/org/jbundle/thin/base/db/mem/base/PDatabase.java | PDatabase.getPTable | public synchronized PTable getPTable(FieldList record, boolean bCreateIfNotFound, boolean bEnableGridAccess) {
"""
Get the physical table that matches this BaseTable and create it if it doesn't exist.
Note: If the bCreateIfNotFound flag was set, create the new table or bump the use count.
@param table The table to create a raw data table from.
@return The raw data table (creates a new one if it doesn't already exist).
"""
Object objKey = this.generateKey(record);
PTable physicalTable = (PTable)m_htTableList.get(objKey);
if (bCreateIfNotFound)
if (physicalTable == null)
physicalTable = this.makeNewPTable(record, objKey);
if (bEnableGridAccess)
new GridMemoryFieldTable(record, physicalTable, null);
return physicalTable;
} | java | public synchronized PTable getPTable(FieldList record, boolean bCreateIfNotFound, boolean bEnableGridAccess)
{
Object objKey = this.generateKey(record);
PTable physicalTable = (PTable)m_htTableList.get(objKey);
if (bCreateIfNotFound)
if (physicalTable == null)
physicalTable = this.makeNewPTable(record, objKey);
if (bEnableGridAccess)
new GridMemoryFieldTable(record, physicalTable, null);
return physicalTable;
} | [
"public",
"synchronized",
"PTable",
"getPTable",
"(",
"FieldList",
"record",
",",
"boolean",
"bCreateIfNotFound",
",",
"boolean",
"bEnableGridAccess",
")",
"{",
"Object",
"objKey",
"=",
"this",
".",
"generateKey",
"(",
"record",
")",
";",
"PTable",
"physicalTable",
"=",
"(",
"PTable",
")",
"m_htTableList",
".",
"get",
"(",
"objKey",
")",
";",
"if",
"(",
"bCreateIfNotFound",
")",
"if",
"(",
"physicalTable",
"==",
"null",
")",
"physicalTable",
"=",
"this",
".",
"makeNewPTable",
"(",
"record",
",",
"objKey",
")",
";",
"if",
"(",
"bEnableGridAccess",
")",
"new",
"GridMemoryFieldTable",
"(",
"record",
",",
"physicalTable",
",",
"null",
")",
";",
"return",
"physicalTable",
";",
"}"
] | Get the physical table that matches this BaseTable and create it if it doesn't exist.
Note: If the bCreateIfNotFound flag was set, create the new table or bump the use count.
@param table The table to create a raw data table from.
@return The raw data table (creates a new one if it doesn't already exist). | [
"Get",
"the",
"physical",
"table",
"that",
"matches",
"this",
"BaseTable",
"and",
"create",
"it",
"if",
"it",
"doesn",
"t",
"exist",
".",
"Note",
":",
"If",
"the",
"bCreateIfNotFound",
"flag",
"was",
"set",
"create",
"the",
"new",
"table",
"or",
"bump",
"the",
"use",
"count",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/mem/base/PDatabase.java#L265-L275 |
apache/reef | lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/driver/RunningWorkers.java | RunningWorkers.doneTasklets | void doneTasklets(final String workerId, final List<Integer> taskletIds) {
"""
Concurrency: Called by multiple threads.
Parameter: Same arguments can come in multiple times.
(e.g. preemption message coming before tasklet completion message multiple times)
"""
lock.lock();
try {
if (!terminated && runningWorkers.containsKey(workerId)) { // Preemption can come before
final VortexWorkerManager worker = this.runningWorkers.get(workerId);
final List<Tasklet> tasklets = worker.taskletsDone(taskletIds);
this.schedulingPolicy.taskletsDone(worker, tasklets);
taskletsToCancel.removeAll(taskletIds); // cleanup to prevent memory leak.
// Notify (possibly) waiting scheduler
noWorkerOrResource.signal();
}
} finally {
lock.unlock();
}
} | java | void doneTasklets(final String workerId, final List<Integer> taskletIds) {
lock.lock();
try {
if (!terminated && runningWorkers.containsKey(workerId)) { // Preemption can come before
final VortexWorkerManager worker = this.runningWorkers.get(workerId);
final List<Tasklet> tasklets = worker.taskletsDone(taskletIds);
this.schedulingPolicy.taskletsDone(worker, tasklets);
taskletsToCancel.removeAll(taskletIds); // cleanup to prevent memory leak.
// Notify (possibly) waiting scheduler
noWorkerOrResource.signal();
}
} finally {
lock.unlock();
}
} | [
"void",
"doneTasklets",
"(",
"final",
"String",
"workerId",
",",
"final",
"List",
"<",
"Integer",
">",
"taskletIds",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"terminated",
"&&",
"runningWorkers",
".",
"containsKey",
"(",
"workerId",
")",
")",
"{",
"// Preemption can come before",
"final",
"VortexWorkerManager",
"worker",
"=",
"this",
".",
"runningWorkers",
".",
"get",
"(",
"workerId",
")",
";",
"final",
"List",
"<",
"Tasklet",
">",
"tasklets",
"=",
"worker",
".",
"taskletsDone",
"(",
"taskletIds",
")",
";",
"this",
".",
"schedulingPolicy",
".",
"taskletsDone",
"(",
"worker",
",",
"tasklets",
")",
";",
"taskletsToCancel",
".",
"removeAll",
"(",
"taskletIds",
")",
";",
"// cleanup to prevent memory leak.",
"// Notify (possibly) waiting scheduler",
"noWorkerOrResource",
".",
"signal",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Concurrency: Called by multiple threads.
Parameter: Same arguments can come in multiple times.
(e.g. preemption message coming before tasklet completion message multiple times) | [
"Concurrency",
":",
"Called",
"by",
"multiple",
"threads",
".",
"Parameter",
":",
"Same",
"arguments",
"can",
"come",
"in",
"multiple",
"times",
".",
"(",
"e",
".",
"g",
".",
"preemption",
"message",
"coming",
"before",
"tasklet",
"completion",
"message",
"multiple",
"times",
")"
] | train | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/driver/RunningWorkers.java#L211-L227 |
JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMFiles.java | JMFiles.writeString | public static boolean writeString(String inputString, File targetFile) {
"""
Write string boolean.
@param inputString the input string
@param targetFile the target file
@return the boolean
"""
if (!targetFile.exists()) {
try {
Files.write(targetFile.toPath(), inputString.getBytes());
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturnFalse(log, e,
"writeString", inputString, targetFile);
}
}
return true;
} | java | public static boolean writeString(String inputString, File targetFile) {
if (!targetFile.exists()) {
try {
Files.write(targetFile.toPath(), inputString.getBytes());
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturnFalse(log, e,
"writeString", inputString, targetFile);
}
}
return true;
} | [
"public",
"static",
"boolean",
"writeString",
"(",
"String",
"inputString",
",",
"File",
"targetFile",
")",
"{",
"if",
"(",
"!",
"targetFile",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"Files",
".",
"write",
"(",
"targetFile",
".",
"toPath",
"(",
")",
",",
"inputString",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"JMExceptionManager",
".",
"handleExceptionAndReturnFalse",
"(",
"log",
",",
"e",
",",
"\"writeString\"",
",",
"inputString",
",",
"targetFile",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Write string boolean.
@param inputString the input string
@param targetFile the target file
@return the boolean | [
"Write",
"string",
"boolean",
"."
] | train | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMFiles.java#L91-L101 |
janvanbesien/java-ipv6 | src/main/java/com/googlecode/ipv6/IPv6Network.java | IPv6Network.fromTwoAddresses | public static IPv6Network fromTwoAddresses(IPv6Address one, IPv6Address two) {
"""
Create an IPv6 network from the two addresses within the network. This will construct the smallest possible network ("longest prefix
length") which contains both addresses.
@param one address one
@param two address two, should be bigger than address one
@return ipv6 network
"""
final IPv6NetworkMask longestPrefixLength = IPv6NetworkMask.fromPrefixLength(IPv6NetworkHelpers.longestPrefixLength(one, two));
return new IPv6Network(one.maskWithNetworkMask(longestPrefixLength), longestPrefixLength);
} | java | public static IPv6Network fromTwoAddresses(IPv6Address one, IPv6Address two)
{
final IPv6NetworkMask longestPrefixLength = IPv6NetworkMask.fromPrefixLength(IPv6NetworkHelpers.longestPrefixLength(one, two));
return new IPv6Network(one.maskWithNetworkMask(longestPrefixLength), longestPrefixLength);
} | [
"public",
"static",
"IPv6Network",
"fromTwoAddresses",
"(",
"IPv6Address",
"one",
",",
"IPv6Address",
"two",
")",
"{",
"final",
"IPv6NetworkMask",
"longestPrefixLength",
"=",
"IPv6NetworkMask",
".",
"fromPrefixLength",
"(",
"IPv6NetworkHelpers",
".",
"longestPrefixLength",
"(",
"one",
",",
"two",
")",
")",
";",
"return",
"new",
"IPv6Network",
"(",
"one",
".",
"maskWithNetworkMask",
"(",
"longestPrefixLength",
")",
",",
"longestPrefixLength",
")",
";",
"}"
] | Create an IPv6 network from the two addresses within the network. This will construct the smallest possible network ("longest prefix
length") which contains both addresses.
@param one address one
@param two address two, should be bigger than address one
@return ipv6 network | [
"Create",
"an",
"IPv6",
"network",
"from",
"the",
"two",
"addresses",
"within",
"the",
"network",
".",
"This",
"will",
"construct",
"the",
"smallest",
"possible",
"network",
"(",
"longest",
"prefix",
"length",
")",
"which",
"contains",
"both",
"addresses",
"."
] | train | https://github.com/janvanbesien/java-ipv6/blob/9af15b4a6c0074f9fa23dfa030027c631b9c2f78/src/main/java/com/googlecode/ipv6/IPv6Network.java#L76-L80 |
Azure/azure-sdk-for-java | logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/SchemasInner.java | SchemasInner.createOrUpdate | public IntegrationAccountSchemaInner createOrUpdate(String resourceGroupName, String integrationAccountName, String schemaName, IntegrationAccountSchemaInner schema) {
"""
Creates or updates an integration account schema.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@param schemaName The integration account schema name.
@param schema The integration account schema.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the IntegrationAccountSchemaInner object if successful.
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, integrationAccountName, schemaName, schema).toBlocking().single().body();
} | java | public IntegrationAccountSchemaInner createOrUpdate(String resourceGroupName, String integrationAccountName, String schemaName, IntegrationAccountSchemaInner schema) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, integrationAccountName, schemaName, schema).toBlocking().single().body();
} | [
"public",
"IntegrationAccountSchemaInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"integrationAccountName",
",",
"String",
"schemaName",
",",
"IntegrationAccountSchemaInner",
"schema",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"integrationAccountName",
",",
"schemaName",
",",
"schema",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Creates or updates an integration account schema.
@param resourceGroupName The resource group name.
@param integrationAccountName The integration account name.
@param schemaName The integration account schema name.
@param schema The integration account schema.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the IntegrationAccountSchemaInner object if successful. | [
"Creates",
"or",
"updates",
"an",
"integration",
"account",
"schema",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/logic/resource-manager/v2016_06_01/src/main/java/com/microsoft/azure/management/logic/v2016_06_01/implementation/SchemasInner.java#L448-L450 |
pryzach/midao | midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java | TypeHandlerUtils.convertClob | public static Object convertClob(Connection conn, String value) throws SQLException {
"""
Transfers data from String into sql.Blob
@param conn connection for which sql.Blob object would be created
@param value String
@return sql.Clob from String
@throws SQLException
"""
return convertClob(conn, value.getBytes());
} | java | public static Object convertClob(Connection conn, String value) throws SQLException {
return convertClob(conn, value.getBytes());
} | [
"public",
"static",
"Object",
"convertClob",
"(",
"Connection",
"conn",
",",
"String",
"value",
")",
"throws",
"SQLException",
"{",
"return",
"convertClob",
"(",
"conn",
",",
"value",
".",
"getBytes",
"(",
")",
")",
";",
"}"
] | Transfers data from String into sql.Blob
@param conn connection for which sql.Blob object would be created
@param value String
@return sql.Clob from String
@throws SQLException | [
"Transfers",
"data",
"from",
"String",
"into",
"sql",
".",
"Blob"
] | train | https://github.com/pryzach/midao/blob/ed9048ed2c792a4794a2116a25779dfb84cd9447/midao-jdbc-core/src/main/java/org/midao/jdbc/core/handlers/type/TypeHandlerUtils.java#L189-L191 |
GerdHolz/TOVAL | src/de/invation/code/toval/misc/ListUtils.java | ListUtils.getRandomSublistMin | public static <T> List<T> getRandomSublistMin(List<T> list, int minCount) {
"""
Generates a random sublist of <code>list</code>, that contains at least
<code>maxCount</code> elements.
@param <T>
Type of list elements
@param list
Basic list for operation
@param minCount
Minimum number of items
@return A sublist with at least <code>minCount</code> elements
"""
int count = RandomUtils.randomIntBetween(minCount, list.size());
return getRandomSublist(list, count);
} | java | public static <T> List<T> getRandomSublistMin(List<T> list, int minCount) {
int count = RandomUtils.randomIntBetween(minCount, list.size());
return getRandomSublist(list, count);
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getRandomSublistMin",
"(",
"List",
"<",
"T",
">",
"list",
",",
"int",
"minCount",
")",
"{",
"int",
"count",
"=",
"RandomUtils",
".",
"randomIntBetween",
"(",
"minCount",
",",
"list",
".",
"size",
"(",
")",
")",
";",
"return",
"getRandomSublist",
"(",
"list",
",",
"count",
")",
";",
"}"
] | Generates a random sublist of <code>list</code>, that contains at least
<code>maxCount</code> elements.
@param <T>
Type of list elements
@param list
Basic list for operation
@param minCount
Minimum number of items
@return A sublist with at least <code>minCount</code> elements | [
"Generates",
"a",
"random",
"sublist",
"of",
"<code",
">",
"list<",
"/",
"code",
">",
"that",
"contains",
"at",
"least",
"<code",
">",
"maxCount<",
"/",
"code",
">",
"elements",
"."
] | train | https://github.com/GerdHolz/TOVAL/blob/036922cdfd710fa53b18e5dbe1e07f226f731fde/src/de/invation/code/toval/misc/ListUtils.java#L501-L504 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/input/location/CmsLocationController.java | CmsLocationController.setPosition | private void setPosition(float latitude, float longitude, boolean updateMap, boolean updateAddress) {
"""
Sets the position values and updates the map view.<p>
@param latitude the latitude
@param longitude the longitude
@param updateMap <code>true</code> to update the map
@param updateAddress <code>true</code> to update the address from the new position data
"""
m_editValue.setLatitude(latitude);
m_editValue.setLongitude(longitude);
m_popupContent.displayValues(m_editValue);
if (updateMap) {
updateMarkerPosition();
}
if (updateAddress) {
updateAddress();
}
} | java | private void setPosition(float latitude, float longitude, boolean updateMap, boolean updateAddress) {
m_editValue.setLatitude(latitude);
m_editValue.setLongitude(longitude);
m_popupContent.displayValues(m_editValue);
if (updateMap) {
updateMarkerPosition();
}
if (updateAddress) {
updateAddress();
}
} | [
"private",
"void",
"setPosition",
"(",
"float",
"latitude",
",",
"float",
"longitude",
",",
"boolean",
"updateMap",
",",
"boolean",
"updateAddress",
")",
"{",
"m_editValue",
".",
"setLatitude",
"(",
"latitude",
")",
";",
"m_editValue",
".",
"setLongitude",
"(",
"longitude",
")",
";",
"m_popupContent",
".",
"displayValues",
"(",
"m_editValue",
")",
";",
"if",
"(",
"updateMap",
")",
"{",
"updateMarkerPosition",
"(",
")",
";",
"}",
"if",
"(",
"updateAddress",
")",
"{",
"updateAddress",
"(",
")",
";",
"}",
"}"
] | Sets the position values and updates the map view.<p>
@param latitude the latitude
@param longitude the longitude
@param updateMap <code>true</code> to update the map
@param updateAddress <code>true</code> to update the address from the new position data | [
"Sets",
"the",
"position",
"values",
"and",
"updates",
"the",
"map",
"view",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/location/CmsLocationController.java#L793-L804 |
atomix/copycat | client/src/main/java/io/atomix/copycat/client/util/ClientConnection.java | ClientConnection.resendRequest | @SuppressWarnings("unchecked")
private <T extends Request> void resendRequest(Throwable cause, T request, BiFunction sender, Connection connection, CompletableFuture future) {
"""
Resends a request due to a request failure, resetting the connection if necessary.
"""
// If the connection has not changed, reset it and connect to the next server.
if (this.connection == connection) {
LOGGER.trace("{} - Resetting connection. Reason: {}", id, cause);
this.connection = null;
connection.close();
}
// Create a new connection and resend the request. This will force retries to piggyback on any existing
// connect attempts.
connect().whenComplete((c, e) -> sendRequest(request, sender, c, e, future));
} | java | @SuppressWarnings("unchecked")
private <T extends Request> void resendRequest(Throwable cause, T request, BiFunction sender, Connection connection, CompletableFuture future) {
// If the connection has not changed, reset it and connect to the next server.
if (this.connection == connection) {
LOGGER.trace("{} - Resetting connection. Reason: {}", id, cause);
this.connection = null;
connection.close();
}
// Create a new connection and resend the request. This will force retries to piggyback on any existing
// connect attempts.
connect().whenComplete((c, e) -> sendRequest(request, sender, c, e, future));
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
"extends",
"Request",
">",
"void",
"resendRequest",
"(",
"Throwable",
"cause",
",",
"T",
"request",
",",
"BiFunction",
"sender",
",",
"Connection",
"connection",
",",
"CompletableFuture",
"future",
")",
"{",
"// If the connection has not changed, reset it and connect to the next server.",
"if",
"(",
"this",
".",
"connection",
"==",
"connection",
")",
"{",
"LOGGER",
".",
"trace",
"(",
"\"{} - Resetting connection. Reason: {}\"",
",",
"id",
",",
"cause",
")",
";",
"this",
".",
"connection",
"=",
"null",
";",
"connection",
".",
"close",
"(",
")",
";",
"}",
"// Create a new connection and resend the request. This will force retries to piggyback on any existing",
"// connect attempts.",
"connect",
"(",
")",
".",
"whenComplete",
"(",
"(",
"c",
",",
"e",
")",
"->",
"sendRequest",
"(",
"request",
",",
"sender",
",",
"c",
",",
"e",
",",
"future",
")",
")",
";",
"}"
] | Resends a request due to a request failure, resetting the connection if necessary. | [
"Resends",
"a",
"request",
"due",
"to",
"a",
"request",
"failure",
"resetting",
"the",
"connection",
"if",
"necessary",
"."
] | train | https://github.com/atomix/copycat/blob/c90b88ccd5c63d6ea0b49fb77c25e2f3272a7b10/client/src/main/java/io/atomix/copycat/client/util/ClientConnection.java#L155-L167 |
wealthfront/magellan | magellan-library/src/main/java/com/wealthfront/magellan/Navigator.java | Navigator.resetWithRoot | public void resetWithRoot(Activity activity, final Screen root) {
"""
Clears the back stack of this Navigator and adds the input Screen as the new root of the back stack.
@param activity activity used to verify this Navigator is in an acceptable state when resetWithRoot is called
@param root new root screen for this Navigator
@throws IllegalStateException if {@link #onCreate(Activity, Bundle)} has already been called on this Navigator
"""
checkOnCreateNotYetCalled(activity, "resetWithRoot() must be called before onCreate()");
backStack.clear();
backStack.push(root);
} | java | public void resetWithRoot(Activity activity, final Screen root) {
checkOnCreateNotYetCalled(activity, "resetWithRoot() must be called before onCreate()");
backStack.clear();
backStack.push(root);
} | [
"public",
"void",
"resetWithRoot",
"(",
"Activity",
"activity",
",",
"final",
"Screen",
"root",
")",
"{",
"checkOnCreateNotYetCalled",
"(",
"activity",
",",
"\"resetWithRoot() must be called before onCreate()\"",
")",
";",
"backStack",
".",
"clear",
"(",
")",
";",
"backStack",
".",
"push",
"(",
"root",
")",
";",
"}"
] | Clears the back stack of this Navigator and adds the input Screen as the new root of the back stack.
@param activity activity used to verify this Navigator is in an acceptable state when resetWithRoot is called
@param root new root screen for this Navigator
@throws IllegalStateException if {@link #onCreate(Activity, Bundle)} has already been called on this Navigator | [
"Clears",
"the",
"back",
"stack",
"of",
"this",
"Navigator",
"and",
"adds",
"the",
"input",
"Screen",
"as",
"the",
"new",
"root",
"of",
"the",
"back",
"stack",
"."
] | train | https://github.com/wealthfront/magellan/blob/f690979161a97e40fb9d11dc9d7e3c8cf85ba312/magellan-library/src/main/java/com/wealthfront/magellan/Navigator.java#L253-L257 |
davetcc/tcMenu | tcMenuJavaApi/src/main/java/com/thecoderscorner/menu/domain/state/MenuTree.java | MenuTree.changeItem | public <T> void changeItem(MenuItem<T> item, MenuState<T> menuState) {
"""
Change the value that's associated with a menu item. if you are changing
a value, just send a command to the device, it will automatically update
the tree.
@param item the item to change
@param menuState the new state
@param <T> the type of the state, picked up automatically
"""
menuStates.put(item.getId(), menuState);
} | java | public <T> void changeItem(MenuItem<T> item, MenuState<T> menuState) {
menuStates.put(item.getId(), menuState);
} | [
"public",
"<",
"T",
">",
"void",
"changeItem",
"(",
"MenuItem",
"<",
"T",
">",
"item",
",",
"MenuState",
"<",
"T",
">",
"menuState",
")",
"{",
"menuStates",
".",
"put",
"(",
"item",
".",
"getId",
"(",
")",
",",
"menuState",
")",
";",
"}"
] | Change the value that's associated with a menu item. if you are changing
a value, just send a command to the device, it will automatically update
the tree.
@param item the item to change
@param menuState the new state
@param <T> the type of the state, picked up automatically | [
"Change",
"the",
"value",
"that",
"s",
"associated",
"with",
"a",
"menu",
"item",
".",
"if",
"you",
"are",
"changing",
"a",
"value",
"just",
"send",
"a",
"command",
"to",
"the",
"device",
"it",
"will",
"automatically",
"update",
"the",
"tree",
"."
] | train | https://github.com/davetcc/tcMenu/blob/61546e4b982b25ceaff384073fe9ec1fff55e64a/tcMenuJavaApi/src/main/java/com/thecoderscorner/menu/domain/state/MenuTree.java#L258-L260 |
cdk/cdk | base/core/src/main/java/org/openscience/cdk/io/random/RandomAccessReader.java | RandomAccessReader.readContent | protected String readContent(int record) throws IOException, CDKException {
"""
Reads the record text content into a String.
@param record The record number
@return A String representation of the record
@throws java.io.IOException if error occurs during reading
@throws org.openscience.cdk.exception.CDKException if the record number is invalid
"""
logger.debug("Current record ", record);
if ((record < 0) || (record >= records)) {
throw new CDKException("No such record " + record);
}
//fireFrameRead();
raFile.seek(index[record][0]);
int length = (int) index[record][1];
raFile.read(b, 0, length);
return new String(b, 0, length);
} | java | protected String readContent(int record) throws IOException, CDKException {
logger.debug("Current record ", record);
if ((record < 0) || (record >= records)) {
throw new CDKException("No such record " + record);
}
//fireFrameRead();
raFile.seek(index[record][0]);
int length = (int) index[record][1];
raFile.read(b, 0, length);
return new String(b, 0, length);
} | [
"protected",
"String",
"readContent",
"(",
"int",
"record",
")",
"throws",
"IOException",
",",
"CDKException",
"{",
"logger",
".",
"debug",
"(",
"\"Current record \"",
",",
"record",
")",
";",
"if",
"(",
"(",
"record",
"<",
"0",
")",
"||",
"(",
"record",
">=",
"records",
")",
")",
"{",
"throw",
"new",
"CDKException",
"(",
"\"No such record \"",
"+",
"record",
")",
";",
"}",
"//fireFrameRead();",
"raFile",
".",
"seek",
"(",
"index",
"[",
"record",
"]",
"[",
"0",
"]",
")",
";",
"int",
"length",
"=",
"(",
"int",
")",
"index",
"[",
"record",
"]",
"[",
"1",
"]",
";",
"raFile",
".",
"read",
"(",
"b",
",",
"0",
",",
"length",
")",
";",
"return",
"new",
"String",
"(",
"b",
",",
"0",
",",
"length",
")",
";",
"}"
] | Reads the record text content into a String.
@param record The record number
@return A String representation of the record
@throws java.io.IOException if error occurs during reading
@throws org.openscience.cdk.exception.CDKException if the record number is invalid | [
"Reads",
"the",
"record",
"text",
"content",
"into",
"a",
"String",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/base/core/src/main/java/org/openscience/cdk/io/random/RandomAccessReader.java#L145-L157 |
Azure/azure-sdk-for-java | privatedns/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/privatedns/v2018_09_01/implementation/PrivateZonesInner.java | PrivateZonesInner.createOrUpdateAsync | public Observable<PrivateZoneInner> createOrUpdateAsync(String resourceGroupName, String privateZoneName, PrivateZoneInner parameters, String ifMatch, String ifNoneMatch) {
"""
Creates or updates a Private DNS zone. Does not modify Links to virtual networks or DNS records within the zone.
@param resourceGroupName The name of the resource group.
@param privateZoneName The name of the Private DNS zone (without a terminating dot).
@param parameters Parameters supplied to the CreateOrUpdate operation.
@param ifMatch The ETag of the Private DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes.
@param ifNoneMatch Set to '*' to allow a new Private DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
"""
return createOrUpdateWithServiceResponseAsync(resourceGroupName, privateZoneName, parameters, ifMatch, ifNoneMatch).map(new Func1<ServiceResponse<PrivateZoneInner>, PrivateZoneInner>() {
@Override
public PrivateZoneInner call(ServiceResponse<PrivateZoneInner> response) {
return response.body();
}
});
} | java | public Observable<PrivateZoneInner> createOrUpdateAsync(String resourceGroupName, String privateZoneName, PrivateZoneInner parameters, String ifMatch, String ifNoneMatch) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, privateZoneName, parameters, ifMatch, ifNoneMatch).map(new Func1<ServiceResponse<PrivateZoneInner>, PrivateZoneInner>() {
@Override
public PrivateZoneInner call(ServiceResponse<PrivateZoneInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"PrivateZoneInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"privateZoneName",
",",
"PrivateZoneInner",
"parameters",
",",
"String",
"ifMatch",
",",
"String",
"ifNoneMatch",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"privateZoneName",
",",
"parameters",
",",
"ifMatch",
",",
"ifNoneMatch",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"PrivateZoneInner",
">",
",",
"PrivateZoneInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"PrivateZoneInner",
"call",
"(",
"ServiceResponse",
"<",
"PrivateZoneInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Creates or updates a Private DNS zone. Does not modify Links to virtual networks or DNS records within the zone.
@param resourceGroupName The name of the resource group.
@param privateZoneName The name of the Private DNS zone (without a terminating dot).
@param parameters Parameters supplied to the CreateOrUpdate operation.
@param ifMatch The ETag of the Private DNS zone. Omit this value to always overwrite the current zone. Specify the last-seen ETag value to prevent accidentally overwriting any concurrent changes.
@param ifNoneMatch Set to '*' to allow a new Private DNS zone to be created, but to prevent updating an existing zone. Other values will be ignored.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request | [
"Creates",
"or",
"updates",
"a",
"Private",
"DNS",
"zone",
".",
"Does",
"not",
"modify",
"Links",
"to",
"virtual",
"networks",
"or",
"DNS",
"records",
"within",
"the",
"zone",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/privatedns/resource-manager/v2018_09_01/src/main/java/com/microsoft/azure/management/privatedns/v2018_09_01/implementation/PrivateZonesInner.java#L236-L243 |
apache/flink | flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/metrics/MetricStore.java | MetricStore.getSubtaskMetricStore | public synchronized ComponentMetricStore getSubtaskMetricStore(String jobID, String taskID, int subtaskIndex) {
"""
Returns the {@link ComponentMetricStore} for the given job/task ID and subtask index.
@param jobID job ID
@param taskID task ID
@param subtaskIndex subtask index
@return SubtaskMetricStore for the given IDs and index, or null if no store for the given arguments exists
"""
JobMetricStore job = jobID == null ? null : jobs.get(jobID);
if (job == null) {
return null;
}
TaskMetricStore task = job.getTaskMetricStore(taskID);
if (task == null) {
return null;
}
return ComponentMetricStore.unmodifiable(task.getSubtaskMetricStore(subtaskIndex));
} | java | public synchronized ComponentMetricStore getSubtaskMetricStore(String jobID, String taskID, int subtaskIndex) {
JobMetricStore job = jobID == null ? null : jobs.get(jobID);
if (job == null) {
return null;
}
TaskMetricStore task = job.getTaskMetricStore(taskID);
if (task == null) {
return null;
}
return ComponentMetricStore.unmodifiable(task.getSubtaskMetricStore(subtaskIndex));
} | [
"public",
"synchronized",
"ComponentMetricStore",
"getSubtaskMetricStore",
"(",
"String",
"jobID",
",",
"String",
"taskID",
",",
"int",
"subtaskIndex",
")",
"{",
"JobMetricStore",
"job",
"=",
"jobID",
"==",
"null",
"?",
"null",
":",
"jobs",
".",
"get",
"(",
"jobID",
")",
";",
"if",
"(",
"job",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"TaskMetricStore",
"task",
"=",
"job",
".",
"getTaskMetricStore",
"(",
"taskID",
")",
";",
"if",
"(",
"task",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"ComponentMetricStore",
".",
"unmodifiable",
"(",
"task",
".",
"getSubtaskMetricStore",
"(",
"subtaskIndex",
")",
")",
";",
"}"
] | Returns the {@link ComponentMetricStore} for the given job/task ID and subtask index.
@param jobID job ID
@param taskID task ID
@param subtaskIndex subtask index
@return SubtaskMetricStore for the given IDs and index, or null if no store for the given arguments exists | [
"Returns",
"the",
"{",
"@link",
"ComponentMetricStore",
"}",
"for",
"the",
"given",
"job",
"/",
"task",
"ID",
"and",
"subtask",
"index",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/rest/handler/legacy/metrics/MetricStore.java#L145-L155 |
lucee/Lucee | core/src/main/java/lucee/runtime/config/XMLConfigWebFactory.java | XMLConfigWebFactory.loadExtensionBundles | private static void loadExtensionBundles(ConfigServerImpl cs, ConfigImpl config, Document doc, Log log) {
"""
loads the bundles defined in the extensions
@param cs
@param config
@param doc
@param log
"""
try {
Element parent = getChildByName(doc.getDocumentElement(), "extensions");
Element[] children = getChildren(parent, "rhextension");
String strBundles;
List<RHExtension> extensions = new ArrayList<RHExtension>();
RHExtension rhe;
for (Element child: children) {
BundleInfo[] bfsq;
try {
rhe = new RHExtension(config, child);
if (rhe.getStartBundles()) rhe.deployBundles(config);
extensions.add(rhe);
}
catch (Exception e) {
log.error("load-extension", e);
continue;
}
}
config.setExtensions(extensions.toArray(new RHExtension[extensions.size()]));
}
catch (Exception e) {
log(config, log, e);
}
} | java | private static void loadExtensionBundles(ConfigServerImpl cs, ConfigImpl config, Document doc, Log log) {
try {
Element parent = getChildByName(doc.getDocumentElement(), "extensions");
Element[] children = getChildren(parent, "rhextension");
String strBundles;
List<RHExtension> extensions = new ArrayList<RHExtension>();
RHExtension rhe;
for (Element child: children) {
BundleInfo[] bfsq;
try {
rhe = new RHExtension(config, child);
if (rhe.getStartBundles()) rhe.deployBundles(config);
extensions.add(rhe);
}
catch (Exception e) {
log.error("load-extension", e);
continue;
}
}
config.setExtensions(extensions.toArray(new RHExtension[extensions.size()]));
}
catch (Exception e) {
log(config, log, e);
}
} | [
"private",
"static",
"void",
"loadExtensionBundles",
"(",
"ConfigServerImpl",
"cs",
",",
"ConfigImpl",
"config",
",",
"Document",
"doc",
",",
"Log",
"log",
")",
"{",
"try",
"{",
"Element",
"parent",
"=",
"getChildByName",
"(",
"doc",
".",
"getDocumentElement",
"(",
")",
",",
"\"extensions\"",
")",
";",
"Element",
"[",
"]",
"children",
"=",
"getChildren",
"(",
"parent",
",",
"\"rhextension\"",
")",
";",
"String",
"strBundles",
";",
"List",
"<",
"RHExtension",
">",
"extensions",
"=",
"new",
"ArrayList",
"<",
"RHExtension",
">",
"(",
")",
";",
"RHExtension",
"rhe",
";",
"for",
"(",
"Element",
"child",
":",
"children",
")",
"{",
"BundleInfo",
"[",
"]",
"bfsq",
";",
"try",
"{",
"rhe",
"=",
"new",
"RHExtension",
"(",
"config",
",",
"child",
")",
";",
"if",
"(",
"rhe",
".",
"getStartBundles",
"(",
")",
")",
"rhe",
".",
"deployBundles",
"(",
"config",
")",
";",
"extensions",
".",
"add",
"(",
"rhe",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"load-extension\"",
",",
"e",
")",
";",
"continue",
";",
"}",
"}",
"config",
".",
"setExtensions",
"(",
"extensions",
".",
"toArray",
"(",
"new",
"RHExtension",
"[",
"extensions",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
"(",
"config",
",",
"log",
",",
"e",
")",
";",
"}",
"}"
] | loads the bundles defined in the extensions
@param cs
@param config
@param doc
@param log | [
"loads",
"the",
"bundles",
"defined",
"in",
"the",
"extensions"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/config/XMLConfigWebFactory.java#L4229-L4255 |
gallandarakhneorg/afc | advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d1/dfx/GeomFactory1dfx.java | GeomFactory1dfx.newVector | @SuppressWarnings("static-method")
public Vector1dfx newVector(ObjectProperty<WeakReference<Segment1D<?, ?>>> segment, DoubleProperty x, DoubleProperty y) {
"""
Create a vector with properties.
@param segment the segment property.
@param x the x property.
@param y the y property.
@return the vector.
"""
return new Vector1dfx(segment, x, y);
} | java | @SuppressWarnings("static-method")
public Vector1dfx newVector(ObjectProperty<WeakReference<Segment1D<?, ?>>> segment, DoubleProperty x, DoubleProperty y) {
return new Vector1dfx(segment, x, y);
} | [
"@",
"SuppressWarnings",
"(",
"\"static-method\"",
")",
"public",
"Vector1dfx",
"newVector",
"(",
"ObjectProperty",
"<",
"WeakReference",
"<",
"Segment1D",
"<",
"?",
",",
"?",
">",
">",
">",
"segment",
",",
"DoubleProperty",
"x",
",",
"DoubleProperty",
"y",
")",
"{",
"return",
"new",
"Vector1dfx",
"(",
"segment",
",",
"x",
",",
"y",
")",
";",
"}"
] | Create a vector with properties.
@param segment the segment property.
@param x the x property.
@param y the y property.
@return the vector. | [
"Create",
"a",
"vector",
"with",
"properties",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/advanced/mathfx/src/main/java/org/arakhne/afc/math/geometry/d1/dfx/GeomFactory1dfx.java#L131-L134 |
apache/flink | flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java | MemorySegment.putIntBigEndian | public final void putIntBigEndian(int index, int value) {
"""
Writes the given int value (32bit, 4 bytes) to the given position in big endian
byte order. This method's speed depends on the system's native byte order, and it
is possibly slower than {@link #putInt(int, int)}. For most cases (such as
transient storage in memory or serialization for I/O and network),
it suffices to know that the byte order in which the value is written is the same as the
one in which it is read, and {@link #putInt(int, int)} is the preferable choice.
@param index The position at which the value will be written.
@param value The int value to be written.
@throws IndexOutOfBoundsException Thrown, if the index is negative, or larger than the segment
size minus 4.
"""
if (LITTLE_ENDIAN) {
putInt(index, Integer.reverseBytes(value));
} else {
putInt(index, value);
}
} | java | public final void putIntBigEndian(int index, int value) {
if (LITTLE_ENDIAN) {
putInt(index, Integer.reverseBytes(value));
} else {
putInt(index, value);
}
} | [
"public",
"final",
"void",
"putIntBigEndian",
"(",
"int",
"index",
",",
"int",
"value",
")",
"{",
"if",
"(",
"LITTLE_ENDIAN",
")",
"{",
"putInt",
"(",
"index",
",",
"Integer",
".",
"reverseBytes",
"(",
"value",
")",
")",
";",
"}",
"else",
"{",
"putInt",
"(",
"index",
",",
"value",
")",
";",
"}",
"}"
] | Writes the given int value (32bit, 4 bytes) to the given position in big endian
byte order. This method's speed depends on the system's native byte order, and it
is possibly slower than {@link #putInt(int, int)}. For most cases (such as
transient storage in memory or serialization for I/O and network),
it suffices to know that the byte order in which the value is written is the same as the
one in which it is read, and {@link #putInt(int, int)} is the preferable choice.
@param index The position at which the value will be written.
@param value The int value to be written.
@throws IndexOutOfBoundsException Thrown, if the index is negative, or larger than the segment
size minus 4. | [
"Writes",
"the",
"given",
"int",
"value",
"(",
"32bit",
"4",
"bytes",
")",
"to",
"the",
"given",
"position",
"in",
"big",
"endian",
"byte",
"order",
".",
"This",
"method",
"s",
"speed",
"depends",
"on",
"the",
"system",
"s",
"native",
"byte",
"order",
"and",
"it",
"is",
"possibly",
"slower",
"than",
"{",
"@link",
"#putInt",
"(",
"int",
"int",
")",
"}",
".",
"For",
"most",
"cases",
"(",
"such",
"as",
"transient",
"storage",
"in",
"memory",
"or",
"serialization",
"for",
"I",
"/",
"O",
"and",
"network",
")",
"it",
"suffices",
"to",
"know",
"that",
"the",
"byte",
"order",
"in",
"which",
"the",
"value",
"is",
"written",
"is",
"the",
"same",
"as",
"the",
"one",
"in",
"which",
"it",
"is",
"read",
"and",
"{",
"@link",
"#putInt",
"(",
"int",
"int",
")",
"}",
"is",
"the",
"preferable",
"choice",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/core/memory/MemorySegment.java#L812-L818 |
liferay/com-liferay-commerce | commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehousePersistenceImpl.java | CommerceWarehousePersistenceImpl.removeByG_C | @Override
public void removeByG_C(long groupId, long commerceCountryId) {
"""
Removes all the commerce warehouses where groupId = ? and commerceCountryId = ? from the database.
@param groupId the group ID
@param commerceCountryId the commerce country ID
"""
for (CommerceWarehouse commerceWarehouse : findByG_C(groupId,
commerceCountryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceWarehouse);
}
} | java | @Override
public void removeByG_C(long groupId, long commerceCountryId) {
for (CommerceWarehouse commerceWarehouse : findByG_C(groupId,
commerceCountryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(commerceWarehouse);
}
} | [
"@",
"Override",
"public",
"void",
"removeByG_C",
"(",
"long",
"groupId",
",",
"long",
"commerceCountryId",
")",
"{",
"for",
"(",
"CommerceWarehouse",
"commerceWarehouse",
":",
"findByG_C",
"(",
"groupId",
",",
"commerceCountryId",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
")",
"{",
"remove",
"(",
"commerceWarehouse",
")",
";",
"}",
"}"
] | Removes all the commerce warehouses where groupId = ? and commerceCountryId = ? from the database.
@param groupId the group ID
@param commerceCountryId the commerce country ID | [
"Removes",
"all",
"the",
"commerce",
"warehouses",
"where",
"groupId",
"=",
"?",
";",
"and",
"commerceCountryId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceWarehousePersistenceImpl.java#L1636-L1642 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java | JavaCompiler.resolveBinaryNameOrIdent | public Symbol resolveBinaryNameOrIdent(String name) {
"""
Resolve an identifier which may be the binary name of a class or
the Java name of a class or package.
@param name The name to resolve
"""
ModuleSymbol msym;
String typeName;
int sep = name.indexOf('/');
if (sep == -1) {
msym = modules.getDefaultModule();
typeName = name;
} else if (source.allowModules()) {
Name modName = names.fromString(name.substring(0, sep));
msym = moduleFinder.findModule(modName);
typeName = name.substring(sep + 1);
} else {
log.error(Errors.InvalidModuleSpecifier(name));
return silentFail;
}
return resolveBinaryNameOrIdent(msym, typeName);
} | java | public Symbol resolveBinaryNameOrIdent(String name) {
ModuleSymbol msym;
String typeName;
int sep = name.indexOf('/');
if (sep == -1) {
msym = modules.getDefaultModule();
typeName = name;
} else if (source.allowModules()) {
Name modName = names.fromString(name.substring(0, sep));
msym = moduleFinder.findModule(modName);
typeName = name.substring(sep + 1);
} else {
log.error(Errors.InvalidModuleSpecifier(name));
return silentFail;
}
return resolveBinaryNameOrIdent(msym, typeName);
} | [
"public",
"Symbol",
"resolveBinaryNameOrIdent",
"(",
"String",
"name",
")",
"{",
"ModuleSymbol",
"msym",
";",
"String",
"typeName",
";",
"int",
"sep",
"=",
"name",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"sep",
"==",
"-",
"1",
")",
"{",
"msym",
"=",
"modules",
".",
"getDefaultModule",
"(",
")",
";",
"typeName",
"=",
"name",
";",
"}",
"else",
"if",
"(",
"source",
".",
"allowModules",
"(",
")",
")",
"{",
"Name",
"modName",
"=",
"names",
".",
"fromString",
"(",
"name",
".",
"substring",
"(",
"0",
",",
"sep",
")",
")",
";",
"msym",
"=",
"moduleFinder",
".",
"findModule",
"(",
"modName",
")",
";",
"typeName",
"=",
"name",
".",
"substring",
"(",
"sep",
"+",
"1",
")",
";",
"}",
"else",
"{",
"log",
".",
"error",
"(",
"Errors",
".",
"InvalidModuleSpecifier",
"(",
"name",
")",
")",
";",
"return",
"silentFail",
";",
"}",
"return",
"resolveBinaryNameOrIdent",
"(",
"msym",
",",
"typeName",
")",
";",
"}"
] | Resolve an identifier which may be the binary name of a class or
the Java name of a class or package.
@param name The name to resolve | [
"Resolve",
"an",
"identifier",
"which",
"may",
"be",
"the",
"binary",
"name",
"of",
"a",
"class",
"or",
"the",
"Java",
"name",
"of",
"a",
"class",
"or",
"package",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java#L675-L693 |
lucee/Lucee | core/src/main/java/lucee/runtime/op/date/DateCaster.java | DateCaster.toDateAdvanced | public static DateTime toDateAdvanced(String str, short convertingType, TimeZone timeZone, DateTime defaultValue) {
"""
converts a String to a DateTime Object (Advanced but slower), returns null if invalid string
@param str String to convert
@param convertingType one of the following values: - CONVERTING_TYPE_NONE: number are not
converted at all - CONVERTING_TYPE_YEAR: integers are handled as years -
CONVERTING_TYPE_OFFSET: numbers are handled as offset from 1899-12-30 00:00:00 UTC
@param timeZone
@param defaultValue
@return Date Time Object
"""
str = str.trim();
if (StringUtil.isEmpty(str)) return defaultValue;
if (!hasDigits(str)) return defaultValue; // every format has digits
timeZone = ThreadLocalPageContext.getTimeZone(timeZone);
DateTime dt = toDateSimple(str, convertingType, true, timeZone, defaultValue);
if (dt == null) {
final DateFormat[] formats = FormatUtil.getCFMLFormats(timeZone, true);
synchronized (formats) {
Date d;
ParsePosition pp = new ParsePosition(0);
for (int i = 0; i < formats.length; i++) {
// try {
pp.setErrorIndex(-1);
pp.setIndex(0);
d = formats[i].parse(str, pp);
if (pp.getIndex() == 0 || d == null || pp.getIndex() < str.length()) continue;
dt = new DateTimeImpl(d.getTime(), false);
return dt;
}
}
dt = toDateTime(Locale.US, str, timeZone, defaultValue, false);
}
return dt;
} | java | public static DateTime toDateAdvanced(String str, short convertingType, TimeZone timeZone, DateTime defaultValue) {
str = str.trim();
if (StringUtil.isEmpty(str)) return defaultValue;
if (!hasDigits(str)) return defaultValue; // every format has digits
timeZone = ThreadLocalPageContext.getTimeZone(timeZone);
DateTime dt = toDateSimple(str, convertingType, true, timeZone, defaultValue);
if (dt == null) {
final DateFormat[] formats = FormatUtil.getCFMLFormats(timeZone, true);
synchronized (formats) {
Date d;
ParsePosition pp = new ParsePosition(0);
for (int i = 0; i < formats.length; i++) {
// try {
pp.setErrorIndex(-1);
pp.setIndex(0);
d = formats[i].parse(str, pp);
if (pp.getIndex() == 0 || d == null || pp.getIndex() < str.length()) continue;
dt = new DateTimeImpl(d.getTime(), false);
return dt;
}
}
dt = toDateTime(Locale.US, str, timeZone, defaultValue, false);
}
return dt;
} | [
"public",
"static",
"DateTime",
"toDateAdvanced",
"(",
"String",
"str",
",",
"short",
"convertingType",
",",
"TimeZone",
"timeZone",
",",
"DateTime",
"defaultValue",
")",
"{",
"str",
"=",
"str",
".",
"trim",
"(",
")",
";",
"if",
"(",
"StringUtil",
".",
"isEmpty",
"(",
"str",
")",
")",
"return",
"defaultValue",
";",
"if",
"(",
"!",
"hasDigits",
"(",
"str",
")",
")",
"return",
"defaultValue",
";",
"// every format has digits",
"timeZone",
"=",
"ThreadLocalPageContext",
".",
"getTimeZone",
"(",
"timeZone",
")",
";",
"DateTime",
"dt",
"=",
"toDateSimple",
"(",
"str",
",",
"convertingType",
",",
"true",
",",
"timeZone",
",",
"defaultValue",
")",
";",
"if",
"(",
"dt",
"==",
"null",
")",
"{",
"final",
"DateFormat",
"[",
"]",
"formats",
"=",
"FormatUtil",
".",
"getCFMLFormats",
"(",
"timeZone",
",",
"true",
")",
";",
"synchronized",
"(",
"formats",
")",
"{",
"Date",
"d",
";",
"ParsePosition",
"pp",
"=",
"new",
"ParsePosition",
"(",
"0",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"formats",
".",
"length",
";",
"i",
"++",
")",
"{",
"// try {",
"pp",
".",
"setErrorIndex",
"(",
"-",
"1",
")",
";",
"pp",
".",
"setIndex",
"(",
"0",
")",
";",
"d",
"=",
"formats",
"[",
"i",
"]",
".",
"parse",
"(",
"str",
",",
"pp",
")",
";",
"if",
"(",
"pp",
".",
"getIndex",
"(",
")",
"==",
"0",
"||",
"d",
"==",
"null",
"||",
"pp",
".",
"getIndex",
"(",
")",
"<",
"str",
".",
"length",
"(",
")",
")",
"continue",
";",
"dt",
"=",
"new",
"DateTimeImpl",
"(",
"d",
".",
"getTime",
"(",
")",
",",
"false",
")",
";",
"return",
"dt",
";",
"}",
"}",
"dt",
"=",
"toDateTime",
"(",
"Locale",
".",
"US",
",",
"str",
",",
"timeZone",
",",
"defaultValue",
",",
"false",
")",
";",
"}",
"return",
"dt",
";",
"}"
] | converts a String to a DateTime Object (Advanced but slower), returns null if invalid string
@param str String to convert
@param convertingType one of the following values: - CONVERTING_TYPE_NONE: number are not
converted at all - CONVERTING_TYPE_YEAR: integers are handled as years -
CONVERTING_TYPE_OFFSET: numbers are handled as offset from 1899-12-30 00:00:00 UTC
@param timeZone
@param defaultValue
@return Date Time Object | [
"converts",
"a",
"String",
"to",
"a",
"DateTime",
"Object",
"(",
"Advanced",
"but",
"slower",
")",
"returns",
"null",
"if",
"invalid",
"string"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/op/date/DateCaster.java#L144-L168 |
RestComm/media-core | stun/src/main/java/org/restcomm/media/core/stun/messages/StunMessage.java | StunMessage.setTransactionID | public void setTransactionID(byte[] tranID) throws StunException {
"""
Copies the specified tranID and sets it as this message's transactionID.
@param tranID
the transaction id to set in this message.
@throws StunException
ILLEGAL_ARGUMENT if the transaction id is not valid.
"""
if (tranID == null || (tranID.length != TRANSACTION_ID_LENGTH && tranID.length != RFC3489_TRANSACTION_ID_LENGTH))
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Invalid transaction id length");
int tranIDLength = tranID.length;
this.transactionID = new byte[tranIDLength];
System.arraycopy(tranID, 0, this.transactionID, 0, tranIDLength);
} | java | public void setTransactionID(byte[] tranID) throws StunException {
if (tranID == null || (tranID.length != TRANSACTION_ID_LENGTH && tranID.length != RFC3489_TRANSACTION_ID_LENGTH))
throw new StunException(StunException.ILLEGAL_ARGUMENT, "Invalid transaction id length");
int tranIDLength = tranID.length;
this.transactionID = new byte[tranIDLength];
System.arraycopy(tranID, 0, this.transactionID, 0, tranIDLength);
} | [
"public",
"void",
"setTransactionID",
"(",
"byte",
"[",
"]",
"tranID",
")",
"throws",
"StunException",
"{",
"if",
"(",
"tranID",
"==",
"null",
"||",
"(",
"tranID",
".",
"length",
"!=",
"TRANSACTION_ID_LENGTH",
"&&",
"tranID",
".",
"length",
"!=",
"RFC3489_TRANSACTION_ID_LENGTH",
")",
")",
"throw",
"new",
"StunException",
"(",
"StunException",
".",
"ILLEGAL_ARGUMENT",
",",
"\"Invalid transaction id length\"",
")",
";",
"int",
"tranIDLength",
"=",
"tranID",
".",
"length",
";",
"this",
".",
"transactionID",
"=",
"new",
"byte",
"[",
"tranIDLength",
"]",
";",
"System",
".",
"arraycopy",
"(",
"tranID",
",",
"0",
",",
"this",
".",
"transactionID",
",",
"0",
",",
"tranIDLength",
")",
";",
"}"
] | Copies the specified tranID and sets it as this message's transactionID.
@param tranID
the transaction id to set in this message.
@throws StunException
ILLEGAL_ARGUMENT if the transaction id is not valid. | [
"Copies",
"the",
"specified",
"tranID",
"and",
"sets",
"it",
"as",
"this",
"message",
"s",
"transactionID",
"."
] | train | https://github.com/RestComm/media-core/blob/07b8703343708599f60af66bae62aded77ee81b5/stun/src/main/java/org/restcomm/media/core/stun/messages/StunMessage.java#L439-L446 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/runtime/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/runtime/implementation/PredictionsImpl.java | PredictionsImpl.resolveAsync | public Observable<LuisResult> resolveAsync(String appId, String query, ResolveOptionalParameter resolveOptionalParameter) {
"""
Gets predictions for a given utterance, in the form of intents and entities. The current maximum query size is 500 characters.
@param appId The LUIS application ID (Guid).
@param query The utterance to predict.
@param resolveOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the LuisResult object
"""
return resolveWithServiceResponseAsync(appId, query, resolveOptionalParameter).map(new Func1<ServiceResponse<LuisResult>, LuisResult>() {
@Override
public LuisResult call(ServiceResponse<LuisResult> response) {
return response.body();
}
});
} | java | public Observable<LuisResult> resolveAsync(String appId, String query, ResolveOptionalParameter resolveOptionalParameter) {
return resolveWithServiceResponseAsync(appId, query, resolveOptionalParameter).map(new Func1<ServiceResponse<LuisResult>, LuisResult>() {
@Override
public LuisResult call(ServiceResponse<LuisResult> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"LuisResult",
">",
"resolveAsync",
"(",
"String",
"appId",
",",
"String",
"query",
",",
"ResolveOptionalParameter",
"resolveOptionalParameter",
")",
"{",
"return",
"resolveWithServiceResponseAsync",
"(",
"appId",
",",
"query",
",",
"resolveOptionalParameter",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"LuisResult",
">",
",",
"LuisResult",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"LuisResult",
"call",
"(",
"ServiceResponse",
"<",
"LuisResult",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets predictions for a given utterance, in the form of intents and entities. The current maximum query size is 500 characters.
@param appId The LUIS application ID (Guid).
@param query The utterance to predict.
@param resolveOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the LuisResult object | [
"Gets",
"predictions",
"for",
"a",
"given",
"utterance",
"in",
"the",
"form",
"of",
"intents",
"and",
"entities",
".",
"The",
"current",
"maximum",
"query",
"size",
"is",
"500",
"characters",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/runtime/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/runtime/implementation/PredictionsImpl.java#L104-L111 |
sculptor/sculptor | sculptor-maven/sculptor-maven-plugin/src/main/java/org/sculptor/maven/plugin/GraphvizMojo.java | GraphvizMojo.executeDot | protected boolean executeDot(Set<String> dotFiles)
throws MojoExecutionException {
"""
Executes the command line tool <code>dot</code>.
@param dotFiles
list of dot files from the
{@link AbstractGeneratorMojo#statusFile}
"""
// Build executor for projects base directory
MavenLogOutputStream stdout = getStdoutStream();
MavenLogOutputStream stderr = getStderrStream();
Executor exec = getExecutor();
exec.setWorkingDirectory(project.getBasedir());
exec.setStreamHandler(new PumpStreamHandler(stdout, stderr, System.in));
// Execute commandline and check return code
try {
int exitValue = exec.execute(getDotCommandLine(dotFiles));
if (exitValue == 0 && stdout.getErrorCount() == 0) {
return true;
}
} catch (ExecuteException e) {
// ignore
} catch (IOException e) {
// ignore
}
return false;
} | java | protected boolean executeDot(Set<String> dotFiles)
throws MojoExecutionException {
// Build executor for projects base directory
MavenLogOutputStream stdout = getStdoutStream();
MavenLogOutputStream stderr = getStderrStream();
Executor exec = getExecutor();
exec.setWorkingDirectory(project.getBasedir());
exec.setStreamHandler(new PumpStreamHandler(stdout, stderr, System.in));
// Execute commandline and check return code
try {
int exitValue = exec.execute(getDotCommandLine(dotFiles));
if (exitValue == 0 && stdout.getErrorCount() == 0) {
return true;
}
} catch (ExecuteException e) {
// ignore
} catch (IOException e) {
// ignore
}
return false;
} | [
"protected",
"boolean",
"executeDot",
"(",
"Set",
"<",
"String",
">",
"dotFiles",
")",
"throws",
"MojoExecutionException",
"{",
"// Build executor for projects base directory",
"MavenLogOutputStream",
"stdout",
"=",
"getStdoutStream",
"(",
")",
";",
"MavenLogOutputStream",
"stderr",
"=",
"getStderrStream",
"(",
")",
";",
"Executor",
"exec",
"=",
"getExecutor",
"(",
")",
";",
"exec",
".",
"setWorkingDirectory",
"(",
"project",
".",
"getBasedir",
"(",
")",
")",
";",
"exec",
".",
"setStreamHandler",
"(",
"new",
"PumpStreamHandler",
"(",
"stdout",
",",
"stderr",
",",
"System",
".",
"in",
")",
")",
";",
"// Execute commandline and check return code",
"try",
"{",
"int",
"exitValue",
"=",
"exec",
".",
"execute",
"(",
"getDotCommandLine",
"(",
"dotFiles",
")",
")",
";",
"if",
"(",
"exitValue",
"==",
"0",
"&&",
"stdout",
".",
"getErrorCount",
"(",
")",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"ExecuteException",
"e",
")",
"{",
"// ignore",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// ignore",
"}",
"return",
"false",
";",
"}"
] | Executes the command line tool <code>dot</code>.
@param dotFiles
list of dot files from the
{@link AbstractGeneratorMojo#statusFile} | [
"Executes",
"the",
"command",
"line",
"tool",
"<code",
">",
"dot<",
"/",
"code",
">",
"."
] | train | https://github.com/sculptor/sculptor/blob/38df06ceb7e40f5f52dbd53b1cd1d07ee11aade5/sculptor-maven/sculptor-maven-plugin/src/main/java/org/sculptor/maven/plugin/GraphvizMojo.java#L161-L183 |
BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java | ExampleSection.selectExample | public void selectExample(final WComponent example, final String exampleName) {
"""
Selects an example.
@param example the example to select.
@param exampleName the name of the example being selected.
"""
WComponent currentExample = container.getChildAt(0).getParent();
if (currentExample != null && currentExample.getClass().equals(example.getClass())) {
// Same example selected, do nothing
return;
}
resetExample();
container.removeAll();
this.getDecoratedLabel().setBody(new WText(exampleName));
WApplication app = WebUtilities.getAncestorOfClass(WApplication.class, this);
if (app != null) {
app.setTitle(exampleName);
}
if (example instanceof ErrorComponent) {
tabset.getTab(0).setText("Error");
source.setSource(null);
} else {
String className = example.getClass().getName();
WDefinitionList list = new WDefinitionList(WDefinitionList.Type.COLUMN);
container.add(list);
list.addTerm("Example path", new WText(className.replaceAll("\\.", " / ")));
list.addTerm("Example JavaDoc", new JavaDocText(getSource(className)));
container.add(new WHorizontalRule());
tabset.getTab(0).setText(example.getClass().getSimpleName());
source.setSource(getSource(className));
}
container.add(example);
example.setLocked(true);
} | java | public void selectExample(final WComponent example, final String exampleName) {
WComponent currentExample = container.getChildAt(0).getParent();
if (currentExample != null && currentExample.getClass().equals(example.getClass())) {
// Same example selected, do nothing
return;
}
resetExample();
container.removeAll();
this.getDecoratedLabel().setBody(new WText(exampleName));
WApplication app = WebUtilities.getAncestorOfClass(WApplication.class, this);
if (app != null) {
app.setTitle(exampleName);
}
if (example instanceof ErrorComponent) {
tabset.getTab(0).setText("Error");
source.setSource(null);
} else {
String className = example.getClass().getName();
WDefinitionList list = new WDefinitionList(WDefinitionList.Type.COLUMN);
container.add(list);
list.addTerm("Example path", new WText(className.replaceAll("\\.", " / ")));
list.addTerm("Example JavaDoc", new JavaDocText(getSource(className)));
container.add(new WHorizontalRule());
tabset.getTab(0).setText(example.getClass().getSimpleName());
source.setSource(getSource(className));
}
container.add(example);
example.setLocked(true);
} | [
"public",
"void",
"selectExample",
"(",
"final",
"WComponent",
"example",
",",
"final",
"String",
"exampleName",
")",
"{",
"WComponent",
"currentExample",
"=",
"container",
".",
"getChildAt",
"(",
"0",
")",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"currentExample",
"!=",
"null",
"&&",
"currentExample",
".",
"getClass",
"(",
")",
".",
"equals",
"(",
"example",
".",
"getClass",
"(",
")",
")",
")",
"{",
"// Same example selected, do nothing",
"return",
";",
"}",
"resetExample",
"(",
")",
";",
"container",
".",
"removeAll",
"(",
")",
";",
"this",
".",
"getDecoratedLabel",
"(",
")",
".",
"setBody",
"(",
"new",
"WText",
"(",
"exampleName",
")",
")",
";",
"WApplication",
"app",
"=",
"WebUtilities",
".",
"getAncestorOfClass",
"(",
"WApplication",
".",
"class",
",",
"this",
")",
";",
"if",
"(",
"app",
"!=",
"null",
")",
"{",
"app",
".",
"setTitle",
"(",
"exampleName",
")",
";",
"}",
"if",
"(",
"example",
"instanceof",
"ErrorComponent",
")",
"{",
"tabset",
".",
"getTab",
"(",
"0",
")",
".",
"setText",
"(",
"\"Error\"",
")",
";",
"source",
".",
"setSource",
"(",
"null",
")",
";",
"}",
"else",
"{",
"String",
"className",
"=",
"example",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"WDefinitionList",
"list",
"=",
"new",
"WDefinitionList",
"(",
"WDefinitionList",
".",
"Type",
".",
"COLUMN",
")",
";",
"container",
".",
"add",
"(",
"list",
")",
";",
"list",
".",
"addTerm",
"(",
"\"Example path\"",
",",
"new",
"WText",
"(",
"className",
".",
"replaceAll",
"(",
"\"\\\\.\"",
",",
"\" / \"",
")",
")",
")",
";",
"list",
".",
"addTerm",
"(",
"\"Example JavaDoc\"",
",",
"new",
"JavaDocText",
"(",
"getSource",
"(",
"className",
")",
")",
")",
";",
"container",
".",
"add",
"(",
"new",
"WHorizontalRule",
"(",
")",
")",
";",
"tabset",
".",
"getTab",
"(",
"0",
")",
".",
"setText",
"(",
"example",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"source",
".",
"setSource",
"(",
"getSource",
"(",
"className",
")",
")",
";",
"}",
"container",
".",
"add",
"(",
"example",
")",
";",
"example",
".",
"setLocked",
"(",
"true",
")",
";",
"}"
] | Selects an example.
@param example the example to select.
@param exampleName the name of the example being selected. | [
"Selects",
"an",
"example",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/ExampleSection.java#L149-L183 |
sockeqwe/AdapterDelegates | library/src/main/java/com/hannesdorfmann/adapterdelegates4/AdapterDelegatesManager.java | AdapterDelegatesManager.addDelegate | public AdapterDelegatesManager<T> addDelegate(int viewType,
@NonNull AdapterDelegate<T> delegate) {
"""
Adds an {@link AdapterDelegate} with the specified view type.
<p>
Internally calls {@link #addDelegate(int, boolean, AdapterDelegate)} with
allowReplacingDelegate = false as parameter.
@param viewType the view type integer if you want to assign manually the view type. Otherwise
use {@link #addDelegate(AdapterDelegate)} where a viewtype will be assigned automatically.
@param delegate the delegate to add
@return self
@throws NullPointerException if passed delegate is null
@see #addDelegate(AdapterDelegate)
@see #addDelegate(int, boolean, AdapterDelegate)
"""
return addDelegate(viewType, false, delegate);
} | java | public AdapterDelegatesManager<T> addDelegate(int viewType,
@NonNull AdapterDelegate<T> delegate) {
return addDelegate(viewType, false, delegate);
} | [
"public",
"AdapterDelegatesManager",
"<",
"T",
">",
"addDelegate",
"(",
"int",
"viewType",
",",
"@",
"NonNull",
"AdapterDelegate",
"<",
"T",
">",
"delegate",
")",
"{",
"return",
"addDelegate",
"(",
"viewType",
",",
"false",
",",
"delegate",
")",
";",
"}"
] | Adds an {@link AdapterDelegate} with the specified view type.
<p>
Internally calls {@link #addDelegate(int, boolean, AdapterDelegate)} with
allowReplacingDelegate = false as parameter.
@param viewType the view type integer if you want to assign manually the view type. Otherwise
use {@link #addDelegate(AdapterDelegate)} where a viewtype will be assigned automatically.
@param delegate the delegate to add
@return self
@throws NullPointerException if passed delegate is null
@see #addDelegate(AdapterDelegate)
@see #addDelegate(int, boolean, AdapterDelegate) | [
"Adds",
"an",
"{",
"@link",
"AdapterDelegate",
"}",
"with",
"the",
"specified",
"view",
"type",
".",
"<p",
">",
"Internally",
"calls",
"{",
"@link",
"#addDelegate",
"(",
"int",
"boolean",
"AdapterDelegate",
")",
"}",
"with",
"allowReplacingDelegate",
"=",
"false",
"as",
"parameter",
"."
] | train | https://github.com/sockeqwe/AdapterDelegates/blob/d18dc609415e5d17a3354bddf4bae62440e017af/library/src/main/java/com/hannesdorfmann/adapterdelegates4/AdapterDelegatesManager.java#L119-L122 |
UrielCh/ovh-java-sdk | ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java | ApiOvhEmailexchange.organizationName_service_exchangeService_publicFolder_path_PUT | public void organizationName_service_exchangeService_publicFolder_path_PUT(String organizationName, String exchangeService, String path, OvhPublicFolder body) throws IOException {
"""
Alter this object properties
REST: PUT /email/exchange/{organizationName}/service/{exchangeService}/publicFolder/{path}
@param body [required] New object properties
@param organizationName [required] The internal name of your exchange organization
@param exchangeService [required] The internal name of your exchange service
@param path [required] Path for public folder
"""
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}/publicFolder/{path}";
StringBuilder sb = path(qPath, organizationName, exchangeService, path);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void organizationName_service_exchangeService_publicFolder_path_PUT(String organizationName, String exchangeService, String path, OvhPublicFolder body) throws IOException {
String qPath = "/email/exchange/{organizationName}/service/{exchangeService}/publicFolder/{path}";
StringBuilder sb = path(qPath, organizationName, exchangeService, path);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"organizationName_service_exchangeService_publicFolder_path_PUT",
"(",
"String",
"organizationName",
",",
"String",
"exchangeService",
",",
"String",
"path",
",",
"OvhPublicFolder",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/email/exchange/{organizationName}/service/{exchangeService}/publicFolder/{path}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"organizationName",
",",
"exchangeService",
",",
"path",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] | Alter this object properties
REST: PUT /email/exchange/{organizationName}/service/{exchangeService}/publicFolder/{path}
@param body [required] New object properties
@param organizationName [required] The internal name of your exchange organization
@param exchangeService [required] The internal name of your exchange service
@param path [required] Path for public folder | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-emailexchange/src/main/java/net/minidev/ovh/api/ApiOvhEmailexchange.java#L182-L186 |
JRebirth/JRebirth | org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/AbstractService.java | AbstractService.bindProgressBar | private void bindProgressBar(final ServiceTaskBase<?> task, final ProgressBar progressBar) {
"""
Bind a task to a progress bar widget to follow its progression.
@param task the service task that we need to follow the progression
@param progressBar graphical progress bar
"""
// Perform this binding into the JAT to respect widget and task API
JRebirth.runIntoJAT("Bind ProgressBar to " + task.getServiceHandlerName(),
() -> {
// Avoid the progress bar to display 100% at start up
task.updateProgress(0, 0);
// Bind the progress bar
progressBar.progressProperty().bind(task.workDoneProperty().divide(task.totalWorkProperty()));
});
} | java | private void bindProgressBar(final ServiceTaskBase<?> task, final ProgressBar progressBar) {
// Perform this binding into the JAT to respect widget and task API
JRebirth.runIntoJAT("Bind ProgressBar to " + task.getServiceHandlerName(),
() -> {
// Avoid the progress bar to display 100% at start up
task.updateProgress(0, 0);
// Bind the progress bar
progressBar.progressProperty().bind(task.workDoneProperty().divide(task.totalWorkProperty()));
});
} | [
"private",
"void",
"bindProgressBar",
"(",
"final",
"ServiceTaskBase",
"<",
"?",
">",
"task",
",",
"final",
"ProgressBar",
"progressBar",
")",
"{",
"// Perform this binding into the JAT to respect widget and task API",
"JRebirth",
".",
"runIntoJAT",
"(",
"\"Bind ProgressBar to \"",
"+",
"task",
".",
"getServiceHandlerName",
"(",
")",
",",
"(",
")",
"->",
"{",
"// Avoid the progress bar to display 100% at start up",
"task",
".",
"updateProgress",
"(",
"0",
",",
"0",
")",
";",
"// Bind the progress bar",
"progressBar",
".",
"progressProperty",
"(",
")",
".",
"bind",
"(",
"task",
".",
"workDoneProperty",
"(",
")",
".",
"divide",
"(",
"task",
".",
"totalWorkProperty",
"(",
")",
")",
")",
";",
"}",
")",
";",
"}"
] | Bind a task to a progress bar widget to follow its progression.
@param task the service task that we need to follow the progression
@param progressBar graphical progress bar | [
"Bind",
"a",
"task",
"to",
"a",
"progress",
"bar",
"widget",
"to",
"follow",
"its",
"progression",
"."
] | train | https://github.com/JRebirth/JRebirth/blob/93f4fc087b83c73db540333b9686e97b4cec694d/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/service/AbstractService.java#L205-L216 |
jglobus/JGlobus | ssl-proxies/src/main/java/org/globus/gsi/bc/BouncyCastleCertProcessingFactory.java | BouncyCastleCertProcessingFactory.createCertificateRequest | public byte[] createCertificateRequest(String subject, KeyPair keyPair) throws GeneralSecurityException {
"""
Creates a certificate request from the specified subject DN and a key pair. The
<I>"MD5WithRSAEncryption"</I> is used as the signing algorithm of the certificate request.
@param subject
the subject of the certificate request
@param keyPair
the key pair of the certificate request
@return the certificate request.
@exception GeneralSecurityException
if security error occurs.
"""
X509Name name = new X509Name(subject);
return createCertificateRequest(name, "MD5WithRSAEncryption", keyPair);
} | java | public byte[] createCertificateRequest(String subject, KeyPair keyPair) throws GeneralSecurityException {
X509Name name = new X509Name(subject);
return createCertificateRequest(name, "MD5WithRSAEncryption", keyPair);
} | [
"public",
"byte",
"[",
"]",
"createCertificateRequest",
"(",
"String",
"subject",
",",
"KeyPair",
"keyPair",
")",
"throws",
"GeneralSecurityException",
"{",
"X509Name",
"name",
"=",
"new",
"X509Name",
"(",
"subject",
")",
";",
"return",
"createCertificateRequest",
"(",
"name",
",",
"\"MD5WithRSAEncryption\"",
",",
"keyPair",
")",
";",
"}"
] | Creates a certificate request from the specified subject DN and a key pair. The
<I>"MD5WithRSAEncryption"</I> is used as the signing algorithm of the certificate request.
@param subject
the subject of the certificate request
@param keyPair
the key pair of the certificate request
@return the certificate request.
@exception GeneralSecurityException
if security error occurs. | [
"Creates",
"a",
"certificate",
"request",
"from",
"the",
"specified",
"subject",
"DN",
"and",
"a",
"key",
"pair",
".",
"The",
"<I",
">",
"MD5WithRSAEncryption",
"<",
"/",
"I",
">",
"is",
"used",
"as",
"the",
"signing",
"algorithm",
"of",
"the",
"certificate",
"request",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/ssl-proxies/src/main/java/org/globus/gsi/bc/BouncyCastleCertProcessingFactory.java#L943-L946 |
webmetrics/browsermob-proxy | src/main/java/org/xbill/DNS/Address.java | Address.getByAddress | public static InetAddress
getByAddress(String addr, int family) throws UnknownHostException {
"""
Converts an address from its string representation to an IP address in
a particular family.
@param addr The address, in string form
@param family The address family, either IPv4 or IPv6.
@return The IP addresses
@throws UnknownHostException The address is not a valid IP address in
the specified address family.
"""
if (family != IPv4 && family != IPv6)
throw new IllegalArgumentException("unknown address family");
byte[] bytes;
bytes = toByteArray(addr, family);
if (bytes != null)
return InetAddress.getByAddress(bytes);
throw new UnknownHostException("Invalid address: " + addr);
} | java | public static InetAddress
getByAddress(String addr, int family) throws UnknownHostException {
if (family != IPv4 && family != IPv6)
throw new IllegalArgumentException("unknown address family");
byte[] bytes;
bytes = toByteArray(addr, family);
if (bytes != null)
return InetAddress.getByAddress(bytes);
throw new UnknownHostException("Invalid address: " + addr);
} | [
"public",
"static",
"InetAddress",
"getByAddress",
"(",
"String",
"addr",
",",
"int",
"family",
")",
"throws",
"UnknownHostException",
"{",
"if",
"(",
"family",
"!=",
"IPv4",
"&&",
"family",
"!=",
"IPv6",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"unknown address family\"",
")",
";",
"byte",
"[",
"]",
"bytes",
";",
"bytes",
"=",
"toByteArray",
"(",
"addr",
",",
"family",
")",
";",
"if",
"(",
"bytes",
"!=",
"null",
")",
"return",
"InetAddress",
".",
"getByAddress",
"(",
"bytes",
")",
";",
"throw",
"new",
"UnknownHostException",
"(",
"\"Invalid address: \"",
"+",
"addr",
")",
";",
"}"
] | Converts an address from its string representation to an IP address in
a particular family.
@param addr The address, in string form
@param family The address family, either IPv4 or IPv6.
@return The IP addresses
@throws UnknownHostException The address is not a valid IP address in
the specified address family. | [
"Converts",
"an",
"address",
"from",
"its",
"string",
"representation",
"to",
"an",
"IP",
"address",
"in",
"a",
"particular",
"family",
"."
] | train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/xbill/DNS/Address.java#L329-L338 |
SimplicityApks/ReminderDatePicker | lib/src/main/java/com/simplicityapks/reminderdatepicker/lib/DateSpinner.java | DateSpinner.setDateFormat | public void setDateFormat(java.text.DateFormat dateFormat, java.text.DateFormat numbersDateFormat) {
"""
Sets the custom date format to use for formatting Calendar objects to displayable strings.
@param dateFormat The new DateFormat, or null to use the default format.
@param numbersDateFormat The DateFormat for formatting the secondary date when both FLAG_NUMBERS
and FLAG_WEEKDAY_NAMES are set, or null to use the default format.
"""
this.customDateFormat = dateFormat;
this.secondaryDateFormat = numbersDateFormat;
// update the spinner with the new date format:
// the only spinner item that will be affected is the month item, so just toggle the flag twice
// instead of rebuilding the whole adapter
if(showMonthItem) {
int monthPosition = getAdapterItemPosition(4);
boolean reselectMonthItem = getSelectedItemPosition() == monthPosition;
setShowMonthItem(false);
setShowMonthItem(true);
if(reselectMonthItem) setSelection(monthPosition);
}
// if we have a temporary date item selected, update that as well
if(getSelectedItemPosition() == getAdapter().getCount())
setSelectedDate(getSelectedDate());
} | java | public void setDateFormat(java.text.DateFormat dateFormat, java.text.DateFormat numbersDateFormat) {
this.customDateFormat = dateFormat;
this.secondaryDateFormat = numbersDateFormat;
// update the spinner with the new date format:
// the only spinner item that will be affected is the month item, so just toggle the flag twice
// instead of rebuilding the whole adapter
if(showMonthItem) {
int monthPosition = getAdapterItemPosition(4);
boolean reselectMonthItem = getSelectedItemPosition() == monthPosition;
setShowMonthItem(false);
setShowMonthItem(true);
if(reselectMonthItem) setSelection(monthPosition);
}
// if we have a temporary date item selected, update that as well
if(getSelectedItemPosition() == getAdapter().getCount())
setSelectedDate(getSelectedDate());
} | [
"public",
"void",
"setDateFormat",
"(",
"java",
".",
"text",
".",
"DateFormat",
"dateFormat",
",",
"java",
".",
"text",
".",
"DateFormat",
"numbersDateFormat",
")",
"{",
"this",
".",
"customDateFormat",
"=",
"dateFormat",
";",
"this",
".",
"secondaryDateFormat",
"=",
"numbersDateFormat",
";",
"// update the spinner with the new date format:",
"// the only spinner item that will be affected is the month item, so just toggle the flag twice",
"// instead of rebuilding the whole adapter",
"if",
"(",
"showMonthItem",
")",
"{",
"int",
"monthPosition",
"=",
"getAdapterItemPosition",
"(",
"4",
")",
";",
"boolean",
"reselectMonthItem",
"=",
"getSelectedItemPosition",
"(",
")",
"==",
"monthPosition",
";",
"setShowMonthItem",
"(",
"false",
")",
";",
"setShowMonthItem",
"(",
"true",
")",
";",
"if",
"(",
"reselectMonthItem",
")",
"setSelection",
"(",
"monthPosition",
")",
";",
"}",
"// if we have a temporary date item selected, update that as well",
"if",
"(",
"getSelectedItemPosition",
"(",
")",
"==",
"getAdapter",
"(",
")",
".",
"getCount",
"(",
")",
")",
"setSelectedDate",
"(",
"getSelectedDate",
"(",
")",
")",
";",
"}"
] | Sets the custom date format to use for formatting Calendar objects to displayable strings.
@param dateFormat The new DateFormat, or null to use the default format.
@param numbersDateFormat The DateFormat for formatting the secondary date when both FLAG_NUMBERS
and FLAG_WEEKDAY_NAMES are set, or null to use the default format. | [
"Sets",
"the",
"custom",
"date",
"format",
"to",
"use",
"for",
"formatting",
"Calendar",
"objects",
"to",
"displayable",
"strings",
"."
] | train | https://github.com/SimplicityApks/ReminderDatePicker/blob/7596fbac77a5d26f687fec11758935a2b7db156f/lib/src/main/java/com/simplicityapks/reminderdatepicker/lib/DateSpinner.java#L333-L351 |
BlueBrain/bluima | modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/maxent/GIS.java | GIS.trainModel | public static GISModel trainModel(int iterations, DataIndexer indexer, boolean printMessagesWhileTraining, boolean smoothing) {
"""
Train a model using the GIS algorithm.
@param iterations The number of GIS iterations to perform.
@param indexer The object which will be used for event compilation.
@param printMessagesWhileTraining Determines whether training status messages are written to STDOUT.
@param smoothing Defines whether the created trainer will use smoothing while training the model.
@return The newly trained model, which can be used immediately or saved
to disk using an opennlp.maxent.io.GISModelWriter object.
"""
GISTrainer trainer = new GISTrainer(printMessagesWhileTraining);
trainer.setSmoothing(smoothing);
trainer.setSmoothingObservation(SMOOTHING_OBSERVATION);
return trainer.trainModel(iterations, indexer);
} | java | public static GISModel trainModel(int iterations, DataIndexer indexer, boolean printMessagesWhileTraining, boolean smoothing) {
GISTrainer trainer = new GISTrainer(printMessagesWhileTraining);
trainer.setSmoothing(smoothing);
trainer.setSmoothingObservation(SMOOTHING_OBSERVATION);
return trainer.trainModel(iterations, indexer);
} | [
"public",
"static",
"GISModel",
"trainModel",
"(",
"int",
"iterations",
",",
"DataIndexer",
"indexer",
",",
"boolean",
"printMessagesWhileTraining",
",",
"boolean",
"smoothing",
")",
"{",
"GISTrainer",
"trainer",
"=",
"new",
"GISTrainer",
"(",
"printMessagesWhileTraining",
")",
";",
"trainer",
".",
"setSmoothing",
"(",
"smoothing",
")",
";",
"trainer",
".",
"setSmoothingObservation",
"(",
"SMOOTHING_OBSERVATION",
")",
";",
"return",
"trainer",
".",
"trainModel",
"(",
"iterations",
",",
"indexer",
")",
";",
"}"
] | Train a model using the GIS algorithm.
@param iterations The number of GIS iterations to perform.
@param indexer The object which will be used for event compilation.
@param printMessagesWhileTraining Determines whether training status messages are written to STDOUT.
@param smoothing Defines whether the created trainer will use smoothing while training the model.
@return The newly trained model, which can be used immediately or saved
to disk using an opennlp.maxent.io.GISModelWriter object. | [
"Train",
"a",
"model",
"using",
"the",
"GIS",
"algorithm",
"."
] | train | https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/maxent/GIS.java#L130-L135 |
thinkaurelius/titan | titan-core/src/main/java/com/thinkaurelius/titan/diskstorage/util/Hex.java | Hex.getProtectedConstructor | public static Constructor getProtectedConstructor(Class klass, Class... paramTypes) {
"""
Used to get access to protected/private constructor of the specified class
@param klass - name of the class
@param paramTypes - types of the constructor parameters
@return Constructor if successful, null if the constructor cannot be
accessed
"""
Constructor c;
try {
c = klass.getDeclaredConstructor(paramTypes);
c.setAccessible(true);
return c;
} catch (Exception e) {
return null;
}
} | java | public static Constructor getProtectedConstructor(Class klass, Class... paramTypes) {
Constructor c;
try {
c = klass.getDeclaredConstructor(paramTypes);
c.setAccessible(true);
return c;
} catch (Exception e) {
return null;
}
} | [
"public",
"static",
"Constructor",
"getProtectedConstructor",
"(",
"Class",
"klass",
",",
"Class",
"...",
"paramTypes",
")",
"{",
"Constructor",
"c",
";",
"try",
"{",
"c",
"=",
"klass",
".",
"getDeclaredConstructor",
"(",
"paramTypes",
")",
";",
"c",
".",
"setAccessible",
"(",
"true",
")",
";",
"return",
"c",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Used to get access to protected/private constructor of the specified class
@param klass - name of the class
@param paramTypes - types of the constructor parameters
@return Constructor if successful, null if the constructor cannot be
accessed | [
"Used",
"to",
"get",
"access",
"to",
"protected",
"/",
"private",
"constructor",
"of",
"the",
"specified",
"class"
] | train | https://github.com/thinkaurelius/titan/blob/ee226e52415b8bf43b700afac75fa5b9767993a5/titan-core/src/main/java/com/thinkaurelius/titan/diskstorage/util/Hex.java#L86-L95 |
jMotif/GI | src/main/java/net/seninp/gi/logic/GIUtils.java | GIUtils.getZeroIntervals | public static List<RuleInterval> getZeroIntervals(int[] coverageArray) {
"""
Run a quick scan along the time series coverage to find a zeroed intervals.
@param coverageArray the coverage to analyze.
@return set of zeroed intervals (if found).
"""
ArrayList<RuleInterval> res = new ArrayList<RuleInterval>();
int start = -1;
boolean inInterval = false;
int intervalsCounter = -1;
// slide over the array from left to the right
//
for (int i = 0; i < coverageArray.length; i++) {
if (0 == coverageArray[i] && !inInterval) {
start = i;
inInterval = true;
}
if (coverageArray[i] > 0 && inInterval) {
res.add(new RuleInterval(intervalsCounter, start, i, 0));
inInterval = false;
intervalsCounter--;
}
}
// we need to check for the last interval here
//
if (inInterval) {
res.add(new RuleInterval(intervalsCounter, start, coverageArray.length, 0));
}
return res;
} | java | public static List<RuleInterval> getZeroIntervals(int[] coverageArray) {
ArrayList<RuleInterval> res = new ArrayList<RuleInterval>();
int start = -1;
boolean inInterval = false;
int intervalsCounter = -1;
// slide over the array from left to the right
//
for (int i = 0; i < coverageArray.length; i++) {
if (0 == coverageArray[i] && !inInterval) {
start = i;
inInterval = true;
}
if (coverageArray[i] > 0 && inInterval) {
res.add(new RuleInterval(intervalsCounter, start, i, 0));
inInterval = false;
intervalsCounter--;
}
}
// we need to check for the last interval here
//
if (inInterval) {
res.add(new RuleInterval(intervalsCounter, start, coverageArray.length, 0));
}
return res;
} | [
"public",
"static",
"List",
"<",
"RuleInterval",
">",
"getZeroIntervals",
"(",
"int",
"[",
"]",
"coverageArray",
")",
"{",
"ArrayList",
"<",
"RuleInterval",
">",
"res",
"=",
"new",
"ArrayList",
"<",
"RuleInterval",
">",
"(",
")",
";",
"int",
"start",
"=",
"-",
"1",
";",
"boolean",
"inInterval",
"=",
"false",
";",
"int",
"intervalsCounter",
"=",
"-",
"1",
";",
"// slide over the array from left to the right",
"//",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"coverageArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"0",
"==",
"coverageArray",
"[",
"i",
"]",
"&&",
"!",
"inInterval",
")",
"{",
"start",
"=",
"i",
";",
"inInterval",
"=",
"true",
";",
"}",
"if",
"(",
"coverageArray",
"[",
"i",
"]",
">",
"0",
"&&",
"inInterval",
")",
"{",
"res",
".",
"add",
"(",
"new",
"RuleInterval",
"(",
"intervalsCounter",
",",
"start",
",",
"i",
",",
"0",
")",
")",
";",
"inInterval",
"=",
"false",
";",
"intervalsCounter",
"--",
";",
"}",
"}",
"// we need to check for the last interval here",
"//",
"if",
"(",
"inInterval",
")",
"{",
"res",
".",
"add",
"(",
"new",
"RuleInterval",
"(",
"intervalsCounter",
",",
"start",
",",
"coverageArray",
".",
"length",
",",
"0",
")",
")",
";",
"}",
"return",
"res",
";",
"}"
] | Run a quick scan along the time series coverage to find a zeroed intervals.
@param coverageArray the coverage to analyze.
@return set of zeroed intervals (if found). | [
"Run",
"a",
"quick",
"scan",
"along",
"the",
"time",
"series",
"coverage",
"to",
"find",
"a",
"zeroed",
"intervals",
"."
] | train | https://github.com/jMotif/GI/blob/381212dd4f193246a6df82bd46f0d2bcd04a68d6/src/main/java/net/seninp/gi/logic/GIUtils.java#L42-L74 |
classgraph/classgraph | src/main/java/io/github/classgraph/ClassInfo.java | ClassInfo.addImplementedInterface | void addImplementedInterface(final String interfaceName, final Map<String, ClassInfo> classNameToClassInfo) {
"""
Add an implemented interface to this class.
@param interfaceName
the interface name
@param classNameToClassInfo
the map from class name to class info
"""
final ClassInfo interfaceClassInfo = getOrCreateClassInfo(interfaceName,
/* classModifiers = */ Modifier.INTERFACE, classNameToClassInfo);
interfaceClassInfo.isInterface = true;
interfaceClassInfo.modifiers |= Modifier.INTERFACE;
this.addRelatedClass(RelType.IMPLEMENTED_INTERFACES, interfaceClassInfo);
interfaceClassInfo.addRelatedClass(RelType.CLASSES_IMPLEMENTING, this);
} | java | void addImplementedInterface(final String interfaceName, final Map<String, ClassInfo> classNameToClassInfo) {
final ClassInfo interfaceClassInfo = getOrCreateClassInfo(interfaceName,
/* classModifiers = */ Modifier.INTERFACE, classNameToClassInfo);
interfaceClassInfo.isInterface = true;
interfaceClassInfo.modifiers |= Modifier.INTERFACE;
this.addRelatedClass(RelType.IMPLEMENTED_INTERFACES, interfaceClassInfo);
interfaceClassInfo.addRelatedClass(RelType.CLASSES_IMPLEMENTING, this);
} | [
"void",
"addImplementedInterface",
"(",
"final",
"String",
"interfaceName",
",",
"final",
"Map",
"<",
"String",
",",
"ClassInfo",
">",
"classNameToClassInfo",
")",
"{",
"final",
"ClassInfo",
"interfaceClassInfo",
"=",
"getOrCreateClassInfo",
"(",
"interfaceName",
",",
"/* classModifiers = */",
"Modifier",
".",
"INTERFACE",
",",
"classNameToClassInfo",
")",
";",
"interfaceClassInfo",
".",
"isInterface",
"=",
"true",
";",
"interfaceClassInfo",
".",
"modifiers",
"|=",
"Modifier",
".",
"INTERFACE",
";",
"this",
".",
"addRelatedClass",
"(",
"RelType",
".",
"IMPLEMENTED_INTERFACES",
",",
"interfaceClassInfo",
")",
";",
"interfaceClassInfo",
".",
"addRelatedClass",
"(",
"RelType",
".",
"CLASSES_IMPLEMENTING",
",",
"this",
")",
";",
"}"
] | Add an implemented interface to this class.
@param interfaceName
the interface name
@param classNameToClassInfo
the map from class name to class info | [
"Add",
"an",
"implemented",
"interface",
"to",
"this",
"class",
"."
] | train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/io/github/classgraph/ClassInfo.java#L383-L390 |
line/armeria | core/src/main/java/com/linecorp/armeria/client/Endpoint.java | Endpoint.withIpAddr | public Endpoint withIpAddr(@Nullable String ipAddr) {
"""
Returns a new host endpoint with the specified IP address.
@return the new endpoint with the specified IP address.
{@code this} if this endpoint has the same IP address.
@throws IllegalStateException if this endpoint is not a host but a group
"""
ensureSingle();
if (ipAddr == null) {
return withoutIpAddr();
}
if (NetUtil.isValidIpV4Address(ipAddr)) {
return withIpAddr(ipAddr, StandardProtocolFamily.INET);
}
if (NetUtil.isValidIpV6Address(ipAddr)) {
if (ipAddr.charAt(0) == '[') {
ipAddr = ipAddr.substring(1, ipAddr.length() - 1);
}
return withIpAddr(ipAddr, StandardProtocolFamily.INET6);
}
throw new IllegalArgumentException("ipAddr: " + ipAddr + " (expected: an IP address)");
} | java | public Endpoint withIpAddr(@Nullable String ipAddr) {
ensureSingle();
if (ipAddr == null) {
return withoutIpAddr();
}
if (NetUtil.isValidIpV4Address(ipAddr)) {
return withIpAddr(ipAddr, StandardProtocolFamily.INET);
}
if (NetUtil.isValidIpV6Address(ipAddr)) {
if (ipAddr.charAt(0) == '[') {
ipAddr = ipAddr.substring(1, ipAddr.length() - 1);
}
return withIpAddr(ipAddr, StandardProtocolFamily.INET6);
}
throw new IllegalArgumentException("ipAddr: " + ipAddr + " (expected: an IP address)");
} | [
"public",
"Endpoint",
"withIpAddr",
"(",
"@",
"Nullable",
"String",
"ipAddr",
")",
"{",
"ensureSingle",
"(",
")",
";",
"if",
"(",
"ipAddr",
"==",
"null",
")",
"{",
"return",
"withoutIpAddr",
"(",
")",
";",
"}",
"if",
"(",
"NetUtil",
".",
"isValidIpV4Address",
"(",
"ipAddr",
")",
")",
"{",
"return",
"withIpAddr",
"(",
"ipAddr",
",",
"StandardProtocolFamily",
".",
"INET",
")",
";",
"}",
"if",
"(",
"NetUtil",
".",
"isValidIpV6Address",
"(",
"ipAddr",
")",
")",
"{",
"if",
"(",
"ipAddr",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"{",
"ipAddr",
"=",
"ipAddr",
".",
"substring",
"(",
"1",
",",
"ipAddr",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"withIpAddr",
"(",
"ipAddr",
",",
"StandardProtocolFamily",
".",
"INET6",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"ipAddr: \"",
"+",
"ipAddr",
"+",
"\" (expected: an IP address)\"",
")",
";",
"}"
] | Returns a new host endpoint with the specified IP address.
@return the new endpoint with the specified IP address.
{@code this} if this endpoint has the same IP address.
@throws IllegalStateException if this endpoint is not a host but a group | [
"Returns",
"a",
"new",
"host",
"endpoint",
"with",
"the",
"specified",
"IP",
"address",
"."
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/client/Endpoint.java#L336-L354 |
mapsforge/mapsforge | mapsforge-poi/src/main/java/org/mapsforge/poi/storage/PoiCategoryRangeQueryGenerator.java | PoiCategoryRangeQueryGenerator.getSQLSelectString | public static String getSQLSelectString(PoiCategoryFilter filter, int count, int version) {
"""
Gets the SQL query that looks up POI entries.
@param filter The filter object for determining all wanted categories.
@param count Count of patterns to search in points of interest names (may be 0).
@param version POI specification version.
@return The SQL query.
"""
StringBuilder sb = new StringBuilder();
sb.append(DbConstants.FIND_IN_BOX_CLAUSE_SELECT);
if (version < 2) {
sb.append(DbConstants.JOIN_DATA_CLAUSE);
} else {
sb.append(DbConstants.JOIN_CATEGORY_CLAUSE);
if (count > 0) {
sb.append(DbConstants.JOIN_DATA_CLAUSE);
}
}
sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE);
sb.append(getSQLWhereClauseString(filter, version));
for (int i = 0; i < count; i++) {
sb.append(DbConstants.FIND_BY_DATA_CLAUSE);
}
return (sb.append(" LIMIT ?;").toString());
} | java | public static String getSQLSelectString(PoiCategoryFilter filter, int count, int version) {
StringBuilder sb = new StringBuilder();
sb.append(DbConstants.FIND_IN_BOX_CLAUSE_SELECT);
if (version < 2) {
sb.append(DbConstants.JOIN_DATA_CLAUSE);
} else {
sb.append(DbConstants.JOIN_CATEGORY_CLAUSE);
if (count > 0) {
sb.append(DbConstants.JOIN_DATA_CLAUSE);
}
}
sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE);
sb.append(getSQLWhereClauseString(filter, version));
for (int i = 0; i < count; i++) {
sb.append(DbConstants.FIND_BY_DATA_CLAUSE);
}
return (sb.append(" LIMIT ?;").toString());
} | [
"public",
"static",
"String",
"getSQLSelectString",
"(",
"PoiCategoryFilter",
"filter",
",",
"int",
"count",
",",
"int",
"version",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"DbConstants",
".",
"FIND_IN_BOX_CLAUSE_SELECT",
")",
";",
"if",
"(",
"version",
"<",
"2",
")",
"{",
"sb",
".",
"append",
"(",
"DbConstants",
".",
"JOIN_DATA_CLAUSE",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"DbConstants",
".",
"JOIN_CATEGORY_CLAUSE",
")",
";",
"if",
"(",
"count",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"DbConstants",
".",
"JOIN_DATA_CLAUSE",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"DbConstants",
".",
"FIND_IN_BOX_CLAUSE_WHERE",
")",
";",
"sb",
".",
"append",
"(",
"getSQLWhereClauseString",
"(",
"filter",
",",
"version",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"DbConstants",
".",
"FIND_BY_DATA_CLAUSE",
")",
";",
"}",
"return",
"(",
"sb",
".",
"append",
"(",
"\" LIMIT ?;\"",
")",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Gets the SQL query that looks up POI entries.
@param filter The filter object for determining all wanted categories.
@param count Count of patterns to search in points of interest names (may be 0).
@param version POI specification version.
@return The SQL query. | [
"Gets",
"the",
"SQL",
"query",
"that",
"looks",
"up",
"POI",
"entries",
"."
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-poi/src/main/java/org/mapsforge/poi/storage/PoiCategoryRangeQueryGenerator.java#L40-L57 |
alkacon/opencms-core | src-modules/org/opencms/workplace/commons/CmsPreferences.java | CmsPreferences.buildSelectWorkplaceSearchResult | public String buildSelectWorkplaceSearchResult(String htmlAttributes) {
"""
Builds the html for the workplace search result list type select box.<p>
@param htmlAttributes optional html attributes for the &lgt;select> tag
@return the html for the workplace search result list type select box
"""
List<String> options = new ArrayList<String>(3);
List<String> values = new ArrayList<String>(3);
int checkedIndex = 0;
// add all styles to the select box
options.add(key(CmsSearchResultStyle.STYLE_EXPLORER.getKey()));
values.add(CmsSearchResultStyle.STYLE_EXPLORER.getMode());
if (getParamTabExWorkplaceSearchResult().equals(CmsSearchResultStyle.STYLE_EXPLORER.toString())) {
// mark the currently active locale
checkedIndex = 0;
}
options.add(key(CmsSearchResultStyle.STYLE_LIST_WITH_EXCERPTS.getKey()));
values.add(CmsSearchResultStyle.STYLE_LIST_WITH_EXCERPTS.getMode());
if (getParamTabExWorkplaceSearchResult().equals(CmsSearchResultStyle.STYLE_LIST_WITH_EXCERPTS.toString())) {
// mark the currently active locale
checkedIndex = 1;
}
options.add(key(CmsSearchResultStyle.STYLE_LIST_WITHOUT_EXCERPTS.getKey()));
values.add(CmsSearchResultStyle.STYLE_LIST_WITHOUT_EXCERPTS.getMode());
if (getParamTabExWorkplaceSearchResult().equals(CmsSearchResultStyle.STYLE_LIST_WITHOUT_EXCERPTS.toString())) {
// mark the currently active locale
checkedIndex = 2;
}
return buildSelect(htmlAttributes, options, values, checkedIndex);
} | java | public String buildSelectWorkplaceSearchResult(String htmlAttributes) {
List<String> options = new ArrayList<String>(3);
List<String> values = new ArrayList<String>(3);
int checkedIndex = 0;
// add all styles to the select box
options.add(key(CmsSearchResultStyle.STYLE_EXPLORER.getKey()));
values.add(CmsSearchResultStyle.STYLE_EXPLORER.getMode());
if (getParamTabExWorkplaceSearchResult().equals(CmsSearchResultStyle.STYLE_EXPLORER.toString())) {
// mark the currently active locale
checkedIndex = 0;
}
options.add(key(CmsSearchResultStyle.STYLE_LIST_WITH_EXCERPTS.getKey()));
values.add(CmsSearchResultStyle.STYLE_LIST_WITH_EXCERPTS.getMode());
if (getParamTabExWorkplaceSearchResult().equals(CmsSearchResultStyle.STYLE_LIST_WITH_EXCERPTS.toString())) {
// mark the currently active locale
checkedIndex = 1;
}
options.add(key(CmsSearchResultStyle.STYLE_LIST_WITHOUT_EXCERPTS.getKey()));
values.add(CmsSearchResultStyle.STYLE_LIST_WITHOUT_EXCERPTS.getMode());
if (getParamTabExWorkplaceSearchResult().equals(CmsSearchResultStyle.STYLE_LIST_WITHOUT_EXCERPTS.toString())) {
// mark the currently active locale
checkedIndex = 2;
}
return buildSelect(htmlAttributes, options, values, checkedIndex);
} | [
"public",
"String",
"buildSelectWorkplaceSearchResult",
"(",
"String",
"htmlAttributes",
")",
"{",
"List",
"<",
"String",
">",
"options",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"3",
")",
";",
"List",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"3",
")",
";",
"int",
"checkedIndex",
"=",
"0",
";",
"// add all styles to the select box",
"options",
".",
"add",
"(",
"key",
"(",
"CmsSearchResultStyle",
".",
"STYLE_EXPLORER",
".",
"getKey",
"(",
")",
")",
")",
";",
"values",
".",
"add",
"(",
"CmsSearchResultStyle",
".",
"STYLE_EXPLORER",
".",
"getMode",
"(",
")",
")",
";",
"if",
"(",
"getParamTabExWorkplaceSearchResult",
"(",
")",
".",
"equals",
"(",
"CmsSearchResultStyle",
".",
"STYLE_EXPLORER",
".",
"toString",
"(",
")",
")",
")",
"{",
"// mark the currently active locale",
"checkedIndex",
"=",
"0",
";",
"}",
"options",
".",
"add",
"(",
"key",
"(",
"CmsSearchResultStyle",
".",
"STYLE_LIST_WITH_EXCERPTS",
".",
"getKey",
"(",
")",
")",
")",
";",
"values",
".",
"add",
"(",
"CmsSearchResultStyle",
".",
"STYLE_LIST_WITH_EXCERPTS",
".",
"getMode",
"(",
")",
")",
";",
"if",
"(",
"getParamTabExWorkplaceSearchResult",
"(",
")",
".",
"equals",
"(",
"CmsSearchResultStyle",
".",
"STYLE_LIST_WITH_EXCERPTS",
".",
"toString",
"(",
")",
")",
")",
"{",
"// mark the currently active locale",
"checkedIndex",
"=",
"1",
";",
"}",
"options",
".",
"add",
"(",
"key",
"(",
"CmsSearchResultStyle",
".",
"STYLE_LIST_WITHOUT_EXCERPTS",
".",
"getKey",
"(",
")",
")",
")",
";",
"values",
".",
"add",
"(",
"CmsSearchResultStyle",
".",
"STYLE_LIST_WITHOUT_EXCERPTS",
".",
"getMode",
"(",
")",
")",
";",
"if",
"(",
"getParamTabExWorkplaceSearchResult",
"(",
")",
".",
"equals",
"(",
"CmsSearchResultStyle",
".",
"STYLE_LIST_WITHOUT_EXCERPTS",
".",
"toString",
"(",
")",
")",
")",
"{",
"// mark the currently active locale",
"checkedIndex",
"=",
"2",
";",
"}",
"return",
"buildSelect",
"(",
"htmlAttributes",
",",
"options",
",",
"values",
",",
"checkedIndex",
")",
";",
"}"
] | Builds the html for the workplace search result list type select box.<p>
@param htmlAttributes optional html attributes for the &lgt;select> tag
@return the html for the workplace search result list type select box | [
"Builds",
"the",
"html",
"for",
"the",
"workplace",
"search",
"result",
"list",
"type",
"select",
"box",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-modules/org/opencms/workplace/commons/CmsPreferences.java#L1013-L1040 |
DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/RestAction.java | RestAction.submitAfter | public ScheduledFuture<T> submitAfter(long delay, TimeUnit unit) {
"""
Schedules a call to {@link #complete()} to be executed after the specified {@code delay}.
<br>This is an <b>asynchronous</b> operation that will return a
{@link java.util.concurrent.ScheduledFuture ScheduledFuture} representing the task.
<p>The returned Future will provide the return type of a {@link #complete()} operation when
received through the <b>blocking</b> call to {@link java.util.concurrent.Future#get()}!
<p>The global JDA {@link java.util.concurrent.ScheduledExecutorService ScheduledExecutorService}
is used for this operation.
<br>You can change the core pool size for this Executor through {@link net.dv8tion.jda.core.JDABuilder#setCorePoolSize(int) JDABuilder.setCorePoolSize(int)}
or you can provide your own Executor using {@link #submitAfter(long, java.util.concurrent.TimeUnit, java.util.concurrent.ScheduledExecutorService)}!
@param delay
The delay after which this computation should be executed, negative to execute immediately
@param unit
The {@link java.util.concurrent.TimeUnit TimeUnit} to convert the specified {@code delay}
@throws java.lang.IllegalArgumentException
If the provided TimeUnit is {@code null}
@return {@link java.util.concurrent.ScheduledFuture ScheduledFuture} representing the
delayed operation
"""
return submitAfter(delay, unit, api.get().getRateLimitPool());
} | java | public ScheduledFuture<T> submitAfter(long delay, TimeUnit unit)
{
return submitAfter(delay, unit, api.get().getRateLimitPool());
} | [
"public",
"ScheduledFuture",
"<",
"T",
">",
"submitAfter",
"(",
"long",
"delay",
",",
"TimeUnit",
"unit",
")",
"{",
"return",
"submitAfter",
"(",
"delay",
",",
"unit",
",",
"api",
".",
"get",
"(",
")",
".",
"getRateLimitPool",
"(",
")",
")",
";",
"}"
] | Schedules a call to {@link #complete()} to be executed after the specified {@code delay}.
<br>This is an <b>asynchronous</b> operation that will return a
{@link java.util.concurrent.ScheduledFuture ScheduledFuture} representing the task.
<p>The returned Future will provide the return type of a {@link #complete()} operation when
received through the <b>blocking</b> call to {@link java.util.concurrent.Future#get()}!
<p>The global JDA {@link java.util.concurrent.ScheduledExecutorService ScheduledExecutorService}
is used for this operation.
<br>You can change the core pool size for this Executor through {@link net.dv8tion.jda.core.JDABuilder#setCorePoolSize(int) JDABuilder.setCorePoolSize(int)}
or you can provide your own Executor using {@link #submitAfter(long, java.util.concurrent.TimeUnit, java.util.concurrent.ScheduledExecutorService)}!
@param delay
The delay after which this computation should be executed, negative to execute immediately
@param unit
The {@link java.util.concurrent.TimeUnit TimeUnit} to convert the specified {@code delay}
@throws java.lang.IllegalArgumentException
If the provided TimeUnit is {@code null}
@return {@link java.util.concurrent.ScheduledFuture ScheduledFuture} representing the
delayed operation | [
"Schedules",
"a",
"call",
"to",
"{",
"@link",
"#complete",
"()",
"}",
"to",
"be",
"executed",
"after",
"the",
"specified",
"{",
"@code",
"delay",
"}",
".",
"<br",
">",
"This",
"is",
"an",
"<b",
">",
"asynchronous<",
"/",
"b",
">",
"operation",
"that",
"will",
"return",
"a",
"{",
"@link",
"java",
".",
"util",
".",
"concurrent",
".",
"ScheduledFuture",
"ScheduledFuture",
"}",
"representing",
"the",
"task",
"."
] | train | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/RestAction.java#L474-L477 |
alkacon/opencms-core | src/org/opencms/util/CmsStringUtil.java | CmsStringUtil.splitAsList | public static List<String> splitAsList(String source, char delimiter) {
"""
Splits a String into substrings along the provided char delimiter and returns
the result as a List of Substrings.<p>
@param source the String to split
@param delimiter the delimiter to split at
@return the List of splitted Substrings
"""
return splitAsList(source, delimiter, false);
} | java | public static List<String> splitAsList(String source, char delimiter) {
return splitAsList(source, delimiter, false);
} | [
"public",
"static",
"List",
"<",
"String",
">",
"splitAsList",
"(",
"String",
"source",
",",
"char",
"delimiter",
")",
"{",
"return",
"splitAsList",
"(",
"source",
",",
"delimiter",
",",
"false",
")",
";",
"}"
] | Splits a String into substrings along the provided char delimiter and returns
the result as a List of Substrings.<p>
@param source the String to split
@param delimiter the delimiter to split at
@return the List of splitted Substrings | [
"Splits",
"a",
"String",
"into",
"substrings",
"along",
"the",
"provided",
"char",
"delimiter",
"and",
"returns",
"the",
"result",
"as",
"a",
"List",
"of",
"Substrings",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/util/CmsStringUtil.java#L1492-L1495 |
apache/incubator-atlas | addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java | HiveMetaStoreBridge.importTables | private int importTables(Referenceable databaseReferenceable, String databaseName, final boolean failOnError) throws Exception {
"""
Imports all tables for the given db
@param databaseReferenceable
@param databaseName
@param failOnError
@throws Exception
"""
int tablesImported = 0;
List<String> hiveTables = hiveClient.getAllTables(databaseName);
LOG.info("Importing tables {} for db {}", hiveTables.toString(), databaseName);
for (String tableName : hiveTables) {
int imported = importTable(databaseReferenceable, databaseName, tableName, failOnError);
tablesImported += imported;
}
if (tablesImported == hiveTables.size()) {
LOG.info("Successfully imported all {} tables from {} ", tablesImported, databaseName);
} else {
LOG.error("Able to import {} tables out of {} tables from {}. Please check logs for import errors", tablesImported, hiveTables.size(), databaseName);
}
return tablesImported;
} | java | private int importTables(Referenceable databaseReferenceable, String databaseName, final boolean failOnError) throws Exception {
int tablesImported = 0;
List<String> hiveTables = hiveClient.getAllTables(databaseName);
LOG.info("Importing tables {} for db {}", hiveTables.toString(), databaseName);
for (String tableName : hiveTables) {
int imported = importTable(databaseReferenceable, databaseName, tableName, failOnError);
tablesImported += imported;
}
if (tablesImported == hiveTables.size()) {
LOG.info("Successfully imported all {} tables from {} ", tablesImported, databaseName);
} else {
LOG.error("Able to import {} tables out of {} tables from {}. Please check logs for import errors", tablesImported, hiveTables.size(), databaseName);
}
return tablesImported;
} | [
"private",
"int",
"importTables",
"(",
"Referenceable",
"databaseReferenceable",
",",
"String",
"databaseName",
",",
"final",
"boolean",
"failOnError",
")",
"throws",
"Exception",
"{",
"int",
"tablesImported",
"=",
"0",
";",
"List",
"<",
"String",
">",
"hiveTables",
"=",
"hiveClient",
".",
"getAllTables",
"(",
"databaseName",
")",
";",
"LOG",
".",
"info",
"(",
"\"Importing tables {} for db {}\"",
",",
"hiveTables",
".",
"toString",
"(",
")",
",",
"databaseName",
")",
";",
"for",
"(",
"String",
"tableName",
":",
"hiveTables",
")",
"{",
"int",
"imported",
"=",
"importTable",
"(",
"databaseReferenceable",
",",
"databaseName",
",",
"tableName",
",",
"failOnError",
")",
";",
"tablesImported",
"+=",
"imported",
";",
"}",
"if",
"(",
"tablesImported",
"==",
"hiveTables",
".",
"size",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Successfully imported all {} tables from {} \"",
",",
"tablesImported",
",",
"databaseName",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"error",
"(",
"\"Able to import {} tables out of {} tables from {}. Please check logs for import errors\"",
",",
"tablesImported",
",",
"hiveTables",
".",
"size",
"(",
")",
",",
"databaseName",
")",
";",
"}",
"return",
"tablesImported",
";",
"}"
] | Imports all tables for the given db
@param databaseReferenceable
@param databaseName
@param failOnError
@throws Exception | [
"Imports",
"all",
"tables",
"for",
"the",
"given",
"db"
] | train | https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java#L267-L283 |
dita-ot/dita-ot | src/main/plugins/org.dita.eclipsehelp/src/main/java/org/dita/dost/writer/EclipseIndexWriter.java | EclipseIndexWriter.outputIndexTermStartElement | private void outputIndexTermStartElement(final IndexTerm term, final XMLStreamWriter serializer, final boolean indexsee) throws XMLStreamException {
"""
/*
Logic for adding various start index entry elements for Eclipse help.
@param term The indexterm to be processed.
@param printWriter The Writer used for writing content to disk.
@param indexsee Boolean value for using the new markup for see references.
"""
//RFE 2987769 Eclipse index-see
if (indexsee){
if (term.getTermPrefix() != null) {
inIndexsee = true;
serializer.writeStartElement("see");
serializer.writeAttribute("keyword", term.getTermName());
} else if (inIndexsee) { // subterm of an indexsee.
serializer.writeStartElement("subpath");
serializer.writeAttribute("keyword", term.getTermName());
serializer.writeEndElement(); // subpath
} else {
serializer.writeStartElement("entry");
serializer.writeAttribute("keyword", term.getTermName());
outputIndexEntryEclipseIndexsee(term, serializer);
}
} else {
serializer.writeStartElement("entry");
serializer.writeAttribute("keyword", term.getTermFullName());
outputIndexEntry(term, serializer);
}
} | java | private void outputIndexTermStartElement(final IndexTerm term, final XMLStreamWriter serializer, final boolean indexsee) throws XMLStreamException {
//RFE 2987769 Eclipse index-see
if (indexsee){
if (term.getTermPrefix() != null) {
inIndexsee = true;
serializer.writeStartElement("see");
serializer.writeAttribute("keyword", term.getTermName());
} else if (inIndexsee) { // subterm of an indexsee.
serializer.writeStartElement("subpath");
serializer.writeAttribute("keyword", term.getTermName());
serializer.writeEndElement(); // subpath
} else {
serializer.writeStartElement("entry");
serializer.writeAttribute("keyword", term.getTermName());
outputIndexEntryEclipseIndexsee(term, serializer);
}
} else {
serializer.writeStartElement("entry");
serializer.writeAttribute("keyword", term.getTermFullName());
outputIndexEntry(term, serializer);
}
} | [
"private",
"void",
"outputIndexTermStartElement",
"(",
"final",
"IndexTerm",
"term",
",",
"final",
"XMLStreamWriter",
"serializer",
",",
"final",
"boolean",
"indexsee",
")",
"throws",
"XMLStreamException",
"{",
"//RFE 2987769 Eclipse index-see",
"if",
"(",
"indexsee",
")",
"{",
"if",
"(",
"term",
".",
"getTermPrefix",
"(",
")",
"!=",
"null",
")",
"{",
"inIndexsee",
"=",
"true",
";",
"serializer",
".",
"writeStartElement",
"(",
"\"see\"",
")",
";",
"serializer",
".",
"writeAttribute",
"(",
"\"keyword\"",
",",
"term",
".",
"getTermName",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"inIndexsee",
")",
"{",
"// subterm of an indexsee.",
"serializer",
".",
"writeStartElement",
"(",
"\"subpath\"",
")",
";",
"serializer",
".",
"writeAttribute",
"(",
"\"keyword\"",
",",
"term",
".",
"getTermName",
"(",
")",
")",
";",
"serializer",
".",
"writeEndElement",
"(",
")",
";",
"// subpath",
"}",
"else",
"{",
"serializer",
".",
"writeStartElement",
"(",
"\"entry\"",
")",
";",
"serializer",
".",
"writeAttribute",
"(",
"\"keyword\"",
",",
"term",
".",
"getTermName",
"(",
")",
")",
";",
"outputIndexEntryEclipseIndexsee",
"(",
"term",
",",
"serializer",
")",
";",
"}",
"}",
"else",
"{",
"serializer",
".",
"writeStartElement",
"(",
"\"entry\"",
")",
";",
"serializer",
".",
"writeAttribute",
"(",
"\"keyword\"",
",",
"term",
".",
"getTermFullName",
"(",
")",
")",
";",
"outputIndexEntry",
"(",
"term",
",",
"serializer",
")",
";",
"}",
"}"
] | /*
Logic for adding various start index entry elements for Eclipse help.
@param term The indexterm to be processed.
@param printWriter The Writer used for writing content to disk.
@param indexsee Boolean value for using the new markup for see references. | [
"/",
"*",
"Logic",
"for",
"adding",
"various",
"start",
"index",
"entry",
"elements",
"for",
"Eclipse",
"help",
"."
] | train | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/plugins/org.dita.eclipsehelp/src/main/java/org/dita/dost/writer/EclipseIndexWriter.java#L316-L337 |
lucee/Lucee | core/src/main/java/lucee/transformer/cfml/script/AbstrCFMLScriptTransformer.java | AbstrCFMLScriptTransformer.caseStatement | private final boolean caseStatement(Data data, Switch swit) throws TemplateException {
"""
Liest ein Case Statement ein
@return case Statement
@throws TemplateException
"""
if (!data.srcCode.forwardIfCurrentAndNoWordAfter("case")) return false;
// int line=data.srcCode.getLine();
comments(data);
Expression expr = super.expression(data);
comments(data);
if (!data.srcCode.forwardIfCurrent(':')) throw new TemplateException(data.srcCode, "case body must start with [:]");
Body body = new BodyBase(data.factory);
switchBlock(data, body);
swit.addCase(expr, body);
return true;
} | java | private final boolean caseStatement(Data data, Switch swit) throws TemplateException {
if (!data.srcCode.forwardIfCurrentAndNoWordAfter("case")) return false;
// int line=data.srcCode.getLine();
comments(data);
Expression expr = super.expression(data);
comments(data);
if (!data.srcCode.forwardIfCurrent(':')) throw new TemplateException(data.srcCode, "case body must start with [:]");
Body body = new BodyBase(data.factory);
switchBlock(data, body);
swit.addCase(expr, body);
return true;
} | [
"private",
"final",
"boolean",
"caseStatement",
"(",
"Data",
"data",
",",
"Switch",
"swit",
")",
"throws",
"TemplateException",
"{",
"if",
"(",
"!",
"data",
".",
"srcCode",
".",
"forwardIfCurrentAndNoWordAfter",
"(",
"\"case\"",
")",
")",
"return",
"false",
";",
"// int line=data.srcCode.getLine();",
"comments",
"(",
"data",
")",
";",
"Expression",
"expr",
"=",
"super",
".",
"expression",
"(",
"data",
")",
";",
"comments",
"(",
"data",
")",
";",
"if",
"(",
"!",
"data",
".",
"srcCode",
".",
"forwardIfCurrent",
"(",
"'",
"'",
")",
")",
"throw",
"new",
"TemplateException",
"(",
"data",
".",
"srcCode",
",",
"\"case body must start with [:]\"",
")",
";",
"Body",
"body",
"=",
"new",
"BodyBase",
"(",
"data",
".",
"factory",
")",
";",
"switchBlock",
"(",
"data",
",",
"body",
")",
";",
"swit",
".",
"addCase",
"(",
"expr",
",",
"body",
")",
";",
"return",
"true",
";",
"}"
] | Liest ein Case Statement ein
@return case Statement
@throws TemplateException | [
"Liest",
"ein",
"Case",
"Statement",
"ein"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/transformer/cfml/script/AbstrCFMLScriptTransformer.java#L495-L509 |
bluejoe2008/elfinder-2.x-servlet | src/main/java/cn/bluejoe/elfinder/impl/DefaultFsService.java | DefaultFsService.findRecursively | private Collection<FsItemEx> findRecursively(FsItemFilter filter,
FsItem root) {
"""
find files recursively in specific folder
@param filter
The filter to apply to select files.
@param root
The location in the hierarchy to search from.
@return A collection of files that match the filter and have the root as
a parent.
"""
List<FsItemEx> results = new ArrayList<FsItemEx>();
FsVolume vol = root.getVolume();
for (FsItem child : vol.listChildren(root))
{
if (vol.isFolder(child))
{
results.addAll(findRecursively(filter, child));
}
else
{
FsItemEx item = new FsItemEx(child, this);
if (filter.accepts(item))
results.add(item);
}
}
return results;
} | java | private Collection<FsItemEx> findRecursively(FsItemFilter filter,
FsItem root)
{
List<FsItemEx> results = new ArrayList<FsItemEx>();
FsVolume vol = root.getVolume();
for (FsItem child : vol.listChildren(root))
{
if (vol.isFolder(child))
{
results.addAll(findRecursively(filter, child));
}
else
{
FsItemEx item = new FsItemEx(child, this);
if (filter.accepts(item))
results.add(item);
}
}
return results;
} | [
"private",
"Collection",
"<",
"FsItemEx",
">",
"findRecursively",
"(",
"FsItemFilter",
"filter",
",",
"FsItem",
"root",
")",
"{",
"List",
"<",
"FsItemEx",
">",
"results",
"=",
"new",
"ArrayList",
"<",
"FsItemEx",
">",
"(",
")",
";",
"FsVolume",
"vol",
"=",
"root",
".",
"getVolume",
"(",
")",
";",
"for",
"(",
"FsItem",
"child",
":",
"vol",
".",
"listChildren",
"(",
"root",
")",
")",
"{",
"if",
"(",
"vol",
".",
"isFolder",
"(",
"child",
")",
")",
"{",
"results",
".",
"addAll",
"(",
"findRecursively",
"(",
"filter",
",",
"child",
")",
")",
";",
"}",
"else",
"{",
"FsItemEx",
"item",
"=",
"new",
"FsItemEx",
"(",
"child",
",",
"this",
")",
";",
"if",
"(",
"filter",
".",
"accepts",
"(",
"item",
")",
")",
"results",
".",
"add",
"(",
"item",
")",
";",
"}",
"}",
"return",
"results",
";",
"}"
] | find files recursively in specific folder
@param filter
The filter to apply to select files.
@param root
The location in the hierarchy to search from.
@return A collection of files that match the filter and have the root as
a parent. | [
"find",
"files",
"recursively",
"in",
"specific",
"folder"
] | train | https://github.com/bluejoe2008/elfinder-2.x-servlet/blob/83caa5c8ccb05a4139c87babb1b37b73248db9da/src/main/java/cn/bluejoe/elfinder/impl/DefaultFsService.java#L66-L86 |
super-csv/super-csv | super-csv-joda/src/main/java/org/supercsv/cellprocessor/joda/ParseDateTimeZone.java | ParseDateTimeZone.execute | public Object execute(final Object value, final CsvContext context) {
"""
{@inheritDoc}
@throws SuperCsvCellProcessorException
if value is null or is not a String
"""
validateInputNotNull(value, context);
if (!(value instanceof String)) {
throw new SuperCsvCellProcessorException(String.class, value,
context, this);
}
final DateTimeZone result;
try {
result = DateTimeZone.forID((String) value);
} catch (IllegalArgumentException e) {
throw new SuperCsvCellProcessorException(
"Failed to parse value as a DateTimeZone", context, this, e);
}
return next.execute(result, context);
} | java | public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if (!(value instanceof String)) {
throw new SuperCsvCellProcessorException(String.class, value,
context, this);
}
final DateTimeZone result;
try {
result = DateTimeZone.forID((String) value);
} catch (IllegalArgumentException e) {
throw new SuperCsvCellProcessorException(
"Failed to parse value as a DateTimeZone", context, this, e);
}
return next.execute(result, context);
} | [
"public",
"Object",
"execute",
"(",
"final",
"Object",
"value",
",",
"final",
"CsvContext",
"context",
")",
"{",
"validateInputNotNull",
"(",
"value",
",",
"context",
")",
";",
"if",
"(",
"!",
"(",
"value",
"instanceof",
"String",
")",
")",
"{",
"throw",
"new",
"SuperCsvCellProcessorException",
"(",
"String",
".",
"class",
",",
"value",
",",
"context",
",",
"this",
")",
";",
"}",
"final",
"DateTimeZone",
"result",
";",
"try",
"{",
"result",
"=",
"DateTimeZone",
".",
"forID",
"(",
"(",
"String",
")",
"value",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"SuperCsvCellProcessorException",
"(",
"\"Failed to parse value as a DateTimeZone\"",
",",
"context",
",",
"this",
",",
"e",
")",
";",
"}",
"return",
"next",
".",
"execute",
"(",
"result",
",",
"context",
")",
";",
"}"
] | {@inheritDoc}
@throws SuperCsvCellProcessorException
if value is null or is not a String | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv-joda/src/main/java/org/supercsv/cellprocessor/joda/ParseDateTimeZone.java#L59-L74 |
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/matrix/AtomicGrowingSparseHashMatrix.java | AtomicGrowingSparseHashMatrix.checkIndices | private void checkIndices(int row, int col, boolean expand) {
"""
Verify that the given row and column value is non-negative, and
optionally expand the size of the matrix if the row or column are outside
the current bounds.
@param row the row index to check.
@param the the column index to check.
@param expand {@code true} if the current dimensions of the matrix should
be updated if either parameter exceeds the current values
"""
if (row < 0 || col < 0) {
throw new ArrayIndexOutOfBoundsException();
}
if (expand) {
int r = row + 1;
int cur = 0;
while (r > (cur = rows.get()) && !rows.compareAndSet(cur, r))
;
int c = col + 1;
cur = 0;
while (c > (cur = cols.get()) && !cols.compareAndSet(cur, c))
;
}
} | java | private void checkIndices(int row, int col, boolean expand) {
if (row < 0 || col < 0) {
throw new ArrayIndexOutOfBoundsException();
}
if (expand) {
int r = row + 1;
int cur = 0;
while (r > (cur = rows.get()) && !rows.compareAndSet(cur, r))
;
int c = col + 1;
cur = 0;
while (c > (cur = cols.get()) && !cols.compareAndSet(cur, c))
;
}
} | [
"private",
"void",
"checkIndices",
"(",
"int",
"row",
",",
"int",
"col",
",",
"boolean",
"expand",
")",
"{",
"if",
"(",
"row",
"<",
"0",
"||",
"col",
"<",
"0",
")",
"{",
"throw",
"new",
"ArrayIndexOutOfBoundsException",
"(",
")",
";",
"}",
"if",
"(",
"expand",
")",
"{",
"int",
"r",
"=",
"row",
"+",
"1",
";",
"int",
"cur",
"=",
"0",
";",
"while",
"(",
"r",
">",
"(",
"cur",
"=",
"rows",
".",
"get",
"(",
")",
")",
"&&",
"!",
"rows",
".",
"compareAndSet",
"(",
"cur",
",",
"r",
")",
")",
";",
"int",
"c",
"=",
"col",
"+",
"1",
";",
"cur",
"=",
"0",
";",
"while",
"(",
"c",
">",
"(",
"cur",
"=",
"cols",
".",
"get",
"(",
")",
")",
"&&",
"!",
"cols",
".",
"compareAndSet",
"(",
"cur",
",",
"c",
")",
")",
";",
"}",
"}"
] | Verify that the given row and column value is non-negative, and
optionally expand the size of the matrix if the row or column are outside
the current bounds.
@param row the row index to check.
@param the the column index to check.
@param expand {@code true} if the current dimensions of the matrix should
be updated if either parameter exceeds the current values | [
"Verify",
"that",
"the",
"given",
"row",
"and",
"column",
"value",
"is",
"non",
"-",
"negative",
"and",
"optionally",
"expand",
"the",
"size",
"of",
"the",
"matrix",
"if",
"the",
"row",
"or",
"column",
"are",
"outside",
"the",
"current",
"bounds",
"."
] | train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/matrix/AtomicGrowingSparseHashMatrix.java#L191-L205 |
dvdme/forecastio-lib-java | src/com/github/dvdme/ForecastIOLib/ForecastIO.java | ForecastIO.setHTTPProxy | public void setHTTPProxy(String PROXYNAME, int PROXYPORT) {
"""
Sets the http-proxy to use.
@param PROXYNAME hostname or ip of the proxy to use (e.g. "127.0.0.1"). If proxyname equals null, no proxy will be used.
@param PROXYPORT port of the proxy to use (e.g. 8080)
"""
if (PROXYNAME == null) {
this.proxy_to_use = null;
}
else {
this.proxy_to_use = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(PROXYNAME, PROXYPORT));
}
} | java | public void setHTTPProxy(String PROXYNAME, int PROXYPORT) {
if (PROXYNAME == null) {
this.proxy_to_use = null;
}
else {
this.proxy_to_use = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(PROXYNAME, PROXYPORT));
}
} | [
"public",
"void",
"setHTTPProxy",
"(",
"String",
"PROXYNAME",
",",
"int",
"PROXYPORT",
")",
"{",
"if",
"(",
"PROXYNAME",
"==",
"null",
")",
"{",
"this",
".",
"proxy_to_use",
"=",
"null",
";",
"}",
"else",
"{",
"this",
".",
"proxy_to_use",
"=",
"new",
"Proxy",
"(",
"Proxy",
".",
"Type",
".",
"HTTP",
",",
"new",
"InetSocketAddress",
"(",
"PROXYNAME",
",",
"PROXYPORT",
")",
")",
";",
"}",
"}"
] | Sets the http-proxy to use.
@param PROXYNAME hostname or ip of the proxy to use (e.g. "127.0.0.1"). If proxyname equals null, no proxy will be used.
@param PROXYPORT port of the proxy to use (e.g. 8080) | [
"Sets",
"the",
"http",
"-",
"proxy",
"to",
"use",
"."
] | train | https://github.com/dvdme/forecastio-lib-java/blob/63c0ff17446eb7eb4e9f8bef4e19272f14c74e85/src/com/github/dvdme/ForecastIOLib/ForecastIO.java#L285-L292 |
Axway/Grapes | utils/src/main/java/org/axway/grapes/utils/client/GrapesClient.java | GrapesClient.postDoNotUseArtifact | public void postDoNotUseArtifact(final String gavc, final Boolean doNotUse, final String user, final String password) throws GrapesCommunicationException, AuthenticationException {
"""
Post boolean flag "DO_NOT_USE" to an artifact
@param gavc
@param doNotUse
@param user
@param password
@throws GrapesCommunicationException
"""
final Client client = getClient(user, password);
final WebResource resource = client.resource(serverURL).path(RequestUtils.getDoNotUseArtifact(gavc));
final ClientResponse response = resource.queryParam(ServerAPI.DO_NOT_USE, doNotUse.toString())
.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
client.destroy();
if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
final String message = "Failed to post do not use artifact";
if(LOG.isErrorEnabled()) {
LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
}
throw new GrapesCommunicationException(message, response.getStatus());
}
} | java | public void postDoNotUseArtifact(final String gavc, final Boolean doNotUse, final String user, final String password) throws GrapesCommunicationException, AuthenticationException {
final Client client = getClient(user, password);
final WebResource resource = client.resource(serverURL).path(RequestUtils.getDoNotUseArtifact(gavc));
final ClientResponse response = resource.queryParam(ServerAPI.DO_NOT_USE, doNotUse.toString())
.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class);
client.destroy();
if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
final String message = "Failed to post do not use artifact";
if(LOG.isErrorEnabled()) {
LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
}
throw new GrapesCommunicationException(message, response.getStatus());
}
} | [
"public",
"void",
"postDoNotUseArtifact",
"(",
"final",
"String",
"gavc",
",",
"final",
"Boolean",
"doNotUse",
",",
"final",
"String",
"user",
",",
"final",
"String",
"password",
")",
"throws",
"GrapesCommunicationException",
",",
"AuthenticationException",
"{",
"final",
"Client",
"client",
"=",
"getClient",
"(",
"user",
",",
"password",
")",
";",
"final",
"WebResource",
"resource",
"=",
"client",
".",
"resource",
"(",
"serverURL",
")",
".",
"path",
"(",
"RequestUtils",
".",
"getDoNotUseArtifact",
"(",
"gavc",
")",
")",
";",
"final",
"ClientResponse",
"response",
"=",
"resource",
".",
"queryParam",
"(",
"ServerAPI",
".",
"DO_NOT_USE",
",",
"doNotUse",
".",
"toString",
"(",
")",
")",
".",
"accept",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
".",
"post",
"(",
"ClientResponse",
".",
"class",
")",
";",
"client",
".",
"destroy",
"(",
")",
";",
"if",
"(",
"ClientResponse",
".",
"Status",
".",
"OK",
".",
"getStatusCode",
"(",
")",
"!=",
"response",
".",
"getStatus",
"(",
")",
")",
"{",
"final",
"String",
"message",
"=",
"\"Failed to post do not use artifact\"",
";",
"if",
"(",
"LOG",
".",
"isErrorEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"error",
"(",
"String",
".",
"format",
"(",
"HTTP_STATUS_TEMPLATE_MSG",
",",
"message",
",",
"response",
".",
"getStatus",
"(",
")",
")",
")",
";",
"}",
"throw",
"new",
"GrapesCommunicationException",
"(",
"message",
",",
"response",
".",
"getStatus",
"(",
")",
")",
";",
"}",
"}"
] | Post boolean flag "DO_NOT_USE" to an artifact
@param gavc
@param doNotUse
@param user
@param password
@throws GrapesCommunicationException | [
"Post",
"boolean",
"flag",
"DO_NOT_USE",
"to",
"an",
"artifact"
] | train | https://github.com/Axway/Grapes/blob/ce9cc73d85f83eaa5fbc991abb593915a8c8374e/utils/src/main/java/org/axway/grapes/utils/client/GrapesClient.java#L513-L527 |
hector-client/hector | core/src/main/java/me/prettyprint/cassandra/io/ChunkOutputStream.java | ChunkOutputStream.writeData | private void writeData(boolean close) throws IOException {
"""
Write the data to column if the configured chunk size is reached or if the
stream should be closed
@param close
@throws IOException
"""
if (pos != 0 && (close || pos == chunk.length - 1)) {
byte[] data;
if (pos != chunk.length - 1) {
data = new byte[(int) pos + 1];
// we need to adjust the array
System.arraycopy(chunk, 0, data, 0, data.length);
} else {
data = chunk;
}
try {
mutator.insert(key, cf, HFactory.createColumn(chunkPos, data, LongSerializer.get(), BytesArraySerializer.get()));
} catch (HectorException e) {
throw new IOException("Unable to write data", e);
}
chunkPos++;
pos = 0;
}
} | java | private void writeData(boolean close) throws IOException {
if (pos != 0 && (close || pos == chunk.length - 1)) {
byte[] data;
if (pos != chunk.length - 1) {
data = new byte[(int) pos + 1];
// we need to adjust the array
System.arraycopy(chunk, 0, data, 0, data.length);
} else {
data = chunk;
}
try {
mutator.insert(key, cf, HFactory.createColumn(chunkPos, data, LongSerializer.get(), BytesArraySerializer.get()));
} catch (HectorException e) {
throw new IOException("Unable to write data", e);
}
chunkPos++;
pos = 0;
}
} | [
"private",
"void",
"writeData",
"(",
"boolean",
"close",
")",
"throws",
"IOException",
"{",
"if",
"(",
"pos",
"!=",
"0",
"&&",
"(",
"close",
"||",
"pos",
"==",
"chunk",
".",
"length",
"-",
"1",
")",
")",
"{",
"byte",
"[",
"]",
"data",
";",
"if",
"(",
"pos",
"!=",
"chunk",
".",
"length",
"-",
"1",
")",
"{",
"data",
"=",
"new",
"byte",
"[",
"(",
"int",
")",
"pos",
"+",
"1",
"]",
";",
"// we need to adjust the array",
"System",
".",
"arraycopy",
"(",
"chunk",
",",
"0",
",",
"data",
",",
"0",
",",
"data",
".",
"length",
")",
";",
"}",
"else",
"{",
"data",
"=",
"chunk",
";",
"}",
"try",
"{",
"mutator",
".",
"insert",
"(",
"key",
",",
"cf",
",",
"HFactory",
".",
"createColumn",
"(",
"chunkPos",
",",
"data",
",",
"LongSerializer",
".",
"get",
"(",
")",
",",
"BytesArraySerializer",
".",
"get",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"HectorException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Unable to write data\"",
",",
"e",
")",
";",
"}",
"chunkPos",
"++",
";",
"pos",
"=",
"0",
";",
"}",
"}"
] | Write the data to column if the configured chunk size is reached or if the
stream should be closed
@param close
@throws IOException | [
"Write",
"the",
"data",
"to",
"column",
"if",
"the",
"configured",
"chunk",
"size",
"is",
"reached",
"or",
"if",
"the",
"stream",
"should",
"be",
"closed"
] | train | https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/cassandra/io/ChunkOutputStream.java#L72-L91 |
raphw/byte-buddy | byte-buddy-dep/src/main/java/net/bytebuddy/implementation/ExceptionMethod.java | ExceptionMethod.throwing | public static Implementation throwing(TypeDescription throwableType, String message) {
"""
Creates an implementation that creates a new instance of the given {@link Throwable} type on each method
invocation which is then thrown immediately. For this to be possible, the given type must define a
constructor that takes a single {@link java.lang.String} as its argument.
@param throwableType The type of the {@link Throwable}.
@param message The string that is handed to the constructor. Usually an exception message.
@return An implementation that will throw an instance of the {@link Throwable} on each method invocation
of the instrumented methods.
"""
if (!throwableType.isAssignableTo(Throwable.class)) {
throw new IllegalArgumentException(throwableType + " does not extend throwable");
}
return new ExceptionMethod(new ConstructionDelegate.ForStringConstructor(throwableType, message));
} | java | public static Implementation throwing(TypeDescription throwableType, String message) {
if (!throwableType.isAssignableTo(Throwable.class)) {
throw new IllegalArgumentException(throwableType + " does not extend throwable");
}
return new ExceptionMethod(new ConstructionDelegate.ForStringConstructor(throwableType, message));
} | [
"public",
"static",
"Implementation",
"throwing",
"(",
"TypeDescription",
"throwableType",
",",
"String",
"message",
")",
"{",
"if",
"(",
"!",
"throwableType",
".",
"isAssignableTo",
"(",
"Throwable",
".",
"class",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"throwableType",
"+",
"\" does not extend throwable\"",
")",
";",
"}",
"return",
"new",
"ExceptionMethod",
"(",
"new",
"ConstructionDelegate",
".",
"ForStringConstructor",
"(",
"throwableType",
",",
"message",
")",
")",
";",
"}"
] | Creates an implementation that creates a new instance of the given {@link Throwable} type on each method
invocation which is then thrown immediately. For this to be possible, the given type must define a
constructor that takes a single {@link java.lang.String} as its argument.
@param throwableType The type of the {@link Throwable}.
@param message The string that is handed to the constructor. Usually an exception message.
@return An implementation that will throw an instance of the {@link Throwable} on each method invocation
of the instrumented methods. | [
"Creates",
"an",
"implementation",
"that",
"creates",
"a",
"new",
"instance",
"of",
"the",
"given",
"{",
"@link",
"Throwable",
"}",
"type",
"on",
"each",
"method",
"invocation",
"which",
"is",
"then",
"thrown",
"immediately",
".",
"For",
"this",
"to",
"be",
"possible",
"the",
"given",
"type",
"must",
"define",
"a",
"constructor",
"that",
"takes",
"a",
"single",
"{",
"@link",
"java",
".",
"lang",
".",
"String",
"}",
"as",
"its",
"argument",
"."
] | train | https://github.com/raphw/byte-buddy/blob/4d2dac80efb6bed89367567260f6811c2f712d12/byte-buddy-dep/src/main/java/net/bytebuddy/implementation/ExceptionMethod.java#L105-L110 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java | PackageIndexWriter.addPackagesList | protected void addPackagesList(Collection<PackageDoc> packages, Content tbody) {
"""
Adds list of packages in the index table. Generate link to each package.
@param packages Packages to which link is to be generated
@param tbody the documentation tree to which the list will be added
"""
boolean altColor = true;
for (PackageDoc pkg : packages) {
if (pkg != null && !pkg.name().isEmpty()) {
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
tdSummary.addStyle(HtmlStyle.colLast);
addSummaryComment(pkg, tdSummary);
HtmlTree tr = HtmlTree.TR(tdPackage);
tr.addContent(tdSummary);
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
tbody.addContent(tr);
}
}
altColor = !altColor;
}
} | java | protected void addPackagesList(Collection<PackageDoc> packages, Content tbody) {
boolean altColor = true;
for (PackageDoc pkg : packages) {
if (pkg != null && !pkg.name().isEmpty()) {
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
tdSummary.addStyle(HtmlStyle.colLast);
addSummaryComment(pkg, tdSummary);
HtmlTree tr = HtmlTree.TR(tdPackage);
tr.addContent(tdSummary);
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
tbody.addContent(tr);
}
}
altColor = !altColor;
}
} | [
"protected",
"void",
"addPackagesList",
"(",
"Collection",
"<",
"PackageDoc",
">",
"packages",
",",
"Content",
"tbody",
")",
"{",
"boolean",
"altColor",
"=",
"true",
";",
"for",
"(",
"PackageDoc",
"pkg",
":",
"packages",
")",
"{",
"if",
"(",
"pkg",
"!=",
"null",
"&&",
"!",
"pkg",
".",
"name",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"!",
"(",
"configuration",
".",
"nodeprecated",
"&&",
"utils",
".",
"isDeprecated",
"(",
"pkg",
")",
")",
")",
"{",
"Content",
"packageLinkContent",
"=",
"getPackageLink",
"(",
"pkg",
",",
"getPackageName",
"(",
"pkg",
")",
")",
";",
"Content",
"tdPackage",
"=",
"HtmlTree",
".",
"TD",
"(",
"HtmlStyle",
".",
"colFirst",
",",
"packageLinkContent",
")",
";",
"HtmlTree",
"tdSummary",
"=",
"new",
"HtmlTree",
"(",
"HtmlTag",
".",
"TD",
")",
";",
"tdSummary",
".",
"addStyle",
"(",
"HtmlStyle",
".",
"colLast",
")",
";",
"addSummaryComment",
"(",
"pkg",
",",
"tdSummary",
")",
";",
"HtmlTree",
"tr",
"=",
"HtmlTree",
".",
"TR",
"(",
"tdPackage",
")",
";",
"tr",
".",
"addContent",
"(",
"tdSummary",
")",
";",
"tr",
".",
"addStyle",
"(",
"altColor",
"?",
"HtmlStyle",
".",
"altColor",
":",
"HtmlStyle",
".",
"rowColor",
")",
";",
"tbody",
".",
"addContent",
"(",
"tr",
")",
";",
"}",
"}",
"altColor",
"=",
"!",
"altColor",
";",
"}",
"}"
] | Adds list of packages in the index table. Generate link to each package.
@param packages Packages to which link is to be generated
@param tbody the documentation tree to which the list will be added | [
"Adds",
"list",
"of",
"packages",
"in",
"the",
"index",
"table",
".",
"Generate",
"link",
"to",
"each",
"package",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java#L153-L171 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.