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
|
---|---|---|---|---|---|---|---|---|---|---|
Alluxio/alluxio | core/common/src/main/java/alluxio/util/CommonUtils.java | CommonUtils.stripSuffixIfPresent | public static String stripSuffixIfPresent(final String key, final String suffix) {
"""
Strips the suffix if it exists. This method will leave keys without a suffix unaltered.
@param key the key to strip the suffix from
@param suffix suffix to remove
@return the key with the suffix removed, or the key unaltered if the suffix is not present
"""
if (key.endsWith(suffix)) {
return key.substring(0, key.length() - suffix.length());
}
return key;
} | java | public static String stripSuffixIfPresent(final String key, final String suffix) {
if (key.endsWith(suffix)) {
return key.substring(0, key.length() - suffix.length());
}
return key;
} | [
"public",
"static",
"String",
"stripSuffixIfPresent",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"suffix",
")",
"{",
"if",
"(",
"key",
".",
"endsWith",
"(",
"suffix",
")",
")",
"{",
"return",
"key",
".",
"substring",
"(",
"0",
",",
"key",
".",
"length",
"(",
")",
"-",
"suffix",
".",
"length",
"(",
")",
")",
";",
"}",
"return",
"key",
";",
"}"
] | Strips the suffix if it exists. This method will leave keys without a suffix unaltered.
@param key the key to strip the suffix from
@param suffix suffix to remove
@return the key with the suffix removed, or the key unaltered if the suffix is not present | [
"Strips",
"the",
"suffix",
"if",
"it",
"exists",
".",
"This",
"method",
"will",
"leave",
"keys",
"without",
"a",
"suffix",
"unaltered",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L347-L352 |
ow2-chameleon/fuchsia | bases/knx/calimero/src/main/java/tuwien/auto/calimero/knxnetip/Discoverer.java | Discoverer.startSearch | public void startSearch(int localPort, NetworkInterface ni, int timeout, boolean wait)
throws KNXException {
"""
Starts a new discovery, the <code>localPort</code> and network interface can be
specified.
<p>
The search will continue for <code>timeout</code> seconds, or infinite if timeout
value is zero. During this time, search responses will get collected asynchronous
in the background by this {@link Discoverer}.<br>
With <code>wait</code> you can force this method into blocking mode to wait until
the search finished, otherwise the method returns with the search running in the
background.<br>
A search is finished if either the <code>timeout</code> was reached or the
background receiver stopped.<br>
The reason the <code>localPort</code> parameter is specified here, in addition to
the port queried at {@link #Discoverer(int, boolean)}, is to distinguish between
search responses if more searches are running concurrently.<br>
@param localPort the port used to bind the socket, a valid port is 0 to 65535, if
localPort is zero an arbitrary unused (ephemeral) port is picked
@param ni the {@link NetworkInterface} used for sending outgoing multicast
messages, or <code>null</code> to use the default multicast interface
@param timeout time window in seconds during which search response messages will
get collected, timeout >= 0. If timeout is zero, no timeout is set, the
search has to be stopped with {@link #stopSearch()}.
@param wait <code>true</code> to block until end of search before return
@throws KNXException on network I/O error
@see MulticastSocket
@see NetworkInterface
"""
if (timeout < 0)
throw new KNXIllegalArgumentException("timeout has to be >= 0");
if (localPort < 0 || localPort > 65535)
throw new KNXIllegalArgumentException("port out of range [0..0xFFFF]");
final Receiver r = search(new InetSocketAddress(host, localPort), ni, timeout);
if (wait)
join(r);
} | java | public void startSearch(int localPort, NetworkInterface ni, int timeout, boolean wait)
throws KNXException
{
if (timeout < 0)
throw new KNXIllegalArgumentException("timeout has to be >= 0");
if (localPort < 0 || localPort > 65535)
throw new KNXIllegalArgumentException("port out of range [0..0xFFFF]");
final Receiver r = search(new InetSocketAddress(host, localPort), ni, timeout);
if (wait)
join(r);
} | [
"public",
"void",
"startSearch",
"(",
"int",
"localPort",
",",
"NetworkInterface",
"ni",
",",
"int",
"timeout",
",",
"boolean",
"wait",
")",
"throws",
"KNXException",
"{",
"if",
"(",
"timeout",
"<",
"0",
")",
"throw",
"new",
"KNXIllegalArgumentException",
"(",
"\"timeout has to be >= 0\"",
")",
";",
"if",
"(",
"localPort",
"<",
"0",
"||",
"localPort",
">",
"65535",
")",
"throw",
"new",
"KNXIllegalArgumentException",
"(",
"\"port out of range [0..0xFFFF]\"",
")",
";",
"final",
"Receiver",
"r",
"=",
"search",
"(",
"new",
"InetSocketAddress",
"(",
"host",
",",
"localPort",
")",
",",
"ni",
",",
"timeout",
")",
";",
"if",
"(",
"wait",
")",
"join",
"(",
"r",
")",
";",
"}"
] | Starts a new discovery, the <code>localPort</code> and network interface can be
specified.
<p>
The search will continue for <code>timeout</code> seconds, or infinite if timeout
value is zero. During this time, search responses will get collected asynchronous
in the background by this {@link Discoverer}.<br>
With <code>wait</code> you can force this method into blocking mode to wait until
the search finished, otherwise the method returns with the search running in the
background.<br>
A search is finished if either the <code>timeout</code> was reached or the
background receiver stopped.<br>
The reason the <code>localPort</code> parameter is specified here, in addition to
the port queried at {@link #Discoverer(int, boolean)}, is to distinguish between
search responses if more searches are running concurrently.<br>
@param localPort the port used to bind the socket, a valid port is 0 to 65535, if
localPort is zero an arbitrary unused (ephemeral) port is picked
@param ni the {@link NetworkInterface} used for sending outgoing multicast
messages, or <code>null</code> to use the default multicast interface
@param timeout time window in seconds during which search response messages will
get collected, timeout >= 0. If timeout is zero, no timeout is set, the
search has to be stopped with {@link #stopSearch()}.
@param wait <code>true</code> to block until end of search before return
@throws KNXException on network I/O error
@see MulticastSocket
@see NetworkInterface | [
"Starts",
"a",
"new",
"discovery",
"the",
"<code",
">",
"localPort<",
"/",
"code",
">",
"and",
"network",
"interface",
"can",
"be",
"specified",
".",
"<p",
">",
"The",
"search",
"will",
"continue",
"for",
"<code",
">",
"timeout<",
"/",
"code",
">",
"seconds",
"or",
"infinite",
"if",
"timeout",
"value",
"is",
"zero",
".",
"During",
"this",
"time",
"search",
"responses",
"will",
"get",
"collected",
"asynchronous",
"in",
"the",
"background",
"by",
"this",
"{",
"@link",
"Discoverer",
"}",
".",
"<br",
">",
"With",
"<code",
">",
"wait<",
"/",
"code",
">",
"you",
"can",
"force",
"this",
"method",
"into",
"blocking",
"mode",
"to",
"wait",
"until",
"the",
"search",
"finished",
"otherwise",
"the",
"method",
"returns",
"with",
"the",
"search",
"running",
"in",
"the",
"background",
".",
"<br",
">",
"A",
"search",
"is",
"finished",
"if",
"either",
"the",
"<code",
">",
"timeout<",
"/",
"code",
">",
"was",
"reached",
"or",
"the",
"background",
"receiver",
"stopped",
".",
"<br",
">",
"The",
"reason",
"the",
"<code",
">",
"localPort<",
"/",
"code",
">",
"parameter",
"is",
"specified",
"here",
"in",
"addition",
"to",
"the",
"port",
"queried",
"at",
"{",
"@link",
"#Discoverer",
"(",
"int",
"boolean",
")",
"}",
"is",
"to",
"distinguish",
"between",
"search",
"responses",
"if",
"more",
"searches",
"are",
"running",
"concurrently",
".",
"<br",
">"
] | train | https://github.com/ow2-chameleon/fuchsia/blob/4e9318eadbdeb945e529789f573b45386e619bed/bases/knx/calimero/src/main/java/tuwien/auto/calimero/knxnetip/Discoverer.java#L243-L253 |
jenkinsci/java-client-api | jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java | JenkinsServer.updateView | public JenkinsServer updateView(String viewName, String viewXml) throws IOException {
"""
Update the xml description of an existing view
@param viewName name of the view.
@param viewXml the view configuration.
@throws IOException in case of an error.
"""
return this.updateView(viewName, viewXml, true);
} | java | public JenkinsServer updateView(String viewName, String viewXml) throws IOException {
return this.updateView(viewName, viewXml, true);
} | [
"public",
"JenkinsServer",
"updateView",
"(",
"String",
"viewName",
",",
"String",
"viewXml",
")",
"throws",
"IOException",
"{",
"return",
"this",
".",
"updateView",
"(",
"viewName",
",",
"viewXml",
",",
"true",
")",
";",
"}"
] | Update the xml description of an existing view
@param viewName name of the view.
@param viewXml the view configuration.
@throws IOException in case of an error. | [
"Update",
"the",
"xml",
"description",
"of",
"an",
"existing",
"view"
] | train | https://github.com/jenkinsci/java-client-api/blob/c4f5953d3d4dda92cd946ad3bf2b811524c32da9/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java#L581-L583 |
vkostyukov/la4j | src/main/java/org/la4j/Matrix.java | Matrix.setColumn | public void setColumn(int j, double value) {
"""
<p>
Sets all elements of the specified column of this matrix to given {@code value}.
</p>
@param j the column index
@param value the element's new value
"""
VectorIterator it = iteratorOfColumn(j);
while (it.hasNext()) {
it.next();
it.set(value);
}
} | java | public void setColumn(int j, double value) {
VectorIterator it = iteratorOfColumn(j);
while (it.hasNext()) {
it.next();
it.set(value);
}
} | [
"public",
"void",
"setColumn",
"(",
"int",
"j",
",",
"double",
"value",
")",
"{",
"VectorIterator",
"it",
"=",
"iteratorOfColumn",
"(",
"j",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"it",
".",
"next",
"(",
")",
";",
"it",
".",
"set",
"(",
"value",
")",
";",
"}",
"}"
] | <p>
Sets all elements of the specified column of this matrix to given {@code value}.
</p>
@param j the column index
@param value the element's new value | [
"<p",
">",
"Sets",
"all",
"elements",
"of",
"the",
"specified",
"column",
"of",
"this",
"matrix",
"to",
"given",
"{",
"@code",
"value",
"}",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/vkostyukov/la4j/blob/dd1b917caf9606399a49afa6b0d738934cd3a7b3/src/main/java/org/la4j/Matrix.java#L458-L465 |
google/closure-compiler | src/com/google/javascript/rhino/JSDocInfoBuilder.java | JSDocInfoBuilder.recordParameter | public boolean recordParameter(String parameterName, JSTypeExpression type) {
"""
Records a typed parameter.
@return {@code true} if the typed parameter was recorded and
{@code false} if a parameter with the same name was already defined
"""
if (!hasAnySingletonTypeTags()
&& currentInfo.declareParam(type, parameterName)) {
populated = true;
return true;
} else {
return false;
}
} | java | public boolean recordParameter(String parameterName, JSTypeExpression type) {
if (!hasAnySingletonTypeTags()
&& currentInfo.declareParam(type, parameterName)) {
populated = true;
return true;
} else {
return false;
}
} | [
"public",
"boolean",
"recordParameter",
"(",
"String",
"parameterName",
",",
"JSTypeExpression",
"type",
")",
"{",
"if",
"(",
"!",
"hasAnySingletonTypeTags",
"(",
")",
"&&",
"currentInfo",
".",
"declareParam",
"(",
"type",
",",
"parameterName",
")",
")",
"{",
"populated",
"=",
"true",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Records a typed parameter.
@return {@code true} if the typed parameter was recorded and
{@code false} if a parameter with the same name was already defined | [
"Records",
"a",
"typed",
"parameter",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/rhino/JSDocInfoBuilder.java#L325-L333 |
OpenLiberty/open-liberty | dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/handlers/LogRepositoryComponent.java | LogRepositoryComponent.addRemoteProcessFile | public static String addRemoteProcessFile(String destinationType, long spTimeStamp, String spPid, String spLabel) {
"""
add a remote file to the cache of files currently considered for retention on the parent. The child process uses
some form of interProcessCommunication to notify receiver of file creation, and this method is driven
@param destinationType Type of destination/repository
@param spTimeStamp timeStamp to be associated with the file
@param spPid Process Id of the creating process
@param spLabel Label of the creating process
@return String with fully qualified name of file to create
"""
LogRepositoryManager destManager = getManager(destinationType) ;
String subProcessFileName = null ;
if (destManager instanceof LogRepositoryManagerImpl)
subProcessFileName = ((LogRepositoryManagerImpl)destManager).addNewFileFromSubProcess(spTimeStamp, spPid, spLabel) ;
return subProcessFileName ;
} | java | public static String addRemoteProcessFile(String destinationType, long spTimeStamp, String spPid, String spLabel) {
LogRepositoryManager destManager = getManager(destinationType) ;
String subProcessFileName = null ;
if (destManager instanceof LogRepositoryManagerImpl)
subProcessFileName = ((LogRepositoryManagerImpl)destManager).addNewFileFromSubProcess(spTimeStamp, spPid, spLabel) ;
return subProcessFileName ;
} | [
"public",
"static",
"String",
"addRemoteProcessFile",
"(",
"String",
"destinationType",
",",
"long",
"spTimeStamp",
",",
"String",
"spPid",
",",
"String",
"spLabel",
")",
"{",
"LogRepositoryManager",
"destManager",
"=",
"getManager",
"(",
"destinationType",
")",
";",
"String",
"subProcessFileName",
"=",
"null",
";",
"if",
"(",
"destManager",
"instanceof",
"LogRepositoryManagerImpl",
")",
"subProcessFileName",
"=",
"(",
"(",
"LogRepositoryManagerImpl",
")",
"destManager",
")",
".",
"addNewFileFromSubProcess",
"(",
"spTimeStamp",
",",
"spPid",
",",
"spLabel",
")",
";",
"return",
"subProcessFileName",
";",
"}"
] | add a remote file to the cache of files currently considered for retention on the parent. The child process uses
some form of interProcessCommunication to notify receiver of file creation, and this method is driven
@param destinationType Type of destination/repository
@param spTimeStamp timeStamp to be associated with the file
@param spPid Process Id of the creating process
@param spLabel Label of the creating process
@return String with fully qualified name of file to create | [
"add",
"a",
"remote",
"file",
"to",
"the",
"cache",
"of",
"files",
"currently",
"considered",
"for",
"retention",
"on",
"the",
"parent",
".",
"The",
"child",
"process",
"uses",
"some",
"form",
"of",
"interProcessCommunication",
"to",
"notify",
"receiver",
"of",
"file",
"creation",
"and",
"this",
"method",
"is",
"driven"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.logging.hpel/src/com/ibm/ws/logging/hpel/handlers/LogRepositoryComponent.java#L104-L110 |
RestComm/media-core | stun/src/main/java/org/restcomm/media/core/stun/messages/StunMessage.java | StunMessage.validateFingerprint | private static boolean validateFingerprint(FingerprintAttribute fingerprint, byte[] message, int offset, int length) {
"""
Recalculates the FINGERPRINT CRC32 checksum of the <tt>message</tt> array
so that we could compare it with the value brought by the
{@link FingerprintAttribute}.
@param fingerprint
the attribute that we need to validate.
@param message
the message whose CRC32 checksum we'd need to recalculate.
@param offset
the index in <tt>message</tt> where data starts.
@param length
the number of bytes in <tt>message</tt> that the CRC32 would
need to be calculated over.
@return <tt>true</tt> if <tt>FINGERPRINT</tt> contains a valid CRC32
value and <tt>false</tt> otherwise.
"""
byte[] incomingCrcBytes = fingerprint.getChecksum();
// now check whether the CRC really is what it's supposed to be.
// re calculate the check sum
byte[] realCrcBytes = FingerprintAttribute.calculateXorCRC32(message, offset, length);
// CRC validation.
if (!Arrays.equals(incomingCrcBytes, realCrcBytes)) {
if (logger.isDebugEnabled()) {
logger.debug("An incoming message arrived with a wrong FINGERPRINT attribute value. "
+ "CRC Was:" + Arrays.toString(incomingCrcBytes)
+ ". Should have been:" + Arrays.toString(realCrcBytes)
+ ". Will ignore.");
}
return false;
}
return true;
} | java | private static boolean validateFingerprint(FingerprintAttribute fingerprint, byte[] message, int offset, int length) {
byte[] incomingCrcBytes = fingerprint.getChecksum();
// now check whether the CRC really is what it's supposed to be.
// re calculate the check sum
byte[] realCrcBytes = FingerprintAttribute.calculateXorCRC32(message, offset, length);
// CRC validation.
if (!Arrays.equals(incomingCrcBytes, realCrcBytes)) {
if (logger.isDebugEnabled()) {
logger.debug("An incoming message arrived with a wrong FINGERPRINT attribute value. "
+ "CRC Was:" + Arrays.toString(incomingCrcBytes)
+ ". Should have been:" + Arrays.toString(realCrcBytes)
+ ". Will ignore.");
}
return false;
}
return true;
} | [
"private",
"static",
"boolean",
"validateFingerprint",
"(",
"FingerprintAttribute",
"fingerprint",
",",
"byte",
"[",
"]",
"message",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"byte",
"[",
"]",
"incomingCrcBytes",
"=",
"fingerprint",
".",
"getChecksum",
"(",
")",
";",
"// now check whether the CRC really is what it's supposed to be.",
"// re calculate the check sum",
"byte",
"[",
"]",
"realCrcBytes",
"=",
"FingerprintAttribute",
".",
"calculateXorCRC32",
"(",
"message",
",",
"offset",
",",
"length",
")",
";",
"// CRC validation.",
"if",
"(",
"!",
"Arrays",
".",
"equals",
"(",
"incomingCrcBytes",
",",
"realCrcBytes",
")",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"An incoming message arrived with a wrong FINGERPRINT attribute value. \"",
"+",
"\"CRC Was:\"",
"+",
"Arrays",
".",
"toString",
"(",
"incomingCrcBytes",
")",
"+",
"\". Should have been:\"",
"+",
"Arrays",
".",
"toString",
"(",
"realCrcBytes",
")",
"+",
"\". Will ignore.\"",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Recalculates the FINGERPRINT CRC32 checksum of the <tt>message</tt> array
so that we could compare it with the value brought by the
{@link FingerprintAttribute}.
@param fingerprint
the attribute that we need to validate.
@param message
the message whose CRC32 checksum we'd need to recalculate.
@param offset
the index in <tt>message</tt> where data starts.
@param length
the number of bytes in <tt>message</tt> that the CRC32 would
need to be calculated over.
@return <tt>true</tt> if <tt>FINGERPRINT</tt> contains a valid CRC32
value and <tt>false</tt> otherwise. | [
"Recalculates",
"the",
"FINGERPRINT",
"CRC32",
"checksum",
"of",
"the",
"<tt",
">",
"message<",
"/",
"tt",
">",
"array",
"so",
"that",
"we",
"could",
"compare",
"it",
"with",
"the",
"value",
"brought",
"by",
"the",
"{",
"@link",
"FingerprintAttribute",
"}",
"."
] | train | https://github.com/RestComm/media-core/blob/07b8703343708599f60af66bae62aded77ee81b5/stun/src/main/java/org/restcomm/media/core/stun/messages/StunMessage.java#L956-L973 |
Jasig/uPortal | uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/ResourceLoader.java | ResourceLoader.getResourceAsString | public static String getResourceAsString(Class<?> requestingClass, String resource)
throws ResourceMissingException, IOException {
"""
Get the contents of a URL as a String
@param requestingClass the java.lang.Class object of the class that is attempting to load the
resource
@param resource a String describing the full or partial URL of the resource whose contents to
load
@return the actual contents of the resource as a String
@throws ResourceMissingException
@throws java.io.IOException
"""
String line = null;
BufferedReader in = null;
StringBuffer sbText = null;
try {
in =
new BufferedReader(
new InputStreamReader(
getResourceAsStream(requestingClass, resource), UTF_8));
sbText = new StringBuffer(1024);
while ((line = in.readLine()) != null) sbText.append(line).append("\n");
} finally {
if (in != null) in.close();
}
return sbText.toString();
} | java | public static String getResourceAsString(Class<?> requestingClass, String resource)
throws ResourceMissingException, IOException {
String line = null;
BufferedReader in = null;
StringBuffer sbText = null;
try {
in =
new BufferedReader(
new InputStreamReader(
getResourceAsStream(requestingClass, resource), UTF_8));
sbText = new StringBuffer(1024);
while ((line = in.readLine()) != null) sbText.append(line).append("\n");
} finally {
if (in != null) in.close();
}
return sbText.toString();
} | [
"public",
"static",
"String",
"getResourceAsString",
"(",
"Class",
"<",
"?",
">",
"requestingClass",
",",
"String",
"resource",
")",
"throws",
"ResourceMissingException",
",",
"IOException",
"{",
"String",
"line",
"=",
"null",
";",
"BufferedReader",
"in",
"=",
"null",
";",
"StringBuffer",
"sbText",
"=",
"null",
";",
"try",
"{",
"in",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"getResourceAsStream",
"(",
"requestingClass",
",",
"resource",
")",
",",
"UTF_8",
")",
")",
";",
"sbText",
"=",
"new",
"StringBuffer",
"(",
"1024",
")",
";",
"while",
"(",
"(",
"line",
"=",
"in",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"sbText",
".",
"append",
"(",
"line",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"in",
"!=",
"null",
")",
"in",
".",
"close",
"(",
")",
";",
"}",
"return",
"sbText",
".",
"toString",
"(",
")",
";",
"}"
] | Get the contents of a URL as a String
@param requestingClass the java.lang.Class object of the class that is attempting to load the
resource
@param resource a String describing the full or partial URL of the resource whose contents to
load
@return the actual contents of the resource as a String
@throws ResourceMissingException
@throws java.io.IOException | [
"Get",
"the",
"contents",
"of",
"a",
"URL",
"as",
"a",
"String"
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-utils/uPortal-utils-core/src/main/java/org/apereo/portal/utils/ResourceLoader.java#L337-L353 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/ComputeNodeOperations.java | ComputeNodeOperations.disableComputeNodeScheduling | public void disableComputeNodeScheduling(String poolId, String nodeId, DisableComputeNodeSchedulingOption nodeDisableSchedulingOption, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
"""
Disables task scheduling on the specified compute node.
@param poolId The ID of the pool.
@param nodeId The ID of the compute node.
@param nodeDisableSchedulingOption Specifies what to do with currently running tasks.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service.
"""
ComputeNodeDisableSchedulingOptions options = new ComputeNodeDisableSchedulingOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
this.parentBatchClient.protocolLayer().computeNodes().disableScheduling(poolId, nodeId, nodeDisableSchedulingOption, options);
} | java | public void disableComputeNodeScheduling(String poolId, String nodeId, DisableComputeNodeSchedulingOption nodeDisableSchedulingOption, Iterable<BatchClientBehavior> additionalBehaviors) throws BatchErrorException, IOException {
ComputeNodeDisableSchedulingOptions options = new ComputeNodeDisableSchedulingOptions();
BehaviorManager bhMgr = new BehaviorManager(this.customBehaviors(), additionalBehaviors);
bhMgr.applyRequestBehaviors(options);
this.parentBatchClient.protocolLayer().computeNodes().disableScheduling(poolId, nodeId, nodeDisableSchedulingOption, options);
} | [
"public",
"void",
"disableComputeNodeScheduling",
"(",
"String",
"poolId",
",",
"String",
"nodeId",
",",
"DisableComputeNodeSchedulingOption",
"nodeDisableSchedulingOption",
",",
"Iterable",
"<",
"BatchClientBehavior",
">",
"additionalBehaviors",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"ComputeNodeDisableSchedulingOptions",
"options",
"=",
"new",
"ComputeNodeDisableSchedulingOptions",
"(",
")",
";",
"BehaviorManager",
"bhMgr",
"=",
"new",
"BehaviorManager",
"(",
"this",
".",
"customBehaviors",
"(",
")",
",",
"additionalBehaviors",
")",
";",
"bhMgr",
".",
"applyRequestBehaviors",
"(",
"options",
")",
";",
"this",
".",
"parentBatchClient",
".",
"protocolLayer",
"(",
")",
".",
"computeNodes",
"(",
")",
".",
"disableScheduling",
"(",
"poolId",
",",
"nodeId",
",",
"nodeDisableSchedulingOption",
",",
"options",
")",
";",
"}"
] | Disables task scheduling on the specified compute node.
@param poolId The ID of the pool.
@param nodeId The ID of the compute node.
@param nodeDisableSchedulingOption Specifies what to do with currently running tasks.
@param additionalBehaviors A collection of {@link BatchClientBehavior} instances that are applied to the Batch service request.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. | [
"Disables",
"task",
"scheduling",
"on",
"the",
"specified",
"compute",
"node",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/ComputeNodeOperations.java#L395-L401 |
GCRC/nunaliit | nunaliit2-couch-onUpload/src/main/java/ca/carleton/gcrc/couch/onUpload/simplifyGeoms/GeometrySimplificationProcessImpl.java | GeometrySimplificationProcessImpl.simplifyGeometryAtResolution | public Geometry simplifyGeometryAtResolution(Geometry geometry, double resolution) throws Exception {
"""
Accepts a geometry and a resolution. Returns a version of the geometry
which is simplified for the given resolution. If the initial geometry
is already simplified enough, then return null.
@param geometry Geometry to simplify
@param resolution Resolution at which the geometry should be simplified
@return The simplified geometry. Null, if no simplification is possible.
@throws Exception
"""
double inverseRes = 1/resolution;
double p = Math.log10(inverseRes);
double exp = Math.ceil( p );
if( exp < 0 ) exp = 0;
double factor = Math.pow(10,exp);
Geometry simplifiedGeometry = simplify(geometry, resolution, factor);
return simplifiedGeometry;
} | java | public Geometry simplifyGeometryAtResolution(Geometry geometry, double resolution) throws Exception {
double inverseRes = 1/resolution;
double p = Math.log10(inverseRes);
double exp = Math.ceil( p );
if( exp < 0 ) exp = 0;
double factor = Math.pow(10,exp);
Geometry simplifiedGeometry = simplify(geometry, resolution, factor);
return simplifiedGeometry;
} | [
"public",
"Geometry",
"simplifyGeometryAtResolution",
"(",
"Geometry",
"geometry",
",",
"double",
"resolution",
")",
"throws",
"Exception",
"{",
"double",
"inverseRes",
"=",
"1",
"/",
"resolution",
";",
"double",
"p",
"=",
"Math",
".",
"log10",
"(",
"inverseRes",
")",
";",
"double",
"exp",
"=",
"Math",
".",
"ceil",
"(",
"p",
")",
";",
"if",
"(",
"exp",
"<",
"0",
")",
"exp",
"=",
"0",
";",
"double",
"factor",
"=",
"Math",
".",
"pow",
"(",
"10",
",",
"exp",
")",
";",
"Geometry",
"simplifiedGeometry",
"=",
"simplify",
"(",
"geometry",
",",
"resolution",
",",
"factor",
")",
";",
"return",
"simplifiedGeometry",
";",
"}"
] | Accepts a geometry and a resolution. Returns a version of the geometry
which is simplified for the given resolution. If the initial geometry
is already simplified enough, then return null.
@param geometry Geometry to simplify
@param resolution Resolution at which the geometry should be simplified
@return The simplified geometry. Null, if no simplification is possible.
@throws Exception | [
"Accepts",
"a",
"geometry",
"and",
"a",
"resolution",
".",
"Returns",
"a",
"version",
"of",
"the",
"geometry",
"which",
"is",
"simplified",
"for",
"the",
"given",
"resolution",
".",
"If",
"the",
"initial",
"geometry",
"is",
"already",
"simplified",
"enough",
"then",
"return",
"null",
"."
] | train | https://github.com/GCRC/nunaliit/blob/0b4abfc64eef2eb8b94f852ce697de2e851d8e67/nunaliit2-couch-onUpload/src/main/java/ca/carleton/gcrc/couch/onUpload/simplifyGeoms/GeometrySimplificationProcessImpl.java#L100-L110 |
apache/incubator-druid | server/src/main/java/org/apache/druid/server/coordinator/helper/NewestSegmentFirstIterator.java | NewestSegmentFirstIterator.updateQueue | private void updateQueue(String dataSourceName, DataSourceCompactionConfig config) {
"""
Find the next segments to compact for the given dataSource and add them to the queue.
{@link #timelineIterators} is updated according to the found segments. That is, the found segments are removed from
the timeline of the given dataSource.
"""
final CompactibleTimelineObjectHolderCursor compactibleTimelineObjectHolderCursor = timelineIterators.get(
dataSourceName
);
if (compactibleTimelineObjectHolderCursor == null) {
log.warn("Cannot find timeline for dataSource[%s]. Skip this dataSource", dataSourceName);
return;
}
final SegmentsToCompact segmentsToCompact = findSegmentsToCompact(
compactibleTimelineObjectHolderCursor,
config
);
if (segmentsToCompact.getNumSegments() > 1) {
queue.add(new QueueEntry(segmentsToCompact.segments));
}
} | java | private void updateQueue(String dataSourceName, DataSourceCompactionConfig config)
{
final CompactibleTimelineObjectHolderCursor compactibleTimelineObjectHolderCursor = timelineIterators.get(
dataSourceName
);
if (compactibleTimelineObjectHolderCursor == null) {
log.warn("Cannot find timeline for dataSource[%s]. Skip this dataSource", dataSourceName);
return;
}
final SegmentsToCompact segmentsToCompact = findSegmentsToCompact(
compactibleTimelineObjectHolderCursor,
config
);
if (segmentsToCompact.getNumSegments() > 1) {
queue.add(new QueueEntry(segmentsToCompact.segments));
}
} | [
"private",
"void",
"updateQueue",
"(",
"String",
"dataSourceName",
",",
"DataSourceCompactionConfig",
"config",
")",
"{",
"final",
"CompactibleTimelineObjectHolderCursor",
"compactibleTimelineObjectHolderCursor",
"=",
"timelineIterators",
".",
"get",
"(",
"dataSourceName",
")",
";",
"if",
"(",
"compactibleTimelineObjectHolderCursor",
"==",
"null",
")",
"{",
"log",
".",
"warn",
"(",
"\"Cannot find timeline for dataSource[%s]. Skip this dataSource\"",
",",
"dataSourceName",
")",
";",
"return",
";",
"}",
"final",
"SegmentsToCompact",
"segmentsToCompact",
"=",
"findSegmentsToCompact",
"(",
"compactibleTimelineObjectHolderCursor",
",",
"config",
")",
";",
"if",
"(",
"segmentsToCompact",
".",
"getNumSegments",
"(",
")",
">",
"1",
")",
"{",
"queue",
".",
"add",
"(",
"new",
"QueueEntry",
"(",
"segmentsToCompact",
".",
"segments",
")",
")",
";",
"}",
"}"
] | Find the next segments to compact for the given dataSource and add them to the queue.
{@link #timelineIterators} is updated according to the found segments. That is, the found segments are removed from
the timeline of the given dataSource. | [
"Find",
"the",
"next",
"segments",
"to",
"compact",
"for",
"the",
"given",
"dataSource",
"and",
"add",
"them",
"to",
"the",
"queue",
".",
"{"
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/server/src/main/java/org/apache/druid/server/coordinator/helper/NewestSegmentFirstIterator.java#L161-L180 |
apptik/jus | benchmark/src/perf/java/com/android/volley/Request.java | Request.getPostBody | @Deprecated
public byte[] getPostBody() throws AuthFailureError {
"""
Returns the raw POST body to be sent.
@throws AuthFailureError In the event of auth failure
@deprecated Use {@link #getBody()} instead.
"""
// Note: For compatibility with legacy clients of volley, this implementation must remain
// here instead of simply calling the getBody() function because this function must
// call getPostParams() and getPostParamsEncoding() since legacy clients would have
// overridden these two member functions for POST requests.
Map<String, String> postParams = getPostParams();
if (postParams != null && postParams.size() > 0) {
return encodeParameters(postParams, getPostParamsEncoding());
}
return null;
} | java | @Deprecated
public byte[] getPostBody() throws AuthFailureError {
// Note: For compatibility with legacy clients of volley, this implementation must remain
// here instead of simply calling the getBody() function because this function must
// call getPostParams() and getPostParamsEncoding() since legacy clients would have
// overridden these two member functions for POST requests.
Map<String, String> postParams = getPostParams();
if (postParams != null && postParams.size() > 0) {
return encodeParameters(postParams, getPostParamsEncoding());
}
return null;
} | [
"@",
"Deprecated",
"public",
"byte",
"[",
"]",
"getPostBody",
"(",
")",
"throws",
"AuthFailureError",
"{",
"// Note: For compatibility with legacy clients of volley, this implementation must remain",
"// here instead of simply calling the getBody() function because this function must",
"// call getPostParams() and getPostParamsEncoding() since legacy clients would have",
"// overridden these two member functions for POST requests.",
"Map",
"<",
"String",
",",
"String",
">",
"postParams",
"=",
"getPostParams",
"(",
")",
";",
"if",
"(",
"postParams",
"!=",
"null",
"&&",
"postParams",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"return",
"encodeParameters",
"(",
"postParams",
",",
"getPostParamsEncoding",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the raw POST body to be sent.
@throws AuthFailureError In the event of auth failure
@deprecated Use {@link #getBody()} instead. | [
"Returns",
"the",
"raw",
"POST",
"body",
"to",
"be",
"sent",
"."
] | train | https://github.com/apptik/jus/blob/8a37a21b41f897d68eaeaab07368ec22a1e5a60e/benchmark/src/perf/java/com/android/volley/Request.java#L350-L361 |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearContourLabelChang2004.java | LinearContourLabelChang2004.handleStep2 | private void handleStep2(GrayS32 labeled, int label) {
"""
Step 2: If the pixel below is unmarked and white then it must be an internal contour
Same behavior it the pixel in question has been labeled or not already
"""
// if the blob is not labeled and in this state it cannot be against the left side of the image
if( label == 0 )
label = labeled.data[indexOut-1];
ContourPacked c = contours.get(label-1);
c.internalIndexes.add( packedPoints.size() );
packedPoints.grow();
tracer.setMaxContourSize(saveInternalContours?maxContourSize:0);
tracer.trace(label,x,y,false);
// See if the inner contour exceeded the maximum or minimum size. If so free its points
if( packedPoints.sizeOfTail() >= maxContourSize || packedPoints.sizeOfTail() < minContourSize ) {
packedPoints.removeTail();
packedPoints.grow();
}
} | java | private void handleStep2(GrayS32 labeled, int label) {
// if the blob is not labeled and in this state it cannot be against the left side of the image
if( label == 0 )
label = labeled.data[indexOut-1];
ContourPacked c = contours.get(label-1);
c.internalIndexes.add( packedPoints.size() );
packedPoints.grow();
tracer.setMaxContourSize(saveInternalContours?maxContourSize:0);
tracer.trace(label,x,y,false);
// See if the inner contour exceeded the maximum or minimum size. If so free its points
if( packedPoints.sizeOfTail() >= maxContourSize || packedPoints.sizeOfTail() < minContourSize ) {
packedPoints.removeTail();
packedPoints.grow();
}
} | [
"private",
"void",
"handleStep2",
"(",
"GrayS32",
"labeled",
",",
"int",
"label",
")",
"{",
"// if the blob is not labeled and in this state it cannot be against the left side of the image",
"if",
"(",
"label",
"==",
"0",
")",
"label",
"=",
"labeled",
".",
"data",
"[",
"indexOut",
"-",
"1",
"]",
";",
"ContourPacked",
"c",
"=",
"contours",
".",
"get",
"(",
"label",
"-",
"1",
")",
";",
"c",
".",
"internalIndexes",
".",
"add",
"(",
"packedPoints",
".",
"size",
"(",
")",
")",
";",
"packedPoints",
".",
"grow",
"(",
")",
";",
"tracer",
".",
"setMaxContourSize",
"(",
"saveInternalContours",
"?",
"maxContourSize",
":",
"0",
")",
";",
"tracer",
".",
"trace",
"(",
"label",
",",
"x",
",",
"y",
",",
"false",
")",
";",
"// See if the inner contour exceeded the maximum or minimum size. If so free its points",
"if",
"(",
"packedPoints",
".",
"sizeOfTail",
"(",
")",
">=",
"maxContourSize",
"||",
"packedPoints",
".",
"sizeOfTail",
"(",
")",
"<",
"minContourSize",
")",
"{",
"packedPoints",
".",
"removeTail",
"(",
")",
";",
"packedPoints",
".",
"grow",
"(",
")",
";",
"}",
"}"
] | Step 2: If the pixel below is unmarked and white then it must be an internal contour
Same behavior it the pixel in question has been labeled or not already | [
"Step",
"2",
":",
"If",
"the",
"pixel",
"below",
"is",
"unmarked",
"and",
"white",
"then",
"it",
"must",
"be",
"an",
"internal",
"contour",
"Same",
"behavior",
"it",
"the",
"pixel",
"in",
"question",
"has",
"been",
"labeled",
"or",
"not",
"already"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearContourLabelChang2004.java#L194-L210 |
apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/reporter/MetricReportReporter.java | MetricReportReporter.serializeGauge | protected List<Metric> serializeGauge(String name, Gauge gauge) {
"""
Extracts metrics from {@link com.codahale.metrics.Gauge}.
@param name name of the {@link com.codahale.metrics.Gauge}.
@param gauge instance of {@link com.codahale.metrics.Gauge} to serialize.
@return a list of {@link org.apache.gobblin.metrics.Metric}.
"""
List<Metric> metrics = Lists.newArrayList();
try {
metrics.add(new Metric(name, Double.parseDouble(gauge.getValue().toString())));
} catch(NumberFormatException exception) {
LOGGER.info("Failed to serialize gauge metric. Not compatible with double value.", exception);
}
return metrics;
} | java | protected List<Metric> serializeGauge(String name, Gauge gauge) {
List<Metric> metrics = Lists.newArrayList();
try {
metrics.add(new Metric(name, Double.parseDouble(gauge.getValue().toString())));
} catch(NumberFormatException exception) {
LOGGER.info("Failed to serialize gauge metric. Not compatible with double value.", exception);
}
return metrics;
} | [
"protected",
"List",
"<",
"Metric",
">",
"serializeGauge",
"(",
"String",
"name",
",",
"Gauge",
"gauge",
")",
"{",
"List",
"<",
"Metric",
">",
"metrics",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"try",
"{",
"metrics",
".",
"add",
"(",
"new",
"Metric",
"(",
"name",
",",
"Double",
".",
"parseDouble",
"(",
"gauge",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"exception",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Failed to serialize gauge metric. Not compatible with double value.\"",
",",
"exception",
")",
";",
"}",
"return",
"metrics",
";",
"}"
] | Extracts metrics from {@link com.codahale.metrics.Gauge}.
@param name name of the {@link com.codahale.metrics.Gauge}.
@param gauge instance of {@link com.codahale.metrics.Gauge} to serialize.
@return a list of {@link org.apache.gobblin.metrics.Metric}. | [
"Extracts",
"metrics",
"from",
"{",
"@link",
"com",
".",
"codahale",
".",
"metrics",
".",
"Gauge",
"}",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/reporter/MetricReportReporter.java#L161-L169 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/topology/ST_Graph.java | ST_Graph.createGraph | public static boolean createGraph(Connection connection,
String tableName,
String spatialFieldName) throws SQLException {
"""
Create the nodes and edges tables from the input table containing
LINESTRINGs in the given column.
<p/>
If the input table has name 'input', then the output tables are named
'input_nodes' and 'input_edges'.
@param connection Connection
@param tableName Input table
@param spatialFieldName Name of column containing LINESTRINGs
@return true if both output tables were created
@throws SQLException
"""
// The default tolerance is zero.
return createGraph(connection, tableName, spatialFieldName, 0.0);
} | java | public static boolean createGraph(Connection connection,
String tableName,
String spatialFieldName) throws SQLException {
// The default tolerance is zero.
return createGraph(connection, tableName, spatialFieldName, 0.0);
} | [
"public",
"static",
"boolean",
"createGraph",
"(",
"Connection",
"connection",
",",
"String",
"tableName",
",",
"String",
"spatialFieldName",
")",
"throws",
"SQLException",
"{",
"// The default tolerance is zero.",
"return",
"createGraph",
"(",
"connection",
",",
"tableName",
",",
"spatialFieldName",
",",
"0.0",
")",
";",
"}"
] | Create the nodes and edges tables from the input table containing
LINESTRINGs in the given column.
<p/>
If the input table has name 'input', then the output tables are named
'input_nodes' and 'input_edges'.
@param connection Connection
@param tableName Input table
@param spatialFieldName Name of column containing LINESTRINGs
@return true if both output tables were created
@throws SQLException | [
"Create",
"the",
"nodes",
"and",
"edges",
"tables",
"from",
"the",
"input",
"table",
"containing",
"LINESTRINGs",
"in",
"the",
"given",
"column",
".",
"<p",
"/",
">",
"If",
"the",
"input",
"table",
"has",
"name",
"input",
"then",
"the",
"output",
"tables",
"are",
"named",
"input_nodes",
"and",
"input_edges",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/topology/ST_Graph.java#L123-L128 |
mgm-tp/jfunk | jfunk-core/src/main/java/com/mgmtp/jfunk/core/mail/MailService.java | MailService.findMessages | public List<MailMessage> findMessages(final MailAccount mailAccount, final Predicate<MailMessage> condition,
final long timeoutSeconds) {
"""
<p>
Tries to find messages for the specified mail account applying the specified
{@code condition} until it times out using the specified {@code timeout} and
{@link EmailConstants#MAIL_SLEEP_MILLIS}.
</p>
<b>Note:</b><br />
This method uses the specified mail account independently without reservation. If, however,
the specified mail account has been reserved by any thread (including the current one), an
{@link IllegalStateException} is thrown. </p>
@param mailAccount
the mail account
@param condition
the condition a message must meet
@param timeoutSeconds
the timeout in seconds
@return an immutable list of mail messages
"""
return findMessages(mailAccount, condition, timeoutSeconds, defaultSleepMillis);
} | java | public List<MailMessage> findMessages(final MailAccount mailAccount, final Predicate<MailMessage> condition,
final long timeoutSeconds) {
return findMessages(mailAccount, condition, timeoutSeconds, defaultSleepMillis);
} | [
"public",
"List",
"<",
"MailMessage",
">",
"findMessages",
"(",
"final",
"MailAccount",
"mailAccount",
",",
"final",
"Predicate",
"<",
"MailMessage",
">",
"condition",
",",
"final",
"long",
"timeoutSeconds",
")",
"{",
"return",
"findMessages",
"(",
"mailAccount",
",",
"condition",
",",
"timeoutSeconds",
",",
"defaultSleepMillis",
")",
";",
"}"
] | <p>
Tries to find messages for the specified mail account applying the specified
{@code condition} until it times out using the specified {@code timeout} and
{@link EmailConstants#MAIL_SLEEP_MILLIS}.
</p>
<b>Note:</b><br />
This method uses the specified mail account independently without reservation. If, however,
the specified mail account has been reserved by any thread (including the current one), an
{@link IllegalStateException} is thrown. </p>
@param mailAccount
the mail account
@param condition
the condition a message must meet
@param timeoutSeconds
the timeout in seconds
@return an immutable list of mail messages | [
"<p",
">",
"Tries",
"to",
"find",
"messages",
"for",
"the",
"specified",
"mail",
"account",
"applying",
"the",
"specified",
"{",
"@code",
"condition",
"}",
"until",
"it",
"times",
"out",
"using",
"the",
"specified",
"{",
"@code",
"timeout",
"}",
"and",
"{",
"@link",
"EmailConstants#MAIL_SLEEP_MILLIS",
"}",
".",
"<",
"/",
"p",
">",
"<b",
">",
"Note",
":",
"<",
"/",
"b",
">",
"<br",
"/",
">",
"This",
"method",
"uses",
"the",
"specified",
"mail",
"account",
"independently",
"without",
"reservation",
".",
"If",
"however",
"the",
"specified",
"mail",
"account",
"has",
"been",
"reserved",
"by",
"any",
"thread",
"(",
"including",
"the",
"current",
"one",
")",
"an",
"{",
"@link",
"IllegalStateException",
"}",
"is",
"thrown",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/mgm-tp/jfunk/blob/5b9fecac5778b988bb458085ded39ea9a4c7c2ae/jfunk-core/src/main/java/com/mgmtp/jfunk/core/mail/MailService.java#L346-L349 |
mygreen/excel-cellformatter | src/main/java/com/github/mygreen/cellformatter/FormatterResolver.java | FormatterResolver.createDefaultFormatter | protected CellFormatter createDefaultFormatter(final String name, final Locale... locales) {
"""
指定したインデックスでプロパティに定義されているフォーマットを作成する。
@param name 書式の名前。({@literal format.<書式の名前>=})
@param locales 検索するロケール。
@return 存在しないインデックス番号の時は、nullを返す。
"""
final String key = String.format("format.%s", name);
final String defaultFormat = messageResolver.getMessage(key);
if(defaultFormat == null) {
return null;
}
CellFormatter formatter = createFormatter(defaultFormat);
// ロケールのフォーマットの取得
for(Locale locale : locales) {
final String localeFormat = messageResolver.getMessage(locale, key, null);
if(localeFormat == null) {
continue;
}
final LocaleSwitchFormatter switchFormatter;
if(formatter instanceof LocaleSwitchFormatter) {
switchFormatter = (LocaleSwitchFormatter) formatter;
} else {
// LocaleSwitchFormatterに入れ替える。
switchFormatter = new LocaleSwitchFormatter(formatter);
formatter = switchFormatter;
}
// ロケールごとのフォーマットの登録
if(locale.equals(Locale.JAPANESE)) {
switchFormatter.register(createFormatter(localeFormat), JAPANESE_LOCALES);
} else {
switchFormatter.register(createFormatter(localeFormat), locale);
}
}
return formatter;
} | java | protected CellFormatter createDefaultFormatter(final String name, final Locale... locales) {
final String key = String.format("format.%s", name);
final String defaultFormat = messageResolver.getMessage(key);
if(defaultFormat == null) {
return null;
}
CellFormatter formatter = createFormatter(defaultFormat);
// ロケールのフォーマットの取得
for(Locale locale : locales) {
final String localeFormat = messageResolver.getMessage(locale, key, null);
if(localeFormat == null) {
continue;
}
final LocaleSwitchFormatter switchFormatter;
if(formatter instanceof LocaleSwitchFormatter) {
switchFormatter = (LocaleSwitchFormatter) formatter;
} else {
// LocaleSwitchFormatterに入れ替える。
switchFormatter = new LocaleSwitchFormatter(formatter);
formatter = switchFormatter;
}
// ロケールごとのフォーマットの登録
if(locale.equals(Locale.JAPANESE)) {
switchFormatter.register(createFormatter(localeFormat), JAPANESE_LOCALES);
} else {
switchFormatter.register(createFormatter(localeFormat), locale);
}
}
return formatter;
} | [
"protected",
"CellFormatter",
"createDefaultFormatter",
"(",
"final",
"String",
"name",
",",
"final",
"Locale",
"...",
"locales",
")",
"{",
"final",
"String",
"key",
"=",
"String",
".",
"format",
"(",
"\"format.%s\"",
",",
"name",
")",
";",
"final",
"String",
"defaultFormat",
"=",
"messageResolver",
".",
"getMessage",
"(",
"key",
")",
";",
"if",
"(",
"defaultFormat",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"CellFormatter",
"formatter",
"=",
"createFormatter",
"(",
"defaultFormat",
")",
";",
"// ロケールのフォーマットの取得\r",
"for",
"(",
"Locale",
"locale",
":",
"locales",
")",
"{",
"final",
"String",
"localeFormat",
"=",
"messageResolver",
".",
"getMessage",
"(",
"locale",
",",
"key",
",",
"null",
")",
";",
"if",
"(",
"localeFormat",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"final",
"LocaleSwitchFormatter",
"switchFormatter",
";",
"if",
"(",
"formatter",
"instanceof",
"LocaleSwitchFormatter",
")",
"{",
"switchFormatter",
"=",
"(",
"LocaleSwitchFormatter",
")",
"formatter",
";",
"}",
"else",
"{",
"// LocaleSwitchFormatterに入れ替える。\r",
"switchFormatter",
"=",
"new",
"LocaleSwitchFormatter",
"(",
"formatter",
")",
";",
"formatter",
"=",
"switchFormatter",
";",
"}",
"// ロケールごとのフォーマットの登録\r",
"if",
"(",
"locale",
".",
"equals",
"(",
"Locale",
".",
"JAPANESE",
")",
")",
"{",
"switchFormatter",
".",
"register",
"(",
"createFormatter",
"(",
"localeFormat",
")",
",",
"JAPANESE_LOCALES",
")",
";",
"}",
"else",
"{",
"switchFormatter",
".",
"register",
"(",
"createFormatter",
"(",
"localeFormat",
")",
",",
"locale",
")",
";",
"}",
"}",
"return",
"formatter",
";",
"}"
] | 指定したインデックスでプロパティに定義されているフォーマットを作成する。
@param name 書式の名前。({@literal format.<書式の名前>=})
@param locales 検索するロケール。
@return 存在しないインデックス番号の時は、nullを返す。 | [
"指定したインデックスでプロパティに定義されているフォーマットを作成する。"
] | train | https://github.com/mygreen/excel-cellformatter/blob/e802af273d49889500591e03799c9262cbf29185/src/main/java/com/github/mygreen/cellformatter/FormatterResolver.java#L114-L155 |
khuxtable/seaglass | src/main/java/com/seaglasslookandfeel/SeaGlassLookAndFeel.java | SeaGlassLookAndFeel.defineSplitPanes | private void defineSplitPanes(UIDefaults d) {
"""
Initialize the split pane UI settings.
@param d the UI defaults map.
"""
d.put("splitPaneDividerBackgroundOuter", new Color(0xd9d9d9));
String p = "SplitPane";
d.put(p + ".contentMargins", new InsetsUIResource(1, 1, 1, 1));
d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical");
d.put(p + ".Vertical", new SplitPaneVerticalState());
d.put(p + ".size", new Integer(11));
d.put(p + ".dividerSize", new Integer(11));
d.put(p + ".centerOneTouchButtons", Boolean.TRUE);
d.put(p + ".oneTouchButtonOffset", new Integer(20));
d.put(p + ".oneTouchButtonVOffset", new Integer(3));
d.put(p + ".oneTouchExpandable", Boolean.FALSE);
d.put(p + ".continuousLayout", Boolean.TRUE);
String c = PAINTER_PREFIX + "SplitPaneDividerPainter";
p = "SplitPane:SplitPaneDivider";
d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical");
d.put(p + ".Vertical", new SplitPaneDividerVerticalState());
d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.BACKGROUND_ENABLED));
d.put(p + "[Focused].backgroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.BACKGROUND_FOCUSED));
d.put(p + "[Enabled].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_ENABLED));
d.put(p + "[Focused].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_FOCUSED));
d.put(p + "[Enabled+Vertical].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_ENABLED_VERTICAL));
d.put(p + "[Focused+Vertical].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_FOCUSED_VERTICAL));
} | java | private void defineSplitPanes(UIDefaults d) {
d.put("splitPaneDividerBackgroundOuter", new Color(0xd9d9d9));
String p = "SplitPane";
d.put(p + ".contentMargins", new InsetsUIResource(1, 1, 1, 1));
d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical");
d.put(p + ".Vertical", new SplitPaneVerticalState());
d.put(p + ".size", new Integer(11));
d.put(p + ".dividerSize", new Integer(11));
d.put(p + ".centerOneTouchButtons", Boolean.TRUE);
d.put(p + ".oneTouchButtonOffset", new Integer(20));
d.put(p + ".oneTouchButtonVOffset", new Integer(3));
d.put(p + ".oneTouchExpandable", Boolean.FALSE);
d.put(p + ".continuousLayout", Boolean.TRUE);
String c = PAINTER_PREFIX + "SplitPaneDividerPainter";
p = "SplitPane:SplitPaneDivider";
d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical");
d.put(p + ".Vertical", new SplitPaneDividerVerticalState());
d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.BACKGROUND_ENABLED));
d.put(p + "[Focused].backgroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.BACKGROUND_FOCUSED));
d.put(p + "[Enabled].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_ENABLED));
d.put(p + "[Focused].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_FOCUSED));
d.put(p + "[Enabled+Vertical].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_ENABLED_VERTICAL));
d.put(p + "[Focused+Vertical].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_FOCUSED_VERTICAL));
} | [
"private",
"void",
"defineSplitPanes",
"(",
"UIDefaults",
"d",
")",
"{",
"d",
".",
"put",
"(",
"\"splitPaneDividerBackgroundOuter\"",
",",
"new",
"Color",
"(",
"0xd9d9d9",
")",
")",
";",
"String",
"p",
"=",
"\"SplitPane\"",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".contentMargins\"",
",",
"new",
"InsetsUIResource",
"(",
"1",
",",
"1",
",",
"1",
",",
"1",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".States\"",
",",
"\"Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical\"",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".Vertical\"",
",",
"new",
"SplitPaneVerticalState",
"(",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".size\"",
",",
"new",
"Integer",
"(",
"11",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".dividerSize\"",
",",
"new",
"Integer",
"(",
"11",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".centerOneTouchButtons\"",
",",
"Boolean",
".",
"TRUE",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".oneTouchButtonOffset\"",
",",
"new",
"Integer",
"(",
"20",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".oneTouchButtonVOffset\"",
",",
"new",
"Integer",
"(",
"3",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".oneTouchExpandable\"",
",",
"Boolean",
".",
"FALSE",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".continuousLayout\"",
",",
"Boolean",
".",
"TRUE",
")",
";",
"String",
"c",
"=",
"PAINTER_PREFIX",
"+",
"\"SplitPaneDividerPainter\"",
";",
"p",
"=",
"\"SplitPane:SplitPaneDivider\"",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".contentMargins\"",
",",
"new",
"InsetsUIResource",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".States\"",
",",
"\"Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical\"",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\".Vertical\"",
",",
"new",
"SplitPaneDividerVerticalState",
"(",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Enabled].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"SplitPaneDividerPainter",
".",
"Which",
".",
"BACKGROUND_ENABLED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Focused].backgroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"SplitPaneDividerPainter",
".",
"Which",
".",
"BACKGROUND_FOCUSED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Enabled].foregroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"SplitPaneDividerPainter",
".",
"Which",
".",
"FOREGROUND_ENABLED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Focused].foregroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"SplitPaneDividerPainter",
".",
"Which",
".",
"FOREGROUND_FOCUSED",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Enabled+Vertical].foregroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"SplitPaneDividerPainter",
".",
"Which",
".",
"FOREGROUND_ENABLED_VERTICAL",
")",
")",
";",
"d",
".",
"put",
"(",
"p",
"+",
"\"[Focused+Vertical].foregroundPainter\"",
",",
"new",
"LazyPainter",
"(",
"c",
",",
"SplitPaneDividerPainter",
".",
"Which",
".",
"FOREGROUND_FOCUSED_VERTICAL",
")",
")",
";",
"}"
] | Initialize the split pane UI settings.
@param d the UI defaults map. | [
"Initialize",
"the",
"split",
"pane",
"UI",
"settings",
"."
] | train | https://github.com/khuxtable/seaglass/blob/f25ecba622923d7b29b64cb7d6068dd8005989b3/src/main/java/com/seaglasslookandfeel/SeaGlassLookAndFeel.java#L1906-L1934 |
UrielCh/ovh-java-sdk | ovh-java-sdk-licenseoffice/src/main/java/net/minidev/ovh/api/ApiOvhLicenseoffice.java | ApiOvhLicenseoffice.serviceName_user_activationEmail_changePassword_POST | public OvhOfficeTask serviceName_user_activationEmail_changePassword_POST(String serviceName, String activationEmail, String notifyEmail, String password, Boolean shouldSendMail) throws IOException {
"""
Change or reset user's password
REST: POST /license/office/{serviceName}/user/{activationEmail}/changePassword
@param shouldSendMail [required] Specify if the new password should be send via email or not.
@param password [required] New password or empty to receive a generated password by email
@param notifyEmail [required] Email to send the new password to. Default is nicAdmin's email.
@param serviceName [required] The unique identifier of your Office service
@param activationEmail [required] Email used to activate Microsoft Office
"""
String qPath = "/license/office/{serviceName}/user/{activationEmail}/changePassword";
StringBuilder sb = path(qPath, serviceName, activationEmail);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "notifyEmail", notifyEmail);
addBody(o, "password", password);
addBody(o, "shouldSendMail", shouldSendMail);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOfficeTask.class);
} | java | public OvhOfficeTask serviceName_user_activationEmail_changePassword_POST(String serviceName, String activationEmail, String notifyEmail, String password, Boolean shouldSendMail) throws IOException {
String qPath = "/license/office/{serviceName}/user/{activationEmail}/changePassword";
StringBuilder sb = path(qPath, serviceName, activationEmail);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "notifyEmail", notifyEmail);
addBody(o, "password", password);
addBody(o, "shouldSendMail", shouldSendMail);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOfficeTask.class);
} | [
"public",
"OvhOfficeTask",
"serviceName_user_activationEmail_changePassword_POST",
"(",
"String",
"serviceName",
",",
"String",
"activationEmail",
",",
"String",
"notifyEmail",
",",
"String",
"password",
",",
"Boolean",
"shouldSendMail",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/license/office/{serviceName}/user/{activationEmail}/changePassword\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"activationEmail",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"notifyEmail\"",
",",
"notifyEmail",
")",
";",
"addBody",
"(",
"o",
",",
"\"password\"",
",",
"password",
")",
";",
"addBody",
"(",
"o",
",",
"\"shouldSendMail\"",
",",
"shouldSendMail",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOfficeTask",
".",
"class",
")",
";",
"}"
] | Change or reset user's password
REST: POST /license/office/{serviceName}/user/{activationEmail}/changePassword
@param shouldSendMail [required] Specify if the new password should be send via email or not.
@param password [required] New password or empty to receive a generated password by email
@param notifyEmail [required] Email to send the new password to. Default is nicAdmin's email.
@param serviceName [required] The unique identifier of your Office service
@param activationEmail [required] Email used to activate Microsoft Office | [
"Change",
"or",
"reset",
"user",
"s",
"password"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-licenseoffice/src/main/java/net/minidev/ovh/api/ApiOvhLicenseoffice.java#L132-L141 |
Alluxio/alluxio | core/server/worker/src/main/java/alluxio/worker/block/evictor/Evictor.java | Factory.create | public static Evictor create(BlockMetadataManagerView view, Allocator allocator) {
"""
Factory for {@link Evictor}.
@param view {@link BlockMetadataManagerView} to pass to {@link Evictor}
@param allocator an allocation policy
@return the generated {@link Evictor}
"""
return CommonUtils.createNewClassInstance(
ServerConfiguration.<Evictor>getClass(PropertyKey.WORKER_EVICTOR_CLASS),
new Class[] {BlockMetadataManagerView.class, Allocator.class},
new Object[] {view, allocator});
} | java | public static Evictor create(BlockMetadataManagerView view, Allocator allocator) {
return CommonUtils.createNewClassInstance(
ServerConfiguration.<Evictor>getClass(PropertyKey.WORKER_EVICTOR_CLASS),
new Class[] {BlockMetadataManagerView.class, Allocator.class},
new Object[] {view, allocator});
} | [
"public",
"static",
"Evictor",
"create",
"(",
"BlockMetadataManagerView",
"view",
",",
"Allocator",
"allocator",
")",
"{",
"return",
"CommonUtils",
".",
"createNewClassInstance",
"(",
"ServerConfiguration",
".",
"<",
"Evictor",
">",
"getClass",
"(",
"PropertyKey",
".",
"WORKER_EVICTOR_CLASS",
")",
",",
"new",
"Class",
"[",
"]",
"{",
"BlockMetadataManagerView",
".",
"class",
",",
"Allocator",
".",
"class",
"}",
",",
"new",
"Object",
"[",
"]",
"{",
"view",
",",
"allocator",
"}",
")",
";",
"}"
] | Factory for {@link Evictor}.
@param view {@link BlockMetadataManagerView} to pass to {@link Evictor}
@param allocator an allocation policy
@return the generated {@link Evictor} | [
"Factory",
"for",
"{",
"@link",
"Evictor",
"}",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/evictor/Evictor.java#L52-L57 |
sarl/sarl | main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/labeling/SARLLabelProvider.java | SARLLabelProvider.signatureWithoutReturnType | protected StyledString signatureWithoutReturnType(StyledString simpleName, JvmExecutable element) {
"""
Create a string representation of a signature without the return type.
@param simpleName the action name.
@param element the executable element.
@return the signature.
"""
return simpleName.append(this.uiStrings.styledParameters(element));
} | java | protected StyledString signatureWithoutReturnType(StyledString simpleName, JvmExecutable element) {
return simpleName.append(this.uiStrings.styledParameters(element));
} | [
"protected",
"StyledString",
"signatureWithoutReturnType",
"(",
"StyledString",
"simpleName",
",",
"JvmExecutable",
"element",
")",
"{",
"return",
"simpleName",
".",
"append",
"(",
"this",
".",
"uiStrings",
".",
"styledParameters",
"(",
"element",
")",
")",
";",
"}"
] | Create a string representation of a signature without the return type.
@param simpleName the action name.
@param element the executable element.
@return the signature. | [
"Create",
"a",
"string",
"representation",
"of",
"a",
"signature",
"without",
"the",
"return",
"type",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/labeling/SARLLabelProvider.java#L182-L184 |
LGoodDatePicker/LGoodDatePicker | Project/src/main/java/com/github/lgooddatepicker/components/DateTimePicker.java | DateTimePicker.setGapSize | public void setGapSize(int gapSize, ConstantSize.Unit units) {
"""
setGapSize, This sets the size of the gap between the date picker and the time picker.
"""
ConstantSize gapSizeObject = new ConstantSize(gapSize, units);
ColumnSpec columnSpec = ColumnSpec.createGap(gapSizeObject);
FormLayout layout = (FormLayout) getLayout();
layout.setColumnSpec(2, columnSpec);
} | java | public void setGapSize(int gapSize, ConstantSize.Unit units) {
ConstantSize gapSizeObject = new ConstantSize(gapSize, units);
ColumnSpec columnSpec = ColumnSpec.createGap(gapSizeObject);
FormLayout layout = (FormLayout) getLayout();
layout.setColumnSpec(2, columnSpec);
} | [
"public",
"void",
"setGapSize",
"(",
"int",
"gapSize",
",",
"ConstantSize",
".",
"Unit",
"units",
")",
"{",
"ConstantSize",
"gapSizeObject",
"=",
"new",
"ConstantSize",
"(",
"gapSize",
",",
"units",
")",
";",
"ColumnSpec",
"columnSpec",
"=",
"ColumnSpec",
".",
"createGap",
"(",
"gapSizeObject",
")",
";",
"FormLayout",
"layout",
"=",
"(",
"FormLayout",
")",
"getLayout",
"(",
")",
";",
"layout",
".",
"setColumnSpec",
"(",
"2",
",",
"columnSpec",
")",
";",
"}"
] | setGapSize, This sets the size of the gap between the date picker and the time picker. | [
"setGapSize",
"This",
"sets",
"the",
"size",
"of",
"the",
"gap",
"between",
"the",
"date",
"picker",
"and",
"the",
"time",
"picker",
"."
] | train | https://github.com/LGoodDatePicker/LGoodDatePicker/blob/c7df05a5fe382e1e08a6237e9391d8dc5fd48692/Project/src/main/java/com/github/lgooddatepicker/components/DateTimePicker.java#L315-L320 |
roboconf/roboconf-platform | core/roboconf-target-iaas-ec2/src/main/java/net/roboconf/target/ec2/internal/Ec2IaasHandler.java | Ec2IaasHandler.createEc2Client | public static AmazonEC2 createEc2Client( Map<String,String> targetProperties ) throws TargetException {
"""
Creates a client for EC2.
@param targetProperties the target properties (not null)
@return a non-null client
@throws TargetException if properties are invalid
"""
parseProperties( targetProperties );
// Configure the IaaS client
AWSCredentials credentials = new BasicAWSCredentials(
targetProperties.get(Ec2Constants.EC2_ACCESS_KEY),
targetProperties.get(Ec2Constants.EC2_SECRET_KEY));
AmazonEC2 ec2 = new AmazonEC2Client( credentials );
ec2.setEndpoint( targetProperties.get(Ec2Constants.EC2_ENDPOINT ));
return ec2;
} | java | public static AmazonEC2 createEc2Client( Map<String,String> targetProperties ) throws TargetException {
parseProperties( targetProperties );
// Configure the IaaS client
AWSCredentials credentials = new BasicAWSCredentials(
targetProperties.get(Ec2Constants.EC2_ACCESS_KEY),
targetProperties.get(Ec2Constants.EC2_SECRET_KEY));
AmazonEC2 ec2 = new AmazonEC2Client( credentials );
ec2.setEndpoint( targetProperties.get(Ec2Constants.EC2_ENDPOINT ));
return ec2;
} | [
"public",
"static",
"AmazonEC2",
"createEc2Client",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"targetProperties",
")",
"throws",
"TargetException",
"{",
"parseProperties",
"(",
"targetProperties",
")",
";",
"// Configure the IaaS client",
"AWSCredentials",
"credentials",
"=",
"new",
"BasicAWSCredentials",
"(",
"targetProperties",
".",
"get",
"(",
"Ec2Constants",
".",
"EC2_ACCESS_KEY",
")",
",",
"targetProperties",
".",
"get",
"(",
"Ec2Constants",
".",
"EC2_SECRET_KEY",
")",
")",
";",
"AmazonEC2",
"ec2",
"=",
"new",
"AmazonEC2Client",
"(",
"credentials",
")",
";",
"ec2",
".",
"setEndpoint",
"(",
"targetProperties",
".",
"get",
"(",
"Ec2Constants",
".",
"EC2_ENDPOINT",
")",
")",
";",
"return",
"ec2",
";",
"}"
] | Creates a client for EC2.
@param targetProperties the target properties (not null)
@return a non-null client
@throws TargetException if properties are invalid | [
"Creates",
"a",
"client",
"for",
"EC2",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-iaas-ec2/src/main/java/net/roboconf/target/ec2/internal/Ec2IaasHandler.java#L268-L281 |
molgenis/molgenis | molgenis-security/src/main/java/org/molgenis/security/token/DataServiceTokenService.java | DataServiceTokenService.generateAndStoreToken | @Override
@Transactional
@RunAsSystem
public String generateAndStoreToken(String username, String description) {
"""
Generates a token and associates it with a user.
<p>Token expires in 2 hours
@param username username
@param description token description
@return token
"""
User user = dataService.query(USER, User.class).eq(USERNAME, username).findOne();
if (user == null) {
throw new IllegalArgumentException(format("Unknown username [%s]", username));
}
String token = tokenGenerator.generateToken();
Token molgenisToken = tokenFactory.create();
molgenisToken.setUser(user);
molgenisToken.setToken(token);
molgenisToken.setDescription(description);
molgenisToken.setExpirationDate(now().plus(2, HOURS));
dataService.add(TOKEN, molgenisToken);
return token;
} | java | @Override
@Transactional
@RunAsSystem
public String generateAndStoreToken(String username, String description) {
User user = dataService.query(USER, User.class).eq(USERNAME, username).findOne();
if (user == null) {
throw new IllegalArgumentException(format("Unknown username [%s]", username));
}
String token = tokenGenerator.generateToken();
Token molgenisToken = tokenFactory.create();
molgenisToken.setUser(user);
molgenisToken.setToken(token);
molgenisToken.setDescription(description);
molgenisToken.setExpirationDate(now().plus(2, HOURS));
dataService.add(TOKEN, molgenisToken);
return token;
} | [
"@",
"Override",
"@",
"Transactional",
"@",
"RunAsSystem",
"public",
"String",
"generateAndStoreToken",
"(",
"String",
"username",
",",
"String",
"description",
")",
"{",
"User",
"user",
"=",
"dataService",
".",
"query",
"(",
"USER",
",",
"User",
".",
"class",
")",
".",
"eq",
"(",
"USERNAME",
",",
"username",
")",
".",
"findOne",
"(",
")",
";",
"if",
"(",
"user",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"format",
"(",
"\"Unknown username [%s]\"",
",",
"username",
")",
")",
";",
"}",
"String",
"token",
"=",
"tokenGenerator",
".",
"generateToken",
"(",
")",
";",
"Token",
"molgenisToken",
"=",
"tokenFactory",
".",
"create",
"(",
")",
";",
"molgenisToken",
".",
"setUser",
"(",
"user",
")",
";",
"molgenisToken",
".",
"setToken",
"(",
"token",
")",
";",
"molgenisToken",
".",
"setDescription",
"(",
"description",
")",
";",
"molgenisToken",
".",
"setExpirationDate",
"(",
"now",
"(",
")",
".",
"plus",
"(",
"2",
",",
"HOURS",
")",
")",
";",
"dataService",
".",
"add",
"(",
"TOKEN",
",",
"molgenisToken",
")",
";",
"return",
"token",
";",
"}"
] | Generates a token and associates it with a user.
<p>Token expires in 2 hours
@param username username
@param description token description
@return token | [
"Generates",
"a",
"token",
"and",
"associates",
"it",
"with",
"a",
"user",
"."
] | train | https://github.com/molgenis/molgenis/blob/b4d0d6b27e6f6c8d7505a3863dc03b589601f987/molgenis-security/src/main/java/org/molgenis/security/token/DataServiceTokenService.java#L64-L83 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/PerspectiveOps.java | PerspectiveOps.createWorldToPixel | public static WorldToCameraToPixel createWorldToPixel(CameraPinholeBrown intrinsic , Se3_F64 worldToCamera ) {
"""
Creates a transform from world coordinates into pixel coordinates. can handle lens distortion
"""
WorldToCameraToPixel alg = new WorldToCameraToPixel();
alg.configure(intrinsic,worldToCamera);
return alg;
} | java | public static WorldToCameraToPixel createWorldToPixel(CameraPinholeBrown intrinsic , Se3_F64 worldToCamera )
{
WorldToCameraToPixel alg = new WorldToCameraToPixel();
alg.configure(intrinsic,worldToCamera);
return alg;
} | [
"public",
"static",
"WorldToCameraToPixel",
"createWorldToPixel",
"(",
"CameraPinholeBrown",
"intrinsic",
",",
"Se3_F64",
"worldToCamera",
")",
"{",
"WorldToCameraToPixel",
"alg",
"=",
"new",
"WorldToCameraToPixel",
"(",
")",
";",
"alg",
".",
"configure",
"(",
"intrinsic",
",",
"worldToCamera",
")",
";",
"return",
"alg",
";",
"}"
] | Creates a transform from world coordinates into pixel coordinates. can handle lens distortion | [
"Creates",
"a",
"transform",
"from",
"world",
"coordinates",
"into",
"pixel",
"coordinates",
".",
"can",
"handle",
"lens",
"distortion"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/PerspectiveOps.java#L687-L692 |
liferay/com-liferay-commerce | commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CProductPersistenceImpl.java | CProductPersistenceImpl.removeByUUID_G | @Override
public CProduct removeByUUID_G(String uuid, long groupId)
throws NoSuchCProductException {
"""
Removes the c product where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the c product that was removed
"""
CProduct cProduct = findByUUID_G(uuid, groupId);
return remove(cProduct);
} | java | @Override
public CProduct removeByUUID_G(String uuid, long groupId)
throws NoSuchCProductException {
CProduct cProduct = findByUUID_G(uuid, groupId);
return remove(cProduct);
} | [
"@",
"Override",
"public",
"CProduct",
"removeByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"NoSuchCProductException",
"{",
"CProduct",
"cProduct",
"=",
"findByUUID_G",
"(",
"uuid",
",",
"groupId",
")",
";",
"return",
"remove",
"(",
"cProduct",
")",
";",
"}"
] | Removes the c product where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the c product that was removed | [
"Removes",
"the",
"c",
"product",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-service/src/main/java/com/liferay/commerce/product/service/persistence/impl/CProductPersistenceImpl.java#L804-L810 |
jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Db.java | Db.findByIds | public static Record findByIds(String tableName, String primaryKey, Object... idValues) {
"""
Find record by ids.
<pre>
Example:
Record user = Db.findByIds("user", "user_id", 123);
Record userRole = Db.findByIds("user_role", "user_id, role_id", 123, 456);
</pre>
@param tableName the table name of the table
@param primaryKey the primary key of the table, composite primary key is separated by comma character: ","
@param idValues the id value of the record, it can be composite id values
"""
return MAIN.findByIds(tableName, primaryKey, idValues);
} | java | public static Record findByIds(String tableName, String primaryKey, Object... idValues) {
return MAIN.findByIds(tableName, primaryKey, idValues);
} | [
"public",
"static",
"Record",
"findByIds",
"(",
"String",
"tableName",
",",
"String",
"primaryKey",
",",
"Object",
"...",
"idValues",
")",
"{",
"return",
"MAIN",
".",
"findByIds",
"(",
"tableName",
",",
"primaryKey",
",",
"idValues",
")",
";",
"}"
] | Find record by ids.
<pre>
Example:
Record user = Db.findByIds("user", "user_id", 123);
Record userRole = Db.findByIds("user_role", "user_id, role_id", 123, 456);
</pre>
@param tableName the table name of the table
@param primaryKey the primary key of the table, composite primary key is separated by comma character: ","
@param idValues the id value of the record, it can be composite id values | [
"Find",
"record",
"by",
"ids",
".",
"<pre",
">",
"Example",
":",
"Record",
"user",
"=",
"Db",
".",
"findByIds",
"(",
"user",
"user_id",
"123",
")",
";",
"Record",
"userRole",
"=",
"Db",
".",
"findByIds",
"(",
"user_role",
"user_id",
"role_id",
"123",
"456",
")",
";",
"<",
"/",
"pre",
">"
] | train | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Db.java#L332-L334 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java | HtmlTree.A_NAME | public static HtmlTree A_NAME(String name, Content body) {
"""
Generates an HTML anchor tag with name attribute and content.
@param name name for the anchor tag
@param body content for the anchor tag
@return an HtmlTree object
"""
HtmlTree htmltree = HtmlTree.A_NAME(name);
htmltree.addContent(nullCheck(body));
return htmltree;
} | java | public static HtmlTree A_NAME(String name, Content body) {
HtmlTree htmltree = HtmlTree.A_NAME(name);
htmltree.addContent(nullCheck(body));
return htmltree;
} | [
"public",
"static",
"HtmlTree",
"A_NAME",
"(",
"String",
"name",
",",
"Content",
"body",
")",
"{",
"HtmlTree",
"htmltree",
"=",
"HtmlTree",
".",
"A_NAME",
"(",
"name",
")",
";",
"htmltree",
".",
"addContent",
"(",
"nullCheck",
"(",
"body",
")",
")",
";",
"return",
"htmltree",
";",
"}"
] | Generates an HTML anchor tag with name attribute and content.
@param name name for the anchor tag
@param body content for the anchor tag
@return an HtmlTree object | [
"Generates",
"an",
"HTML",
"anchor",
"tag",
"with",
"name",
"attribute",
"and",
"content",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java#L232-L236 |
l0rdn1kk0n/wicket-jquery-selectors | src/main/java/de/agilecoders/wicket/jquery/util/Json.java | Json.fromJson | public static <T> T fromJson(final JsonNode json, final Class<T> clazz) {
"""
Convert a JsonNode to a Java value
@param json Json value to convert.
@param clazz Expected Java value type.
@param <T> type of return object
@return casted value of given json object
@throws ParseException to runtime if json node can't be casted to clazz.
"""
try {
return createObjectMapper().treeToValue(json, clazz);
} catch (Exception e) {
throw new ParseException(e);
}
} | java | public static <T> T fromJson(final JsonNode json, final Class<T> clazz) {
try {
return createObjectMapper().treeToValue(json, clazz);
} catch (Exception e) {
throw new ParseException(e);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"fromJson",
"(",
"final",
"JsonNode",
"json",
",",
"final",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"try",
"{",
"return",
"createObjectMapper",
"(",
")",
".",
"treeToValue",
"(",
"json",
",",
"clazz",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"e",
")",
";",
"}",
"}"
] | Convert a JsonNode to a Java value
@param json Json value to convert.
@param clazz Expected Java value type.
@param <T> type of return object
@return casted value of given json object
@throws ParseException to runtime if json node can't be casted to clazz. | [
"Convert",
"a",
"JsonNode",
"to",
"a",
"Java",
"value"
] | train | https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/util/Json.java#L88-L94 |
belaban/JGroups | src/org/jgroups/util/RingBuffer.java | RingBuffer.drainToBlocking | public int drainToBlocking(Collection<? super T> c, int max_elements) throws InterruptedException {
"""
Removes a number of messages and adds them to c. Contrary to {@link #drainTo(Collection,int)}, this method
blocks until at least one message is available, or the caller thread is interrupted.
@param c The collection to which to add the removed messages.
@param max_elements The max number of messages to remove. The actual number of messages removed may be smaller
if the buffer has fewer elements
@return The number of messages removed
@throws NullPointerException If c is null
"""
lock.lockInterruptibly(); // fail fast
try {
while(count == 0)
not_empty.await();
return drainTo(c, max_elements);
}
finally {
lock.unlock();
}
} | java | public int drainToBlocking(Collection<? super T> c, int max_elements) throws InterruptedException {
lock.lockInterruptibly(); // fail fast
try {
while(count == 0)
not_empty.await();
return drainTo(c, max_elements);
}
finally {
lock.unlock();
}
} | [
"public",
"int",
"drainToBlocking",
"(",
"Collection",
"<",
"?",
"super",
"T",
">",
"c",
",",
"int",
"max_elements",
")",
"throws",
"InterruptedException",
"{",
"lock",
".",
"lockInterruptibly",
"(",
")",
";",
"// fail fast",
"try",
"{",
"while",
"(",
"count",
"==",
"0",
")",
"not_empty",
".",
"await",
"(",
")",
";",
"return",
"drainTo",
"(",
"c",
",",
"max_elements",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Removes a number of messages and adds them to c. Contrary to {@link #drainTo(Collection,int)}, this method
blocks until at least one message is available, or the caller thread is interrupted.
@param c The collection to which to add the removed messages.
@param max_elements The max number of messages to remove. The actual number of messages removed may be smaller
if the buffer has fewer elements
@return The number of messages removed
@throws NullPointerException If c is null | [
"Removes",
"a",
"number",
"of",
"messages",
"and",
"adds",
"them",
"to",
"c",
".",
"Contrary",
"to",
"{"
] | train | https://github.com/belaban/JGroups/blob/bd3ca786aa57fed41dfbc10a94b1281e388be03b/src/org/jgroups/util/RingBuffer.java#L196-L206 |
apache/flink | flink-core/src/main/java/org/apache/flink/api/common/operators/base/CoGroupRawOperatorBase.java | CoGroupRawOperatorBase.setGroupOrder | public void setGroupOrder(int inputNum, Ordering order) {
"""
Sets the order of the elements within a group for the given input.
@param inputNum The number of the input (here either <i>0</i> or <i>1</i>).
@param order The order for the elements in a group.
"""
if (inputNum == 0) {
this.groupOrder1 = order;
} else if (inputNum == 1) {
this.groupOrder2 = order;
} else {
throw new IndexOutOfBoundsException();
}
} | java | public void setGroupOrder(int inputNum, Ordering order) {
if (inputNum == 0) {
this.groupOrder1 = order;
} else if (inputNum == 1) {
this.groupOrder2 = order;
} else {
throw new IndexOutOfBoundsException();
}
} | [
"public",
"void",
"setGroupOrder",
"(",
"int",
"inputNum",
",",
"Ordering",
"order",
")",
"{",
"if",
"(",
"inputNum",
"==",
"0",
")",
"{",
"this",
".",
"groupOrder1",
"=",
"order",
";",
"}",
"else",
"if",
"(",
"inputNum",
"==",
"1",
")",
"{",
"this",
".",
"groupOrder2",
"=",
"order",
";",
"}",
"else",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"}"
] | Sets the order of the elements within a group for the given input.
@param inputNum The number of the input (here either <i>0</i> or <i>1</i>).
@param order The order for the elements in a group. | [
"Sets",
"the",
"order",
"of",
"the",
"elements",
"within",
"a",
"group",
"for",
"the",
"given",
"input",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-core/src/main/java/org/apache/flink/api/common/operators/base/CoGroupRawOperatorBase.java#L89-L97 |
BradleyWood/Software-Quality-Test-Framework | sqtf-core/src/main/java/org/sqtf/assertions/Assert.java | Assert.assertEquals | public static void assertEquals(float expected, float actual, float delta, String message) {
"""
Asserts that the two floats are equal. If they are not
the test will fail
@param expected The expected value
@param actual The actual value
@param delta The maximum amount that expected and actual values may deviate by
@param message The message to report on failure
"""
if (expected + delta < actual || expected - delta > actual) {
fail(message);
}
} | java | public static void assertEquals(float expected, float actual, float delta, String message) {
if (expected + delta < actual || expected - delta > actual) {
fail(message);
}
} | [
"public",
"static",
"void",
"assertEquals",
"(",
"float",
"expected",
",",
"float",
"actual",
",",
"float",
"delta",
",",
"String",
"message",
")",
"{",
"if",
"(",
"expected",
"+",
"delta",
"<",
"actual",
"||",
"expected",
"-",
"delta",
">",
"actual",
")",
"{",
"fail",
"(",
"message",
")",
";",
"}",
"}"
] | Asserts that the two floats are equal. If they are not
the test will fail
@param expected The expected value
@param actual The actual value
@param delta The maximum amount that expected and actual values may deviate by
@param message The message to report on failure | [
"Asserts",
"that",
"the",
"two",
"floats",
"are",
"equal",
".",
"If",
"they",
"are",
"not",
"the",
"test",
"will",
"fail"
] | train | https://github.com/BradleyWood/Software-Quality-Test-Framework/blob/010dea3bfc8e025a4304ab9ef4a213c1adcb1aa0/sqtf-core/src/main/java/org/sqtf/assertions/Assert.java#L138-L142 |
smurn/jPLY | jply/src/main/java/org/smurn/jply/util/RectBounds.java | RectBounds.addPoint | public void addPoint(final double x, final double y, final double z) {
"""
Increases the bounds to include a given point.
<p>If the point is already in the interior of the bounded
area the bounds are not changed.</p>
@param x Coordinate of the point to include.
@param y Coordinate of the point to include.
@param z Coordinate of the point to include.
"""
minX = Math.min(minX, x);
minY = Math.min(minY, y);
minZ = Math.min(minZ, z);
maxX = Math.max(maxX, x);
maxY = Math.max(maxY, y);
maxZ = Math.max(maxZ, z);
} | java | public void addPoint(final double x, final double y, final double z) {
minX = Math.min(minX, x);
minY = Math.min(minY, y);
minZ = Math.min(minZ, z);
maxX = Math.max(maxX, x);
maxY = Math.max(maxY, y);
maxZ = Math.max(maxZ, z);
} | [
"public",
"void",
"addPoint",
"(",
"final",
"double",
"x",
",",
"final",
"double",
"y",
",",
"final",
"double",
"z",
")",
"{",
"minX",
"=",
"Math",
".",
"min",
"(",
"minX",
",",
"x",
")",
";",
"minY",
"=",
"Math",
".",
"min",
"(",
"minY",
",",
"y",
")",
";",
"minZ",
"=",
"Math",
".",
"min",
"(",
"minZ",
",",
"z",
")",
";",
"maxX",
"=",
"Math",
".",
"max",
"(",
"maxX",
",",
"x",
")",
";",
"maxY",
"=",
"Math",
".",
"max",
"(",
"maxY",
",",
"y",
")",
";",
"maxZ",
"=",
"Math",
".",
"max",
"(",
"maxZ",
",",
"z",
")",
";",
"}"
] | Increases the bounds to include a given point.
<p>If the point is already in the interior of the bounded
area the bounds are not changed.</p>
@param x Coordinate of the point to include.
@param y Coordinate of the point to include.
@param z Coordinate of the point to include. | [
"Increases",
"the",
"bounds",
"to",
"include",
"a",
"given",
"point",
".",
"<p",
">",
"If",
"the",
"point",
"is",
"already",
"in",
"the",
"interior",
"of",
"the",
"bounded",
"area",
"the",
"bounds",
"are",
"not",
"changed",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/smurn/jPLY/blob/77cb8c47fff7549ae1da8d8568ad8bdf374fe89f/jply/src/main/java/org/smurn/jply/util/RectBounds.java#L70-L77 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/query/impl/getters/SuffixModifierUtils.java | SuffixModifierUtils.getModifierSuffix | public static String getModifierSuffix(String fullName, String baseName) {
"""
Get modifier suffix if fullName contains any otherwise returns null.
In contains no validation of input parameters as it assumes the validation
has been already done by {@link #removeModifierSuffix(String)}
@param fullName
@param baseName as returned by {@link #removeModifierSuffix(String)}
@return modifier suffix or null if no suffix is present
"""
if (fullName.equals(baseName)) {
return null;
}
int indexOfOpeningBracket = fullName.indexOf(MODIFIER_OPENING_TOKEN);
return fullName.substring(indexOfOpeningBracket, fullName.length());
} | java | public static String getModifierSuffix(String fullName, String baseName) {
if (fullName.equals(baseName)) {
return null;
}
int indexOfOpeningBracket = fullName.indexOf(MODIFIER_OPENING_TOKEN);
return fullName.substring(indexOfOpeningBracket, fullName.length());
} | [
"public",
"static",
"String",
"getModifierSuffix",
"(",
"String",
"fullName",
",",
"String",
"baseName",
")",
"{",
"if",
"(",
"fullName",
".",
"equals",
"(",
"baseName",
")",
")",
"{",
"return",
"null",
";",
"}",
"int",
"indexOfOpeningBracket",
"=",
"fullName",
".",
"indexOf",
"(",
"MODIFIER_OPENING_TOKEN",
")",
";",
"return",
"fullName",
".",
"substring",
"(",
"indexOfOpeningBracket",
",",
"fullName",
".",
"length",
"(",
")",
")",
";",
"}"
] | Get modifier suffix if fullName contains any otherwise returns null.
In contains no validation of input parameters as it assumes the validation
has been already done by {@link #removeModifierSuffix(String)}
@param fullName
@param baseName as returned by {@link #removeModifierSuffix(String)}
@return modifier suffix or null if no suffix is present | [
"Get",
"modifier",
"suffix",
"if",
"fullName",
"contains",
"any",
"otherwise",
"returns",
"null",
"."
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/query/impl/getters/SuffixModifierUtils.java#L74-L80 |
jamesagnew/hapi-fhir | hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/filters/Remove_First.java | Remove_First.apply | @Override
public Object apply(Object value, Object... params) {
"""
/*
remove_first(input, string)
remove the first occurrences of a substring
"""
String original = super.asString(value);
Object needle = super.get(0, params);
if (needle == null) {
throw new RuntimeException("invalid pattern: " + needle);
}
return original.replaceFirst(Pattern.quote(String.valueOf(needle)), "");
} | java | @Override
public Object apply(Object value, Object... params) {
String original = super.asString(value);
Object needle = super.get(0, params);
if (needle == null) {
throw new RuntimeException("invalid pattern: " + needle);
}
return original.replaceFirst(Pattern.quote(String.valueOf(needle)), "");
} | [
"@",
"Override",
"public",
"Object",
"apply",
"(",
"Object",
"value",
",",
"Object",
"...",
"params",
")",
"{",
"String",
"original",
"=",
"super",
".",
"asString",
"(",
"value",
")",
";",
"Object",
"needle",
"=",
"super",
".",
"get",
"(",
"0",
",",
"params",
")",
";",
"if",
"(",
"needle",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"invalid pattern: \"",
"+",
"needle",
")",
";",
"}",
"return",
"original",
".",
"replaceFirst",
"(",
"Pattern",
".",
"quote",
"(",
"String",
".",
"valueOf",
"(",
"needle",
")",
")",
",",
"\"\"",
")",
";",
"}"
] | /*
remove_first(input, string)
remove the first occurrences of a substring | [
"/",
"*",
"remove_first",
"(",
"input",
"string",
")"
] | train | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/filters/Remove_First.java#L12-L24 |
wcm-io/wcm-io-tooling | commons/content-package-builder/src/main/java/io/wcm/tooling/commons/contentpackagebuilder/XmlContentBuilder.java | XmlContentBuilder.buildContent | public Document buildContent(Map<String, Object> content) {
"""
Build XML for any JCR content.
@param content Content with properties and nested nodes
@return JCR XML
"""
Document doc = documentBuilder.newDocument();
String primaryType = StringUtils.defaultString((String)content.get(PN_PRIMARY_TYPE), NT_UNSTRUCTURED);
Element jcrRoot = createJcrRoot(doc, primaryType);
exportPayload(doc, jcrRoot, content);
return doc;
} | java | public Document buildContent(Map<String, Object> content) {
Document doc = documentBuilder.newDocument();
String primaryType = StringUtils.defaultString((String)content.get(PN_PRIMARY_TYPE), NT_UNSTRUCTURED);
Element jcrRoot = createJcrRoot(doc, primaryType);
exportPayload(doc, jcrRoot, content);
return doc;
} | [
"public",
"Document",
"buildContent",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"content",
")",
"{",
"Document",
"doc",
"=",
"documentBuilder",
".",
"newDocument",
"(",
")",
";",
"String",
"primaryType",
"=",
"StringUtils",
".",
"defaultString",
"(",
"(",
"String",
")",
"content",
".",
"get",
"(",
"PN_PRIMARY_TYPE",
")",
",",
"NT_UNSTRUCTURED",
")",
";",
"Element",
"jcrRoot",
"=",
"createJcrRoot",
"(",
"doc",
",",
"primaryType",
")",
";",
"exportPayload",
"(",
"doc",
",",
"jcrRoot",
",",
"content",
")",
";",
"return",
"doc",
";",
"}"
] | Build XML for any JCR content.
@param content Content with properties and nested nodes
@return JCR XML | [
"Build",
"XML",
"for",
"any",
"JCR",
"content",
"."
] | train | https://github.com/wcm-io/wcm-io-tooling/blob/1abcd01dd3ad4cc248f03b431f929573d84fa9b4/commons/content-package-builder/src/main/java/io/wcm/tooling/commons/contentpackagebuilder/XmlContentBuilder.java#L119-L128 |
tractionsoftware/gwt-traction | src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImplShared.java | UTCTimeBoxImplShared.parseUsingFallbacksWithColon | protected static final Long parseUsingFallbacksWithColon(String text, DateTimeFormat timeFormat) {
"""
Attempts to insert a colon so that a value without a colon can
be parsed.
"""
if (text.indexOf(':') == -1) {
text = text.replace(" ", "");
int numdigits = 0;
int lastdigit = 0;
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (Character.isDigit(c)) {
numdigits++;
lastdigit = i;
}
}
if (numdigits == 1 || numdigits == 2) {
// insert :00
int colon = lastdigit + 1;
text = text.substring(0, colon) + ":00" + text.substring(colon);
}
else if (numdigits > 2) {
// insert :
int colon = lastdigit - 1;
text = text.substring(0, colon) + ":" + text.substring(colon);
}
return parseUsingFallbacks(text, timeFormat);
}
else {
return null;
}
} | java | protected static final Long parseUsingFallbacksWithColon(String text, DateTimeFormat timeFormat) {
if (text.indexOf(':') == -1) {
text = text.replace(" ", "");
int numdigits = 0;
int lastdigit = 0;
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (Character.isDigit(c)) {
numdigits++;
lastdigit = i;
}
}
if (numdigits == 1 || numdigits == 2) {
// insert :00
int colon = lastdigit + 1;
text = text.substring(0, colon) + ":00" + text.substring(colon);
}
else if (numdigits > 2) {
// insert :
int colon = lastdigit - 1;
text = text.substring(0, colon) + ":" + text.substring(colon);
}
return parseUsingFallbacks(text, timeFormat);
}
else {
return null;
}
} | [
"protected",
"static",
"final",
"Long",
"parseUsingFallbacksWithColon",
"(",
"String",
"text",
",",
"DateTimeFormat",
"timeFormat",
")",
"{",
"if",
"(",
"text",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"-",
"1",
")",
"{",
"text",
"=",
"text",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
";",
"int",
"numdigits",
"=",
"0",
";",
"int",
"lastdigit",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"text",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"text",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"Character",
".",
"isDigit",
"(",
"c",
")",
")",
"{",
"numdigits",
"++",
";",
"lastdigit",
"=",
"i",
";",
"}",
"}",
"if",
"(",
"numdigits",
"==",
"1",
"||",
"numdigits",
"==",
"2",
")",
"{",
"// insert :00",
"int",
"colon",
"=",
"lastdigit",
"+",
"1",
";",
"text",
"=",
"text",
".",
"substring",
"(",
"0",
",",
"colon",
")",
"+",
"\":00\"",
"+",
"text",
".",
"substring",
"(",
"colon",
")",
";",
"}",
"else",
"if",
"(",
"numdigits",
">",
"2",
")",
"{",
"// insert :",
"int",
"colon",
"=",
"lastdigit",
"-",
"1",
";",
"text",
"=",
"text",
".",
"substring",
"(",
"0",
",",
"colon",
")",
"+",
"\":\"",
"+",
"text",
".",
"substring",
"(",
"colon",
")",
";",
"}",
"return",
"parseUsingFallbacks",
"(",
"text",
",",
"timeFormat",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Attempts to insert a colon so that a value without a colon can
be parsed. | [
"Attempts",
"to",
"insert",
"a",
"colon",
"so",
"that",
"a",
"value",
"without",
"a",
"colon",
"can",
"be",
"parsed",
"."
] | train | https://github.com/tractionsoftware/gwt-traction/blob/efc1423c619439763fb064b777b7235e9ce414a3/src/main/java/com/tractionsoftware/gwt/user/client/ui/impl/UTCTimeBoxImplShared.java#L129-L156 |
Viascom/groundwork | foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/util/BasicAuthUtil.java | BasicAuthUtil.getBasicAuthenticationEncoding | public static String getBasicAuthenticationEncoding(String username, String password) throws FoxHttpRequestException {
"""
Create user:password string for authentication.
@return user:password string
"""
String userPassword = username + ":" + password;
Class<?> base64;
try {
base64 = Class.forName("java.util.Base64");
Object objectToInvokeOn = base64.getEnclosingClass();
Method encoderMethod = base64.getDeclaredMethod("getEncoder");
Object encoder = encoderMethod.invoke(objectToInvokeOn);
Method method = encoder.getClass().getDeclaredMethod("encodeToString", byte[].class);
return (String) (method.invoke(encoder, (Object) userPassword.getBytes()));
} catch (ClassNotFoundException e) {
try {
base64 = Class.forName("android.util.Base64");
Object objectToInvokeOn = base64.getEnclosingClass();
Method encoderMethod = base64.getDeclaredMethod("encodeToString", byte[].class, int.class);
return (String) (encoderMethod.invoke(objectToInvokeOn, userPassword.getBytes(), 2));
} catch (Exception e1) {
throw new FoxHttpRequestException(e1);
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new FoxHttpRequestException(e);
}
} | java | public static String getBasicAuthenticationEncoding(String username, String password) throws FoxHttpRequestException {
String userPassword = username + ":" + password;
Class<?> base64;
try {
base64 = Class.forName("java.util.Base64");
Object objectToInvokeOn = base64.getEnclosingClass();
Method encoderMethod = base64.getDeclaredMethod("getEncoder");
Object encoder = encoderMethod.invoke(objectToInvokeOn);
Method method = encoder.getClass().getDeclaredMethod("encodeToString", byte[].class);
return (String) (method.invoke(encoder, (Object) userPassword.getBytes()));
} catch (ClassNotFoundException e) {
try {
base64 = Class.forName("android.util.Base64");
Object objectToInvokeOn = base64.getEnclosingClass();
Method encoderMethod = base64.getDeclaredMethod("encodeToString", byte[].class, int.class);
return (String) (encoderMethod.invoke(objectToInvokeOn, userPassword.getBytes(), 2));
} catch (Exception e1) {
throw new FoxHttpRequestException(e1);
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new FoxHttpRequestException(e);
}
} | [
"public",
"static",
"String",
"getBasicAuthenticationEncoding",
"(",
"String",
"username",
",",
"String",
"password",
")",
"throws",
"FoxHttpRequestException",
"{",
"String",
"userPassword",
"=",
"username",
"+",
"\":\"",
"+",
"password",
";",
"Class",
"<",
"?",
">",
"base64",
";",
"try",
"{",
"base64",
"=",
"Class",
".",
"forName",
"(",
"\"java.util.Base64\"",
")",
";",
"Object",
"objectToInvokeOn",
"=",
"base64",
".",
"getEnclosingClass",
"(",
")",
";",
"Method",
"encoderMethod",
"=",
"base64",
".",
"getDeclaredMethod",
"(",
"\"getEncoder\"",
")",
";",
"Object",
"encoder",
"=",
"encoderMethod",
".",
"invoke",
"(",
"objectToInvokeOn",
")",
";",
"Method",
"method",
"=",
"encoder",
".",
"getClass",
"(",
")",
".",
"getDeclaredMethod",
"(",
"\"encodeToString\"",
",",
"byte",
"[",
"]",
".",
"class",
")",
";",
"return",
"(",
"String",
")",
"(",
"method",
".",
"invoke",
"(",
"encoder",
",",
"(",
"Object",
")",
"userPassword",
".",
"getBytes",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"try",
"{",
"base64",
"=",
"Class",
".",
"forName",
"(",
"\"android.util.Base64\"",
")",
";",
"Object",
"objectToInvokeOn",
"=",
"base64",
".",
"getEnclosingClass",
"(",
")",
";",
"Method",
"encoderMethod",
"=",
"base64",
".",
"getDeclaredMethod",
"(",
"\"encodeToString\"",
",",
"byte",
"[",
"]",
".",
"class",
",",
"int",
".",
"class",
")",
";",
"return",
"(",
"String",
")",
"(",
"encoderMethod",
".",
"invoke",
"(",
"objectToInvokeOn",
",",
"userPassword",
".",
"getBytes",
"(",
")",
",",
"2",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e1",
")",
"{",
"throw",
"new",
"FoxHttpRequestException",
"(",
"e1",
")",
";",
"}",
"}",
"catch",
"(",
"NoSuchMethodException",
"|",
"IllegalAccessException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"FoxHttpRequestException",
"(",
"e",
")",
";",
"}",
"}"
] | Create user:password string for authentication.
@return user:password string | [
"Create",
"user",
":",
"password",
"string",
"for",
"authentication",
"."
] | train | https://github.com/Viascom/groundwork/blob/d3f7d0df65e2e75861fc7db938090683f2cdf919/foxhttp/src/main/java/ch/viascom/groundwork/foxhttp/util/BasicAuthUtil.java#L17-L44 |
davityle/ngAndroid | ng-processor/src/main/java/com/github/davityle/ngprocessor/finders/FileHelper.java | FileHelper.findRootProjectHolder | public Option<FileHolder> findRootProjectHolder() {
"""
We use a dirty trick to find the AndroidManifest.xml file, since it's not
available in the classpath. The idea is quite simple : create a fake
class file, retrieve its URI, and start going up in parent folders to
find the AndroidManifest.xml file. Any better solution will be
appreciated.
"""
Filer filer = processingEnv.getFiler();
FileObject dummySourceFile;
try {
dummySourceFile = filer.createResource(StandardLocation.SOURCE_OUTPUT, "com", "dummy" + System.currentTimeMillis());
} catch (IOException ignored) {
return Option.absent();
}
String dummySourceFilePath = dummySourceFile.toUri().toString();
if (dummySourceFilePath.startsWith("file:")) {
if (!dummySourceFilePath.startsWith("file://")) {
dummySourceFilePath = "file://" + dummySourceFilePath.substring("file:".length());
}
} else {
dummySourceFilePath = "file://" + dummySourceFilePath;
}
URI cleanURI;
try {
cleanURI = new URI(dummySourceFilePath);
} catch (URISyntaxException e) {
return Option.absent();
}
try {
File dummyFile = new File(cleanURI);
File sourcesGenerationFolder = dummyFile.getParentFile();
File projectRoot = sourcesGenerationFolder.getParentFile();
return Option.of(new FileHolder(dummySourceFilePath, sourcesGenerationFolder, projectRoot));
}catch(IllegalArgumentException ex){
return Option.absent();
}
} | java | public Option<FileHolder> findRootProjectHolder() {
Filer filer = processingEnv.getFiler();
FileObject dummySourceFile;
try {
dummySourceFile = filer.createResource(StandardLocation.SOURCE_OUTPUT, "com", "dummy" + System.currentTimeMillis());
} catch (IOException ignored) {
return Option.absent();
}
String dummySourceFilePath = dummySourceFile.toUri().toString();
if (dummySourceFilePath.startsWith("file:")) {
if (!dummySourceFilePath.startsWith("file://")) {
dummySourceFilePath = "file://" + dummySourceFilePath.substring("file:".length());
}
} else {
dummySourceFilePath = "file://" + dummySourceFilePath;
}
URI cleanURI;
try {
cleanURI = new URI(dummySourceFilePath);
} catch (URISyntaxException e) {
return Option.absent();
}
try {
File dummyFile = new File(cleanURI);
File sourcesGenerationFolder = dummyFile.getParentFile();
File projectRoot = sourcesGenerationFolder.getParentFile();
return Option.of(new FileHolder(dummySourceFilePath, sourcesGenerationFolder, projectRoot));
}catch(IllegalArgumentException ex){
return Option.absent();
}
} | [
"public",
"Option",
"<",
"FileHolder",
">",
"findRootProjectHolder",
"(",
")",
"{",
"Filer",
"filer",
"=",
"processingEnv",
".",
"getFiler",
"(",
")",
";",
"FileObject",
"dummySourceFile",
";",
"try",
"{",
"dummySourceFile",
"=",
"filer",
".",
"createResource",
"(",
"StandardLocation",
".",
"SOURCE_OUTPUT",
",",
"\"com\"",
",",
"\"dummy\"",
"+",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ignored",
")",
"{",
"return",
"Option",
".",
"absent",
"(",
")",
";",
"}",
"String",
"dummySourceFilePath",
"=",
"dummySourceFile",
".",
"toUri",
"(",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"dummySourceFilePath",
".",
"startsWith",
"(",
"\"file:\"",
")",
")",
"{",
"if",
"(",
"!",
"dummySourceFilePath",
".",
"startsWith",
"(",
"\"file://\"",
")",
")",
"{",
"dummySourceFilePath",
"=",
"\"file://\"",
"+",
"dummySourceFilePath",
".",
"substring",
"(",
"\"file:\"",
".",
"length",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"dummySourceFilePath",
"=",
"\"file://\"",
"+",
"dummySourceFilePath",
";",
"}",
"URI",
"cleanURI",
";",
"try",
"{",
"cleanURI",
"=",
"new",
"URI",
"(",
"dummySourceFilePath",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"return",
"Option",
".",
"absent",
"(",
")",
";",
"}",
"try",
"{",
"File",
"dummyFile",
"=",
"new",
"File",
"(",
"cleanURI",
")",
";",
"File",
"sourcesGenerationFolder",
"=",
"dummyFile",
".",
"getParentFile",
"(",
")",
";",
"File",
"projectRoot",
"=",
"sourcesGenerationFolder",
".",
"getParentFile",
"(",
")",
";",
"return",
"Option",
".",
"of",
"(",
"new",
"FileHolder",
"(",
"dummySourceFilePath",
",",
"sourcesGenerationFolder",
",",
"projectRoot",
")",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ex",
")",
"{",
"return",
"Option",
".",
"absent",
"(",
")",
";",
"}",
"}"
] | We use a dirty trick to find the AndroidManifest.xml file, since it's not
available in the classpath. The idea is quite simple : create a fake
class file, retrieve its URI, and start going up in parent folders to
find the AndroidManifest.xml file. Any better solution will be
appreciated. | [
"We",
"use",
"a",
"dirty",
"trick",
"to",
"find",
"the",
"AndroidManifest",
".",
"xml",
"file",
"since",
"it",
"s",
"not",
"available",
"in",
"the",
"classpath",
".",
"The",
"idea",
"is",
"quite",
"simple",
":",
"create",
"a",
"fake",
"class",
"file",
"retrieve",
"its",
"URI",
"and",
"start",
"going",
"up",
"in",
"parent",
"folders",
"to",
"find",
"the",
"AndroidManifest",
".",
"xml",
"file",
".",
"Any",
"better",
"solution",
"will",
"be",
"appreciated",
"."
] | train | https://github.com/davityle/ngAndroid/blob/1497a9752cd3d4918035531cd072fd01576328e9/ng-processor/src/main/java/com/github/davityle/ngprocessor/finders/FileHelper.java#L48-L82 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/crdt/CRDTReplicationMigrationService.java | CRDTReplicationMigrationService.scheduleMigrationTask | void scheduleMigrationTask(long delaySeconds) {
"""
Schedules a {@link CRDTMigrationTask} with a delay of {@code delaySeconds}
seconds.
"""
if (nodeEngine.getLocalMember().isLiteMember()) {
return;
}
nodeEngine.getExecutionService().schedule(CRDT_REPLICATION_MIGRATION_EXECUTOR,
new CRDTMigrationTask(nodeEngine, this), delaySeconds, TimeUnit.SECONDS);
} | java | void scheduleMigrationTask(long delaySeconds) {
if (nodeEngine.getLocalMember().isLiteMember()) {
return;
}
nodeEngine.getExecutionService().schedule(CRDT_REPLICATION_MIGRATION_EXECUTOR,
new CRDTMigrationTask(nodeEngine, this), delaySeconds, TimeUnit.SECONDS);
} | [
"void",
"scheduleMigrationTask",
"(",
"long",
"delaySeconds",
")",
"{",
"if",
"(",
"nodeEngine",
".",
"getLocalMember",
"(",
")",
".",
"isLiteMember",
"(",
")",
")",
"{",
"return",
";",
"}",
"nodeEngine",
".",
"getExecutionService",
"(",
")",
".",
"schedule",
"(",
"CRDT_REPLICATION_MIGRATION_EXECUTOR",
",",
"new",
"CRDTMigrationTask",
"(",
"nodeEngine",
",",
"this",
")",
",",
"delaySeconds",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}"
] | Schedules a {@link CRDTMigrationTask} with a delay of {@code delaySeconds}
seconds. | [
"Schedules",
"a",
"{"
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/crdt/CRDTReplicationMigrationService.java#L251-L257 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/patterns/StepPattern.java | StepPattern.getMatchScore | public double getMatchScore(XPathContext xctxt, int context)
throws javax.xml.transform.TransformerException {
"""
Get the match score of the given node.
@param xctxt The XPath runtime context.
@param context The node to be tested.
@return {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
{@link org.apache.xpath.patterns.NodeTest#SCORE_NONE},
{@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
{@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
{@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.
@throws javax.xml.transform.TransformerException
"""
xctxt.pushCurrentNode(context);
xctxt.pushCurrentExpressionNode(context);
try
{
XObject score = execute(xctxt);
return score.num();
}
finally
{
xctxt.popCurrentNode();
xctxt.popCurrentExpressionNode();
}
// return XPath.MATCH_SCORE_NONE;
} | java | public double getMatchScore(XPathContext xctxt, int context)
throws javax.xml.transform.TransformerException
{
xctxt.pushCurrentNode(context);
xctxt.pushCurrentExpressionNode(context);
try
{
XObject score = execute(xctxt);
return score.num();
}
finally
{
xctxt.popCurrentNode();
xctxt.popCurrentExpressionNode();
}
// return XPath.MATCH_SCORE_NONE;
} | [
"public",
"double",
"getMatchScore",
"(",
"XPathContext",
"xctxt",
",",
"int",
"context",
")",
"throws",
"javax",
".",
"xml",
".",
"transform",
".",
"TransformerException",
"{",
"xctxt",
".",
"pushCurrentNode",
"(",
"context",
")",
";",
"xctxt",
".",
"pushCurrentExpressionNode",
"(",
"context",
")",
";",
"try",
"{",
"XObject",
"score",
"=",
"execute",
"(",
"xctxt",
")",
";",
"return",
"score",
".",
"num",
"(",
")",
";",
"}",
"finally",
"{",
"xctxt",
".",
"popCurrentNode",
"(",
")",
";",
"xctxt",
".",
"popCurrentExpressionNode",
"(",
")",
";",
"}",
"// return XPath.MATCH_SCORE_NONE;",
"}"
] | Get the match score of the given node.
@param xctxt The XPath runtime context.
@param context The node to be tested.
@return {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
{@link org.apache.xpath.patterns.NodeTest#SCORE_NONE},
{@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
{@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
{@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.
@throws javax.xml.transform.TransformerException | [
"Get",
"the",
"match",
"score",
"of",
"the",
"given",
"node",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xpath/patterns/StepPattern.java#L892-L912 |
stephanenicolas/robospice | robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/RequestProcessor.java | RequestProcessor.dontNotifyRequestListenersForRequest | public void dontNotifyRequestListenersForRequest(final CachedSpiceRequest<?> request, final Collection<RequestListener<?>> listRequestListener) {
"""
Disable request listeners notifications for a specific request.<br/>
All listeners associated to this request won't be called when request
will finish.<br/>
@param request
Request on which you want to disable listeners
@param listRequestListener
the collection of listeners associated to request not to be
notified
"""
requestProgressManager.dontNotifyRequestListenersForRequest(request, listRequestListener);
} | java | public void dontNotifyRequestListenersForRequest(final CachedSpiceRequest<?> request, final Collection<RequestListener<?>> listRequestListener) {
requestProgressManager.dontNotifyRequestListenersForRequest(request, listRequestListener);
} | [
"public",
"void",
"dontNotifyRequestListenersForRequest",
"(",
"final",
"CachedSpiceRequest",
"<",
"?",
">",
"request",
",",
"final",
"Collection",
"<",
"RequestListener",
"<",
"?",
">",
">",
"listRequestListener",
")",
"{",
"requestProgressManager",
".",
"dontNotifyRequestListenersForRequest",
"(",
"request",
",",
"listRequestListener",
")",
";",
"}"
] | Disable request listeners notifications for a specific request.<br/>
All listeners associated to this request won't be called when request
will finish.<br/>
@param request
Request on which you want to disable listeners
@param listRequestListener
the collection of listeners associated to request not to be
notified | [
"Disable",
"request",
"listeners",
"notifications",
"for",
"a",
"specific",
"request",
".",
"<br",
"/",
">",
"All",
"listeners",
"associated",
"to",
"this",
"request",
"won",
"t",
"be",
"called",
"when",
"request",
"will",
"finish",
".",
"<br",
"/",
">"
] | train | https://github.com/stephanenicolas/robospice/blob/8bffde88b3534a961a13cab72a8f07a755f0a0fe/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/RequestProcessor.java#L145-L147 |
mirage-sql/mirage | src/main/java/com/miragesql/miragesql/SqlExecutor.java | SqlExecutor.fillIdentityPrimaryKeys | @SuppressWarnings("unchecked")
protected void fillIdentityPrimaryKeys(Object entity, ResultSet rs) throws SQLException {
"""
Sets GenerationType.IDENTITY properties value.
@param entity the entity
@param rs the result set
@throws SQLException if something goes wrong.
"""
BeanDesc beanDesc = beanDescFactory.getBeanDesc(entity.getClass());
int size = beanDesc.getPropertyDescSize();
for(int i=0; i < size; i++){
PropertyDesc propertyDesc = beanDesc.getPropertyDesc(i);
PrimaryKey primaryKey = propertyDesc.getAnnotation(PrimaryKey.class);
if(primaryKey != null && primaryKey.generationType() == GenerationType.IDENTITY){
if(rs.next()){
Class<?> propertyType = propertyDesc.getPropertyType();
@SuppressWarnings("rawtypes")
ValueType valueType = MirageUtil.getValueType(propertyType, propertyDesc, dialect, valueTypes);
if(valueType != null){
propertyDesc.setValue(entity, valueType.get(propertyType, rs, 1));
}
}
}
}
} | java | @SuppressWarnings("unchecked")
protected void fillIdentityPrimaryKeys(Object entity, ResultSet rs) throws SQLException {
BeanDesc beanDesc = beanDescFactory.getBeanDesc(entity.getClass());
int size = beanDesc.getPropertyDescSize();
for(int i=0; i < size; i++){
PropertyDesc propertyDesc = beanDesc.getPropertyDesc(i);
PrimaryKey primaryKey = propertyDesc.getAnnotation(PrimaryKey.class);
if(primaryKey != null && primaryKey.generationType() == GenerationType.IDENTITY){
if(rs.next()){
Class<?> propertyType = propertyDesc.getPropertyType();
@SuppressWarnings("rawtypes")
ValueType valueType = MirageUtil.getValueType(propertyType, propertyDesc, dialect, valueTypes);
if(valueType != null){
propertyDesc.setValue(entity, valueType.get(propertyType, rs, 1));
}
}
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"void",
"fillIdentityPrimaryKeys",
"(",
"Object",
"entity",
",",
"ResultSet",
"rs",
")",
"throws",
"SQLException",
"{",
"BeanDesc",
"beanDesc",
"=",
"beanDescFactory",
".",
"getBeanDesc",
"(",
"entity",
".",
"getClass",
"(",
")",
")",
";",
"int",
"size",
"=",
"beanDesc",
".",
"getPropertyDescSize",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"PropertyDesc",
"propertyDesc",
"=",
"beanDesc",
".",
"getPropertyDesc",
"(",
"i",
")",
";",
"PrimaryKey",
"primaryKey",
"=",
"propertyDesc",
".",
"getAnnotation",
"(",
"PrimaryKey",
".",
"class",
")",
";",
"if",
"(",
"primaryKey",
"!=",
"null",
"&&",
"primaryKey",
".",
"generationType",
"(",
")",
"==",
"GenerationType",
".",
"IDENTITY",
")",
"{",
"if",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"Class",
"<",
"?",
">",
"propertyType",
"=",
"propertyDesc",
".",
"getPropertyType",
"(",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"ValueType",
"valueType",
"=",
"MirageUtil",
".",
"getValueType",
"(",
"propertyType",
",",
"propertyDesc",
",",
"dialect",
",",
"valueTypes",
")",
";",
"if",
"(",
"valueType",
"!=",
"null",
")",
"{",
"propertyDesc",
".",
"setValue",
"(",
"entity",
",",
"valueType",
".",
"get",
"(",
"propertyType",
",",
"rs",
",",
"1",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Sets GenerationType.IDENTITY properties value.
@param entity the entity
@param rs the result set
@throws SQLException if something goes wrong. | [
"Sets",
"GenerationType",
".",
"IDENTITY",
"properties",
"value",
"."
] | train | https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/SqlExecutor.java#L437-L457 |
FINRAOS/DataGenerator | dg-core/src/main/java/org/finra/datagenerator/writer/JsonWriter.java | JsonWriter.getJsonFormatted | public JSONObject getJsonFormatted(Map<String, String> dataMap) {
"""
Given an array of variable names, returns a JsonObject
of values.
@param dataMap an map containing variable names and their corresponding values
names.
@return a json object of values
"""
JSONObject oneRowJson = new JSONObject();
for (int i = 0; i < outTemplate.length; i++) {
oneRowJson.put(outTemplate[i], dataMap.get(outTemplate[i]));
}
return oneRowJson;
} | java | public JSONObject getJsonFormatted(Map<String, String> dataMap) {
JSONObject oneRowJson = new JSONObject();
for (int i = 0; i < outTemplate.length; i++) {
oneRowJson.put(outTemplate[i], dataMap.get(outTemplate[i]));
}
return oneRowJson;
} | [
"public",
"JSONObject",
"getJsonFormatted",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"dataMap",
")",
"{",
"JSONObject",
"oneRowJson",
"=",
"new",
"JSONObject",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"outTemplate",
".",
"length",
";",
"i",
"++",
")",
"{",
"oneRowJson",
".",
"put",
"(",
"outTemplate",
"[",
"i",
"]",
",",
"dataMap",
".",
"get",
"(",
"outTemplate",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"oneRowJson",
";",
"}"
] | Given an array of variable names, returns a JsonObject
of values.
@param dataMap an map containing variable names and their corresponding values
names.
@return a json object of values | [
"Given",
"an",
"array",
"of",
"variable",
"names",
"returns",
"a",
"JsonObject",
"of",
"values",
"."
] | train | https://github.com/FINRAOS/DataGenerator/blob/1f69f949401cbed4db4f553c3eb8350832c4d45a/dg-core/src/main/java/org/finra/datagenerator/writer/JsonWriter.java#L80-L89 |
casbin/jcasbin | src/main/java/org/casbin/jcasbin/main/ManagementEnforcer.java | ManagementEnforcer.removeFilteredNamedGroupingPolicy | public boolean removeFilteredNamedGroupingPolicy(String ptype, int fieldIndex, String... fieldValues) {
"""
removeFilteredNamedGroupingPolicy removes a role inheritance rule from the current named policy, field filters can be specified.
@param ptype the policy type, can be "g", "g2", "g3", ..
@param fieldIndex the policy rule's start index to be matched.
@param fieldValues the field values to be matched, value ""
means not to match this field.
@return succeeds or not.
"""
boolean ruleRemoved = removeFilteredPolicy("g", ptype, fieldIndex, fieldValues);
if (autoBuildRoleLinks) {
buildRoleLinks();
}
return ruleRemoved;
} | java | public boolean removeFilteredNamedGroupingPolicy(String ptype, int fieldIndex, String... fieldValues) {
boolean ruleRemoved = removeFilteredPolicy("g", ptype, fieldIndex, fieldValues);
if (autoBuildRoleLinks) {
buildRoleLinks();
}
return ruleRemoved;
} | [
"public",
"boolean",
"removeFilteredNamedGroupingPolicy",
"(",
"String",
"ptype",
",",
"int",
"fieldIndex",
",",
"String",
"...",
"fieldValues",
")",
"{",
"boolean",
"ruleRemoved",
"=",
"removeFilteredPolicy",
"(",
"\"g\"",
",",
"ptype",
",",
"fieldIndex",
",",
"fieldValues",
")",
";",
"if",
"(",
"autoBuildRoleLinks",
")",
"{",
"buildRoleLinks",
"(",
")",
";",
"}",
"return",
"ruleRemoved",
";",
"}"
] | removeFilteredNamedGroupingPolicy removes a role inheritance rule from the current named policy, field filters can be specified.
@param ptype the policy type, can be "g", "g2", "g3", ..
@param fieldIndex the policy rule's start index to be matched.
@param fieldValues the field values to be matched, value ""
means not to match this field.
@return succeeds or not. | [
"removeFilteredNamedGroupingPolicy",
"removes",
"a",
"role",
"inheritance",
"rule",
"from",
"the",
"current",
"named",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | train | https://github.com/casbin/jcasbin/blob/b46d7a756b6c39cdb17e0600607e5fcdc66edd11/src/main/java/org/casbin/jcasbin/main/ManagementEnforcer.java#L538-L545 |
googleads/googleads-java-lib | modules/ads_lib/src/main/java/com/google/api/ads/common/lib/soap/AuthorizationHeaderHandler.java | AuthorizationHeaderHandler.setAuthorization | @SuppressWarnings("unchecked") /* See constructor comments. */
public void setAuthorization(Object soapClient, AdsSession adsSession)
throws AuthenticationException {
"""
Sets the authorization header created from the session on the soap client.
@param soapClient the SOAP client to set the HTTP header on
@param adsSession the session
@throws AuthenticationException if the authorization header could not be
created
"""
final String authorizationHeader =
authorizationHeaderProvider.getAuthorizationHeader(adsSession,
soapClientHandler.getEndpointAddress(soapClient));
soapClientHandler.putAllHttpHeaders(soapClient, new HashMap<String, String>() {
{
put("Authorization", authorizationHeader);
}
});
} | java | @SuppressWarnings("unchecked") /* See constructor comments. */
public void setAuthorization(Object soapClient, AdsSession adsSession)
throws AuthenticationException {
final String authorizationHeader =
authorizationHeaderProvider.getAuthorizationHeader(adsSession,
soapClientHandler.getEndpointAddress(soapClient));
soapClientHandler.putAllHttpHeaders(soapClient, new HashMap<String, String>() {
{
put("Authorization", authorizationHeader);
}
});
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"/* See constructor comments. */",
"public",
"void",
"setAuthorization",
"(",
"Object",
"soapClient",
",",
"AdsSession",
"adsSession",
")",
"throws",
"AuthenticationException",
"{",
"final",
"String",
"authorizationHeader",
"=",
"authorizationHeaderProvider",
".",
"getAuthorizationHeader",
"(",
"adsSession",
",",
"soapClientHandler",
".",
"getEndpointAddress",
"(",
"soapClient",
")",
")",
";",
"soapClientHandler",
".",
"putAllHttpHeaders",
"(",
"soapClient",
",",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
"{",
"{",
"put",
"(",
"\"Authorization\"",
",",
"authorizationHeader",
")",
";",
"}",
"}",
")",
";",
"}"
] | Sets the authorization header created from the session on the soap client.
@param soapClient the SOAP client to set the HTTP header on
@param adsSession the session
@throws AuthenticationException if the authorization header could not be
created | [
"Sets",
"the",
"authorization",
"header",
"created",
"from",
"the",
"session",
"on",
"the",
"soap",
"client",
"."
] | train | https://github.com/googleads/googleads-java-lib/blob/967957cc4f6076514e3a7926fe653e4f1f7cc9c9/modules/ads_lib/src/main/java/com/google/api/ads/common/lib/soap/AuthorizationHeaderHandler.java#L61-L72 |
craterdog/java-smart-objects | src/main/java/craterdog/smart/SmartObject.java | SmartObject.addSerializableClass | protected void addSerializableClass(Class<?> serializable, Class<?> mixin) {
"""
This protected method allows a subclass to add to the mappers a class type that can be
serialized using mixin class.
@param serializable The type of class that can be serialized using its toString() method.
@param mixin The type of class that can be used to serialized the serializable class.
"""
safeMapper.addMixIn(serializable, mixin);
fullMapper.addMixIn(serializable, mixin);
} | java | protected void addSerializableClass(Class<?> serializable, Class<?> mixin) {
safeMapper.addMixIn(serializable, mixin);
fullMapper.addMixIn(serializable, mixin);
} | [
"protected",
"void",
"addSerializableClass",
"(",
"Class",
"<",
"?",
">",
"serializable",
",",
"Class",
"<",
"?",
">",
"mixin",
")",
"{",
"safeMapper",
".",
"addMixIn",
"(",
"serializable",
",",
"mixin",
")",
";",
"fullMapper",
".",
"addMixIn",
"(",
"serializable",
",",
"mixin",
")",
";",
"}"
] | This protected method allows a subclass to add to the mappers a class type that can be
serialized using mixin class.
@param serializable The type of class that can be serialized using its toString() method.
@param mixin The type of class that can be used to serialized the serializable class. | [
"This",
"protected",
"method",
"allows",
"a",
"subclass",
"to",
"add",
"to",
"the",
"mappers",
"a",
"class",
"type",
"that",
"can",
"be",
"serialized",
"using",
"mixin",
"class",
"."
] | train | https://github.com/craterdog/java-smart-objects/blob/6d11e2f345e4d2836e3aca3990c8ed2db330d856/src/main/java/craterdog/smart/SmartObject.java#L265-L268 |
sarl/sarl | main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/markdown/MarkdownParser.java | MarkdownParser.formatSectionTitle | protected String formatSectionTitle(String prefix, String sectionNumber, String title, String sectionId) {
"""
Format the section title.
@param prefix the Markdown prefix.
@param sectionNumber the section number.
@param title the section title.
@param sectionId the identifier of the section.
@return the formatted section title.
"""
return MessageFormat.format(getSectionTitleFormat(), prefix, sectionNumber, title, sectionId) + "\n"; //$NON-NLS-1$
} | java | protected String formatSectionTitle(String prefix, String sectionNumber, String title, String sectionId) {
return MessageFormat.format(getSectionTitleFormat(), prefix, sectionNumber, title, sectionId) + "\n"; //$NON-NLS-1$
} | [
"protected",
"String",
"formatSectionTitle",
"(",
"String",
"prefix",
",",
"String",
"sectionNumber",
",",
"String",
"title",
",",
"String",
"sectionId",
")",
"{",
"return",
"MessageFormat",
".",
"format",
"(",
"getSectionTitleFormat",
"(",
")",
",",
"prefix",
",",
"sectionNumber",
",",
"title",
",",
"sectionId",
")",
"+",
"\"\\n\"",
";",
"//$NON-NLS-1$",
"}"
] | Format the section title.
@param prefix the Markdown prefix.
@param sectionNumber the section number.
@param title the section title.
@param sectionId the identifier of the section.
@return the formatted section title. | [
"Format",
"the",
"section",
"title",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/externalmaven/io.sarl.maven.docs.generator/src/main/java/io/sarl/maven/docs/markdown/MarkdownParser.java#L955-L957 |
cdk/cdk | tool/tautomer/src/main/java/org/openscience/cdk/tautomers/InChITautomerGenerator.java | InChITautomerGenerator.getConnectivity | private int getConnectivity(IAtom atom, IAtomContainer container) {
"""
Sums the number of bonds (counting order) an atom is hooked up with.
@param atom an atom in the container
@param container the container
@return valence (bond order sum) of the atom
"""
int connectivity = 0;
for (IBond bond : container.bonds()) {
if (bond.contains(atom)) {
switch (bond.getOrder()) {
case SINGLE:
connectivity++;
break;
case DOUBLE:
connectivity += 2;
break;
case TRIPLE:
connectivity += 3;
break;
case QUADRUPLE:
connectivity += 4;
break;
default:
connectivity += 10;
}
}
}
return connectivity;
} | java | private int getConnectivity(IAtom atom, IAtomContainer container) {
int connectivity = 0;
for (IBond bond : container.bonds()) {
if (bond.contains(atom)) {
switch (bond.getOrder()) {
case SINGLE:
connectivity++;
break;
case DOUBLE:
connectivity += 2;
break;
case TRIPLE:
connectivity += 3;
break;
case QUADRUPLE:
connectivity += 4;
break;
default:
connectivity += 10;
}
}
}
return connectivity;
} | [
"private",
"int",
"getConnectivity",
"(",
"IAtom",
"atom",
",",
"IAtomContainer",
"container",
")",
"{",
"int",
"connectivity",
"=",
"0",
";",
"for",
"(",
"IBond",
"bond",
":",
"container",
".",
"bonds",
"(",
")",
")",
"{",
"if",
"(",
"bond",
".",
"contains",
"(",
"atom",
")",
")",
"{",
"switch",
"(",
"bond",
".",
"getOrder",
"(",
")",
")",
"{",
"case",
"SINGLE",
":",
"connectivity",
"++",
";",
"break",
";",
"case",
"DOUBLE",
":",
"connectivity",
"+=",
"2",
";",
"break",
";",
"case",
"TRIPLE",
":",
"connectivity",
"+=",
"3",
";",
"break",
";",
"case",
"QUADRUPLE",
":",
"connectivity",
"+=",
"4",
";",
"break",
";",
"default",
":",
"connectivity",
"+=",
"10",
";",
"}",
"}",
"}",
"return",
"connectivity",
";",
"}"
] | Sums the number of bonds (counting order) an atom is hooked up with.
@param atom an atom in the container
@param container the container
@return valence (bond order sum) of the atom | [
"Sums",
"the",
"number",
"of",
"bonds",
"(",
"counting",
"order",
")",
"an",
"atom",
"is",
"hooked",
"up",
"with",
"."
] | train | https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/tool/tautomer/src/main/java/org/openscience/cdk/tautomers/InChITautomerGenerator.java#L696-L719 |
BBN-E/bue-common-open | common-core-open/src/main/java/com/bbn/bue/common/ModuleUtils.java | ModuleUtils.classNameToModule | @Nonnull
// it's reflection, can't avoid unchecked cast
@SuppressWarnings("unchecked")
public static Module classNameToModule(final Parameters parameters, final Class<?> clazz,
Optional<? extends Class<? extends Annotation>> annotation)
throws IllegalAccessException, InvocationTargetException, InstantiationException {
"""
Attempts to convert a module class name to an instantiate module by applying heuristics to
construct it.
It first tries to instantiate the provided class itself as a module, if possible. If it is not
a module, it looks for an inner class called "Module",
"FromParametersModule", or "FromParamsModule" which is a {@link Module}.
When instantiating a module, it tries to find a constructor taking parameters and an annotation
(if annotation is present), just an annotation, just parameters, or zero arguments.
"""
if (Module.class.isAssignableFrom(clazz)) {
return instantiateModule((Class<? extends Module>) clazz, parameters, annotation);
} else {
// to abbreviate the names of modules in param files, if a class name is provided which
// is not a Module, we check if there is an inner-class named Module which is a Module
for (final String fallbackInnerClassName : FALLBACK_INNER_CLASS_NAMES) {
final String fullyQualifiedName = clazz.getName() + "$" + fallbackInnerClassName;
final Class<? extends Module> innerModuleClazz;
try {
innerModuleClazz = (Class<? extends Module>) Class.forName(fullyQualifiedName);
} catch (ClassNotFoundException cnfe) {
// it's okay, we just try the next one
continue;
}
if (Module.class.isAssignableFrom(innerModuleClazz)) {
return instantiateModule(innerModuleClazz, parameters, annotation);
} else {
throw new RuntimeException(clazz.getName() + " is not a module; "
+ fullyQualifiedName + " exists but is not a module");
}
}
// if we got here, we didn't find any module
throw new RuntimeException("Could not find inner class of " + clazz.getName()
+ " matching any of " + FALLBACK_INNER_CLASS_NAMES);
}
} | java | @Nonnull
// it's reflection, can't avoid unchecked cast
@SuppressWarnings("unchecked")
public static Module classNameToModule(final Parameters parameters, final Class<?> clazz,
Optional<? extends Class<? extends Annotation>> annotation)
throws IllegalAccessException, InvocationTargetException, InstantiationException {
if (Module.class.isAssignableFrom(clazz)) {
return instantiateModule((Class<? extends Module>) clazz, parameters, annotation);
} else {
// to abbreviate the names of modules in param files, if a class name is provided which
// is not a Module, we check if there is an inner-class named Module which is a Module
for (final String fallbackInnerClassName : FALLBACK_INNER_CLASS_NAMES) {
final String fullyQualifiedName = clazz.getName() + "$" + fallbackInnerClassName;
final Class<? extends Module> innerModuleClazz;
try {
innerModuleClazz = (Class<? extends Module>) Class.forName(fullyQualifiedName);
} catch (ClassNotFoundException cnfe) {
// it's okay, we just try the next one
continue;
}
if (Module.class.isAssignableFrom(innerModuleClazz)) {
return instantiateModule(innerModuleClazz, parameters, annotation);
} else {
throw new RuntimeException(clazz.getName() + " is not a module; "
+ fullyQualifiedName + " exists but is not a module");
}
}
// if we got here, we didn't find any module
throw new RuntimeException("Could not find inner class of " + clazz.getName()
+ " matching any of " + FALLBACK_INNER_CLASS_NAMES);
}
} | [
"@",
"Nonnull",
"// it's reflection, can't avoid unchecked cast",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Module",
"classNameToModule",
"(",
"final",
"Parameters",
"parameters",
",",
"final",
"Class",
"<",
"?",
">",
"clazz",
",",
"Optional",
"<",
"?",
"extends",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
">",
"annotation",
")",
"throws",
"IllegalAccessException",
",",
"InvocationTargetException",
",",
"InstantiationException",
"{",
"if",
"(",
"Module",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
")",
"{",
"return",
"instantiateModule",
"(",
"(",
"Class",
"<",
"?",
"extends",
"Module",
">",
")",
"clazz",
",",
"parameters",
",",
"annotation",
")",
";",
"}",
"else",
"{",
"// to abbreviate the names of modules in param files, if a class name is provided which",
"// is not a Module, we check if there is an inner-class named Module which is a Module",
"for",
"(",
"final",
"String",
"fallbackInnerClassName",
":",
"FALLBACK_INNER_CLASS_NAMES",
")",
"{",
"final",
"String",
"fullyQualifiedName",
"=",
"clazz",
".",
"getName",
"(",
")",
"+",
"\"$\"",
"+",
"fallbackInnerClassName",
";",
"final",
"Class",
"<",
"?",
"extends",
"Module",
">",
"innerModuleClazz",
";",
"try",
"{",
"innerModuleClazz",
"=",
"(",
"Class",
"<",
"?",
"extends",
"Module",
">",
")",
"Class",
".",
"forName",
"(",
"fullyQualifiedName",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"cnfe",
")",
"{",
"// it's okay, we just try the next one",
"continue",
";",
"}",
"if",
"(",
"Module",
".",
"class",
".",
"isAssignableFrom",
"(",
"innerModuleClazz",
")",
")",
"{",
"return",
"instantiateModule",
"(",
"innerModuleClazz",
",",
"parameters",
",",
"annotation",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"clazz",
".",
"getName",
"(",
")",
"+",
"\" is not a module; \"",
"+",
"fullyQualifiedName",
"+",
"\" exists but is not a module\"",
")",
";",
"}",
"}",
"// if we got here, we didn't find any module",
"throw",
"new",
"RuntimeException",
"(",
"\"Could not find inner class of \"",
"+",
"clazz",
".",
"getName",
"(",
")",
"+",
"\" matching any of \"",
"+",
"FALLBACK_INNER_CLASS_NAMES",
")",
";",
"}",
"}"
] | Attempts to convert a module class name to an instantiate module by applying heuristics to
construct it.
It first tries to instantiate the provided class itself as a module, if possible. If it is not
a module, it looks for an inner class called "Module",
"FromParametersModule", or "FromParamsModule" which is a {@link Module}.
When instantiating a module, it tries to find a constructor taking parameters and an annotation
(if annotation is present), just an annotation, just parameters, or zero arguments. | [
"Attempts",
"to",
"convert",
"a",
"module",
"class",
"name",
"to",
"an",
"instantiate",
"module",
"by",
"applying",
"heuristics",
"to",
"construct",
"it",
"."
] | train | https://github.com/BBN-E/bue-common-open/blob/d618652674d647867306e2e4b987a21b7c29c015/common-core-open/src/main/java/com/bbn/bue/common/ModuleUtils.java#L47-L80 |
joniles/mpxj | src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java | UniversalProjectReader.handleByteOrderMark | private ProjectFile handleByteOrderMark(InputStream stream, int length, Charset charset) throws Exception {
"""
The file we are working with has a byte order mark. Skip this and try again to read the file.
@param stream schedule data
@param length length of the byte order mark
@param charset charset indicated by byte order mark
@return ProjectFile instance
"""
UniversalProjectReader reader = new UniversalProjectReader();
reader.setSkipBytes(length);
reader.setCharset(charset);
return reader.read(stream);
} | java | private ProjectFile handleByteOrderMark(InputStream stream, int length, Charset charset) throws Exception
{
UniversalProjectReader reader = new UniversalProjectReader();
reader.setSkipBytes(length);
reader.setCharset(charset);
return reader.read(stream);
} | [
"private",
"ProjectFile",
"handleByteOrderMark",
"(",
"InputStream",
"stream",
",",
"int",
"length",
",",
"Charset",
"charset",
")",
"throws",
"Exception",
"{",
"UniversalProjectReader",
"reader",
"=",
"new",
"UniversalProjectReader",
"(",
")",
";",
"reader",
".",
"setSkipBytes",
"(",
"length",
")",
";",
"reader",
".",
"setCharset",
"(",
"charset",
")",
";",
"return",
"reader",
".",
"read",
"(",
"stream",
")",
";",
"}"
] | The file we are working with has a byte order mark. Skip this and try again to read the file.
@param stream schedule data
@param length length of the byte order mark
@param charset charset indicated by byte order mark
@return ProjectFile instance | [
"The",
"file",
"we",
"are",
"working",
"with",
"has",
"a",
"byte",
"order",
"mark",
".",
"Skip",
"this",
"and",
"try",
"again",
"to",
"read",
"the",
"file",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L674-L680 |
larsga/Duke | duke-core/src/main/java/no/priv/garshol/duke/utils/ObjectUtils.java | ObjectUtils.getEnumConstantByName | public static Object getEnumConstantByName(Class klass, String name) {
"""
Returns the enum constant from the given enum class representing
the constant with the given identifier/name.
"""
name = name.toUpperCase();
Object c[] = klass.getEnumConstants();
for (int ix = 0; ix < c.length; ix++)
if (c[ix].toString().equals(name))
return c[ix];
throw new DukeConfigException("No such " + klass + ": '" + name + "'");
} | java | public static Object getEnumConstantByName(Class klass, String name) {
name = name.toUpperCase();
Object c[] = klass.getEnumConstants();
for (int ix = 0; ix < c.length; ix++)
if (c[ix].toString().equals(name))
return c[ix];
throw new DukeConfigException("No such " + klass + ": '" + name + "'");
} | [
"public",
"static",
"Object",
"getEnumConstantByName",
"(",
"Class",
"klass",
",",
"String",
"name",
")",
"{",
"name",
"=",
"name",
".",
"toUpperCase",
"(",
")",
";",
"Object",
"c",
"[",
"]",
"=",
"klass",
".",
"getEnumConstants",
"(",
")",
";",
"for",
"(",
"int",
"ix",
"=",
"0",
";",
"ix",
"<",
"c",
".",
"length",
";",
"ix",
"++",
")",
"if",
"(",
"c",
"[",
"ix",
"]",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"return",
"c",
"[",
"ix",
"]",
";",
"throw",
"new",
"DukeConfigException",
"(",
"\"No such \"",
"+",
"klass",
"+",
"\": '\"",
"+",
"name",
"+",
"\"'\"",
")",
";",
"}"
] | Returns the enum constant from the given enum class representing
the constant with the given identifier/name. | [
"Returns",
"the",
"enum",
"constant",
"from",
"the",
"given",
"enum",
"class",
"representing",
"the",
"constant",
"with",
"the",
"given",
"identifier",
"/",
"name",
"."
] | train | https://github.com/larsga/Duke/blob/6263f9c6e984c26362a76241c7c7ea3bb4469bac/duke-core/src/main/java/no/priv/garshol/duke/utils/ObjectUtils.java#L19-L26 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java | AjaxAddableTabbedPanel.newAddTabButtonLabel | protected Label newAddTabButtonLabel(final String id, final IModel<String> model) {
"""
Factory method for creating the new label of the button.
@param id
the id
@param model
the model
@return the new label of the button.
"""
return ComponentFactory.newLabel(id, model);
} | java | protected Label newAddTabButtonLabel(final String id, final IModel<String> model)
{
return ComponentFactory.newLabel(id, model);
} | [
"protected",
"Label",
"newAddTabButtonLabel",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"String",
">",
"model",
")",
"{",
"return",
"ComponentFactory",
".",
"newLabel",
"(",
"id",
",",
"model",
")",
";",
"}"
] | Factory method for creating the new label of the button.
@param id
the id
@param model
the model
@return the new label of the button. | [
"Factory",
"method",
"for",
"creating",
"the",
"new",
"label",
"of",
"the",
"button",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/ajax/editable/tabs/AjaxAddableTabbedPanel.java#L315-L318 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/math/ArrayMath.java | ArrayMath.pearsonCorrelation | public static double pearsonCorrelation(double[] x, double[] y) {
"""
Direct computation of Pearson product-moment correlation coefficient.
Note that if x and y are involved in several computations of
pearsonCorrelation, it is perhaps more advisable to first standardize
x and y, then compute innerProduct(x,y)/(x.length-1).
"""
double result;
double sum_sq_x = 0, sum_sq_y = 0;
double mean_x = x[0], mean_y = y[0];
double sum_coproduct = 0;
for(int i=2; i<x.length+1;++i) {
double w = (i - 1)*1.0/i;
double delta_x = x[i-1] - mean_x;
double delta_y = y[i-1] - mean_y;
sum_sq_x += delta_x * delta_x*w;
sum_sq_y += delta_y * delta_y*w;
sum_coproduct += delta_x * delta_y*w;
mean_x += delta_x / i;
mean_y += delta_y / i;
}
double pop_sd_x = Math.sqrt(sum_sq_x/x.length);
double pop_sd_y = Math.sqrt(sum_sq_y/y.length);
double cov_x_y = sum_coproduct / x.length;
double denom = pop_sd_x*pop_sd_y;
if(denom == 0.0)
return 0.0;
result = cov_x_y/denom;
return result;
} | java | public static double pearsonCorrelation(double[] x, double[] y) {
double result;
double sum_sq_x = 0, sum_sq_y = 0;
double mean_x = x[0], mean_y = y[0];
double sum_coproduct = 0;
for(int i=2; i<x.length+1;++i) {
double w = (i - 1)*1.0/i;
double delta_x = x[i-1] - mean_x;
double delta_y = y[i-1] - mean_y;
sum_sq_x += delta_x * delta_x*w;
sum_sq_y += delta_y * delta_y*w;
sum_coproduct += delta_x * delta_y*w;
mean_x += delta_x / i;
mean_y += delta_y / i;
}
double pop_sd_x = Math.sqrt(sum_sq_x/x.length);
double pop_sd_y = Math.sqrt(sum_sq_y/y.length);
double cov_x_y = sum_coproduct / x.length;
double denom = pop_sd_x*pop_sd_y;
if(denom == 0.0)
return 0.0;
result = cov_x_y/denom;
return result;
} | [
"public",
"static",
"double",
"pearsonCorrelation",
"(",
"double",
"[",
"]",
"x",
",",
"double",
"[",
"]",
"y",
")",
"{",
"double",
"result",
";",
"double",
"sum_sq_x",
"=",
"0",
",",
"sum_sq_y",
"=",
"0",
";",
"double",
"mean_x",
"=",
"x",
"[",
"0",
"]",
",",
"mean_y",
"=",
"y",
"[",
"0",
"]",
";",
"double",
"sum_coproduct",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"2",
";",
"i",
"<",
"x",
".",
"length",
"+",
"1",
";",
"++",
"i",
")",
"{",
"double",
"w",
"=",
"(",
"i",
"-",
"1",
")",
"*",
"1.0",
"/",
"i",
";",
"double",
"delta_x",
"=",
"x",
"[",
"i",
"-",
"1",
"]",
"-",
"mean_x",
";",
"double",
"delta_y",
"=",
"y",
"[",
"i",
"-",
"1",
"]",
"-",
"mean_y",
";",
"sum_sq_x",
"+=",
"delta_x",
"*",
"delta_x",
"*",
"w",
";",
"sum_sq_y",
"+=",
"delta_y",
"*",
"delta_y",
"*",
"w",
";",
"sum_coproduct",
"+=",
"delta_x",
"*",
"delta_y",
"*",
"w",
";",
"mean_x",
"+=",
"delta_x",
"/",
"i",
";",
"mean_y",
"+=",
"delta_y",
"/",
"i",
";",
"}",
"double",
"pop_sd_x",
"=",
"Math",
".",
"sqrt",
"(",
"sum_sq_x",
"/",
"x",
".",
"length",
")",
";",
"double",
"pop_sd_y",
"=",
"Math",
".",
"sqrt",
"(",
"sum_sq_y",
"/",
"y",
".",
"length",
")",
";",
"double",
"cov_x_y",
"=",
"sum_coproduct",
"/",
"x",
".",
"length",
";",
"double",
"denom",
"=",
"pop_sd_x",
"*",
"pop_sd_y",
";",
"if",
"(",
"denom",
"==",
"0.0",
")",
"return",
"0.0",
";",
"result",
"=",
"cov_x_y",
"/",
"denom",
";",
"return",
"result",
";",
"}"
] | Direct computation of Pearson product-moment correlation coefficient.
Note that if x and y are involved in several computations of
pearsonCorrelation, it is perhaps more advisable to first standardize
x and y, then compute innerProduct(x,y)/(x.length-1). | [
"Direct",
"computation",
"of",
"Pearson",
"product",
"-",
"moment",
"correlation",
"coefficient",
".",
"Note",
"that",
"if",
"x",
"and",
"y",
"are",
"involved",
"in",
"several",
"computations",
"of",
"pearsonCorrelation",
"it",
"is",
"perhaps",
"more",
"advisable",
"to",
"first",
"standardize",
"x",
"and",
"y",
"then",
"compute",
"innerProduct",
"(",
"x",
"y",
")",
"/",
"(",
"x",
".",
"length",
"-",
"1",
")",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/math/ArrayMath.java#L1450-L1473 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java | JBBPDslBuilder.DoubleArray | public JBBPDslBuilder DoubleArray(final String name, final String sizeExpression) {
"""
Add named double array field which size calculated trough expression.
@param name name of the field, can be null for anonymous
@param sizeExpression expression to be used to calculate array size, must not be null
@return the builder instance, must not be null
"""
final Item item = new Item(BinType.DOUBLE_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | java | public JBBPDslBuilder DoubleArray(final String name, final String sizeExpression) {
final Item item = new Item(BinType.DOUBLE_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | [
"public",
"JBBPDslBuilder",
"DoubleArray",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"sizeExpression",
")",
"{",
"final",
"Item",
"item",
"=",
"new",
"Item",
"(",
"BinType",
".",
"DOUBLE_ARRAY",
",",
"name",
",",
"this",
".",
"byteOrder",
")",
";",
"item",
".",
"sizeExpression",
"=",
"assertExpressionChars",
"(",
"sizeExpression",
")",
";",
"this",
".",
"addItem",
"(",
"item",
")",
";",
"return",
"this",
";",
"}"
] | Add named double array field which size calculated trough expression.
@param name name of the field, can be null for anonymous
@param sizeExpression expression to be used to calculate array size, must not be null
@return the builder instance, must not be null | [
"Add",
"named",
"double",
"array",
"field",
"which",
"size",
"calculated",
"trough",
"expression",
"."
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L1356-L1361 |
pwittchen/ReactiveWiFi | library/src/main/java/com/github/pwittchen/reactivewifi/ReactiveWifi.java | ReactiveWifi.observeWifiSignalLevel | @RequiresPermission(ACCESS_WIFI_STATE)
public static Observable<WifiSignalLevel> observeWifiSignalLevel(final Context context) {
"""
Observes WiFi signal level with predefined max num levels.
Returns WiFi signal level as enum with information about current level
@param context Context of the activity or an application
@return WifiSignalLevel as an enum
"""
return observeWifiSignalLevel(context, WifiSignalLevel.getMaxLevel()).map(
new Function<Integer, WifiSignalLevel>() {
@Override public WifiSignalLevel apply(Integer level) throws Exception {
return WifiSignalLevel.fromLevel(level);
}
});
} | java | @RequiresPermission(ACCESS_WIFI_STATE)
public static Observable<WifiSignalLevel> observeWifiSignalLevel(final Context context) {
return observeWifiSignalLevel(context, WifiSignalLevel.getMaxLevel()).map(
new Function<Integer, WifiSignalLevel>() {
@Override public WifiSignalLevel apply(Integer level) throws Exception {
return WifiSignalLevel.fromLevel(level);
}
});
} | [
"@",
"RequiresPermission",
"(",
"ACCESS_WIFI_STATE",
")",
"public",
"static",
"Observable",
"<",
"WifiSignalLevel",
">",
"observeWifiSignalLevel",
"(",
"final",
"Context",
"context",
")",
"{",
"return",
"observeWifiSignalLevel",
"(",
"context",
",",
"WifiSignalLevel",
".",
"getMaxLevel",
"(",
")",
")",
".",
"map",
"(",
"new",
"Function",
"<",
"Integer",
",",
"WifiSignalLevel",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"WifiSignalLevel",
"apply",
"(",
"Integer",
"level",
")",
"throws",
"Exception",
"{",
"return",
"WifiSignalLevel",
".",
"fromLevel",
"(",
"level",
")",
";",
"}",
"}",
")",
";",
"}"
] | Observes WiFi signal level with predefined max num levels.
Returns WiFi signal level as enum with information about current level
@param context Context of the activity or an application
@return WifiSignalLevel as an enum | [
"Observes",
"WiFi",
"signal",
"level",
"with",
"predefined",
"max",
"num",
"levels",
".",
"Returns",
"WiFi",
"signal",
"level",
"as",
"enum",
"with",
"information",
"about",
"current",
"level"
] | train | https://github.com/pwittchen/ReactiveWiFi/blob/eb2048663c1593b1706cfafb876542a41a223a1f/library/src/main/java/com/github/pwittchen/reactivewifi/ReactiveWifi.java#L125-L133 |
Samsung/GearVRf | GVRf/Extensions/3DCursor/IODevices/gearwear/PhoneSide/gearinputprovider/src/main/java/com/samsung/mpl/gearinputprovider/backend/InputProviderService.java | InputProviderService.sendEvent | public static void sendEvent(Context context, Parcelable event) {
"""
Send an event to other applications
@param context context in which to send the broadcast
@param event event to send
"""
Intent intent = new Intent(EventManager.ACTION_ACCESSORY_EVENT);
intent.putExtra(EventManager.EXTRA_EVENT, event);
context.sendBroadcast(intent);
} | java | public static void sendEvent(Context context, Parcelable event) {
Intent intent = new Intent(EventManager.ACTION_ACCESSORY_EVENT);
intent.putExtra(EventManager.EXTRA_EVENT, event);
context.sendBroadcast(intent);
} | [
"public",
"static",
"void",
"sendEvent",
"(",
"Context",
"context",
",",
"Parcelable",
"event",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"EventManager",
".",
"ACTION_ACCESSORY_EVENT",
")",
";",
"intent",
".",
"putExtra",
"(",
"EventManager",
".",
"EXTRA_EVENT",
",",
"event",
")",
";",
"context",
".",
"sendBroadcast",
"(",
"intent",
")",
";",
"}"
] | Send an event to other applications
@param context context in which to send the broadcast
@param event event to send | [
"Send",
"an",
"event",
"to",
"other",
"applications"
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Extensions/3DCursor/IODevices/gearwear/PhoneSide/gearinputprovider/src/main/java/com/samsung/mpl/gearinputprovider/backend/InputProviderService.java#L286-L290 |
rundeck/rundeck | core/src/main/java/com/dtolabs/rundeck/core/resources/format/ResourceFormatParserService.java | ResourceFormatParserService.getParserForFormat | public ResourceFormatParser getParserForFormat(final String format) throws UnsupportedFormatException {
"""
Return a parser for the exact format name
@param format the format name
@return the parser found for the format
@throws com.dtolabs.rundeck.core.resources.format.UnsupportedFormatException if format is not supported
"""
try {
return providerOfType(format);
} catch (ExecutionServiceException e) {
throw new UnsupportedFormatException("No provider available to parse format: " + format,e);
}
} | java | public ResourceFormatParser getParserForFormat(final String format) throws UnsupportedFormatException {
try {
return providerOfType(format);
} catch (ExecutionServiceException e) {
throw new UnsupportedFormatException("No provider available to parse format: " + format,e);
}
} | [
"public",
"ResourceFormatParser",
"getParserForFormat",
"(",
"final",
"String",
"format",
")",
"throws",
"UnsupportedFormatException",
"{",
"try",
"{",
"return",
"providerOfType",
"(",
"format",
")",
";",
"}",
"catch",
"(",
"ExecutionServiceException",
"e",
")",
"{",
"throw",
"new",
"UnsupportedFormatException",
"(",
"\"No provider available to parse format: \"",
"+",
"format",
",",
"e",
")",
";",
"}",
"}"
] | Return a parser for the exact format name
@param format the format name
@return the parser found for the format
@throws com.dtolabs.rundeck.core.resources.format.UnsupportedFormatException if format is not supported | [
"Return",
"a",
"parser",
"for",
"the",
"exact",
"format",
"name"
] | train | https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/resources/format/ResourceFormatParserService.java#L150-L156 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/date/format/FastDateFormat.java | FastDateFormat.getDateTimeInstance | public static FastDateFormat getDateTimeInstance(final int dateStyle, final int timeStyle, final Locale locale) {
"""
获得 {@link FastDateFormat} 实例<br>
支持缓存
@param dateStyle date style: FULL, LONG, MEDIUM, or SHORT
@param timeStyle time style: FULL, LONG, MEDIUM, or SHORT
@param locale {@link Locale} 日期地理位置
@return 本地化 {@link FastDateFormat}
"""
return cache.getDateTimeInstance(dateStyle, timeStyle, null, locale);
} | java | public static FastDateFormat getDateTimeInstance(final int dateStyle, final int timeStyle, final Locale locale) {
return cache.getDateTimeInstance(dateStyle, timeStyle, null, locale);
} | [
"public",
"static",
"FastDateFormat",
"getDateTimeInstance",
"(",
"final",
"int",
"dateStyle",
",",
"final",
"int",
"timeStyle",
",",
"final",
"Locale",
"locale",
")",
"{",
"return",
"cache",
".",
"getDateTimeInstance",
"(",
"dateStyle",
",",
"timeStyle",
",",
"null",
",",
"locale",
")",
";",
"}"
] | 获得 {@link FastDateFormat} 实例<br>
支持缓存
@param dateStyle date style: FULL, LONG, MEDIUM, or SHORT
@param timeStyle time style: FULL, LONG, MEDIUM, or SHORT
@param locale {@link Locale} 日期地理位置
@return 本地化 {@link FastDateFormat} | [
"获得",
"{",
"@link",
"FastDateFormat",
"}",
"实例<br",
">",
"支持缓存"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/date/format/FastDateFormat.java#L233-L235 |
jbundle/jbundle | base/screen/model/src/main/java/org/jbundle/base/screen/model/ScreenField.java | ScreenField.printStartRecordData | public void printStartRecordData(Rec record, PrintWriter out, int iPrintOptions) {
"""
Display the start record in input format.
@return true if default params were found for this form.
@param out The http output stream.
@exception DBException File exception.
"""
this.getScreenFieldView().printStartRecordData(record, out, iPrintOptions);
} | java | public void printStartRecordData(Rec record, PrintWriter out, int iPrintOptions)
{
this.getScreenFieldView().printStartRecordData(record, out, iPrintOptions);
} | [
"public",
"void",
"printStartRecordData",
"(",
"Rec",
"record",
",",
"PrintWriter",
"out",
",",
"int",
"iPrintOptions",
")",
"{",
"this",
".",
"getScreenFieldView",
"(",
")",
".",
"printStartRecordData",
"(",
"record",
",",
"out",
",",
"iPrintOptions",
")",
";",
"}"
] | Display the start record in input format.
@return true if default params were found for this form.
@param out The http output stream.
@exception DBException File exception. | [
"Display",
"the",
"start",
"record",
"in",
"input",
"format",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/model/src/main/java/org/jbundle/base/screen/model/ScreenField.java#L854-L857 |
DV8FromTheWorld/JDA | src/main/java/net/dv8tion/jda/core/requests/RestAction.java | RestAction.completeAfter | public T completeAfter(long delay, TimeUnit unit) {
"""
Blocks the current Thread for the specified delay and calls {@link #complete()}
when delay has been reached.
<br>If the specified delay is negative this action will execute immediately. (see: {@link TimeUnit#sleep(long)})
@param delay
The delay after which to execute a call to {@link #complete()}
@param unit
The {@link java.util.concurrent.TimeUnit TimeUnit} which should be used
(this will use {@link java.util.concurrent.TimeUnit#sleep(long) unit.sleep(delay)})
@throws java.lang.IllegalArgumentException
If the specified {@link java.util.concurrent.TimeUnit TimeUnit} is {@code null}
@throws java.lang.RuntimeException
If the sleep operation is interrupted
@return The response value
"""
Checks.notNull(unit, "TimeUnit");
try
{
unit.sleep(delay);
return complete();
}
catch (InterruptedException e)
{
throw new RuntimeException(e);
}
} | java | public T completeAfter(long delay, TimeUnit unit)
{
Checks.notNull(unit, "TimeUnit");
try
{
unit.sleep(delay);
return complete();
}
catch (InterruptedException e)
{
throw new RuntimeException(e);
}
} | [
"public",
"T",
"completeAfter",
"(",
"long",
"delay",
",",
"TimeUnit",
"unit",
")",
"{",
"Checks",
".",
"notNull",
"(",
"unit",
",",
"\"TimeUnit\"",
")",
";",
"try",
"{",
"unit",
".",
"sleep",
"(",
"delay",
")",
";",
"return",
"complete",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Blocks the current Thread for the specified delay and calls {@link #complete()}
when delay has been reached.
<br>If the specified delay is negative this action will execute immediately. (see: {@link TimeUnit#sleep(long)})
@param delay
The delay after which to execute a call to {@link #complete()}
@param unit
The {@link java.util.concurrent.TimeUnit TimeUnit} which should be used
(this will use {@link java.util.concurrent.TimeUnit#sleep(long) unit.sleep(delay)})
@throws java.lang.IllegalArgumentException
If the specified {@link java.util.concurrent.TimeUnit TimeUnit} is {@code null}
@throws java.lang.RuntimeException
If the sleep operation is interrupted
@return The response value | [
"Blocks",
"the",
"current",
"Thread",
"for",
"the",
"specified",
"delay",
"and",
"calls",
"{",
"@link",
"#complete",
"()",
"}",
"when",
"delay",
"has",
"been",
"reached",
".",
"<br",
">",
"If",
"the",
"specified",
"delay",
"is",
"negative",
"this",
"action",
"will",
"execute",
"immediately",
".",
"(",
"see",
":",
"{",
"@link",
"TimeUnit#sleep",
"(",
"long",
")",
"}",
")"
] | train | https://github.com/DV8FromTheWorld/JDA/blob/8ecbbe354d03f6bf448411bba573d0d4c268b560/src/main/java/net/dv8tion/jda/core/requests/RestAction.java#L528-L540 |
line/armeria | core/src/main/java/com/linecorp/armeria/client/ClientOptions.java | ClientOptions.of | public static ClientOptions of(ClientOptions baseOptions, ClientOptions options) {
"""
Merges the specified two {@link ClientOptions} into one.
@return the merged {@link ClientOptions}
"""
// TODO(trustin): Reduce the cost of creating a derived ClientOptions.
requireNonNull(baseOptions, "baseOptions");
requireNonNull(options, "options");
return new ClientOptions(baseOptions, options);
} | java | public static ClientOptions of(ClientOptions baseOptions, ClientOptions options) {
// TODO(trustin): Reduce the cost of creating a derived ClientOptions.
requireNonNull(baseOptions, "baseOptions");
requireNonNull(options, "options");
return new ClientOptions(baseOptions, options);
} | [
"public",
"static",
"ClientOptions",
"of",
"(",
"ClientOptions",
"baseOptions",
",",
"ClientOptions",
"options",
")",
"{",
"// TODO(trustin): Reduce the cost of creating a derived ClientOptions.",
"requireNonNull",
"(",
"baseOptions",
",",
"\"baseOptions\"",
")",
";",
"requireNonNull",
"(",
"options",
",",
"\"options\"",
")",
";",
"return",
"new",
"ClientOptions",
"(",
"baseOptions",
",",
"options",
")",
";",
"}"
] | Merges the specified two {@link ClientOptions} into one.
@return the merged {@link ClientOptions} | [
"Merges",
"the",
"specified",
"two",
"{",
"@link",
"ClientOptions",
"}",
"into",
"one",
"."
] | train | https://github.com/line/armeria/blob/67d29e019fd35a35f89c45cc8f9119ff9b12b44d/core/src/main/java/com/linecorp/armeria/client/ClientOptions.java#L137-L142 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/stat/cmp/cmppolicy_stats.java | cmppolicy_stats.get | public static cmppolicy_stats get(nitro_service service, String name) throws Exception {
"""
Use this API to fetch statistics of cmppolicy_stats resource of given name .
"""
cmppolicy_stats obj = new cmppolicy_stats();
obj.set_name(name);
cmppolicy_stats response = (cmppolicy_stats) obj.stat_resource(service);
return response;
} | java | public static cmppolicy_stats get(nitro_service service, String name) throws Exception{
cmppolicy_stats obj = new cmppolicy_stats();
obj.set_name(name);
cmppolicy_stats response = (cmppolicy_stats) obj.stat_resource(service);
return response;
} | [
"public",
"static",
"cmppolicy_stats",
"get",
"(",
"nitro_service",
"service",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"cmppolicy_stats",
"obj",
"=",
"new",
"cmppolicy_stats",
"(",
")",
";",
"obj",
".",
"set_name",
"(",
"name",
")",
";",
"cmppolicy_stats",
"response",
"=",
"(",
"cmppolicy_stats",
")",
"obj",
".",
"stat_resource",
"(",
"service",
")",
";",
"return",
"response",
";",
"}"
] | Use this API to fetch statistics of cmppolicy_stats resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"statistics",
"of",
"cmppolicy_stats",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/stat/cmp/cmppolicy_stats.java#L169-L174 |
pravega/pravega | controller/src/main/java/io/pravega/controller/metrics/TransactionMetrics.java | TransactionMetrics.createTransactionFailed | public void createTransactionFailed(String scope, String streamName) {
"""
This method increments the global and Stream-related counters of failed Transaction create operations.
@param scope Scope.
@param streamName Name of the Stream.
"""
DYNAMIC_LOGGER.incCounterValue(globalMetricName(CREATE_TRANSACTION_FAILED), 1);
DYNAMIC_LOGGER.incCounterValue(CREATE_TRANSACTION_FAILED, 1, streamTags(scope, streamName));
} | java | public void createTransactionFailed(String scope, String streamName) {
DYNAMIC_LOGGER.incCounterValue(globalMetricName(CREATE_TRANSACTION_FAILED), 1);
DYNAMIC_LOGGER.incCounterValue(CREATE_TRANSACTION_FAILED, 1, streamTags(scope, streamName));
} | [
"public",
"void",
"createTransactionFailed",
"(",
"String",
"scope",
",",
"String",
"streamName",
")",
"{",
"DYNAMIC_LOGGER",
".",
"incCounterValue",
"(",
"globalMetricName",
"(",
"CREATE_TRANSACTION_FAILED",
")",
",",
"1",
")",
";",
"DYNAMIC_LOGGER",
".",
"incCounterValue",
"(",
"CREATE_TRANSACTION_FAILED",
",",
"1",
",",
"streamTags",
"(",
"scope",
",",
"streamName",
")",
")",
";",
"}"
] | This method increments the global and Stream-related counters of failed Transaction create operations.
@param scope Scope.
@param streamName Name of the Stream. | [
"This",
"method",
"increments",
"the",
"global",
"and",
"Stream",
"-",
"related",
"counters",
"of",
"failed",
"Transaction",
"create",
"operations",
"."
] | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/controller/src/main/java/io/pravega/controller/metrics/TransactionMetrics.java#L58-L61 |
before/quality-check | modules/quality-check/src/main/java/net/sf/qualitycheck/Check.java | Check.isNumber | @ArgumentsChecked
@Throws( {
"""
Ensures that a string argument is a number according to {@code Integer.parseInt}
@param value
value which must be a number
@param name
name of object reference (in source code)
@return the given string argument converted to an int
@throws IllegalNumberArgumentException
if the given argument {@code value} is no number
""" IllegalNullArgumentException.class, IllegalNumberArgumentException.class })
public static int isNumber(@Nonnull final String value, @Nullable final String name) {
Check.notNull(value, "value");
return Check.isNumber(value, name, Integer.class).intValue();
} | java | @ArgumentsChecked
@Throws({ IllegalNullArgumentException.class, IllegalNumberArgumentException.class })
public static int isNumber(@Nonnull final String value, @Nullable final String name) {
Check.notNull(value, "value");
return Check.isNumber(value, name, Integer.class).intValue();
} | [
"@",
"ArgumentsChecked",
"@",
"Throws",
"(",
"{",
"IllegalNullArgumentException",
".",
"class",
",",
"IllegalNumberArgumentException",
".",
"class",
"}",
")",
"public",
"static",
"int",
"isNumber",
"(",
"@",
"Nonnull",
"final",
"String",
"value",
",",
"@",
"Nullable",
"final",
"String",
"name",
")",
"{",
"Check",
".",
"notNull",
"(",
"value",
",",
"\"value\"",
")",
";",
"return",
"Check",
".",
"isNumber",
"(",
"value",
",",
"name",
",",
"Integer",
".",
"class",
")",
".",
"intValue",
"(",
")",
";",
"}"
] | Ensures that a string argument is a number according to {@code Integer.parseInt}
@param value
value which must be a number
@param name
name of object reference (in source code)
@return the given string argument converted to an int
@throws IllegalNumberArgumentException
if the given argument {@code value} is no number | [
"Ensures",
"that",
"a",
"string",
"argument",
"is",
"a",
"number",
"according",
"to",
"{",
"@code",
"Integer",
".",
"parseInt",
"}"
] | train | https://github.com/before/quality-check/blob/a75c32c39434ddb1f89bece57acae0536724c15a/modules/quality-check/src/main/java/net/sf/qualitycheck/Check.java#L1267-L1272 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/base/base_resource.java | base_resource.perform_operationEx | public base_resource perform_operationEx(nitro_service service, String action) throws Exception {
"""
Use this method to perform a POST operation that returns a resource ...etc
operation on netscaler resource.
@param service nitro_service object.
@param action action needs to be taken on resource.
@return requested resource
@throws Exception Nitro exception is thrown.
"""
if (!service.isLogin() && !get_object_type().equals("login"))
service.login();
options option = new options();
option.set_action(action);
base_resource response = post_requestEx(service, option);
return response;
} | java | public base_resource perform_operationEx(nitro_service service, String action) throws Exception
{
if (!service.isLogin() && !get_object_type().equals("login"))
service.login();
options option = new options();
option.set_action(action);
base_resource response = post_requestEx(service, option);
return response;
} | [
"public",
"base_resource",
"perform_operationEx",
"(",
"nitro_service",
"service",
",",
"String",
"action",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"service",
".",
"isLogin",
"(",
")",
"&&",
"!",
"get_object_type",
"(",
")",
".",
"equals",
"(",
"\"login\"",
")",
")",
"service",
".",
"login",
"(",
")",
";",
"options",
"option",
"=",
"new",
"options",
"(",
")",
";",
"option",
".",
"set_action",
"(",
"action",
")",
";",
"base_resource",
"response",
"=",
"post_requestEx",
"(",
"service",
",",
"option",
")",
";",
"return",
"response",
";",
"}"
] | Use this method to perform a POST operation that returns a resource ...etc
operation on netscaler resource.
@param service nitro_service object.
@param action action needs to be taken on resource.
@return requested resource
@throws Exception Nitro exception is thrown. | [
"Use",
"this",
"method",
"to",
"perform",
"a",
"POST",
"operation",
"that",
"returns",
"a",
"resource",
"...",
"etc",
"operation",
"on",
"netscaler",
"resource",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/base/base_resource.java#L374-L382 |
ksclarke/freelib-utils | src/main/java/info/freelibrary/util/StringUtils.java | StringUtils.joinKeys | public static String joinKeys(final Map<String, ?> aMap, final char aSeparator) {
"""
Turns the keys in a map into a character delimited string. The order is only consistent if the map is sorted.
@param aMap The map from which to pull the keys
@param aSeparator The character separator for the construction of the string
@return A string constructed from the keys in the map
"""
if (aMap.isEmpty()) {
return "";
}
final Iterator<String> iterator = aMap.keySet().iterator();
final StringBuilder buffer = new StringBuilder();
while (iterator.hasNext()) {
buffer.append(iterator.next()).append(aSeparator);
}
final int length = buffer.length() - 1;
return buffer.charAt(length) == aSeparator ? buffer.substring(0, length) : buffer.toString();
} | java | public static String joinKeys(final Map<String, ?> aMap, final char aSeparator) {
if (aMap.isEmpty()) {
return "";
}
final Iterator<String> iterator = aMap.keySet().iterator();
final StringBuilder buffer = new StringBuilder();
while (iterator.hasNext()) {
buffer.append(iterator.next()).append(aSeparator);
}
final int length = buffer.length() - 1;
return buffer.charAt(length) == aSeparator ? buffer.substring(0, length) : buffer.toString();
} | [
"public",
"static",
"String",
"joinKeys",
"(",
"final",
"Map",
"<",
"String",
",",
"?",
">",
"aMap",
",",
"final",
"char",
"aSeparator",
")",
"{",
"if",
"(",
"aMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"final",
"Iterator",
"<",
"String",
">",
"iterator",
"=",
"aMap",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"final",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"buffer",
".",
"append",
"(",
"iterator",
".",
"next",
"(",
")",
")",
".",
"append",
"(",
"aSeparator",
")",
";",
"}",
"final",
"int",
"length",
"=",
"buffer",
".",
"length",
"(",
")",
"-",
"1",
";",
"return",
"buffer",
".",
"charAt",
"(",
"length",
")",
"==",
"aSeparator",
"?",
"buffer",
".",
"substring",
"(",
"0",
",",
"length",
")",
":",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Turns the keys in a map into a character delimited string. The order is only consistent if the map is sorted.
@param aMap The map from which to pull the keys
@param aSeparator The character separator for the construction of the string
@return A string constructed from the keys in the map | [
"Turns",
"the",
"keys",
"in",
"a",
"map",
"into",
"a",
"character",
"delimited",
"string",
".",
"The",
"order",
"is",
"only",
"consistent",
"if",
"the",
"map",
"is",
"sorted",
"."
] | train | https://github.com/ksclarke/freelib-utils/blob/54e822ae4c11b3d74793fd82a1a535ffafffaf45/src/main/java/info/freelibrary/util/StringUtils.java#L399-L414 |
eclipse/xtext-extras | org.eclipse.xtext.common.types/src/org/eclipse/xtext/common/types/access/binary/asm/SignatureUtil.java | SignatureUtil.scanTypeSignature | static int scanTypeSignature(String string, int start) {
"""
Scans the given string for a type signature starting at the given index
and returns the index of the last character.
<pre>
TypeSignature:
| BaseTypeSignature
| ArrayTypeSignature
| ClassTypeSignature
| TypeVariableSignature
</pre>
@param string the signature string
@param start the 0-based character index of the first character
@return the 0-based character index of the last character
@exception IllegalArgumentException if this is not a type signature
"""
// need a minimum 1 char
if (start >= string.length()) {
throw new IllegalArgumentException();
}
char c = string.charAt(start);
switch (c) {
case C_ARRAY :
return scanArrayTypeSignature(string, start);
case C_RESOLVED :
case C_UNRESOLVED :
return scanClassTypeSignature(string, start);
case C_TYPE_VARIABLE :
return scanTypeVariableSignature(string, start);
case C_BOOLEAN :
case C_BYTE :
case C_CHAR :
case C_DOUBLE :
case C_FLOAT :
case C_INT :
case C_LONG :
case C_SHORT :
case C_VOID :
return scanBaseTypeSignature(string, start);
case C_CAPTURE :
return scanCaptureTypeSignature(string, start);
case C_EXTENDS:
case C_SUPER:
case C_STAR:
return scanTypeBoundSignature(string, start);
default :
throw new IllegalArgumentException();
}
} | java | static int scanTypeSignature(String string, int start) {
// need a minimum 1 char
if (start >= string.length()) {
throw new IllegalArgumentException();
}
char c = string.charAt(start);
switch (c) {
case C_ARRAY :
return scanArrayTypeSignature(string, start);
case C_RESOLVED :
case C_UNRESOLVED :
return scanClassTypeSignature(string, start);
case C_TYPE_VARIABLE :
return scanTypeVariableSignature(string, start);
case C_BOOLEAN :
case C_BYTE :
case C_CHAR :
case C_DOUBLE :
case C_FLOAT :
case C_INT :
case C_LONG :
case C_SHORT :
case C_VOID :
return scanBaseTypeSignature(string, start);
case C_CAPTURE :
return scanCaptureTypeSignature(string, start);
case C_EXTENDS:
case C_SUPER:
case C_STAR:
return scanTypeBoundSignature(string, start);
default :
throw new IllegalArgumentException();
}
} | [
"static",
"int",
"scanTypeSignature",
"(",
"String",
"string",
",",
"int",
"start",
")",
"{",
"// need a minimum 1 char",
"if",
"(",
"start",
">=",
"string",
".",
"length",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"char",
"c",
"=",
"string",
".",
"charAt",
"(",
"start",
")",
";",
"switch",
"(",
"c",
")",
"{",
"case",
"C_ARRAY",
":",
"return",
"scanArrayTypeSignature",
"(",
"string",
",",
"start",
")",
";",
"case",
"C_RESOLVED",
":",
"case",
"C_UNRESOLVED",
":",
"return",
"scanClassTypeSignature",
"(",
"string",
",",
"start",
")",
";",
"case",
"C_TYPE_VARIABLE",
":",
"return",
"scanTypeVariableSignature",
"(",
"string",
",",
"start",
")",
";",
"case",
"C_BOOLEAN",
":",
"case",
"C_BYTE",
":",
"case",
"C_CHAR",
":",
"case",
"C_DOUBLE",
":",
"case",
"C_FLOAT",
":",
"case",
"C_INT",
":",
"case",
"C_LONG",
":",
"case",
"C_SHORT",
":",
"case",
"C_VOID",
":",
"return",
"scanBaseTypeSignature",
"(",
"string",
",",
"start",
")",
";",
"case",
"C_CAPTURE",
":",
"return",
"scanCaptureTypeSignature",
"(",
"string",
",",
"start",
")",
";",
"case",
"C_EXTENDS",
":",
"case",
"C_SUPER",
":",
"case",
"C_STAR",
":",
"return",
"scanTypeBoundSignature",
"(",
"string",
",",
"start",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"}"
] | Scans the given string for a type signature starting at the given index
and returns the index of the last character.
<pre>
TypeSignature:
| BaseTypeSignature
| ArrayTypeSignature
| ClassTypeSignature
| TypeVariableSignature
</pre>
@param string the signature string
@param start the 0-based character index of the first character
@return the 0-based character index of the last character
@exception IllegalArgumentException if this is not a type signature | [
"Scans",
"the",
"given",
"string",
"for",
"a",
"type",
"signature",
"starting",
"at",
"the",
"given",
"index",
"and",
"returns",
"the",
"index",
"of",
"the",
"last",
"character",
".",
"<pre",
">",
"TypeSignature",
":",
"|",
"BaseTypeSignature",
"|",
"ArrayTypeSignature",
"|",
"ClassTypeSignature",
"|",
"TypeVariableSignature",
"<",
"/",
"pre",
">"
] | train | https://github.com/eclipse/xtext-extras/blob/451359541295323a29f5855e633f770cec02069a/org.eclipse.xtext.common.types/src/org/eclipse/xtext/common/types/access/binary/asm/SignatureUtil.java#L169-L202 |
hibernate/hibernate-ogm | neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/query/parsing/impl/Neo4jAliasResolver.java | Neo4jAliasResolver.createAliasForAssociation | public String createAliasForAssociation(String entityAlias, List<String> propertyPathWithoutAlias, String targetNodeType,
boolean optionalMatch) {
"""
Given the path to an association, it will create an alias to use in the query for the association.
<p>
The alias will be saved and can be returned using the method {@link #findAlias(String, List)}.
<p>
For example, using n as entity alias and [association, anotherAssociation] as path to the association will
return "_n2" as alias for "n.association.anotherAssociation".
<p>
Note that you need to create an alias for every embedded/association in the path before this one.
@param entityAlias the alias of the entity that contains the embedded
@param propertyPathWithoutAlias the path to the property without the alias
@param targetNodeType the name of the target node type
@param optionalMatch if true, the alias does not represent a required match in the query (It will appear in the OPTIONAL MATCH clause)
@return the alias of the embedded containing the property
"""
return createAliasForRelationship( entityAlias, propertyPathWithoutAlias, targetNodeType, optionalMatch );
} | java | public String createAliasForAssociation(String entityAlias, List<String> propertyPathWithoutAlias, String targetNodeType,
boolean optionalMatch) {
return createAliasForRelationship( entityAlias, propertyPathWithoutAlias, targetNodeType, optionalMatch );
} | [
"public",
"String",
"createAliasForAssociation",
"(",
"String",
"entityAlias",
",",
"List",
"<",
"String",
">",
"propertyPathWithoutAlias",
",",
"String",
"targetNodeType",
",",
"boolean",
"optionalMatch",
")",
"{",
"return",
"createAliasForRelationship",
"(",
"entityAlias",
",",
"propertyPathWithoutAlias",
",",
"targetNodeType",
",",
"optionalMatch",
")",
";",
"}"
] | Given the path to an association, it will create an alias to use in the query for the association.
<p>
The alias will be saved and can be returned using the method {@link #findAlias(String, List)}.
<p>
For example, using n as entity alias and [association, anotherAssociation] as path to the association will
return "_n2" as alias for "n.association.anotherAssociation".
<p>
Note that you need to create an alias for every embedded/association in the path before this one.
@param entityAlias the alias of the entity that contains the embedded
@param propertyPathWithoutAlias the path to the property without the alias
@param targetNodeType the name of the target node type
@param optionalMatch if true, the alias does not represent a required match in the query (It will appear in the OPTIONAL MATCH clause)
@return the alias of the embedded containing the property | [
"Given",
"the",
"path",
"to",
"an",
"association",
"it",
"will",
"create",
"an",
"alias",
"to",
"use",
"in",
"the",
"query",
"for",
"the",
"association",
".",
"<p",
">",
"The",
"alias",
"will",
"be",
"saved",
"and",
"can",
"be",
"returned",
"using",
"the",
"method",
"{",
"@link",
"#findAlias",
"(",
"String",
"List",
")",
"}",
".",
"<p",
">",
"For",
"example",
"using",
"n",
"as",
"entity",
"alias",
"and",
"[",
"association",
"anotherAssociation",
"]",
"as",
"path",
"to",
"the",
"association",
"will",
"return",
"_n2",
"as",
"alias",
"for",
"n",
".",
"association",
".",
"anotherAssociation",
".",
"<p",
">",
"Note",
"that",
"you",
"need",
"to",
"create",
"an",
"alias",
"for",
"every",
"embedded",
"/",
"association",
"in",
"the",
"path",
"before",
"this",
"one",
"."
] | train | https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/query/parsing/impl/Neo4jAliasResolver.java#L82-L85 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java | CloudStorageFileSystemProvider.createDirectory | @Override
public void createDirectory(Path dir, FileAttribute<?>... attrs) {
"""
Does nothing since Google Cloud Storage uses fake directories.
"""
CloudStorageUtil.checkPath(dir);
CloudStorageUtil.checkNotNullArray(attrs);
} | java | @Override
public void createDirectory(Path dir, FileAttribute<?>... attrs) {
CloudStorageUtil.checkPath(dir);
CloudStorageUtil.checkNotNullArray(attrs);
} | [
"@",
"Override",
"public",
"void",
"createDirectory",
"(",
"Path",
"dir",
",",
"FileAttribute",
"<",
"?",
">",
"...",
"attrs",
")",
"{",
"CloudStorageUtil",
".",
"checkPath",
"(",
"dir",
")",
";",
"CloudStorageUtil",
".",
"checkNotNullArray",
"(",
"attrs",
")",
";",
"}"
] | Does nothing since Google Cloud Storage uses fake directories. | [
"Does",
"nothing",
"since",
"Google",
"Cloud",
"Storage",
"uses",
"fake",
"directories",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java#L859-L863 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/ExponentialBackoff.java | ExponentialBackoff.evaluateConditionUntilTrue | @Builder(builderMethodName = "awaitCondition", buildMethodName = "await")
private static boolean evaluateConditionUntilTrue(Callable<Boolean> callable, Double alpha, Integer maxRetries,
Long maxWait, Long maxDelay, Long initialDelay) throws ExecutionException, InterruptedException {
"""
Evaluate a condition until true with exponential backoff.
@param callable Condition.
@return true if the condition returned true.
@throws ExecutionException if the condition throws an exception.
"""
ExponentialBackoff exponentialBackoff = new ExponentialBackoff(alpha, maxRetries, maxWait, maxDelay, initialDelay);
while (true) {
try {
if (callable.call()) {
return true;
}
} catch (Throwable t) {
throw new ExecutionException(t);
}
if (!exponentialBackoff.awaitNextRetryIfAvailable()) {
return false;
}
}
} | java | @Builder(builderMethodName = "awaitCondition", buildMethodName = "await")
private static boolean evaluateConditionUntilTrue(Callable<Boolean> callable, Double alpha, Integer maxRetries,
Long maxWait, Long maxDelay, Long initialDelay) throws ExecutionException, InterruptedException {
ExponentialBackoff exponentialBackoff = new ExponentialBackoff(alpha, maxRetries, maxWait, maxDelay, initialDelay);
while (true) {
try {
if (callable.call()) {
return true;
}
} catch (Throwable t) {
throw new ExecutionException(t);
}
if (!exponentialBackoff.awaitNextRetryIfAvailable()) {
return false;
}
}
} | [
"@",
"Builder",
"(",
"builderMethodName",
"=",
"\"awaitCondition\"",
",",
"buildMethodName",
"=",
"\"await\"",
")",
"private",
"static",
"boolean",
"evaluateConditionUntilTrue",
"(",
"Callable",
"<",
"Boolean",
">",
"callable",
",",
"Double",
"alpha",
",",
"Integer",
"maxRetries",
",",
"Long",
"maxWait",
",",
"Long",
"maxDelay",
",",
"Long",
"initialDelay",
")",
"throws",
"ExecutionException",
",",
"InterruptedException",
"{",
"ExponentialBackoff",
"exponentialBackoff",
"=",
"new",
"ExponentialBackoff",
"(",
"alpha",
",",
"maxRetries",
",",
"maxWait",
",",
"maxDelay",
",",
"initialDelay",
")",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"if",
"(",
"callable",
".",
"call",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"ExecutionException",
"(",
"t",
")",
";",
"}",
"if",
"(",
"!",
"exponentialBackoff",
".",
"awaitNextRetryIfAvailable",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}"
] | Evaluate a condition until true with exponential backoff.
@param callable Condition.
@return true if the condition returned true.
@throws ExecutionException if the condition throws an exception. | [
"Evaluate",
"a",
"condition",
"until",
"true",
"with",
"exponential",
"backoff",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ExponentialBackoff.java#L112-L128 |
magro/memcached-session-manager | javolution-serializer/src/main/java/de/javakaffee/web/msm/serializer/javolution/JavolutionTranscoderFactory.java | JavolutionTranscoderFactory.getTranscoder | private JavolutionTranscoder getTranscoder( final SessionManager manager ) {
"""
Gets/creates a single instance of {@link JavolutionTranscoder}. We need to have a single
instance so that {@link XMLFormat}s are not created twice which would lead to errors.
@param manager the manager that will be passed to the transcoder.
@return for all invocations the same instance of {@link JavolutionTranscoder}.
"""
if ( _transcoder == null ) {
final CustomXMLFormat<?>[] customFormats = loadCustomFormats( manager );
_transcoder = new JavolutionTranscoder( manager, _copyCollectionsForSerialization, customFormats );
}
return _transcoder;
} | java | private JavolutionTranscoder getTranscoder( final SessionManager manager ) {
if ( _transcoder == null ) {
final CustomXMLFormat<?>[] customFormats = loadCustomFormats( manager );
_transcoder = new JavolutionTranscoder( manager, _copyCollectionsForSerialization, customFormats );
}
return _transcoder;
} | [
"private",
"JavolutionTranscoder",
"getTranscoder",
"(",
"final",
"SessionManager",
"manager",
")",
"{",
"if",
"(",
"_transcoder",
"==",
"null",
")",
"{",
"final",
"CustomXMLFormat",
"<",
"?",
">",
"[",
"]",
"customFormats",
"=",
"loadCustomFormats",
"(",
"manager",
")",
";",
"_transcoder",
"=",
"new",
"JavolutionTranscoder",
"(",
"manager",
",",
"_copyCollectionsForSerialization",
",",
"customFormats",
")",
";",
"}",
"return",
"_transcoder",
";",
"}"
] | Gets/creates a single instance of {@link JavolutionTranscoder}. We need to have a single
instance so that {@link XMLFormat}s are not created twice which would lead to errors.
@param manager the manager that will be passed to the transcoder.
@return for all invocations the same instance of {@link JavolutionTranscoder}. | [
"Gets",
"/",
"creates",
"a",
"single",
"instance",
"of",
"{",
"@link",
"JavolutionTranscoder",
"}",
".",
"We",
"need",
"to",
"have",
"a",
"single",
"instance",
"so",
"that",
"{",
"@link",
"XMLFormat",
"}",
"s",
"are",
"not",
"created",
"twice",
"which",
"would",
"lead",
"to",
"errors",
"."
] | train | https://github.com/magro/memcached-session-manager/blob/716e147c9840ab10298c4d2b9edd0662058331e6/javolution-serializer/src/main/java/de/javakaffee/web/msm/serializer/javolution/JavolutionTranscoderFactory.java#L53-L59 |
hudson3-plugins/warnings-plugin | src/main/java/hudson/plugins/warnings/parser/MsBuildParser.java | MsBuildParser.determinePriority | private Priority determinePriority(final Matcher matcher) {
"""
Determines the priority of the warning.
@param matcher
the matcher to get the matches from
@return the priority of the warning
"""
if (isOfType(matcher, "note") || isOfType(matcher, "info")) {
return Priority.LOW;
}
else if (isOfType(matcher, "warning")) {
return Priority.NORMAL;
}
return Priority.HIGH;
} | java | private Priority determinePriority(final Matcher matcher) {
if (isOfType(matcher, "note") || isOfType(matcher, "info")) {
return Priority.LOW;
}
else if (isOfType(matcher, "warning")) {
return Priority.NORMAL;
}
return Priority.HIGH;
} | [
"private",
"Priority",
"determinePriority",
"(",
"final",
"Matcher",
"matcher",
")",
"{",
"if",
"(",
"isOfType",
"(",
"matcher",
",",
"\"note\"",
")",
"||",
"isOfType",
"(",
"matcher",
",",
"\"info\"",
")",
")",
"{",
"return",
"Priority",
".",
"LOW",
";",
"}",
"else",
"if",
"(",
"isOfType",
"(",
"matcher",
",",
"\"warning\"",
")",
")",
"{",
"return",
"Priority",
".",
"NORMAL",
";",
"}",
"return",
"Priority",
".",
"HIGH",
";",
"}"
] | Determines the priority of the warning.
@param matcher
the matcher to get the matches from
@return the priority of the warning | [
"Determines",
"the",
"priority",
"of",
"the",
"warning",
"."
] | train | https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/MsBuildParser.java#L91-L99 |
sdl/odata | odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java | EntityDataModelUtil.getAndCheckSingleton | public static Singleton getAndCheckSingleton(EntityDataModel entityDataModel, String singletonName) {
"""
Gets the singleton with the specified name, throws an exception if no singleton with the specified name exists.
@param entityDataModel The entity data model.
@param singletonName The name of the singleton.
@return The singleton.
@throws ODataSystemException If the entity data model does not contain a singleton with the specified name.
"""
Singleton singleton = entityDataModel.getEntityContainer().getSingleton(singletonName);
if (singleton == null) {
throw new ODataSystemException("Singleton not found in the entity data model: " + singletonName);
}
return singleton;
} | java | public static Singleton getAndCheckSingleton(EntityDataModel entityDataModel, String singletonName) {
Singleton singleton = entityDataModel.getEntityContainer().getSingleton(singletonName);
if (singleton == null) {
throw new ODataSystemException("Singleton not found in the entity data model: " + singletonName);
}
return singleton;
} | [
"public",
"static",
"Singleton",
"getAndCheckSingleton",
"(",
"EntityDataModel",
"entityDataModel",
",",
"String",
"singletonName",
")",
"{",
"Singleton",
"singleton",
"=",
"entityDataModel",
".",
"getEntityContainer",
"(",
")",
".",
"getSingleton",
"(",
"singletonName",
")",
";",
"if",
"(",
"singleton",
"==",
"null",
")",
"{",
"throw",
"new",
"ODataSystemException",
"(",
"\"Singleton not found in the entity data model: \"",
"+",
"singletonName",
")",
";",
"}",
"return",
"singleton",
";",
"}"
] | Gets the singleton with the specified name, throws an exception if no singleton with the specified name exists.
@param entityDataModel The entity data model.
@param singletonName The name of the singleton.
@return The singleton.
@throws ODataSystemException If the entity data model does not contain a singleton with the specified name. | [
"Gets",
"the",
"singleton",
"with",
"the",
"specified",
"name",
"throws",
"an",
"exception",
"if",
"no",
"singleton",
"with",
"the",
"specified",
"name",
"exists",
"."
] | train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_api/src/main/java/com/sdl/odata/util/edm/EntityDataModelUtil.java#L582-L588 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java | SecurityCenterClient.groupFindings | public final GroupFindingsPagedResponse groupFindings(SourceName parent, String groupBy) {
"""
Filters an organization or source's findings and groups them by their specified properties.
<p>To group across all sources provide a `-` as the source id. Example:
/v1/organizations/123/sources/-/findings
<p>Sample code:
<pre><code>
try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) {
SourceName parent = SourceName.of("[ORGANIZATION]", "[SOURCE]");
String groupBy = "";
for (GroupResult element : securityCenterClient.groupFindings(parent, groupBy).iterateAll()) {
// doThingsWith(element);
}
}
</code></pre>
@param parent Name of the source to groupBy. Its format is
"organizations/[organization_id]/sources/[source_id]". To groupBy across all sources
provide a source_id of `-`. For example: organizations/123/sources/-
@param groupBy Expression that defines what assets fields to use for grouping (including
`state_change`). The string value should follow SQL syntax: comma separated list of fields.
For example: "parent,resource_name".
<p>The following fields are supported:
<p>* resource_name * category * state * parent
<p>The following fields are supported when compare_duration is set:
<p>* state_change
@throws com.google.api.gax.rpc.ApiException if the remote call fails
"""
GroupFindingsRequest request =
GroupFindingsRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setGroupBy(groupBy)
.build();
return groupFindings(request);
} | java | public final GroupFindingsPagedResponse groupFindings(SourceName parent, String groupBy) {
GroupFindingsRequest request =
GroupFindingsRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setGroupBy(groupBy)
.build();
return groupFindings(request);
} | [
"public",
"final",
"GroupFindingsPagedResponse",
"groupFindings",
"(",
"SourceName",
"parent",
",",
"String",
"groupBy",
")",
"{",
"GroupFindingsRequest",
"request",
"=",
"GroupFindingsRequest",
".",
"newBuilder",
"(",
")",
".",
"setParent",
"(",
"parent",
"==",
"null",
"?",
"null",
":",
"parent",
".",
"toString",
"(",
")",
")",
".",
"setGroupBy",
"(",
"groupBy",
")",
".",
"build",
"(",
")",
";",
"return",
"groupFindings",
"(",
"request",
")",
";",
"}"
] | Filters an organization or source's findings and groups them by their specified properties.
<p>To group across all sources provide a `-` as the source id. Example:
/v1/organizations/123/sources/-/findings
<p>Sample code:
<pre><code>
try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) {
SourceName parent = SourceName.of("[ORGANIZATION]", "[SOURCE]");
String groupBy = "";
for (GroupResult element : securityCenterClient.groupFindings(parent, groupBy).iterateAll()) {
// doThingsWith(element);
}
}
</code></pre>
@param parent Name of the source to groupBy. Its format is
"organizations/[organization_id]/sources/[source_id]". To groupBy across all sources
provide a source_id of `-`. For example: organizations/123/sources/-
@param groupBy Expression that defines what assets fields to use for grouping (including
`state_change`). The string value should follow SQL syntax: comma separated list of fields.
For example: "parent,resource_name".
<p>The following fields are supported:
<p>* resource_name * category * state * parent
<p>The following fields are supported when compare_duration is set:
<p>* state_change
@throws com.google.api.gax.rpc.ApiException if the remote call fails | [
"Filters",
"an",
"organization",
"or",
"source",
"s",
"findings",
"and",
"groups",
"them",
"by",
"their",
"specified",
"properties",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java#L813-L820 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/renderkit/RendererUtils.java | RendererUtils.findNestingForm | public static FormInfo findNestingForm(UIComponent uiComponent,
FacesContext facesContext) {
"""
Find the enclosing form of a component
in the view-tree.
All Subclasses of <code>UIForm</code> and all known
form-families are searched for.
Currently those are the Trinidad form family,
and the (old) ADF Faces form family.
<p/>
There might be additional form families
which have to be explicitly entered here.
@param uiComponent
@param facesContext
@return FormInfo Information about the form - the form itself and its name.
"""
UIComponent parent = uiComponent.getParent();
while (parent != null
&& (!ADF_FORM_COMPONENT_FAMILY.equals(parent.getFamily())
&& !TRINIDAD_FORM_COMPONENT_FAMILY.equals(parent
.getFamily()) && !(parent instanceof UIForm)))
{
parent = parent.getParent();
}
if (parent != null)
{
//link is nested inside a form
String formName = parent.getClientId(facesContext);
return new FormInfo(parent, formName);
}
return null;
} | java | public static FormInfo findNestingForm(UIComponent uiComponent,
FacesContext facesContext)
{
UIComponent parent = uiComponent.getParent();
while (parent != null
&& (!ADF_FORM_COMPONENT_FAMILY.equals(parent.getFamily())
&& !TRINIDAD_FORM_COMPONENT_FAMILY.equals(parent
.getFamily()) && !(parent instanceof UIForm)))
{
parent = parent.getParent();
}
if (parent != null)
{
//link is nested inside a form
String formName = parent.getClientId(facesContext);
return new FormInfo(parent, formName);
}
return null;
} | [
"public",
"static",
"FormInfo",
"findNestingForm",
"(",
"UIComponent",
"uiComponent",
",",
"FacesContext",
"facesContext",
")",
"{",
"UIComponent",
"parent",
"=",
"uiComponent",
".",
"getParent",
"(",
")",
";",
"while",
"(",
"parent",
"!=",
"null",
"&&",
"(",
"!",
"ADF_FORM_COMPONENT_FAMILY",
".",
"equals",
"(",
"parent",
".",
"getFamily",
"(",
")",
")",
"&&",
"!",
"TRINIDAD_FORM_COMPONENT_FAMILY",
".",
"equals",
"(",
"parent",
".",
"getFamily",
"(",
")",
")",
"&&",
"!",
"(",
"parent",
"instanceof",
"UIForm",
")",
")",
")",
"{",
"parent",
"=",
"parent",
".",
"getParent",
"(",
")",
";",
"}",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"//link is nested inside a form",
"String",
"formName",
"=",
"parent",
".",
"getClientId",
"(",
"facesContext",
")",
";",
"return",
"new",
"FormInfo",
"(",
"parent",
",",
"formName",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Find the enclosing form of a component
in the view-tree.
All Subclasses of <code>UIForm</code> and all known
form-families are searched for.
Currently those are the Trinidad form family,
and the (old) ADF Faces form family.
<p/>
There might be additional form families
which have to be explicitly entered here.
@param uiComponent
@param facesContext
@return FormInfo Information about the form - the form itself and its name. | [
"Find",
"the",
"enclosing",
"form",
"of",
"a",
"component",
"in",
"the",
"view",
"-",
"tree",
".",
"All",
"Subclasses",
"of",
"<code",
">",
"UIForm<",
"/",
"code",
">",
"and",
"all",
"known",
"form",
"-",
"families",
"are",
"searched",
"for",
".",
"Currently",
"those",
"are",
"the",
"Trinidad",
"form",
"family",
"and",
"the",
"(",
"old",
")",
"ADF",
"Faces",
"form",
"family",
".",
"<p",
"/",
">",
"There",
"might",
"be",
"additional",
"form",
"families",
"which",
"have",
"to",
"be",
"explicitly",
"entered",
"here",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/renderkit/RendererUtils.java#L1098-L1118 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/CoreAdapterFactory.java | CoreAdapterFactory.getAdapter | protected static <AdapterType> AdapterType getAdapter(Resource resource, Class<AdapterType> type) {
"""
Handles <code>resource.adaptTo(ResourceHandle.class)</code>, to wrap a resource with an ResourceHandle.
@param resource resource to adapt/wrap
@param type target type
@return wrapped resource
"""
if (type == ResourceHandle.class) {
return type.cast(new ResourceHandle(resource));
}
log.info("Unable to adapt resource on {} to type {}", resource.getPath(), type.getName());
return null;
} | java | protected static <AdapterType> AdapterType getAdapter(Resource resource, Class<AdapterType> type) {
if (type == ResourceHandle.class) {
return type.cast(new ResourceHandle(resource));
}
log.info("Unable to adapt resource on {} to type {}", resource.getPath(), type.getName());
return null;
} | [
"protected",
"static",
"<",
"AdapterType",
">",
"AdapterType",
"getAdapter",
"(",
"Resource",
"resource",
",",
"Class",
"<",
"AdapterType",
">",
"type",
")",
"{",
"if",
"(",
"type",
"==",
"ResourceHandle",
".",
"class",
")",
"{",
"return",
"type",
".",
"cast",
"(",
"new",
"ResourceHandle",
"(",
"resource",
")",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"Unable to adapt resource on {} to type {}\"",
",",
"resource",
".",
"getPath",
"(",
")",
",",
"type",
".",
"getName",
"(",
")",
")",
";",
"return",
"null",
";",
"}"
] | Handles <code>resource.adaptTo(ResourceHandle.class)</code>, to wrap a resource with an ResourceHandle.
@param resource resource to adapt/wrap
@param type target type
@return wrapped resource | [
"Handles",
"<code",
">",
"resource",
".",
"adaptTo",
"(",
"ResourceHandle",
".",
"class",
")",
"<",
"/",
"code",
">",
"to",
"wrap",
"a",
"resource",
"with",
"an",
"ResourceHandle",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/CoreAdapterFactory.java#L71-L77 |
JOML-CI/JOML | src/org/joml/Matrix4x3f.java | Matrix4x3f.lookAt | public Matrix4x3f lookAt(float eyeX, float eyeY, float eyeZ,
float centerX, float centerY, float centerZ,
float upX, float upY, float upZ) {
"""
Apply a "lookat" transformation to this matrix for a right-handed coordinate system,
that aligns <code>-z</code> with <code>center - eye</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>L</code> the lookat matrix,
then the new matrix will be <code>M * L</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * L * v</code>,
the lookat transformation will be applied first!
<p>
In order to set the matrix to a lookat transformation without post-multiplying it,
use {@link #setLookAt(float, float, float, float, float, float, float, float, float) setLookAt()}.
@see #lookAt(Vector3fc, Vector3fc, Vector3fc)
@see #setLookAt(float, float, float, float, float, float, float, float, float)
@param eyeX
the x-coordinate of the eye/camera location
@param eyeY
the y-coordinate of the eye/camera location
@param eyeZ
the z-coordinate of the eye/camera location
@param centerX
the x-coordinate of the point to look at
@param centerY
the y-coordinate of the point to look at
@param centerZ
the z-coordinate of the point to look at
@param upX
the x-coordinate of the up vector
@param upY
the y-coordinate of the up vector
@param upZ
the z-coordinate of the up vector
@return this
"""
return lookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ, this);
} | java | public Matrix4x3f lookAt(float eyeX, float eyeY, float eyeZ,
float centerX, float centerY, float centerZ,
float upX, float upY, float upZ) {
return lookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ, this);
} | [
"public",
"Matrix4x3f",
"lookAt",
"(",
"float",
"eyeX",
",",
"float",
"eyeY",
",",
"float",
"eyeZ",
",",
"float",
"centerX",
",",
"float",
"centerY",
",",
"float",
"centerZ",
",",
"float",
"upX",
",",
"float",
"upY",
",",
"float",
"upZ",
")",
"{",
"return",
"lookAt",
"(",
"eyeX",
",",
"eyeY",
",",
"eyeZ",
",",
"centerX",
",",
"centerY",
",",
"centerZ",
",",
"upX",
",",
"upY",
",",
"upZ",
",",
"this",
")",
";",
"}"
] | Apply a "lookat" transformation to this matrix for a right-handed coordinate system,
that aligns <code>-z</code> with <code>center - eye</code>.
<p>
If <code>M</code> is <code>this</code> matrix and <code>L</code> the lookat matrix,
then the new matrix will be <code>M * L</code>. So when transforming a
vector <code>v</code> with the new matrix by using <code>M * L * v</code>,
the lookat transformation will be applied first!
<p>
In order to set the matrix to a lookat transformation without post-multiplying it,
use {@link #setLookAt(float, float, float, float, float, float, float, float, float) setLookAt()}.
@see #lookAt(Vector3fc, Vector3fc, Vector3fc)
@see #setLookAt(float, float, float, float, float, float, float, float, float)
@param eyeX
the x-coordinate of the eye/camera location
@param eyeY
the y-coordinate of the eye/camera location
@param eyeZ
the z-coordinate of the eye/camera location
@param centerX
the x-coordinate of the point to look at
@param centerY
the y-coordinate of the point to look at
@param centerZ
the z-coordinate of the point to look at
@param upX
the x-coordinate of the up vector
@param upY
the y-coordinate of the up vector
@param upZ
the z-coordinate of the up vector
@return this | [
"Apply",
"a",
"lookat",
"transformation",
"to",
"this",
"matrix",
"for",
"a",
"right",
"-",
"handed",
"coordinate",
"system",
"that",
"aligns",
"<code",
">",
"-",
"z<",
"/",
"code",
">",
"with",
"<code",
">",
"center",
"-",
"eye<",
"/",
"code",
">",
".",
"<p",
">",
"If",
"<code",
">",
"M<",
"/",
"code",
">",
"is",
"<code",
">",
"this<",
"/",
"code",
">",
"matrix",
"and",
"<code",
">",
"L<",
"/",
"code",
">",
"the",
"lookat",
"matrix",
"then",
"the",
"new",
"matrix",
"will",
"be",
"<code",
">",
"M",
"*",
"L<",
"/",
"code",
">",
".",
"So",
"when",
"transforming",
"a",
"vector",
"<code",
">",
"v<",
"/",
"code",
">",
"with",
"the",
"new",
"matrix",
"by",
"using",
"<code",
">",
"M",
"*",
"L",
"*",
"v<",
"/",
"code",
">",
"the",
"lookat",
"transformation",
"will",
"be",
"applied",
"first!",
"<p",
">",
"In",
"order",
"to",
"set",
"the",
"matrix",
"to",
"a",
"lookat",
"transformation",
"without",
"post",
"-",
"multiplying",
"it",
"use",
"{",
"@link",
"#setLookAt",
"(",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
")",
"setLookAt",
"()",
"}",
"."
] | train | https://github.com/JOML-CI/JOML/blob/ce2652fc236b42bda3875c591f8e6645048a678f/src/org/joml/Matrix4x3f.java#L6490-L6494 |
httl/httl | httl/src/main/java/httl/Context.java | Context.getContext | public static Context getContext() {
"""
Get the current context from thread local.
@return current context
"""
Context context = LOCAL.get();
if (context == null) {
context = new Context(null, null);
LOCAL.set(context);
}
return context;
} | java | public static Context getContext() {
Context context = LOCAL.get();
if (context == null) {
context = new Context(null, null);
LOCAL.set(context);
}
return context;
} | [
"public",
"static",
"Context",
"getContext",
"(",
")",
"{",
"Context",
"context",
"=",
"LOCAL",
".",
"get",
"(",
")",
";",
"if",
"(",
"context",
"==",
"null",
")",
"{",
"context",
"=",
"new",
"Context",
"(",
"null",
",",
"null",
")",
";",
"LOCAL",
".",
"set",
"(",
"context",
")",
";",
"}",
"return",
"context",
";",
"}"
] | Get the current context from thread local.
@return current context | [
"Get",
"the",
"current",
"context",
"from",
"thread",
"local",
"."
] | train | https://github.com/httl/httl/blob/e13e00f4ab41252a8f53d6dafd4a6610be9dcaad/httl/src/main/java/httl/Context.java#L83-L90 |
digitalpetri/modbus | modbus-master-tcp/src/main/java/com/digitalpetri/modbus/master/ModbusTcpMaster.java | ModbusTcpMaster.onExceptionCaught | @SuppressWarnings("WeakerAccess")
protected void onExceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
"""
Logs the exception on DEBUG level.
<p>
Subclasses may override to customize logging behavior.
@param ctx the {@link ChannelHandlerContext}.
@param cause the exception that was caught.
"""
logger.debug("Exception caught: {}", cause.getMessage(), cause);
} | java | @SuppressWarnings("WeakerAccess")
protected void onExceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
logger.debug("Exception caught: {}", cause.getMessage(), cause);
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"protected",
"void",
"onExceptionCaught",
"(",
"ChannelHandlerContext",
"ctx",
",",
"Throwable",
"cause",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Exception caught: {}\"",
",",
"cause",
".",
"getMessage",
"(",
")",
",",
"cause",
")",
";",
"}"
] | Logs the exception on DEBUG level.
<p>
Subclasses may override to customize logging behavior.
@param ctx the {@link ChannelHandlerContext}.
@param cause the exception that was caught. | [
"Logs",
"the",
"exception",
"on",
"DEBUG",
"level",
".",
"<p",
">",
"Subclasses",
"may",
"override",
"to",
"customize",
"logging",
"behavior",
"."
] | train | https://github.com/digitalpetri/modbus/blob/66281d811e64dfcdf8c8a8d0e85cdd80ae809a19/modbus-master-tcp/src/main/java/com/digitalpetri/modbus/master/ModbusTcpMaster.java#L195-L198 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/JCublasNDArrayFactory.java | JCublasNDArrayFactory.pullRows | @Override
public INDArray pullRows(INDArray source, int sourceDimension, int[] indexes, char order) {
"""
This method produces concatenated array, that consist from tensors, fetched from source array, against some dimension and specified indexes
@param source source tensor
@param sourceDimension dimension of source tensor
@param indexes indexes from source array
@return
"""
if (indexes == null || indexes.length < 1)
throw new IllegalStateException("Indexes can't be null or zero-length");
long[] shape;
if (source.rank() == 1) {
shape = new long[]{indexes.length};
} else if (sourceDimension == 1)
shape = new long[] {indexes.length, source.shape()[sourceDimension]};
else if (sourceDimension == 0)
shape = new long[] {source.shape()[sourceDimension], indexes.length};
else
throw new UnsupportedOperationException("2D input is expected");
return pullRows(source, Nd4j.createUninitialized(source.dataType(), shape, order), sourceDimension, indexes);
} | java | @Override
public INDArray pullRows(INDArray source, int sourceDimension, int[] indexes, char order) {
if (indexes == null || indexes.length < 1)
throw new IllegalStateException("Indexes can't be null or zero-length");
long[] shape;
if (source.rank() == 1) {
shape = new long[]{indexes.length};
} else if (sourceDimension == 1)
shape = new long[] {indexes.length, source.shape()[sourceDimension]};
else if (sourceDimension == 0)
shape = new long[] {source.shape()[sourceDimension], indexes.length};
else
throw new UnsupportedOperationException("2D input is expected");
return pullRows(source, Nd4j.createUninitialized(source.dataType(), shape, order), sourceDimension, indexes);
} | [
"@",
"Override",
"public",
"INDArray",
"pullRows",
"(",
"INDArray",
"source",
",",
"int",
"sourceDimension",
",",
"int",
"[",
"]",
"indexes",
",",
"char",
"order",
")",
"{",
"if",
"(",
"indexes",
"==",
"null",
"||",
"indexes",
".",
"length",
"<",
"1",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Indexes can't be null or zero-length\"",
")",
";",
"long",
"[",
"]",
"shape",
";",
"if",
"(",
"source",
".",
"rank",
"(",
")",
"==",
"1",
")",
"{",
"shape",
"=",
"new",
"long",
"[",
"]",
"{",
"indexes",
".",
"length",
"}",
";",
"}",
"else",
"if",
"(",
"sourceDimension",
"==",
"1",
")",
"shape",
"=",
"new",
"long",
"[",
"]",
"{",
"indexes",
".",
"length",
",",
"source",
".",
"shape",
"(",
")",
"[",
"sourceDimension",
"]",
"}",
";",
"else",
"if",
"(",
"sourceDimension",
"==",
"0",
")",
"shape",
"=",
"new",
"long",
"[",
"]",
"{",
"source",
".",
"shape",
"(",
")",
"[",
"sourceDimension",
"]",
",",
"indexes",
".",
"length",
"}",
";",
"else",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"2D input is expected\"",
")",
";",
"return",
"pullRows",
"(",
"source",
",",
"Nd4j",
".",
"createUninitialized",
"(",
"source",
".",
"dataType",
"(",
")",
",",
"shape",
",",
"order",
")",
",",
"sourceDimension",
",",
"indexes",
")",
";",
"}"
] | This method produces concatenated array, that consist from tensors, fetched from source array, against some dimension and specified indexes
@param source source tensor
@param sourceDimension dimension of source tensor
@param indexes indexes from source array
@return | [
"This",
"method",
"produces",
"concatenated",
"array",
"that",
"consist",
"from",
"tensors",
"fetched",
"from",
"source",
"array",
"against",
"some",
"dimension",
"and",
"specified",
"indexes"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/JCublasNDArrayFactory.java#L635-L652 |
deeplearning4j/deeplearning4j | nd4j/nd4j-common/src/main/java/org/nd4j/linalg/primitives/Counter.java | Counter.incrementAll | public void incrementAll(Collection<T> elements, double inc) {
"""
This method will increment all elements in collection
@param elements
@param inc
"""
for (T element: elements) {
incrementCount(element, inc);
}
} | java | public void incrementAll(Collection<T> elements, double inc) {
for (T element: elements) {
incrementCount(element, inc);
}
} | [
"public",
"void",
"incrementAll",
"(",
"Collection",
"<",
"T",
">",
"elements",
",",
"double",
"inc",
")",
"{",
"for",
"(",
"T",
"element",
":",
"elements",
")",
"{",
"incrementCount",
"(",
"element",
",",
"inc",
")",
";",
"}",
"}"
] | This method will increment all elements in collection
@param elements
@param inc | [
"This",
"method",
"will",
"increment",
"all",
"elements",
"in",
"collection"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/primitives/Counter.java#L64-L68 |
versionone/VersionOne.SDK.Java.ObjectModel | src/main/java/com/versionone/om/V1InstanceCreator.java | V1InstanceCreator.buildRun | public BuildRun buildRun(BuildProject buildProject, String name,
DateTime date) {
"""
Create a new Build Run in the given Build Project with a name and date.
@param buildProject The Build Project this Build Run belongs to.
@param name Name of the build project.
@param date The Date this Build Run ran.
@return A newly minted Build Run that exists in the VersionOne system.
"""
return buildRun(buildProject, name, date, null);
} | java | public BuildRun buildRun(BuildProject buildProject, String name,
DateTime date) {
return buildRun(buildProject, name, date, null);
} | [
"public",
"BuildRun",
"buildRun",
"(",
"BuildProject",
"buildProject",
",",
"String",
"name",
",",
"DateTime",
"date",
")",
"{",
"return",
"buildRun",
"(",
"buildProject",
",",
"name",
",",
"date",
",",
"null",
")",
";",
"}"
] | Create a new Build Run in the given Build Project with a name and date.
@param buildProject The Build Project this Build Run belongs to.
@param name Name of the build project.
@param date The Date this Build Run ran.
@return A newly minted Build Run that exists in the VersionOne system. | [
"Create",
"a",
"new",
"Build",
"Run",
"in",
"the",
"given",
"Build",
"Project",
"with",
"a",
"name",
"and",
"date",
"."
] | train | https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/V1InstanceCreator.java#L896-L899 |
jeremylong/DependencyCheck | utils/src/main/java/org/owasp/dependencycheck/utils/Checksum.java | Checksum.getChecksum | public static String getChecksum(String algorithm, byte[] bytes) {
"""
Calculates the MD5 checksum of a specified bytes.
@param algorithm the algorithm to use (md5, sha1, etc.) to calculate the
message digest
@param bytes the bytes to generate the MD5 checksum
@return the hex representation of the MD5 hash
"""
final MessageDigest digest = getMessageDigest(algorithm);
final byte[] b = digest.digest(bytes);
return getHex(b);
} | java | public static String getChecksum(String algorithm, byte[] bytes) {
final MessageDigest digest = getMessageDigest(algorithm);
final byte[] b = digest.digest(bytes);
return getHex(b);
} | [
"public",
"static",
"String",
"getChecksum",
"(",
"String",
"algorithm",
",",
"byte",
"[",
"]",
"bytes",
")",
"{",
"final",
"MessageDigest",
"digest",
"=",
"getMessageDigest",
"(",
"algorithm",
")",
";",
"final",
"byte",
"[",
"]",
"b",
"=",
"digest",
".",
"digest",
"(",
"bytes",
")",
";",
"return",
"getHex",
"(",
"b",
")",
";",
"}"
] | Calculates the MD5 checksum of a specified bytes.
@param algorithm the algorithm to use (md5, sha1, etc.) to calculate the
message digest
@param bytes the bytes to generate the MD5 checksum
@return the hex representation of the MD5 hash | [
"Calculates",
"the",
"MD5",
"checksum",
"of",
"a",
"specified",
"bytes",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/utils/src/main/java/org/owasp/dependencycheck/utils/Checksum.java#L146-L150 |
LearnLib/learnlib | commons/counterexamples/src/main/java/de/learnlib/counterexamples/GlobalSuffixFinders.java | GlobalSuffixFinders.findLinear | public static <I, D> List<Word<I>> findLinear(Query<I, D> ceQuery,
AccessSequenceTransformer<I> asTransformer,
SuffixOutput<I, D> hypOutput,
MembershipOracle<I, D> oracle,
boolean allSuffixes) {
"""
Returns the suffix (plus all of its suffixes, if {@code allSuffixes} is true) found by the access sequence
transformation in ascending linear order.
@param ceQuery
the counterexample query
@param asTransformer
the access sequence transformer
@param hypOutput
interface to the hypothesis output
@param oracle
interface to the SUL output
@param allSuffixes
whether or not to include all suffixes of the found suffix
@return the distinguishing suffixes
@see LocalSuffixFinders#findLinear(Query, AccessSequenceTransformer, SuffixOutput, MembershipOracle)
"""
int idx = LocalSuffixFinders.findLinear(ceQuery, asTransformer, hypOutput, oracle);
return suffixesForLocalOutput(ceQuery, idx, allSuffixes);
} | java | public static <I, D> List<Word<I>> findLinear(Query<I, D> ceQuery,
AccessSequenceTransformer<I> asTransformer,
SuffixOutput<I, D> hypOutput,
MembershipOracle<I, D> oracle,
boolean allSuffixes) {
int idx = LocalSuffixFinders.findLinear(ceQuery, asTransformer, hypOutput, oracle);
return suffixesForLocalOutput(ceQuery, idx, allSuffixes);
} | [
"public",
"static",
"<",
"I",
",",
"D",
">",
"List",
"<",
"Word",
"<",
"I",
">",
">",
"findLinear",
"(",
"Query",
"<",
"I",
",",
"D",
">",
"ceQuery",
",",
"AccessSequenceTransformer",
"<",
"I",
">",
"asTransformer",
",",
"SuffixOutput",
"<",
"I",
",",
"D",
">",
"hypOutput",
",",
"MembershipOracle",
"<",
"I",
",",
"D",
">",
"oracle",
",",
"boolean",
"allSuffixes",
")",
"{",
"int",
"idx",
"=",
"LocalSuffixFinders",
".",
"findLinear",
"(",
"ceQuery",
",",
"asTransformer",
",",
"hypOutput",
",",
"oracle",
")",
";",
"return",
"suffixesForLocalOutput",
"(",
"ceQuery",
",",
"idx",
",",
"allSuffixes",
")",
";",
"}"
] | Returns the suffix (plus all of its suffixes, if {@code allSuffixes} is true) found by the access sequence
transformation in ascending linear order.
@param ceQuery
the counterexample query
@param asTransformer
the access sequence transformer
@param hypOutput
interface to the hypothesis output
@param oracle
interface to the SUL output
@param allSuffixes
whether or not to include all suffixes of the found suffix
@return the distinguishing suffixes
@see LocalSuffixFinders#findLinear(Query, AccessSequenceTransformer, SuffixOutput, MembershipOracle) | [
"Returns",
"the",
"suffix",
"(",
"plus",
"all",
"of",
"its",
"suffixes",
"if",
"{",
"@code",
"allSuffixes",
"}",
"is",
"true",
")",
"found",
"by",
"the",
"access",
"sequence",
"transformation",
"in",
"ascending",
"linear",
"order",
"."
] | train | https://github.com/LearnLib/learnlib/blob/fa38a14adcc0664099f180d671ffa42480318d7b/commons/counterexamples/src/main/java/de/learnlib/counterexamples/GlobalSuffixFinders.java#L276-L283 |
apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.setTopology | public Boolean setTopology(TopologyAPI.Topology topology, String topologyName) {
"""
Set the topology definition for the given topology
@param topologyName the name of the topology
@return Boolean - Success or Failure
"""
return awaitResult(delegate.setTopology(topology, topologyName));
} | java | public Boolean setTopology(TopologyAPI.Topology topology, String topologyName) {
return awaitResult(delegate.setTopology(topology, topologyName));
} | [
"public",
"Boolean",
"setTopology",
"(",
"TopologyAPI",
".",
"Topology",
"topology",
",",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"setTopology",
"(",
"topology",
",",
"topologyName",
")",
")",
";",
"}"
] | Set the topology definition for the given topology
@param topologyName the name of the topology
@return Boolean - Success or Failure | [
"Set",
"the",
"topology",
"definition",
"for",
"the",
"given",
"topology"
] | train | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L118-L120 |
hal/core | gui/src/main/java/org/useware/kernel/gui/behaviour/Integrity.java | Integrity.assertConsumer | private static void assertConsumer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {
"""
Assertion that a consumer exists for the produced resources of an interaction unit.
@param unit
@param err
"""
Set<Resource<ResourceType>> producedTypes = unit.getOutputs();
for (Resource<ResourceType> resource : producedTypes) {
boolean match = false;
for(QName id : behaviours.keySet())
{
for (Behaviour behaviour : behaviours.get(id)) {
if (behaviour.doesConsume(resource)) {
match = true;
break;
}
}
}
if (!match)
err.add(unit.getId(), "Missing consumer for <<" + resource + ">>");
}
} | java | private static void assertConsumer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {
Set<Resource<ResourceType>> producedTypes = unit.getOutputs();
for (Resource<ResourceType> resource : producedTypes) {
boolean match = false;
for(QName id : behaviours.keySet())
{
for (Behaviour behaviour : behaviours.get(id)) {
if (behaviour.doesConsume(resource)) {
match = true;
break;
}
}
}
if (!match)
err.add(unit.getId(), "Missing consumer for <<" + resource + ">>");
}
} | [
"private",
"static",
"void",
"assertConsumer",
"(",
"InteractionUnit",
"unit",
",",
"Map",
"<",
"QName",
",",
"Set",
"<",
"Procedure",
">",
">",
"behaviours",
",",
"IntegrityErrors",
"err",
")",
"{",
"Set",
"<",
"Resource",
"<",
"ResourceType",
">>",
"producedTypes",
"=",
"unit",
".",
"getOutputs",
"(",
")",
";",
"for",
"(",
"Resource",
"<",
"ResourceType",
">",
"resource",
":",
"producedTypes",
")",
"{",
"boolean",
"match",
"=",
"false",
";",
"for",
"(",
"QName",
"id",
":",
"behaviours",
".",
"keySet",
"(",
")",
")",
"{",
"for",
"(",
"Behaviour",
"behaviour",
":",
"behaviours",
".",
"get",
"(",
"id",
")",
")",
"{",
"if",
"(",
"behaviour",
".",
"doesConsume",
"(",
"resource",
")",
")",
"{",
"match",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"match",
")",
"err",
".",
"add",
"(",
"unit",
".",
"getId",
"(",
")",
",",
"\"Missing consumer for <<\"",
"+",
"resource",
"+",
"\">>\"",
")",
";",
"}",
"}"
] | Assertion that a consumer exists for the produced resources of an interaction unit.
@param unit
@param err | [
"Assertion",
"that",
"a",
"consumer",
"exists",
"for",
"the",
"produced",
"resources",
"of",
"an",
"interaction",
"unit",
"."
] | train | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/gui/behaviour/Integrity.java#L63-L84 |
atomix/atomix | storage/src/main/java/io/atomix/storage/journal/JournalSegmentFile.java | JournalSegmentFile.isSegmentFile | public static boolean isSegmentFile(String journalName, String fileName) {
"""
Returns a boolean value indicating whether the given file appears to be a parsable segment file.
@param journalName the name of the journal
@param fileName the name of the file to check
@throws NullPointerException if {@code file} is null
"""
checkNotNull(journalName, "journalName cannot be null");
checkNotNull(fileName, "fileName cannot be null");
int partSeparator = fileName.lastIndexOf(PART_SEPARATOR);
int extensionSeparator = fileName.lastIndexOf(EXTENSION_SEPARATOR);
if (extensionSeparator == -1
|| partSeparator == -1
|| extensionSeparator < partSeparator
|| !fileName.endsWith(EXTENSION)) {
return false;
}
for (int i = partSeparator + 1; i < extensionSeparator; i++) {
if (!Character.isDigit(fileName.charAt(i))) {
return false;
}
}
return fileName.startsWith(journalName);
} | java | public static boolean isSegmentFile(String journalName, String fileName) {
checkNotNull(journalName, "journalName cannot be null");
checkNotNull(fileName, "fileName cannot be null");
int partSeparator = fileName.lastIndexOf(PART_SEPARATOR);
int extensionSeparator = fileName.lastIndexOf(EXTENSION_SEPARATOR);
if (extensionSeparator == -1
|| partSeparator == -1
|| extensionSeparator < partSeparator
|| !fileName.endsWith(EXTENSION)) {
return false;
}
for (int i = partSeparator + 1; i < extensionSeparator; i++) {
if (!Character.isDigit(fileName.charAt(i))) {
return false;
}
}
return fileName.startsWith(journalName);
} | [
"public",
"static",
"boolean",
"isSegmentFile",
"(",
"String",
"journalName",
",",
"String",
"fileName",
")",
"{",
"checkNotNull",
"(",
"journalName",
",",
"\"journalName cannot be null\"",
")",
";",
"checkNotNull",
"(",
"fileName",
",",
"\"fileName cannot be null\"",
")",
";",
"int",
"partSeparator",
"=",
"fileName",
".",
"lastIndexOf",
"(",
"PART_SEPARATOR",
")",
";",
"int",
"extensionSeparator",
"=",
"fileName",
".",
"lastIndexOf",
"(",
"EXTENSION_SEPARATOR",
")",
";",
"if",
"(",
"extensionSeparator",
"==",
"-",
"1",
"||",
"partSeparator",
"==",
"-",
"1",
"||",
"extensionSeparator",
"<",
"partSeparator",
"||",
"!",
"fileName",
".",
"endsWith",
"(",
"EXTENSION",
")",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"partSeparator",
"+",
"1",
";",
"i",
"<",
"extensionSeparator",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"Character",
".",
"isDigit",
"(",
"fileName",
".",
"charAt",
"(",
"i",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"fileName",
".",
"startsWith",
"(",
"journalName",
")",
";",
"}"
] | Returns a boolean value indicating whether the given file appears to be a parsable segment file.
@param journalName the name of the journal
@param fileName the name of the file to check
@throws NullPointerException if {@code file} is null | [
"Returns",
"a",
"boolean",
"value",
"indicating",
"whether",
"the",
"given",
"file",
"appears",
"to",
"be",
"a",
"parsable",
"segment",
"file",
"."
] | train | https://github.com/atomix/atomix/blob/3a94b7c80576d762dd0d396d4645df07a0b37c31/storage/src/main/java/io/atomix/storage/journal/JournalSegmentFile.java#L49-L70 |
RestComm/sip-servlets | containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/annotations/AnnotationsClassLoader.java | AnnotationsClassLoader.findResourceInternal | protected ResourceEntry findResourceInternal(File file, String path) {
"""
Find specified resource in local repositories. This block
will execute under an AccessControl.doPrivilege block.
@return the loaded resource, or null if the resource isn't found
"""
ResourceEntry entry = new ResourceEntry();
try {
entry.source = getURI(new File(file, path));
entry.codeBase = getURL(new File(file, path), false);
} catch (MalformedURLException e) {
return null;
}
return entry;
} | java | protected ResourceEntry findResourceInternal(File file, String path){
ResourceEntry entry = new ResourceEntry();
try {
entry.source = getURI(new File(file, path));
entry.codeBase = getURL(new File(file, path), false);
} catch (MalformedURLException e) {
return null;
}
return entry;
} | [
"protected",
"ResourceEntry",
"findResourceInternal",
"(",
"File",
"file",
",",
"String",
"path",
")",
"{",
"ResourceEntry",
"entry",
"=",
"new",
"ResourceEntry",
"(",
")",
";",
"try",
"{",
"entry",
".",
"source",
"=",
"getURI",
"(",
"new",
"File",
"(",
"file",
",",
"path",
")",
")",
";",
"entry",
".",
"codeBase",
"=",
"getURL",
"(",
"new",
"File",
"(",
"file",
",",
"path",
")",
",",
"false",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"return",
"entry",
";",
"}"
] | Find specified resource in local repositories. This block
will execute under an AccessControl.doPrivilege block.
@return the loaded resource, or null if the resource isn't found | [
"Find",
"specified",
"resource",
"in",
"local",
"repositories",
".",
"This",
"block",
"will",
"execute",
"under",
"an",
"AccessControl",
".",
"doPrivilege",
"block",
"."
] | train | https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/annotations/AnnotationsClassLoader.java#L1870-L1879 |
apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/watermark/TimestampWatermark.java | TimestampWatermark.adjustWatermark | public static long adjustWatermark(String baseWatermark, int diff) {
"""
Adjust the given watermark by diff
@param baseWatermark the original watermark
@param diff the amount to change
@return the adjusted watermark value
"""
SimpleDateFormat parser = new SimpleDateFormat(INPUTFORMAT);
try {
Date date = parser.parse(baseWatermark);
return Long.parseLong(parser.format(Utils.addSecondsToDate(date, diff)));
} catch (ParseException e) {
LOG.error("Fail to adjust timestamp watermark", e);
}
return -1;
} | java | public static long adjustWatermark(String baseWatermark, int diff) {
SimpleDateFormat parser = new SimpleDateFormat(INPUTFORMAT);
try {
Date date = parser.parse(baseWatermark);
return Long.parseLong(parser.format(Utils.addSecondsToDate(date, diff)));
} catch (ParseException e) {
LOG.error("Fail to adjust timestamp watermark", e);
}
return -1;
} | [
"public",
"static",
"long",
"adjustWatermark",
"(",
"String",
"baseWatermark",
",",
"int",
"diff",
")",
"{",
"SimpleDateFormat",
"parser",
"=",
"new",
"SimpleDateFormat",
"(",
"INPUTFORMAT",
")",
";",
"try",
"{",
"Date",
"date",
"=",
"parser",
".",
"parse",
"(",
"baseWatermark",
")",
";",
"return",
"Long",
".",
"parseLong",
"(",
"parser",
".",
"format",
"(",
"Utils",
".",
"addSecondsToDate",
"(",
"date",
",",
"diff",
")",
")",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Fail to adjust timestamp watermark\"",
",",
"e",
")",
";",
"}",
"return",
"-",
"1",
";",
"}"
] | Adjust the given watermark by diff
@param baseWatermark the original watermark
@param diff the amount to change
@return the adjusted watermark value | [
"Adjust",
"the",
"given",
"watermark",
"by",
"diff"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/watermark/TimestampWatermark.java#L153-L162 |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/SNE.java | SNE.optimizeSNE | protected void optimizeSNE(AffinityMatrix pij, double[][] sol) {
"""
Perform the actual tSNE optimization.
@param pij Initial affinity matrix
@param sol Solution output array (preinitialized)
"""
final int size = pij.size();
if(size * 3L * dim > 0x7FFF_FFFAL) {
throw new AbortException("Memory exceeds Java array size limit.");
}
// Meta information on each point; joined for memory locality.
// Gradient, Momentum, and learning rate
// For performance, we use a flat memory layout!
double[] meta = new double[size * 3 * dim];
final int dim3 = dim * 3;
for(int off = 2 * dim; off < meta.length; off += dim3) {
Arrays.fill(meta, off, off + dim, 1.); // Initial learning rate
}
// Affinity matrix in projected space
double[][] qij = new double[size][size];
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Iterative Optimization", iterations, LOG) : null;
Duration timer = LOG.isStatistics() ? LOG.newDuration(this.getClass().getName() + ".runtime.optimization").begin() : null;
// Optimize
for(int it = 0; it < iterations; it++) {
double qij_sum = computeQij(qij, sol);
computeGradient(pij, qij, 1. / qij_sum, sol, meta);
updateSolution(sol, meta, it);
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
if(timer != null) {
LOG.statistics(timer.end());
}
} | java | protected void optimizeSNE(AffinityMatrix pij, double[][] sol) {
final int size = pij.size();
if(size * 3L * dim > 0x7FFF_FFFAL) {
throw new AbortException("Memory exceeds Java array size limit.");
}
// Meta information on each point; joined for memory locality.
// Gradient, Momentum, and learning rate
// For performance, we use a flat memory layout!
double[] meta = new double[size * 3 * dim];
final int dim3 = dim * 3;
for(int off = 2 * dim; off < meta.length; off += dim3) {
Arrays.fill(meta, off, off + dim, 1.); // Initial learning rate
}
// Affinity matrix in projected space
double[][] qij = new double[size][size];
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Iterative Optimization", iterations, LOG) : null;
Duration timer = LOG.isStatistics() ? LOG.newDuration(this.getClass().getName() + ".runtime.optimization").begin() : null;
// Optimize
for(int it = 0; it < iterations; it++) {
double qij_sum = computeQij(qij, sol);
computeGradient(pij, qij, 1. / qij_sum, sol, meta);
updateSolution(sol, meta, it);
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
if(timer != null) {
LOG.statistics(timer.end());
}
} | [
"protected",
"void",
"optimizeSNE",
"(",
"AffinityMatrix",
"pij",
",",
"double",
"[",
"]",
"[",
"]",
"sol",
")",
"{",
"final",
"int",
"size",
"=",
"pij",
".",
"size",
"(",
")",
";",
"if",
"(",
"size",
"*",
"3L",
"*",
"dim",
">",
"0x7FFF_FFFA",
"L",
")",
"{",
"throw",
"new",
"AbortException",
"(",
"\"Memory exceeds Java array size limit.\"",
")",
";",
"}",
"// Meta information on each point; joined for memory locality.",
"// Gradient, Momentum, and learning rate",
"// For performance, we use a flat memory layout!",
"double",
"[",
"]",
"meta",
"=",
"new",
"double",
"[",
"size",
"*",
"3",
"*",
"dim",
"]",
";",
"final",
"int",
"dim3",
"=",
"dim",
"*",
"3",
";",
"for",
"(",
"int",
"off",
"=",
"2",
"*",
"dim",
";",
"off",
"<",
"meta",
".",
"length",
";",
"off",
"+=",
"dim3",
")",
"{",
"Arrays",
".",
"fill",
"(",
"meta",
",",
"off",
",",
"off",
"+",
"dim",
",",
"1.",
")",
";",
"// Initial learning rate",
"}",
"// Affinity matrix in projected space",
"double",
"[",
"]",
"[",
"]",
"qij",
"=",
"new",
"double",
"[",
"size",
"]",
"[",
"size",
"]",
";",
"FiniteProgress",
"prog",
"=",
"LOG",
".",
"isVerbose",
"(",
")",
"?",
"new",
"FiniteProgress",
"(",
"\"Iterative Optimization\"",
",",
"iterations",
",",
"LOG",
")",
":",
"null",
";",
"Duration",
"timer",
"=",
"LOG",
".",
"isStatistics",
"(",
")",
"?",
"LOG",
".",
"newDuration",
"(",
"this",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".runtime.optimization\"",
")",
".",
"begin",
"(",
")",
":",
"null",
";",
"// Optimize",
"for",
"(",
"int",
"it",
"=",
"0",
";",
"it",
"<",
"iterations",
";",
"it",
"++",
")",
"{",
"double",
"qij_sum",
"=",
"computeQij",
"(",
"qij",
",",
"sol",
")",
";",
"computeGradient",
"(",
"pij",
",",
"qij",
",",
"1.",
"/",
"qij_sum",
",",
"sol",
",",
"meta",
")",
";",
"updateSolution",
"(",
"sol",
",",
"meta",
",",
"it",
")",
";",
"LOG",
".",
"incrementProcessed",
"(",
"prog",
")",
";",
"}",
"LOG",
".",
"ensureCompleted",
"(",
"prog",
")",
";",
"if",
"(",
"timer",
"!=",
"null",
")",
"{",
"LOG",
".",
"statistics",
"(",
"timer",
".",
"end",
"(",
")",
")",
";",
"}",
"}"
] | Perform the actual tSNE optimization.
@param pij Initial affinity matrix
@param sol Solution output array (preinitialized) | [
"Perform",
"the",
"actual",
"tSNE",
"optimization",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/projection/SNE.java#L219-L248 |
google/error-prone-javac | src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java | Types.overrideEquivalent | public boolean overrideEquivalent(Type t, Type s) {
"""
Returns true iff these signatures are related by <em>override
equivalence</em>. This is the natural extension of
isSubSignature to an equivalence relation.
@jls section 8.4.2.
@see #isSubSignature(Type t, Type s)
@param t a signature (possible raw, could be subjected to
erasure).
@param s a signature (possible raw, could be subjected to
erasure).
@return true if either argument is a sub signature of the other.
"""
return hasSameArgs(t, s) ||
hasSameArgs(t, erasure(s)) || hasSameArgs(erasure(t), s);
} | java | public boolean overrideEquivalent(Type t, Type s) {
return hasSameArgs(t, s) ||
hasSameArgs(t, erasure(s)) || hasSameArgs(erasure(t), s);
} | [
"public",
"boolean",
"overrideEquivalent",
"(",
"Type",
"t",
",",
"Type",
"s",
")",
"{",
"return",
"hasSameArgs",
"(",
"t",
",",
"s",
")",
"||",
"hasSameArgs",
"(",
"t",
",",
"erasure",
"(",
"s",
")",
")",
"||",
"hasSameArgs",
"(",
"erasure",
"(",
"t",
")",
",",
"s",
")",
";",
"}"
] | Returns true iff these signatures are related by <em>override
equivalence</em>. This is the natural extension of
isSubSignature to an equivalence relation.
@jls section 8.4.2.
@see #isSubSignature(Type t, Type s)
@param t a signature (possible raw, could be subjected to
erasure).
@param s a signature (possible raw, could be subjected to
erasure).
@return true if either argument is a sub signature of the other. | [
"Returns",
"true",
"iff",
"these",
"signatures",
"are",
"related",
"by",
"<em",
">",
"override",
"equivalence<",
"/",
"em",
">",
".",
"This",
"is",
"the",
"natural",
"extension",
"of",
"isSubSignature",
"to",
"an",
"equivalence",
"relation",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java#L2515-L2518 |
alkacon/opencms-core | src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageHandler.java | CmsContainerpageHandler.createRawMenuEntry | protected CmsContextMenuEntry createRawMenuEntry(CmsUUID structureId, final Runnable action) {
"""
Creates a menu entry based on a structure id and action without anything else.<p>
@param structureId the structure id
@param action the action for the menu entry
@return the new menu entry
"""
CmsContextMenuEntry entry = new CmsContextMenuEntry(this, structureId, new I_CmsContextMenuCommand() {
public void execute(
CmsUUID innerStructureId,
I_CmsContextMenuHandler handler,
CmsContextMenuEntryBean bean) {
if (action != null) {
action.run();
}
}
public A_CmsContextMenuItem getItemWidget(
CmsUUID innerStructureId,
I_CmsContextMenuHandler handler,
CmsContextMenuEntryBean bean) {
return null;
}
public boolean hasItemWidget() {
return false;
}
});
return entry;
} | java | protected CmsContextMenuEntry createRawMenuEntry(CmsUUID structureId, final Runnable action) {
CmsContextMenuEntry entry = new CmsContextMenuEntry(this, structureId, new I_CmsContextMenuCommand() {
public void execute(
CmsUUID innerStructureId,
I_CmsContextMenuHandler handler,
CmsContextMenuEntryBean bean) {
if (action != null) {
action.run();
}
}
public A_CmsContextMenuItem getItemWidget(
CmsUUID innerStructureId,
I_CmsContextMenuHandler handler,
CmsContextMenuEntryBean bean) {
return null;
}
public boolean hasItemWidget() {
return false;
}
});
return entry;
} | [
"protected",
"CmsContextMenuEntry",
"createRawMenuEntry",
"(",
"CmsUUID",
"structureId",
",",
"final",
"Runnable",
"action",
")",
"{",
"CmsContextMenuEntry",
"entry",
"=",
"new",
"CmsContextMenuEntry",
"(",
"this",
",",
"structureId",
",",
"new",
"I_CmsContextMenuCommand",
"(",
")",
"{",
"public",
"void",
"execute",
"(",
"CmsUUID",
"innerStructureId",
",",
"I_CmsContextMenuHandler",
"handler",
",",
"CmsContextMenuEntryBean",
"bean",
")",
"{",
"if",
"(",
"action",
"!=",
"null",
")",
"{",
"action",
".",
"run",
"(",
")",
";",
"}",
"}",
"public",
"A_CmsContextMenuItem",
"getItemWidget",
"(",
"CmsUUID",
"innerStructureId",
",",
"I_CmsContextMenuHandler",
"handler",
",",
"CmsContextMenuEntryBean",
"bean",
")",
"{",
"return",
"null",
";",
"}",
"public",
"boolean",
"hasItemWidget",
"(",
")",
"{",
"return",
"false",
";",
"}",
"}",
")",
";",
"return",
"entry",
";",
"}"
] | Creates a menu entry based on a structure id and action without anything else.<p>
@param structureId the structure id
@param action the action for the menu entry
@return the new menu entry | [
"Creates",
"a",
"menu",
"entry",
"based",
"on",
"a",
"structure",
"id",
"and",
"action",
"without",
"anything",
"else",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/containerpage/client/CmsContainerpageHandler.java#L1266-L1295 |
Sciss/abc4j | abc/src/main/java/abc/parser/AbcGrammar.java | AbcGrammar.BracketedVoice | Rule BracketedVoice() {
"""
bracketed-voice ::= "[" *WSP (single-voice / braced-voice / paren-voice)
1*(bar-staves (single-voice / braced-voice / paren-voice)) *WSP "]"
<p>
staves joined by bracket
"""
return Sequence('[', ZeroOrMore(WSP()),
FirstOf(SingleVoice(), BracedVoice(), ParenVoice()),
OneOrMore(Sequence(BarStaves(),
FirstOf(SingleVoice(), BracedVoice(), ParenVoice()))),
ZeroOrMore(WSP()),
']')
.label(BracketedVoice);
} | java | Rule BracketedVoice() {
return Sequence('[', ZeroOrMore(WSP()),
FirstOf(SingleVoice(), BracedVoice(), ParenVoice()),
OneOrMore(Sequence(BarStaves(),
FirstOf(SingleVoice(), BracedVoice(), ParenVoice()))),
ZeroOrMore(WSP()),
']')
.label(BracketedVoice);
} | [
"Rule",
"BracketedVoice",
"(",
")",
"{",
"return",
"Sequence",
"(",
"'",
"'",
",",
"ZeroOrMore",
"(",
"WSP",
"(",
")",
")",
",",
"FirstOf",
"(",
"SingleVoice",
"(",
")",
",",
"BracedVoice",
"(",
")",
",",
"ParenVoice",
"(",
")",
")",
",",
"OneOrMore",
"(",
"Sequence",
"(",
"BarStaves",
"(",
")",
",",
"FirstOf",
"(",
"SingleVoice",
"(",
")",
",",
"BracedVoice",
"(",
")",
",",
"ParenVoice",
"(",
")",
")",
")",
")",
",",
"ZeroOrMore",
"(",
"WSP",
"(",
")",
")",
",",
"'",
"'",
")",
".",
"label",
"(",
"BracketedVoice",
")",
";",
"}"
] | bracketed-voice ::= "[" *WSP (single-voice / braced-voice / paren-voice)
1*(bar-staves (single-voice / braced-voice / paren-voice)) *WSP "]"
<p>
staves joined by bracket | [
"bracketed",
"-",
"voice",
"::",
"=",
"[",
"*",
"WSP",
"(",
"single",
"-",
"voice",
"/",
"braced",
"-",
"voice",
"/",
"paren",
"-",
"voice",
")",
"1",
"*",
"(",
"bar",
"-",
"staves",
"(",
"single",
"-",
"voice",
"/",
"braced",
"-",
"voice",
"/",
"paren",
"-",
"voice",
"))",
"*",
"WSP",
"]",
"<p",
">",
"staves",
"joined",
"by",
"bracket"
] | train | https://github.com/Sciss/abc4j/blob/117b405642c84a7bfca4e3e13668838258b90ca7/abc/src/main/java/abc/parser/AbcGrammar.java#L2113-L2121 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_ovhPabx_serviceName_menu_menuId_entry_entryId_DELETE | public void billingAccount_ovhPabx_serviceName_menu_menuId_entry_entryId_DELETE(String billingAccount, String serviceName, Long menuId, Long entryId) throws IOException {
"""
Delete the given menu entry
REST: DELETE /telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry/{entryId}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param menuId [required]
@param entryId [required]
"""
String qPath = "/telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry/{entryId}";
StringBuilder sb = path(qPath, billingAccount, serviceName, menuId, entryId);
exec(qPath, "DELETE", sb.toString(), null);
} | java | public void billingAccount_ovhPabx_serviceName_menu_menuId_entry_entryId_DELETE(String billingAccount, String serviceName, Long menuId, Long entryId) throws IOException {
String qPath = "/telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry/{entryId}";
StringBuilder sb = path(qPath, billingAccount, serviceName, menuId, entryId);
exec(qPath, "DELETE", sb.toString(), null);
} | [
"public",
"void",
"billingAccount_ovhPabx_serviceName_menu_menuId_entry_entryId_DELETE",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"Long",
"menuId",
",",
"Long",
"entryId",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry/{entryId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
",",
"menuId",
",",
"entryId",
")",
";",
"exec",
"(",
"qPath",
",",
"\"DELETE\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"}"
] | Delete the given menu entry
REST: DELETE /telephony/{billingAccount}/ovhPabx/{serviceName}/menu/{menuId}/entry/{entryId}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param menuId [required]
@param entryId [required] | [
"Delete",
"the",
"given",
"menu",
"entry"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L7524-L7528 |
camunda/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/LegacyBehavior.java | LegacyBehavior.repairParentRelationships | public static void repairParentRelationships(Collection<ActivityInstanceImpl> values, String processInstanceId) {
"""
This is relevant for {@link GetActivityInstanceCmd} where in case of legacy multi-instance execution trees, the default
algorithm omits multi-instance activity instances.
"""
for (ActivityInstanceImpl activityInstance : values) {
// if the determined activity instance id and the parent activity instance are equal,
// just put the activity instance under the process instance
if (valuesEqual(activityInstance.getId(), activityInstance.getParentActivityInstanceId())) {
activityInstance.setParentActivityInstanceId(processInstanceId);
}
}
} | java | public static void repairParentRelationships(Collection<ActivityInstanceImpl> values, String processInstanceId) {
for (ActivityInstanceImpl activityInstance : values) {
// if the determined activity instance id and the parent activity instance are equal,
// just put the activity instance under the process instance
if (valuesEqual(activityInstance.getId(), activityInstance.getParentActivityInstanceId())) {
activityInstance.setParentActivityInstanceId(processInstanceId);
}
}
} | [
"public",
"static",
"void",
"repairParentRelationships",
"(",
"Collection",
"<",
"ActivityInstanceImpl",
">",
"values",
",",
"String",
"processInstanceId",
")",
"{",
"for",
"(",
"ActivityInstanceImpl",
"activityInstance",
":",
"values",
")",
"{",
"// if the determined activity instance id and the parent activity instance are equal,",
"// just put the activity instance under the process instance",
"if",
"(",
"valuesEqual",
"(",
"activityInstance",
".",
"getId",
"(",
")",
",",
"activityInstance",
".",
"getParentActivityInstanceId",
"(",
")",
")",
")",
"{",
"activityInstance",
".",
"setParentActivityInstanceId",
"(",
"processInstanceId",
")",
";",
"}",
"}",
"}"
] | This is relevant for {@link GetActivityInstanceCmd} where in case of legacy multi-instance execution trees, the default
algorithm omits multi-instance activity instances. | [
"This",
"is",
"relevant",
"for",
"{"
] | train | https://github.com/camunda/camunda-bpm-platform/blob/1a464fc887ef3760e53d6f91b9e5b871a0d77cc0/engine/src/main/java/org/camunda/bpm/engine/impl/pvm/runtime/LegacyBehavior.java#L508-L516 |
groupby/api-java | src/main/java/com/groupbyinc/api/Query.java | Query.setRestrictNavigation | public Query setRestrictNavigation(String name, int count) {
"""
<code>
<b>Warning</b> See {@link Query#setRestrictNavigation(RestrictNavigation)}. This is a convenience method.
</code>
@param name
the name of the field should be used in the navigation restriction in the second query.
@param count
the number of fields matches
@return this query
"""
this.restrictNavigation = new RestrictNavigation().setName(name).setCount(count);
return this;
} | java | public Query setRestrictNavigation(String name, int count) {
this.restrictNavigation = new RestrictNavigation().setName(name).setCount(count);
return this;
} | [
"public",
"Query",
"setRestrictNavigation",
"(",
"String",
"name",
",",
"int",
"count",
")",
"{",
"this",
".",
"restrictNavigation",
"=",
"new",
"RestrictNavigation",
"(",
")",
".",
"setName",
"(",
"name",
")",
".",
"setCount",
"(",
"count",
")",
";",
"return",
"this",
";",
"}"
] | <code>
<b>Warning</b> See {@link Query#setRestrictNavigation(RestrictNavigation)}. This is a convenience method.
</code>
@param name
the name of the field should be used in the navigation restriction in the second query.
@param count
the number of fields matches
@return this query | [
"<code",
">",
"<b",
">",
"Warning<",
"/",
"b",
">",
"See",
"{",
"@link",
"Query#setRestrictNavigation",
"(",
"RestrictNavigation",
")",
"}",
".",
"This",
"is",
"a",
"convenience",
"method",
".",
"<",
"/",
"code",
">"
] | train | https://github.com/groupby/api-java/blob/257c4ed0777221e5e4ade3b29b9921300fac4e2e/src/main/java/com/groupbyinc/api/Query.java#L1123-L1126 |
alkacon/opencms-core | src/org/opencms/ui/apps/sitemanager/CmsEditSiteForm.java | CmsEditSiteForm.getAvailableLocalVariant | private String getAvailableLocalVariant(String path, String baseName) {
"""
Returns the correct varaint of a resource name accoreding to locale.<p>
@param path where the considered resource is.
@param baseName of the resource
@return localized name of resource
"""
//First look for a bundle with the locale of the folder..
try {
CmsProperty propLoc = m_clonedCms.readPropertyObject(path, CmsPropertyDefinition.PROPERTY_LOCALE, true);
if (!propLoc.isNullProperty()) {
if (m_clonedCms.existsResource(path + baseName + "_" + propLoc.getValue())) {
return baseName + "_" + propLoc.getValue();
}
}
} catch (CmsException e) {
LOG.error("Can not read locale property", e);
}
//If no bundle was found with the locale of the folder, or the property was not set, search for other locales
A_CmsUI.get();
List<String> localVariations = CmsLocaleManager.getLocaleVariants(
baseName,
UI.getCurrent().getLocale(),
false,
true);
for (String name : localVariations) {
if (m_clonedCms.existsResource(path + name)) {
return name;
}
}
return null;
} | java | private String getAvailableLocalVariant(String path, String baseName) {
//First look for a bundle with the locale of the folder..
try {
CmsProperty propLoc = m_clonedCms.readPropertyObject(path, CmsPropertyDefinition.PROPERTY_LOCALE, true);
if (!propLoc.isNullProperty()) {
if (m_clonedCms.existsResource(path + baseName + "_" + propLoc.getValue())) {
return baseName + "_" + propLoc.getValue();
}
}
} catch (CmsException e) {
LOG.error("Can not read locale property", e);
}
//If no bundle was found with the locale of the folder, or the property was not set, search for other locales
A_CmsUI.get();
List<String> localVariations = CmsLocaleManager.getLocaleVariants(
baseName,
UI.getCurrent().getLocale(),
false,
true);
for (String name : localVariations) {
if (m_clonedCms.existsResource(path + name)) {
return name;
}
}
return null;
} | [
"private",
"String",
"getAvailableLocalVariant",
"(",
"String",
"path",
",",
"String",
"baseName",
")",
"{",
"//First look for a bundle with the locale of the folder..",
"try",
"{",
"CmsProperty",
"propLoc",
"=",
"m_clonedCms",
".",
"readPropertyObject",
"(",
"path",
",",
"CmsPropertyDefinition",
".",
"PROPERTY_LOCALE",
",",
"true",
")",
";",
"if",
"(",
"!",
"propLoc",
".",
"isNullProperty",
"(",
")",
")",
"{",
"if",
"(",
"m_clonedCms",
".",
"existsResource",
"(",
"path",
"+",
"baseName",
"+",
"\"_\"",
"+",
"propLoc",
".",
"getValue",
"(",
")",
")",
")",
"{",
"return",
"baseName",
"+",
"\"_\"",
"+",
"propLoc",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"CmsException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Can not read locale property\"",
",",
"e",
")",
";",
"}",
"//If no bundle was found with the locale of the folder, or the property was not set, search for other locales",
"A_CmsUI",
".",
"get",
"(",
")",
";",
"List",
"<",
"String",
">",
"localVariations",
"=",
"CmsLocaleManager",
".",
"getLocaleVariants",
"(",
"baseName",
",",
"UI",
".",
"getCurrent",
"(",
")",
".",
"getLocale",
"(",
")",
",",
"false",
",",
"true",
")",
";",
"for",
"(",
"String",
"name",
":",
"localVariations",
")",
"{",
"if",
"(",
"m_clonedCms",
".",
"existsResource",
"(",
"path",
"+",
"name",
")",
")",
"{",
"return",
"name",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the correct varaint of a resource name accoreding to locale.<p>
@param path where the considered resource is.
@param baseName of the resource
@return localized name of resource | [
"Returns",
"the",
"correct",
"varaint",
"of",
"a",
"resource",
"name",
"accoreding",
"to",
"locale",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/apps/sitemanager/CmsEditSiteForm.java#L1667-L1696 |
fedups/com.obdobion.argument | src/main/java/com/obdobion/argument/type/DefaultCLA.java | DefaultCLA.applyDefaults | public void applyDefaults(final char commandPrefix, final List<ICmdLineArg<?>> allKnownArgs) {
"""
<p>
applyDefaults.
</p>
@param commandPrefix a char.
@param allKnownArgs a {@link java.util.List} object.
"""
for (final String argNameToReset : getValues())
{
if (argNameToReset == null)
return;
Token token = null;
if (argNameToReset.trim().length() == 1)
token = new Token(commandPrefix, commandPrefix + argNameToReset);
else
token = new Token(commandPrefix, "" + commandPrefix + commandPrefix + argNameToReset);
final List<ICmdLineArg<?>> bestArgs = new ArrayList<>();
CmdLine.matchingArgs(bestArgs, allKnownArgs, token, true);
if (bestArgs.isEmpty())
return;
final ICmdLineArg<?> target = bestArgs.get(0);
target.useDefaults();
}
} | java | public void applyDefaults(final char commandPrefix, final List<ICmdLineArg<?>> allKnownArgs)
{
for (final String argNameToReset : getValues())
{
if (argNameToReset == null)
return;
Token token = null;
if (argNameToReset.trim().length() == 1)
token = new Token(commandPrefix, commandPrefix + argNameToReset);
else
token = new Token(commandPrefix, "" + commandPrefix + commandPrefix + argNameToReset);
final List<ICmdLineArg<?>> bestArgs = new ArrayList<>();
CmdLine.matchingArgs(bestArgs, allKnownArgs, token, true);
if (bestArgs.isEmpty())
return;
final ICmdLineArg<?> target = bestArgs.get(0);
target.useDefaults();
}
} | [
"public",
"void",
"applyDefaults",
"(",
"final",
"char",
"commandPrefix",
",",
"final",
"List",
"<",
"ICmdLineArg",
"<",
"?",
">",
">",
"allKnownArgs",
")",
"{",
"for",
"(",
"final",
"String",
"argNameToReset",
":",
"getValues",
"(",
")",
")",
"{",
"if",
"(",
"argNameToReset",
"==",
"null",
")",
"return",
";",
"Token",
"token",
"=",
"null",
";",
"if",
"(",
"argNameToReset",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"1",
")",
"token",
"=",
"new",
"Token",
"(",
"commandPrefix",
",",
"commandPrefix",
"+",
"argNameToReset",
")",
";",
"else",
"token",
"=",
"new",
"Token",
"(",
"commandPrefix",
",",
"\"\"",
"+",
"commandPrefix",
"+",
"commandPrefix",
"+",
"argNameToReset",
")",
";",
"final",
"List",
"<",
"ICmdLineArg",
"<",
"?",
">",
">",
"bestArgs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"CmdLine",
".",
"matchingArgs",
"(",
"bestArgs",
",",
"allKnownArgs",
",",
"token",
",",
"true",
")",
";",
"if",
"(",
"bestArgs",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"final",
"ICmdLineArg",
"<",
"?",
">",
"target",
"=",
"bestArgs",
".",
"get",
"(",
"0",
")",
";",
"target",
".",
"useDefaults",
"(",
")",
";",
"}",
"}"
] | <p>
applyDefaults.
</p>
@param commandPrefix a char.
@param allKnownArgs a {@link java.util.List} object. | [
"<p",
">",
"applyDefaults",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/fedups/com.obdobion.argument/blob/9679aebbeedaef4e592227842fa0e91410708a67/src/main/java/com/obdobion/argument/type/DefaultCLA.java#L38-L59 |
Azure/azure-sdk-for-java | keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java | KeyVaultClientBaseImpl.getCertificateIssuerAsync | public ServiceFuture<IssuerBundle> getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback<IssuerBundle> serviceCallback) {
"""
Lists the specified certificate issuer.
The GetCertificateIssuer operation returns the specified certificate issuer resources in the specified key vault. This operation requires the certificates/manageissuers/getissuers permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param issuerName The name of the issuer.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object
"""
return ServiceFuture.fromResponse(getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback);
} | java | public ServiceFuture<IssuerBundle> getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback<IssuerBundle> serviceCallback) {
return ServiceFuture.fromResponse(getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback);
} | [
"public",
"ServiceFuture",
"<",
"IssuerBundle",
">",
"getCertificateIssuerAsync",
"(",
"String",
"vaultBaseUrl",
",",
"String",
"issuerName",
",",
"final",
"ServiceCallback",
"<",
"IssuerBundle",
">",
"serviceCallback",
")",
"{",
"return",
"ServiceFuture",
".",
"fromResponse",
"(",
"getCertificateIssuerWithServiceResponseAsync",
"(",
"vaultBaseUrl",
",",
"issuerName",
")",
",",
"serviceCallback",
")",
";",
"}"
] | Lists the specified certificate issuer.
The GetCertificateIssuer operation returns the specified certificate issuer resources in the specified key vault. This operation requires the certificates/manageissuers/getissuers permission.
@param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
@param issuerName The name of the issuer.
@param serviceCallback the async ServiceCallback to handle successful and failed responses.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceFuture} object | [
"Lists",
"the",
"specified",
"certificate",
"issuer",
".",
"The",
"GetCertificateIssuer",
"operation",
"returns",
"the",
"specified",
"certificate",
"issuer",
"resources",
"in",
"the",
"specified",
"key",
"vault",
".",
"This",
"operation",
"requires",
"the",
"certificates",
"/",
"manageissuers",
"/",
"getissuers",
"permission",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/keyvault/data-plane/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientBaseImpl.java#L6326-L6328 |