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
|
---|---|---|---|---|---|---|---|---|---|---|
alkacon/opencms-core | src/org/opencms/jsp/CmsJspTagInfo.java | CmsJspTagInfo.infoTagAction | public static String infoTagAction(String property, HttpServletRequest req) {
"""
Returns the selected info property value based on the provided
parameters.<p>
@param property the info property to look up
@param req the currents request
@return the looked up property value
"""
if (property == null) {
CmsMessageContainer errMsgContainer = Messages.get().container(Messages.GUI_ERR_INVALID_INFO_PROP_0);
return Messages.getLocalizedMessage(errMsgContainer, req);
}
CmsFlexController controller = CmsFlexController.getController(req);
String result = null;
switch (SYSTEM_PROPERTIES_LIST.indexOf(property)) {
case 0: // opencms.version
result = OpenCms.getSystemInfo().getVersionNumber();
break;
case 1: // opencms.url
result = req.getRequestURL().toString();
break;
case 2: // opencms.uri
result = req.getRequestURI();
break;
case 3: // opencms.webapp
result = OpenCms.getSystemInfo().getWebApplicationName();
break;
case 4: // opencms.webbasepath
result = OpenCms.getSystemInfo().getWebApplicationRfsPath();
break;
case 5: // opencms.request.uri
result = controller.getCmsObject().getRequestContext().getUri();
break;
case 6: // opencms.request.element.uri
result = controller.getCurrentRequest().getElementUri();
break;
case 7: // opencms.request.folder
result = CmsResource.getParentFolder(controller.getCmsObject().getRequestContext().getUri());
break;
case 8: // opencms.request.encoding
result = controller.getCmsObject().getRequestContext().getEncoding();
break;
case 9: // opencms.request.locale
result = controller.getCmsObject().getRequestContext().getLocale().toString();
break;
case 10: // opencms.title
result = getTitleInfo(controller, req);
break;
case 11: // opencms.description
result = getDescriptionInfo(controller, req);
break;
case 12: // opencms.keywords
result = getKeywordsInfo(controller, req);
break;
default:
result = System.getProperty(property);
if (result == null) {
CmsMessageContainer errMsgContainer = Messages.get().container(
Messages.GUI_ERR_INVALID_INFO_PROP_1,
property);
return Messages.getLocalizedMessage(errMsgContainer, req);
}
}
return result;
} | java | public static String infoTagAction(String property, HttpServletRequest req) {
if (property == null) {
CmsMessageContainer errMsgContainer = Messages.get().container(Messages.GUI_ERR_INVALID_INFO_PROP_0);
return Messages.getLocalizedMessage(errMsgContainer, req);
}
CmsFlexController controller = CmsFlexController.getController(req);
String result = null;
switch (SYSTEM_PROPERTIES_LIST.indexOf(property)) {
case 0: // opencms.version
result = OpenCms.getSystemInfo().getVersionNumber();
break;
case 1: // opencms.url
result = req.getRequestURL().toString();
break;
case 2: // opencms.uri
result = req.getRequestURI();
break;
case 3: // opencms.webapp
result = OpenCms.getSystemInfo().getWebApplicationName();
break;
case 4: // opencms.webbasepath
result = OpenCms.getSystemInfo().getWebApplicationRfsPath();
break;
case 5: // opencms.request.uri
result = controller.getCmsObject().getRequestContext().getUri();
break;
case 6: // opencms.request.element.uri
result = controller.getCurrentRequest().getElementUri();
break;
case 7: // opencms.request.folder
result = CmsResource.getParentFolder(controller.getCmsObject().getRequestContext().getUri());
break;
case 8: // opencms.request.encoding
result = controller.getCmsObject().getRequestContext().getEncoding();
break;
case 9: // opencms.request.locale
result = controller.getCmsObject().getRequestContext().getLocale().toString();
break;
case 10: // opencms.title
result = getTitleInfo(controller, req);
break;
case 11: // opencms.description
result = getDescriptionInfo(controller, req);
break;
case 12: // opencms.keywords
result = getKeywordsInfo(controller, req);
break;
default:
result = System.getProperty(property);
if (result == null) {
CmsMessageContainer errMsgContainer = Messages.get().container(
Messages.GUI_ERR_INVALID_INFO_PROP_1,
property);
return Messages.getLocalizedMessage(errMsgContainer, req);
}
}
return result;
} | [
"public",
"static",
"String",
"infoTagAction",
"(",
"String",
"property",
",",
"HttpServletRequest",
"req",
")",
"{",
"if",
"(",
"property",
"==",
"null",
")",
"{",
"CmsMessageContainer",
"errMsgContainer",
"=",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"GUI_ERR_INVALID_INFO_PROP_0",
")",
";",
"return",
"Messages",
".",
"getLocalizedMessage",
"(",
"errMsgContainer",
",",
"req",
")",
";",
"}",
"CmsFlexController",
"controller",
"=",
"CmsFlexController",
".",
"getController",
"(",
"req",
")",
";",
"String",
"result",
"=",
"null",
";",
"switch",
"(",
"SYSTEM_PROPERTIES_LIST",
".",
"indexOf",
"(",
"property",
")",
")",
"{",
"case",
"0",
":",
"// opencms.version",
"result",
"=",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getVersionNumber",
"(",
")",
";",
"break",
";",
"case",
"1",
":",
"// opencms.url",
"result",
"=",
"req",
".",
"getRequestURL",
"(",
")",
".",
"toString",
"(",
")",
";",
"break",
";",
"case",
"2",
":",
"// opencms.uri",
"result",
"=",
"req",
".",
"getRequestURI",
"(",
")",
";",
"break",
";",
"case",
"3",
":",
"// opencms.webapp",
"result",
"=",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getWebApplicationName",
"(",
")",
";",
"break",
";",
"case",
"4",
":",
"// opencms.webbasepath",
"result",
"=",
"OpenCms",
".",
"getSystemInfo",
"(",
")",
".",
"getWebApplicationRfsPath",
"(",
")",
";",
"break",
";",
"case",
"5",
":",
"// opencms.request.uri",
"result",
"=",
"controller",
".",
"getCmsObject",
"(",
")",
".",
"getRequestContext",
"(",
")",
".",
"getUri",
"(",
")",
";",
"break",
";",
"case",
"6",
":",
"// opencms.request.element.uri",
"result",
"=",
"controller",
".",
"getCurrentRequest",
"(",
")",
".",
"getElementUri",
"(",
")",
";",
"break",
";",
"case",
"7",
":",
"// opencms.request.folder",
"result",
"=",
"CmsResource",
".",
"getParentFolder",
"(",
"controller",
".",
"getCmsObject",
"(",
")",
".",
"getRequestContext",
"(",
")",
".",
"getUri",
"(",
")",
")",
";",
"break",
";",
"case",
"8",
":",
"// opencms.request.encoding",
"result",
"=",
"controller",
".",
"getCmsObject",
"(",
")",
".",
"getRequestContext",
"(",
")",
".",
"getEncoding",
"(",
")",
";",
"break",
";",
"case",
"9",
":",
"// opencms.request.locale",
"result",
"=",
"controller",
".",
"getCmsObject",
"(",
")",
".",
"getRequestContext",
"(",
")",
".",
"getLocale",
"(",
")",
".",
"toString",
"(",
")",
";",
"break",
";",
"case",
"10",
":",
"// opencms.title",
"result",
"=",
"getTitleInfo",
"(",
"controller",
",",
"req",
")",
";",
"break",
";",
"case",
"11",
":",
"// opencms.description",
"result",
"=",
"getDescriptionInfo",
"(",
"controller",
",",
"req",
")",
";",
"break",
";",
"case",
"12",
":",
"// opencms.keywords",
"result",
"=",
"getKeywordsInfo",
"(",
"controller",
",",
"req",
")",
";",
"break",
";",
"default",
":",
"result",
"=",
"System",
".",
"getProperty",
"(",
"property",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"CmsMessageContainer",
"errMsgContainer",
"=",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"GUI_ERR_INVALID_INFO_PROP_1",
",",
"property",
")",
";",
"return",
"Messages",
".",
"getLocalizedMessage",
"(",
"errMsgContainer",
",",
"req",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Returns the selected info property value based on the provided
parameters.<p>
@param property the info property to look up
@param req the currents request
@return the looked up property value | [
"Returns",
"the",
"selected",
"info",
"property",
"value",
"based",
"on",
"the",
"provided",
"parameters",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/CmsJspTagInfo.java#L264-L324 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/base/base_resource.java | base_resource.perform_operation | public base_response perform_operation(nitro_service service, options option) throws Exception {
"""
Use this method to perform a clear/sync/link/unlink/save ...etc
operation on netscaler resource.
@param service nitro_service object.
@param option options object with action that is to be performed set.
@return status of the operation performed.
@throws Exception Nitro exception is thrown.
"""
if (!service.isLogin() && !get_object_type().equals("login"))
service.login();
base_response response = post_request(service, option);
return response;
} | java | public base_response perform_operation(nitro_service service, options option) throws Exception
{
if (!service.isLogin() && !get_object_type().equals("login"))
service.login();
base_response response = post_request(service, option);
return response;
} | [
"public",
"base_response",
"perform_operation",
"(",
"nitro_service",
"service",
",",
"options",
"option",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"service",
".",
"isLogin",
"(",
")",
"&&",
"!",
"get_object_type",
"(",
")",
".",
"equals",
"(",
"\"login\"",
")",
")",
"service",
".",
"login",
"(",
")",
";",
"base_response",
"response",
"=",
"post_request",
"(",
"service",
",",
"option",
")",
";",
"return",
"response",
";",
"}"
] | Use this method to perform a clear/sync/link/unlink/save ...etc
operation on netscaler resource.
@param service nitro_service object.
@param option options object with action that is to be performed set.
@return status of the operation performed.
@throws Exception Nitro exception is thrown. | [
"Use",
"this",
"method",
"to",
"perform",
"a",
"clear",
"/",
"sync",
"/",
"link",
"/",
"unlink",
"/",
"save",
"...",
"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#L407-L414 |
apache/incubator-gobblin | gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java | GPGFileDecryptor.decryptFile | public InputStream decryptFile(InputStream inputStream, InputStream keyIn, String passPhrase)
throws IOException {
"""
Taking in a file inputstream, keyring inputstream and a passPhrase, generate a decrypted file inputstream.
@param inputStream file inputstream
@param keyIn keyring inputstream. This InputStream is owned by the caller.
@param passPhrase passPhrase
@return an {@link InputStream} for the decrypted content
@throws IOException
"""
try {
PGPEncryptedDataList enc = getPGPEncryptedDataList(inputStream);
Iterator it = enc.getEncryptedDataObjects();
PGPPrivateKey sKey = null;
PGPPublicKeyEncryptedData pbe = null;
PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyIn), new BcKeyFingerprintCalculator());
while (sKey == null && it.hasNext()) {
pbe = (PGPPublicKeyEncryptedData) it.next();
sKey = findSecretKey(pgpSec, pbe.getKeyID(), passPhrase);
}
if (sKey == null) {
throw new IllegalArgumentException("secret key for message not found.");
}
InputStream clear = pbe.getDataStream(
new JcePublicKeyDataDecryptorFactoryBuilder().setProvider(BouncyCastleProvider.PROVIDER_NAME).build(sKey));
JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(clear);
return new LazyMaterializeDecryptorInputStream(pgpFact);
} catch (PGPException e) {
throw new IOException(e);
}
} | java | public InputStream decryptFile(InputStream inputStream, InputStream keyIn, String passPhrase)
throws IOException {
try {
PGPEncryptedDataList enc = getPGPEncryptedDataList(inputStream);
Iterator it = enc.getEncryptedDataObjects();
PGPPrivateKey sKey = null;
PGPPublicKeyEncryptedData pbe = null;
PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyIn), new BcKeyFingerprintCalculator());
while (sKey == null && it.hasNext()) {
pbe = (PGPPublicKeyEncryptedData) it.next();
sKey = findSecretKey(pgpSec, pbe.getKeyID(), passPhrase);
}
if (sKey == null) {
throw new IllegalArgumentException("secret key for message not found.");
}
InputStream clear = pbe.getDataStream(
new JcePublicKeyDataDecryptorFactoryBuilder().setProvider(BouncyCastleProvider.PROVIDER_NAME).build(sKey));
JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(clear);
return new LazyMaterializeDecryptorInputStream(pgpFact);
} catch (PGPException e) {
throw new IOException(e);
}
} | [
"public",
"InputStream",
"decryptFile",
"(",
"InputStream",
"inputStream",
",",
"InputStream",
"keyIn",
",",
"String",
"passPhrase",
")",
"throws",
"IOException",
"{",
"try",
"{",
"PGPEncryptedDataList",
"enc",
"=",
"getPGPEncryptedDataList",
"(",
"inputStream",
")",
";",
"Iterator",
"it",
"=",
"enc",
".",
"getEncryptedDataObjects",
"(",
")",
";",
"PGPPrivateKey",
"sKey",
"=",
"null",
";",
"PGPPublicKeyEncryptedData",
"pbe",
"=",
"null",
";",
"PGPSecretKeyRingCollection",
"pgpSec",
"=",
"new",
"PGPSecretKeyRingCollection",
"(",
"PGPUtil",
".",
"getDecoderStream",
"(",
"keyIn",
")",
",",
"new",
"BcKeyFingerprintCalculator",
"(",
")",
")",
";",
"while",
"(",
"sKey",
"==",
"null",
"&&",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"pbe",
"=",
"(",
"PGPPublicKeyEncryptedData",
")",
"it",
".",
"next",
"(",
")",
";",
"sKey",
"=",
"findSecretKey",
"(",
"pgpSec",
",",
"pbe",
".",
"getKeyID",
"(",
")",
",",
"passPhrase",
")",
";",
"}",
"if",
"(",
"sKey",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"secret key for message not found.\"",
")",
";",
"}",
"InputStream",
"clear",
"=",
"pbe",
".",
"getDataStream",
"(",
"new",
"JcePublicKeyDataDecryptorFactoryBuilder",
"(",
")",
".",
"setProvider",
"(",
"BouncyCastleProvider",
".",
"PROVIDER_NAME",
")",
".",
"build",
"(",
"sKey",
")",
")",
";",
"JcaPGPObjectFactory",
"pgpFact",
"=",
"new",
"JcaPGPObjectFactory",
"(",
"clear",
")",
";",
"return",
"new",
"LazyMaterializeDecryptorInputStream",
"(",
"pgpFact",
")",
";",
"}",
"catch",
"(",
"PGPException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"}"
] | Taking in a file inputstream, keyring inputstream and a passPhrase, generate a decrypted file inputstream.
@param inputStream file inputstream
@param keyIn keyring inputstream. This InputStream is owned by the caller.
@param passPhrase passPhrase
@return an {@link InputStream} for the decrypted content
@throws IOException | [
"Taking",
"in",
"a",
"file",
"inputstream",
"keyring",
"inputstream",
"and",
"a",
"passPhrase",
"generate",
"a",
"decrypted",
"file",
"inputstream",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java#L89-L115 |
samskivert/samskivert | src/main/java/com/samskivert/util/Throttle.java | Throttle.reinit | public void reinit (int operations, long period) {
"""
Updates the number of operations for this throttle to a new maximum, retaining the current
history of operations if the limit is being increased and truncating the oldest operations
if the limit is decreased.
@param operations the new maximum number of operations.
@param period the new period.
"""
_period = period;
if (operations != _ops.length) {
long[] ops = new long[operations];
if (operations > _ops.length) {
// copy to a larger buffer, leaving zeroes at the beginning
int lastOp = _lastOp + operations - _ops.length;
System.arraycopy(_ops, 0, ops, 0, _lastOp);
System.arraycopy(_ops, _lastOp, ops, lastOp, _ops.length - _lastOp);
} else {
// if we're truncating, copy the first (oldest) stamps into ops[0..]
int endCount = Math.min(operations, _ops.length - _lastOp);
System.arraycopy(_ops, _lastOp, ops, 0, endCount);
System.arraycopy(_ops, 0, ops, endCount, operations - endCount);
_lastOp = 0;
}
_ops = ops;
}
} | java | public void reinit (int operations, long period)
{
_period = period;
if (operations != _ops.length) {
long[] ops = new long[operations];
if (operations > _ops.length) {
// copy to a larger buffer, leaving zeroes at the beginning
int lastOp = _lastOp + operations - _ops.length;
System.arraycopy(_ops, 0, ops, 0, _lastOp);
System.arraycopy(_ops, _lastOp, ops, lastOp, _ops.length - _lastOp);
} else {
// if we're truncating, copy the first (oldest) stamps into ops[0..]
int endCount = Math.min(operations, _ops.length - _lastOp);
System.arraycopy(_ops, _lastOp, ops, 0, endCount);
System.arraycopy(_ops, 0, ops, endCount, operations - endCount);
_lastOp = 0;
}
_ops = ops;
}
} | [
"public",
"void",
"reinit",
"(",
"int",
"operations",
",",
"long",
"period",
")",
"{",
"_period",
"=",
"period",
";",
"if",
"(",
"operations",
"!=",
"_ops",
".",
"length",
")",
"{",
"long",
"[",
"]",
"ops",
"=",
"new",
"long",
"[",
"operations",
"]",
";",
"if",
"(",
"operations",
">",
"_ops",
".",
"length",
")",
"{",
"// copy to a larger buffer, leaving zeroes at the beginning",
"int",
"lastOp",
"=",
"_lastOp",
"+",
"operations",
"-",
"_ops",
".",
"length",
";",
"System",
".",
"arraycopy",
"(",
"_ops",
",",
"0",
",",
"ops",
",",
"0",
",",
"_lastOp",
")",
";",
"System",
".",
"arraycopy",
"(",
"_ops",
",",
"_lastOp",
",",
"ops",
",",
"lastOp",
",",
"_ops",
".",
"length",
"-",
"_lastOp",
")",
";",
"}",
"else",
"{",
"// if we're truncating, copy the first (oldest) stamps into ops[0..]",
"int",
"endCount",
"=",
"Math",
".",
"min",
"(",
"operations",
",",
"_ops",
".",
"length",
"-",
"_lastOp",
")",
";",
"System",
".",
"arraycopy",
"(",
"_ops",
",",
"_lastOp",
",",
"ops",
",",
"0",
",",
"endCount",
")",
";",
"System",
".",
"arraycopy",
"(",
"_ops",
",",
"0",
",",
"ops",
",",
"endCount",
",",
"operations",
"-",
"endCount",
")",
";",
"_lastOp",
"=",
"0",
";",
"}",
"_ops",
"=",
"ops",
";",
"}",
"}"
] | Updates the number of operations for this throttle to a new maximum, retaining the current
history of operations if the limit is being increased and truncating the oldest operations
if the limit is decreased.
@param operations the new maximum number of operations.
@param period the new period. | [
"Updates",
"the",
"number",
"of",
"operations",
"for",
"this",
"throttle",
"to",
"a",
"new",
"maximum",
"retaining",
"the",
"current",
"history",
"of",
"operations",
"if",
"the",
"limit",
"is",
"being",
"increased",
"and",
"truncating",
"the",
"oldest",
"operations",
"if",
"the",
"limit",
"is",
"decreased",
"."
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Throttle.java#L59-L80 |
prestodb/presto | presto-main/src/main/java/com/facebook/presto/operator/aggregation/NumericHistogram.java | NumericHistogram.initializeQueue | private static PriorityQueue<Entry> initializeQueue(double[] values, double[] weights, int nextIndex) {
"""
Create a priority queue with an entry for each bucket, ordered by the penalty score with respect to the bucket to its right
The inputs must be sorted by "value" in increasing order
The last bucket has a penalty of infinity
Entries are doubly-linked to keep track of the relative position of each bucket
"""
checkArgument(nextIndex > 0, "nextIndex must be > 0");
PriorityQueue<Entry> queue = new PriorityQueue<>(nextIndex);
Entry right = new Entry(nextIndex - 1, values[nextIndex - 1], weights[nextIndex - 1], null);
queue.add(right);
for (int i = nextIndex - 2; i >= 0; i--) {
Entry current = new Entry(i, values[i], weights[i], right);
queue.add(current);
right = current;
}
return queue;
} | java | private static PriorityQueue<Entry> initializeQueue(double[] values, double[] weights, int nextIndex)
{
checkArgument(nextIndex > 0, "nextIndex must be > 0");
PriorityQueue<Entry> queue = new PriorityQueue<>(nextIndex);
Entry right = new Entry(nextIndex - 1, values[nextIndex - 1], weights[nextIndex - 1], null);
queue.add(right);
for (int i = nextIndex - 2; i >= 0; i--) {
Entry current = new Entry(i, values[i], weights[i], right);
queue.add(current);
right = current;
}
return queue;
} | [
"private",
"static",
"PriorityQueue",
"<",
"Entry",
">",
"initializeQueue",
"(",
"double",
"[",
"]",
"values",
",",
"double",
"[",
"]",
"weights",
",",
"int",
"nextIndex",
")",
"{",
"checkArgument",
"(",
"nextIndex",
">",
"0",
",",
"\"nextIndex must be > 0\"",
")",
";",
"PriorityQueue",
"<",
"Entry",
">",
"queue",
"=",
"new",
"PriorityQueue",
"<>",
"(",
"nextIndex",
")",
";",
"Entry",
"right",
"=",
"new",
"Entry",
"(",
"nextIndex",
"-",
"1",
",",
"values",
"[",
"nextIndex",
"-",
"1",
"]",
",",
"weights",
"[",
"nextIndex",
"-",
"1",
"]",
",",
"null",
")",
";",
"queue",
".",
"add",
"(",
"right",
")",
";",
"for",
"(",
"int",
"i",
"=",
"nextIndex",
"-",
"2",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"Entry",
"current",
"=",
"new",
"Entry",
"(",
"i",
",",
"values",
"[",
"i",
"]",
",",
"weights",
"[",
"i",
"]",
",",
"right",
")",
";",
"queue",
".",
"add",
"(",
"current",
")",
";",
"right",
"=",
"current",
";",
"}",
"return",
"queue",
";",
"}"
] | Create a priority queue with an entry for each bucket, ordered by the penalty score with respect to the bucket to its right
The inputs must be sorted by "value" in increasing order
The last bucket has a penalty of infinity
Entries are doubly-linked to keep track of the relative position of each bucket | [
"Create",
"a",
"priority",
"queue",
"with",
"an",
"entry",
"for",
"each",
"bucket",
"ordered",
"by",
"the",
"penalty",
"score",
"with",
"respect",
"to",
"the",
"bucket",
"to",
"its",
"right",
"The",
"inputs",
"must",
"be",
"sorted",
"by",
"value",
"in",
"increasing",
"order",
"The",
"last",
"bucket",
"has",
"a",
"penalty",
"of",
"infinity",
"Entries",
"are",
"doubly",
"-",
"linked",
"to",
"keep",
"track",
"of",
"the",
"relative",
"position",
"of",
"each",
"bucket"
] | train | https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-main/src/main/java/com/facebook/presto/operator/aggregation/NumericHistogram.java#L271-L286 |
lessthanoptimal/BoofCV | integration/boofcv-swing/src/main/java/boofcv/gui/StandardAlgConfigPanel.java | StandardAlgConfigPanel.removeChildInsidePanel | protected static void removeChildInsidePanel( JComponent root , JComponent target ) {
"""
Searches inside the children of "root" for a component that's a JPanel. Then inside the JPanel it
looks for the target. If the target is inside the JPanel the JPanel is removed from root.
"""
int N = root.getComponentCount();
for (int i = 0; i < N; i++) {
try {
JPanel p = (JPanel)root.getComponent(i);
Component[] children = p.getComponents();
for (int j = 0; j < children.length; j++) {
if( children[j] == target ) {
root.remove(i);
return;
}
}
}catch( ClassCastException ignore){}
}
} | java | protected static void removeChildInsidePanel( JComponent root , JComponent target ) {
int N = root.getComponentCount();
for (int i = 0; i < N; i++) {
try {
JPanel p = (JPanel)root.getComponent(i);
Component[] children = p.getComponents();
for (int j = 0; j < children.length; j++) {
if( children[j] == target ) {
root.remove(i);
return;
}
}
}catch( ClassCastException ignore){}
}
} | [
"protected",
"static",
"void",
"removeChildInsidePanel",
"(",
"JComponent",
"root",
",",
"JComponent",
"target",
")",
"{",
"int",
"N",
"=",
"root",
".",
"getComponentCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"try",
"{",
"JPanel",
"p",
"=",
"(",
"JPanel",
")",
"root",
".",
"getComponent",
"(",
"i",
")",
";",
"Component",
"[",
"]",
"children",
"=",
"p",
".",
"getComponents",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"children",
".",
"length",
";",
"j",
"++",
")",
"{",
"if",
"(",
"children",
"[",
"j",
"]",
"==",
"target",
")",
"{",
"root",
".",
"remove",
"(",
"i",
")",
";",
"return",
";",
"}",
"}",
"}",
"catch",
"(",
"ClassCastException",
"ignore",
")",
"{",
"}",
"}",
"}"
] | Searches inside the children of "root" for a component that's a JPanel. Then inside the JPanel it
looks for the target. If the target is inside the JPanel the JPanel is removed from root. | [
"Searches",
"inside",
"the",
"children",
"of",
"root",
"for",
"a",
"component",
"that",
"s",
"a",
"JPanel",
".",
"Then",
"inside",
"the",
"JPanel",
"it",
"looks",
"for",
"the",
"target",
".",
"If",
"the",
"target",
"is",
"inside",
"the",
"JPanel",
"the",
"JPanel",
"is",
"removed",
"from",
"root",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/StandardAlgConfigPanel.java#L263-L278 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ImageModerationsImpl.java | ImageModerationsImpl.oCRFileInputWithServiceResponseAsync | public Observable<ServiceResponse<OCR>> oCRFileInputWithServiceResponseAsync(String language, byte[] imageStream, OCRFileInputOptionalParameter oCRFileInputOptionalParameter) {
"""
Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
@param language Language of the terms.
@param imageStream The image file.
@param oCRFileInputOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OCR object
"""
if (this.client.baseUrl() == null) {
throw new IllegalArgumentException("Parameter this.client.baseUrl() is required and cannot be null.");
}
if (language == null) {
throw new IllegalArgumentException("Parameter language is required and cannot be null.");
}
if (imageStream == null) {
throw new IllegalArgumentException("Parameter imageStream is required and cannot be null.");
}
final Boolean cacheImage = oCRFileInputOptionalParameter != null ? oCRFileInputOptionalParameter.cacheImage() : null;
final Boolean enhanced = oCRFileInputOptionalParameter != null ? oCRFileInputOptionalParameter.enhanced() : null;
return oCRFileInputWithServiceResponseAsync(language, imageStream, cacheImage, enhanced);
} | java | public Observable<ServiceResponse<OCR>> oCRFileInputWithServiceResponseAsync(String language, byte[] imageStream, OCRFileInputOptionalParameter oCRFileInputOptionalParameter) {
if (this.client.baseUrl() == null) {
throw new IllegalArgumentException("Parameter this.client.baseUrl() is required and cannot be null.");
}
if (language == null) {
throw new IllegalArgumentException("Parameter language is required and cannot be null.");
}
if (imageStream == null) {
throw new IllegalArgumentException("Parameter imageStream is required and cannot be null.");
}
final Boolean cacheImage = oCRFileInputOptionalParameter != null ? oCRFileInputOptionalParameter.cacheImage() : null;
final Boolean enhanced = oCRFileInputOptionalParameter != null ? oCRFileInputOptionalParameter.enhanced() : null;
return oCRFileInputWithServiceResponseAsync(language, imageStream, cacheImage, enhanced);
} | [
"public",
"Observable",
"<",
"ServiceResponse",
"<",
"OCR",
">",
">",
"oCRFileInputWithServiceResponseAsync",
"(",
"String",
"language",
",",
"byte",
"[",
"]",
"imageStream",
",",
"OCRFileInputOptionalParameter",
"oCRFileInputOptionalParameter",
")",
"{",
"if",
"(",
"this",
".",
"client",
".",
"baseUrl",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter this.client.baseUrl() is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"language",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter language is required and cannot be null.\"",
")",
";",
"}",
"if",
"(",
"imageStream",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter imageStream is required and cannot be null.\"",
")",
";",
"}",
"final",
"Boolean",
"cacheImage",
"=",
"oCRFileInputOptionalParameter",
"!=",
"null",
"?",
"oCRFileInputOptionalParameter",
".",
"cacheImage",
"(",
")",
":",
"null",
";",
"final",
"Boolean",
"enhanced",
"=",
"oCRFileInputOptionalParameter",
"!=",
"null",
"?",
"oCRFileInputOptionalParameter",
".",
"enhanced",
"(",
")",
":",
"null",
";",
"return",
"oCRFileInputWithServiceResponseAsync",
"(",
"language",
",",
"imageStream",
",",
"cacheImage",
",",
"enhanced",
")",
";",
"}"
] | Returns any text found in the image for the language specified. If no language is specified in input then the detection defaults to English.
@param language Language of the terms.
@param imageStream The image file.
@param oCRFileInputOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OCR object | [
"Returns",
"any",
"text",
"found",
"in",
"the",
"image",
"for",
"the",
"language",
"specified",
".",
"If",
"no",
"language",
"is",
"specified",
"in",
"input",
"then",
"the",
"detection",
"defaults",
"to",
"English",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/contentmoderator/src/main/java/com/microsoft/azure/cognitiveservices/vision/contentmoderator/implementation/ImageModerationsImpl.java#L1291-L1305 |
buschmais/jqa-javaee6-plugin | src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/WebXmlScannerPlugin.java | WebXmlScannerPlugin.getOrCreateNamedDescriptor | private <T extends NamedDescriptor> T getOrCreateNamedDescriptor(Class<T> type, String name, Map<String, T> descriptors, Store store) {
"""
Get or create a named descriptor.
@param type
The descriptor type.
@param name
The name.
@param descriptors
The map of known named descriptors.
@param store
The store.
@return The servlet descriptor.
"""
T descriptor = descriptors.get(name);
if (descriptor == null) {
descriptor = store.create(type);
descriptor.setName(name);
descriptors.put(name, descriptor);
}
return descriptor;
} | java | private <T extends NamedDescriptor> T getOrCreateNamedDescriptor(Class<T> type, String name, Map<String, T> descriptors, Store store) {
T descriptor = descriptors.get(name);
if (descriptor == null) {
descriptor = store.create(type);
descriptor.setName(name);
descriptors.put(name, descriptor);
}
return descriptor;
} | [
"private",
"<",
"T",
"extends",
"NamedDescriptor",
">",
"T",
"getOrCreateNamedDescriptor",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"T",
">",
"descriptors",
",",
"Store",
"store",
")",
"{",
"T",
"descriptor",
"=",
"descriptors",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"descriptor",
"==",
"null",
")",
"{",
"descriptor",
"=",
"store",
".",
"create",
"(",
"type",
")",
";",
"descriptor",
".",
"setName",
"(",
"name",
")",
";",
"descriptors",
".",
"put",
"(",
"name",
",",
"descriptor",
")",
";",
"}",
"return",
"descriptor",
";",
"}"
] | Get or create a named descriptor.
@param type
The descriptor type.
@param name
The name.
@param descriptors
The map of known named descriptors.
@param store
The store.
@return The servlet descriptor. | [
"Get",
"or",
"create",
"a",
"named",
"descriptor",
"."
] | train | https://github.com/buschmais/jqa-javaee6-plugin/blob/f5776604d9255206807e5aca90b8767bde494e14/src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/WebXmlScannerPlugin.java#L439-L447 |
mojohaus/xml-maven-plugin | src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java | AbstractXmlMojo.asFiles | protected File[] asFiles( File pDir, String[] pFileNames ) {
"""
Converts the given set of file names into a set of {@link File} instances. The file names may be relative to the
given base directory.
"""
if ( pFileNames == null )
{
return new File[0];
}
File dir = asAbsoluteFile( pDir );
File[] result = new File[pFileNames.length];
for ( int i = 0; i < pFileNames.length; i++ )
{
result[i] = new File( dir, pFileNames[i] );
}
return result;
} | java | protected File[] asFiles( File pDir, String[] pFileNames )
{
if ( pFileNames == null )
{
return new File[0];
}
File dir = asAbsoluteFile( pDir );
File[] result = new File[pFileNames.length];
for ( int i = 0; i < pFileNames.length; i++ )
{
result[i] = new File( dir, pFileNames[i] );
}
return result;
} | [
"protected",
"File",
"[",
"]",
"asFiles",
"(",
"File",
"pDir",
",",
"String",
"[",
"]",
"pFileNames",
")",
"{",
"if",
"(",
"pFileNames",
"==",
"null",
")",
"{",
"return",
"new",
"File",
"[",
"0",
"]",
";",
"}",
"File",
"dir",
"=",
"asAbsoluteFile",
"(",
"pDir",
")",
";",
"File",
"[",
"]",
"result",
"=",
"new",
"File",
"[",
"pFileNames",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pFileNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"result",
"[",
"i",
"]",
"=",
"new",
"File",
"(",
"dir",
",",
"pFileNames",
"[",
"i",
"]",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Converts the given set of file names into a set of {@link File} instances. The file names may be relative to the
given base directory. | [
"Converts",
"the",
"given",
"set",
"of",
"file",
"names",
"into",
"a",
"set",
"of",
"{"
] | train | https://github.com/mojohaus/xml-maven-plugin/blob/161edde37bbfe7a472369a9675c44d91ec24561d/src/main/java/org/codehaus/mojo/xml/AbstractXmlMojo.java#L220-L234 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/Maps.java | Maps.sortedEntries | public static <K extends Comparable<? super K>, V> List<Map.Entry<K, V>> sortedEntries(Collection<Map.Entry<K, V>> entries) {
"""
Sorts a list of entries. This menthod is here since the entries might come from a Counter.
"""
List<Entry<K,V>> entriesList = new ArrayList<Map.Entry<K, V>>(entries);
Collections.sort(entriesList, new Comparator<Map.Entry<K, V>>() {
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
return e1.getKey().compareTo(e2.getKey());
}
});
return entriesList;
} | java | public static <K extends Comparable<? super K>, V> List<Map.Entry<K, V>> sortedEntries(Collection<Map.Entry<K, V>> entries) {
List<Entry<K,V>> entriesList = new ArrayList<Map.Entry<K, V>>(entries);
Collections.sort(entriesList, new Comparator<Map.Entry<K, V>>() {
public int compare(Map.Entry<K, V> e1, Map.Entry<K, V> e2) {
return e1.getKey().compareTo(e2.getKey());
}
});
return entriesList;
} | [
"public",
"static",
"<",
"K",
"extends",
"Comparable",
"<",
"?",
"super",
"K",
">",
",",
"V",
">",
"List",
"<",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"sortedEntries",
"(",
"Collection",
"<",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"entries",
")",
"{",
"List",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"entriesList",
"=",
"new",
"ArrayList",
"<",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"(",
"entries",
")",
";",
"Collections",
".",
"sort",
"(",
"entriesList",
",",
"new",
"Comparator",
"<",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"(",
")",
"{",
"public",
"int",
"compare",
"(",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
"e1",
",",
"Map",
".",
"Entry",
"<",
"K",
",",
"V",
">",
"e2",
")",
"{",
"return",
"e1",
".",
"getKey",
"(",
")",
".",
"compareTo",
"(",
"e2",
".",
"getKey",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"entriesList",
";",
"}"
] | Sorts a list of entries. This menthod is here since the entries might come from a Counter. | [
"Sorts",
"a",
"list",
"of",
"entries",
".",
"This",
"menthod",
"is",
"here",
"since",
"the",
"entries",
"might",
"come",
"from",
"a",
"Counter",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/Maps.java#L98-L106 |
elki-project/elki | elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/timeseries/AbstractEditDistanceFunction.java | AbstractEditDistanceFunction.effectiveBandSize | protected int effectiveBandSize(final int dim1, final int dim2) {
"""
Compute the effective band size.
@param dim1 First dimensionality
@param dim2 Second dimensionality
@return Effective bandsize
"""
if(bandSize == Double.POSITIVE_INFINITY) {
return (dim1 > dim2) ? dim1 : dim2;
}
if(bandSize >= 1.) {
return (int) bandSize;
}
// Max * bandSize:
return (int) Math.ceil((dim1 >= dim2 ? dim1 : dim2) * bandSize);
} | java | protected int effectiveBandSize(final int dim1, final int dim2) {
if(bandSize == Double.POSITIVE_INFINITY) {
return (dim1 > dim2) ? dim1 : dim2;
}
if(bandSize >= 1.) {
return (int) bandSize;
}
// Max * bandSize:
return (int) Math.ceil((dim1 >= dim2 ? dim1 : dim2) * bandSize);
} | [
"protected",
"int",
"effectiveBandSize",
"(",
"final",
"int",
"dim1",
",",
"final",
"int",
"dim2",
")",
"{",
"if",
"(",
"bandSize",
"==",
"Double",
".",
"POSITIVE_INFINITY",
")",
"{",
"return",
"(",
"dim1",
">",
"dim2",
")",
"?",
"dim1",
":",
"dim2",
";",
"}",
"if",
"(",
"bandSize",
">=",
"1.",
")",
"{",
"return",
"(",
"int",
")",
"bandSize",
";",
"}",
"// Max * bandSize:",
"return",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"(",
"dim1",
">=",
"dim2",
"?",
"dim1",
":",
"dim2",
")",
"*",
"bandSize",
")",
";",
"}"
] | Compute the effective band size.
@param dim1 First dimensionality
@param dim2 Second dimensionality
@return Effective bandsize | [
"Compute",
"the",
"effective",
"band",
"size",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/timeseries/AbstractEditDistanceFunction.java#L61-L70 |
wmdietl/jsr308-langtools | src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java | HtmlTree.FRAME | public static HtmlTree FRAME(String src, String name, String title, String scrolling) {
"""
Generates a FRAME tag.
@param src the url of the document to be shown in the frame
@param name specifies the name of the frame
@param title the title for the frame
@param scrolling specifies whether to display scrollbars in the frame
@return an HtmlTree object for the FRAME tag
"""
HtmlTree htmltree = new HtmlTree(HtmlTag.FRAME);
htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
htmltree.addAttr(HtmlAttr.NAME, nullCheck(name));
htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
if (scrolling != null)
htmltree.addAttr(HtmlAttr.SCROLLING, scrolling);
return htmltree;
} | java | public static HtmlTree FRAME(String src, String name, String title, String scrolling) {
HtmlTree htmltree = new HtmlTree(HtmlTag.FRAME);
htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
htmltree.addAttr(HtmlAttr.NAME, nullCheck(name));
htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
if (scrolling != null)
htmltree.addAttr(HtmlAttr.SCROLLING, scrolling);
return htmltree;
} | [
"public",
"static",
"HtmlTree",
"FRAME",
"(",
"String",
"src",
",",
"String",
"name",
",",
"String",
"title",
",",
"String",
"scrolling",
")",
"{",
"HtmlTree",
"htmltree",
"=",
"new",
"HtmlTree",
"(",
"HtmlTag",
".",
"FRAME",
")",
";",
"htmltree",
".",
"addAttr",
"(",
"HtmlAttr",
".",
"SRC",
",",
"nullCheck",
"(",
"src",
")",
")",
";",
"htmltree",
".",
"addAttr",
"(",
"HtmlAttr",
".",
"NAME",
",",
"nullCheck",
"(",
"name",
")",
")",
";",
"htmltree",
".",
"addAttr",
"(",
"HtmlAttr",
".",
"TITLE",
",",
"nullCheck",
"(",
"title",
")",
")",
";",
"if",
"(",
"scrolling",
"!=",
"null",
")",
"htmltree",
".",
"addAttr",
"(",
"HtmlAttr",
".",
"SCROLLING",
",",
"scrolling",
")",
";",
"return",
"htmltree",
";",
"}"
] | Generates a FRAME tag.
@param src the url of the document to be shown in the frame
@param name specifies the name of the frame
@param title the title for the frame
@param scrolling specifies whether to display scrollbars in the frame
@return an HtmlTree object for the FRAME tag | [
"Generates",
"a",
"FRAME",
"tag",
"."
] | train | https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java#L339-L347 |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/translator/VariableTranslator.java | VariableTranslator.realToString | public static String realToString(Package pkg, String type, Object value) {
"""
Serializes a runtime variable object to its string value. Documents are expanded.
@param pkg workflow package
@param type variable type
@param value object value
@return serialized string value
"""
if (value == null)
return "";
com.centurylink.mdw.variable.VariableTranslator trans = getTranslator(pkg, type);
if (trans instanceof DocumentReferenceTranslator)
return ((DocumentReferenceTranslator)trans).realToString(value);
else
return trans.toString(value);
} | java | public static String realToString(Package pkg, String type, Object value) {
if (value == null)
return "";
com.centurylink.mdw.variable.VariableTranslator trans = getTranslator(pkg, type);
if (trans instanceof DocumentReferenceTranslator)
return ((DocumentReferenceTranslator)trans).realToString(value);
else
return trans.toString(value);
} | [
"public",
"static",
"String",
"realToString",
"(",
"Package",
"pkg",
",",
"String",
"type",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"\"\"",
";",
"com",
".",
"centurylink",
".",
"mdw",
".",
"variable",
".",
"VariableTranslator",
"trans",
"=",
"getTranslator",
"(",
"pkg",
",",
"type",
")",
";",
"if",
"(",
"trans",
"instanceof",
"DocumentReferenceTranslator",
")",
"return",
"(",
"(",
"DocumentReferenceTranslator",
")",
"trans",
")",
".",
"realToString",
"(",
"value",
")",
";",
"else",
"return",
"trans",
".",
"toString",
"(",
"value",
")",
";",
"}"
] | Serializes a runtime variable object to its string value. Documents are expanded.
@param pkg workflow package
@param type variable type
@param value object value
@return serialized string value | [
"Serializes",
"a",
"runtime",
"variable",
"object",
"to",
"its",
"string",
"value",
".",
"Documents",
"are",
"expanded",
"."
] | train | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/translator/VariableTranslator.java#L139-L147 |
amzn/ion-java | src/com/amazon/ion/Timestamp.java | Timestamp.forSqlTimestampZ | public static Timestamp forSqlTimestampZ(java.sql.Timestamp sqlTimestamp) {
"""
Converts a {@link java.sql.Timestamp} to a Timestamp in UTC representing
the same point in time.
<p>
The resulting Timestamp will be precise to the nanosecond.
@param sqlTimestamp assumed to have nanoseconds precision
@return
a new Timestamp instance, in UTC, precise to the
nanosecond
{@code null} if {@code sqlTimestamp} is {@code null}
"""
if (sqlTimestamp == null) return null;
long millis = sqlTimestamp.getTime();
Timestamp ts = new Timestamp(millis, UTC_OFFSET);
int nanos = sqlTimestamp.getNanos();
BigDecimal frac = BigDecimal.valueOf(nanos).movePointLeft(9);
ts._fraction = frac;
return ts;
} | java | public static Timestamp forSqlTimestampZ(java.sql.Timestamp sqlTimestamp)
{
if (sqlTimestamp == null) return null;
long millis = sqlTimestamp.getTime();
Timestamp ts = new Timestamp(millis, UTC_OFFSET);
int nanos = sqlTimestamp.getNanos();
BigDecimal frac = BigDecimal.valueOf(nanos).movePointLeft(9);
ts._fraction = frac;
return ts;
} | [
"public",
"static",
"Timestamp",
"forSqlTimestampZ",
"(",
"java",
".",
"sql",
".",
"Timestamp",
"sqlTimestamp",
")",
"{",
"if",
"(",
"sqlTimestamp",
"==",
"null",
")",
"return",
"null",
";",
"long",
"millis",
"=",
"sqlTimestamp",
".",
"getTime",
"(",
")",
";",
"Timestamp",
"ts",
"=",
"new",
"Timestamp",
"(",
"millis",
",",
"UTC_OFFSET",
")",
";",
"int",
"nanos",
"=",
"sqlTimestamp",
".",
"getNanos",
"(",
")",
";",
"BigDecimal",
"frac",
"=",
"BigDecimal",
".",
"valueOf",
"(",
"nanos",
")",
".",
"movePointLeft",
"(",
"9",
")",
";",
"ts",
".",
"_fraction",
"=",
"frac",
";",
"return",
"ts",
";",
"}"
] | Converts a {@link java.sql.Timestamp} to a Timestamp in UTC representing
the same point in time.
<p>
The resulting Timestamp will be precise to the nanosecond.
@param sqlTimestamp assumed to have nanoseconds precision
@return
a new Timestamp instance, in UTC, precise to the
nanosecond
{@code null} if {@code sqlTimestamp} is {@code null} | [
"Converts",
"a",
"{",
"@link",
"java",
".",
"sql",
".",
"Timestamp",
"}",
"to",
"a",
"Timestamp",
"in",
"UTC",
"representing",
"the",
"same",
"point",
"in",
"time",
".",
"<p",
">",
"The",
"resulting",
"Timestamp",
"will",
"be",
"precise",
"to",
"the",
"nanosecond",
"."
] | train | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/Timestamp.java#L1438-L1448 |
stratosphere/stratosphere | stratosphere-compiler/src/main/java/eu/stratosphere/compiler/dataproperties/RequestedGlobalProperties.java | RequestedGlobalProperties.parameterizeChannel | public void parameterizeChannel(Channel channel, boolean globalDopChange, boolean localDopChange) {
"""
Parameterizes the ship strategy fields of a channel such that the channel produces the desired global properties.
@param channel The channel to parameterize.
@param globalDopChange
@param localDopChange
"""
// if we request nothing, then we need no special strategy. forward, if the number of instances remains
// the same, randomly repartition otherwise
if (isTrivial()) {
channel.setShipStrategy(globalDopChange ? ShipStrategyType.PARTITION_RANDOM : ShipStrategyType.FORWARD);
return;
}
final GlobalProperties inGlobals = channel.getSource().getGlobalProperties();
// if we have no global parallelism change, check if we have already compatible global properties
if (!globalDopChange && isMetBy(inGlobals)) {
if (localDopChange) {
// if the local degree of parallelism changes, we need to adjust
if (inGlobals.getPartitioning() == PartitioningProperty.HASH_PARTITIONED) {
// to preserve the hash partitioning, we need to locally hash re-partition
channel.setShipStrategy(ShipStrategyType.PARTITION_LOCAL_HASH, inGlobals.getPartitioningFields());
return;
}
// else fall though
} else {
// we meet already everything, so go forward
channel.setShipStrategy(ShipStrategyType.FORWARD);
return;
}
}
// if we fall through the conditions until here, we need to re-establish
switch (this.partitioning) {
case FULL_REPLICATION:
channel.setShipStrategy(ShipStrategyType.BROADCAST);
break;
case ANY_PARTITIONING:
case HASH_PARTITIONED:
channel.setShipStrategy(ShipStrategyType.PARTITION_HASH, Utils.createOrderedFromSet(this.partitioningFields));
break;
case RANGE_PARTITIONED:
channel.setShipStrategy(ShipStrategyType.PARTITION_RANGE, this.ordering.getInvolvedIndexes(), this.ordering.getFieldSortDirections());
if(this.dataDistribution != null) {
channel.setDataDistribution(this.dataDistribution);
}
break;
default:
throw new CompilerException();
}
} | java | public void parameterizeChannel(Channel channel, boolean globalDopChange, boolean localDopChange) {
// if we request nothing, then we need no special strategy. forward, if the number of instances remains
// the same, randomly repartition otherwise
if (isTrivial()) {
channel.setShipStrategy(globalDopChange ? ShipStrategyType.PARTITION_RANDOM : ShipStrategyType.FORWARD);
return;
}
final GlobalProperties inGlobals = channel.getSource().getGlobalProperties();
// if we have no global parallelism change, check if we have already compatible global properties
if (!globalDopChange && isMetBy(inGlobals)) {
if (localDopChange) {
// if the local degree of parallelism changes, we need to adjust
if (inGlobals.getPartitioning() == PartitioningProperty.HASH_PARTITIONED) {
// to preserve the hash partitioning, we need to locally hash re-partition
channel.setShipStrategy(ShipStrategyType.PARTITION_LOCAL_HASH, inGlobals.getPartitioningFields());
return;
}
// else fall though
} else {
// we meet already everything, so go forward
channel.setShipStrategy(ShipStrategyType.FORWARD);
return;
}
}
// if we fall through the conditions until here, we need to re-establish
switch (this.partitioning) {
case FULL_REPLICATION:
channel.setShipStrategy(ShipStrategyType.BROADCAST);
break;
case ANY_PARTITIONING:
case HASH_PARTITIONED:
channel.setShipStrategy(ShipStrategyType.PARTITION_HASH, Utils.createOrderedFromSet(this.partitioningFields));
break;
case RANGE_PARTITIONED:
channel.setShipStrategy(ShipStrategyType.PARTITION_RANGE, this.ordering.getInvolvedIndexes(), this.ordering.getFieldSortDirections());
if(this.dataDistribution != null) {
channel.setDataDistribution(this.dataDistribution);
}
break;
default:
throw new CompilerException();
}
} | [
"public",
"void",
"parameterizeChannel",
"(",
"Channel",
"channel",
",",
"boolean",
"globalDopChange",
",",
"boolean",
"localDopChange",
")",
"{",
"// if we request nothing, then we need no special strategy. forward, if the number of instances remains",
"// the same, randomly repartition otherwise",
"if",
"(",
"isTrivial",
"(",
")",
")",
"{",
"channel",
".",
"setShipStrategy",
"(",
"globalDopChange",
"?",
"ShipStrategyType",
".",
"PARTITION_RANDOM",
":",
"ShipStrategyType",
".",
"FORWARD",
")",
";",
"return",
";",
"}",
"final",
"GlobalProperties",
"inGlobals",
"=",
"channel",
".",
"getSource",
"(",
")",
".",
"getGlobalProperties",
"(",
")",
";",
"// if we have no global parallelism change, check if we have already compatible global properties",
"if",
"(",
"!",
"globalDopChange",
"&&",
"isMetBy",
"(",
"inGlobals",
")",
")",
"{",
"if",
"(",
"localDopChange",
")",
"{",
"// if the local degree of parallelism changes, we need to adjust",
"if",
"(",
"inGlobals",
".",
"getPartitioning",
"(",
")",
"==",
"PartitioningProperty",
".",
"HASH_PARTITIONED",
")",
"{",
"// to preserve the hash partitioning, we need to locally hash re-partition",
"channel",
".",
"setShipStrategy",
"(",
"ShipStrategyType",
".",
"PARTITION_LOCAL_HASH",
",",
"inGlobals",
".",
"getPartitioningFields",
"(",
")",
")",
";",
"return",
";",
"}",
"// else fall though",
"}",
"else",
"{",
"// we meet already everything, so go forward",
"channel",
".",
"setShipStrategy",
"(",
"ShipStrategyType",
".",
"FORWARD",
")",
";",
"return",
";",
"}",
"}",
"// if we fall through the conditions until here, we need to re-establish",
"switch",
"(",
"this",
".",
"partitioning",
")",
"{",
"case",
"FULL_REPLICATION",
":",
"channel",
".",
"setShipStrategy",
"(",
"ShipStrategyType",
".",
"BROADCAST",
")",
";",
"break",
";",
"case",
"ANY_PARTITIONING",
":",
"case",
"HASH_PARTITIONED",
":",
"channel",
".",
"setShipStrategy",
"(",
"ShipStrategyType",
".",
"PARTITION_HASH",
",",
"Utils",
".",
"createOrderedFromSet",
"(",
"this",
".",
"partitioningFields",
")",
")",
";",
"break",
";",
"case",
"RANGE_PARTITIONED",
":",
"channel",
".",
"setShipStrategy",
"(",
"ShipStrategyType",
".",
"PARTITION_RANGE",
",",
"this",
".",
"ordering",
".",
"getInvolvedIndexes",
"(",
")",
",",
"this",
".",
"ordering",
".",
"getFieldSortDirections",
"(",
")",
")",
";",
"if",
"(",
"this",
".",
"dataDistribution",
"!=",
"null",
")",
"{",
"channel",
".",
"setDataDistribution",
"(",
"this",
".",
"dataDistribution",
")",
";",
"}",
"break",
";",
"default",
":",
"throw",
"new",
"CompilerException",
"(",
")",
";",
"}",
"}"
] | Parameterizes the ship strategy fields of a channel such that the channel produces the desired global properties.
@param channel The channel to parameterize.
@param globalDopChange
@param localDopChange | [
"Parameterizes",
"the",
"ship",
"strategy",
"fields",
"of",
"a",
"channel",
"such",
"that",
"the",
"channel",
"produces",
"the",
"desired",
"global",
"properties",
"."
] | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-compiler/src/main/java/eu/stratosphere/compiler/dataproperties/RequestedGlobalProperties.java#L223-L268 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/learning/AdaDeltaUpdater.java | AdaDeltaUpdater.applyUpdater | @Override
public void applyUpdater(INDArray gradient, int iteration, int epoch) {
"""
Get the updated gradient for the given gradient
and also update the state of ada delta.
@param gradient the gradient to get the
updated gradient for
@param iteration
@return the update gradient
"""
if (msg == null || msdx == null)
throw new IllegalStateException("Updater has not been initialized with view state");
double rho = config.getRho();
double epsilon = config.getEpsilon();
//Line 4 of Algorithm 1: https://arxiv.org/pdf/1212.5701v1.pdf
//E[g^2]_t = rho * E[g^2]_{t−1} + (1-rho)*g^2_t
msg.muli(rho).addi(gradient.mul(gradient).muli(1 - rho));
//Calculate update:
//dX = - g * RMS[delta x]_{t-1} / RMS[g]_t
//Note: negative is applied in the DL4J step function: params -= update rather than params += update
INDArray rmsdx_t1 = Transforms.sqrt(msdx.add(epsilon), false);
INDArray rmsg_t = Transforms.sqrt(msg.add(epsilon), false);
INDArray update = gradient.muli(rmsdx_t1.divi(rmsg_t));
//Accumulate gradients: E[delta x^2]_t = rho * E[delta x^2]_{t-1} + (1-rho)* (delta x_t)^2
msdx.muli(rho).addi(update.mul(update).muli(1 - rho));
} | java | @Override
public void applyUpdater(INDArray gradient, int iteration, int epoch) {
if (msg == null || msdx == null)
throw new IllegalStateException("Updater has not been initialized with view state");
double rho = config.getRho();
double epsilon = config.getEpsilon();
//Line 4 of Algorithm 1: https://arxiv.org/pdf/1212.5701v1.pdf
//E[g^2]_t = rho * E[g^2]_{t−1} + (1-rho)*g^2_t
msg.muli(rho).addi(gradient.mul(gradient).muli(1 - rho));
//Calculate update:
//dX = - g * RMS[delta x]_{t-1} / RMS[g]_t
//Note: negative is applied in the DL4J step function: params -= update rather than params += update
INDArray rmsdx_t1 = Transforms.sqrt(msdx.add(epsilon), false);
INDArray rmsg_t = Transforms.sqrt(msg.add(epsilon), false);
INDArray update = gradient.muli(rmsdx_t1.divi(rmsg_t));
//Accumulate gradients: E[delta x^2]_t = rho * E[delta x^2]_{t-1} + (1-rho)* (delta x_t)^2
msdx.muli(rho).addi(update.mul(update).muli(1 - rho));
} | [
"@",
"Override",
"public",
"void",
"applyUpdater",
"(",
"INDArray",
"gradient",
",",
"int",
"iteration",
",",
"int",
"epoch",
")",
"{",
"if",
"(",
"msg",
"==",
"null",
"||",
"msdx",
"==",
"null",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Updater has not been initialized with view state\"",
")",
";",
"double",
"rho",
"=",
"config",
".",
"getRho",
"(",
")",
";",
"double",
"epsilon",
"=",
"config",
".",
"getEpsilon",
"(",
")",
";",
"//Line 4 of Algorithm 1: https://arxiv.org/pdf/1212.5701v1.pdf",
"//E[g^2]_t = rho * E[g^2]_{t−1} + (1-rho)*g^2_t",
"msg",
".",
"muli",
"(",
"rho",
")",
".",
"addi",
"(",
"gradient",
".",
"mul",
"(",
"gradient",
")",
".",
"muli",
"(",
"1",
"-",
"rho",
")",
")",
";",
"//Calculate update:",
"//dX = - g * RMS[delta x]_{t-1} / RMS[g]_t",
"//Note: negative is applied in the DL4J step function: params -= update rather than params += update",
"INDArray",
"rmsdx_t1",
"=",
"Transforms",
".",
"sqrt",
"(",
"msdx",
".",
"add",
"(",
"epsilon",
")",
",",
"false",
")",
";",
"INDArray",
"rmsg_t",
"=",
"Transforms",
".",
"sqrt",
"(",
"msg",
".",
"add",
"(",
"epsilon",
")",
",",
"false",
")",
";",
"INDArray",
"update",
"=",
"gradient",
".",
"muli",
"(",
"rmsdx_t1",
".",
"divi",
"(",
"rmsg_t",
")",
")",
";",
"//Accumulate gradients: E[delta x^2]_t = rho * E[delta x^2]_{t-1} + (1-rho)* (delta x_t)^2",
"msdx",
".",
"muli",
"(",
"rho",
")",
".",
"addi",
"(",
"update",
".",
"mul",
"(",
"update",
")",
".",
"muli",
"(",
"1",
"-",
"rho",
")",
")",
";",
"}"
] | Get the updated gradient for the given gradient
and also update the state of ada delta.
@param gradient the gradient to get the
updated gradient for
@param iteration
@return the update gradient | [
"Get",
"the",
"updated",
"gradient",
"for",
"the",
"given",
"gradient",
"and",
"also",
"update",
"the",
"state",
"of",
"ada",
"delta",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/learning/AdaDeltaUpdater.java#L75-L96 |
lessthanoptimal/BoofCV | integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java | ConvertBitmap.bitmapToBoof | public static <T extends ImageBase<T>>
void bitmapToBoof( Bitmap input , T output , byte[] storage) {
"""
Converts a {@link Bitmap} into a BoofCV image. Type is determined at runtime.
@param input Bitmap image.
@param output Output image. Automatically resized to match input shape.
@param storage Byte array used for internal storage. If null it will be declared internally.
"""
if( BOverrideConvertAndroid.invokeBitmapToBoof(input,output,storage))
return;
switch( output.getImageType().getFamily() ) {
case GRAY: {
if( output.getClass() == GrayF32.class )
bitmapToGray(input, (GrayF32) output, storage);
else if( output.getClass() == GrayU8.class )
bitmapToGray(input,(GrayU8)output,storage);
else
throw new IllegalArgumentException("Unsupported BoofCV Image Type");
} break;
case PLANAR:
Planar pl = (Planar)output;
bitmapToPlanar(input,pl,pl.getBandType(),storage);
break;
default:
throw new IllegalArgumentException("Unsupported BoofCV Image Type");
}
} | java | public static <T extends ImageBase<T>>
void bitmapToBoof( Bitmap input , T output , byte[] storage) {
if( BOverrideConvertAndroid.invokeBitmapToBoof(input,output,storage))
return;
switch( output.getImageType().getFamily() ) {
case GRAY: {
if( output.getClass() == GrayF32.class )
bitmapToGray(input, (GrayF32) output, storage);
else if( output.getClass() == GrayU8.class )
bitmapToGray(input,(GrayU8)output,storage);
else
throw new IllegalArgumentException("Unsupported BoofCV Image Type");
} break;
case PLANAR:
Planar pl = (Planar)output;
bitmapToPlanar(input,pl,pl.getBandType(),storage);
break;
default:
throw new IllegalArgumentException("Unsupported BoofCV Image Type");
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageBase",
"<",
"T",
">",
">",
"void",
"bitmapToBoof",
"(",
"Bitmap",
"input",
",",
"T",
"output",
",",
"byte",
"[",
"]",
"storage",
")",
"{",
"if",
"(",
"BOverrideConvertAndroid",
".",
"invokeBitmapToBoof",
"(",
"input",
",",
"output",
",",
"storage",
")",
")",
"return",
";",
"switch",
"(",
"output",
".",
"getImageType",
"(",
")",
".",
"getFamily",
"(",
")",
")",
"{",
"case",
"GRAY",
":",
"{",
"if",
"(",
"output",
".",
"getClass",
"(",
")",
"==",
"GrayF32",
".",
"class",
")",
"bitmapToGray",
"(",
"input",
",",
"(",
"GrayF32",
")",
"output",
",",
"storage",
")",
";",
"else",
"if",
"(",
"output",
".",
"getClass",
"(",
")",
"==",
"GrayU8",
".",
"class",
")",
"bitmapToGray",
"(",
"input",
",",
"(",
"GrayU8",
")",
"output",
",",
"storage",
")",
";",
"else",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported BoofCV Image Type\"",
")",
";",
"}",
"break",
";",
"case",
"PLANAR",
":",
"Planar",
"pl",
"=",
"(",
"Planar",
")",
"output",
";",
"bitmapToPlanar",
"(",
"input",
",",
"pl",
",",
"pl",
".",
"getBandType",
"(",
")",
",",
"storage",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported BoofCV Image Type\"",
")",
";",
"}",
"}"
] | Converts a {@link Bitmap} into a BoofCV image. Type is determined at runtime.
@param input Bitmap image.
@param output Output image. Automatically resized to match input shape.
@param storage Byte array used for internal storage. If null it will be declared internally. | [
"Converts",
"a",
"{"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java#L61-L85 |
sai-pullabhotla/catatumbo | src/main/java/com/jmethods/catatumbo/impl/EmbeddableIntrospector.java | EmbeddableIntrospector.processEmbeddedField | private void processEmbeddedField(Field field) {
"""
Processes a nested embedded field.
@param field
the embedded field.
"""
// We are creating a PropertyMetadata for the embedded field... The new
// Mapper, EmbeddedObjectMapper, takes care of mapping embedded fields
// to embedded entities.
Embedded embeddedAnnotation = field.getAnnotation(Embedded.class);
String name = embeddedAnnotation.name();
if (name == null || name.trim().length() == 0) {
name = field.getName();
}
boolean indexed = embeddedAnnotation.indexed();
boolean optional = embeddedAnnotation.optional();
PropertyMetadata propertyMetadata = new PropertyMetadata(field, name, indexed, optional);
metadata.putPropertyMetadata(propertyMetadata);
} | java | private void processEmbeddedField(Field field) {
// We are creating a PropertyMetadata for the embedded field... The new
// Mapper, EmbeddedObjectMapper, takes care of mapping embedded fields
// to embedded entities.
Embedded embeddedAnnotation = field.getAnnotation(Embedded.class);
String name = embeddedAnnotation.name();
if (name == null || name.trim().length() == 0) {
name = field.getName();
}
boolean indexed = embeddedAnnotation.indexed();
boolean optional = embeddedAnnotation.optional();
PropertyMetadata propertyMetadata = new PropertyMetadata(field, name, indexed, optional);
metadata.putPropertyMetadata(propertyMetadata);
} | [
"private",
"void",
"processEmbeddedField",
"(",
"Field",
"field",
")",
"{",
"// We are creating a PropertyMetadata for the embedded field... The new",
"// Mapper, EmbeddedObjectMapper, takes care of mapping embedded fields",
"// to embedded entities.",
"Embedded",
"embeddedAnnotation",
"=",
"field",
".",
"getAnnotation",
"(",
"Embedded",
".",
"class",
")",
";",
"String",
"name",
"=",
"embeddedAnnotation",
".",
"name",
"(",
")",
";",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"name",
"=",
"field",
".",
"getName",
"(",
")",
";",
"}",
"boolean",
"indexed",
"=",
"embeddedAnnotation",
".",
"indexed",
"(",
")",
";",
"boolean",
"optional",
"=",
"embeddedAnnotation",
".",
"optional",
"(",
")",
";",
"PropertyMetadata",
"propertyMetadata",
"=",
"new",
"PropertyMetadata",
"(",
"field",
",",
"name",
",",
"indexed",
",",
"optional",
")",
";",
"metadata",
".",
"putPropertyMetadata",
"(",
"propertyMetadata",
")",
";",
"}"
] | Processes a nested embedded field.
@param field
the embedded field. | [
"Processes",
"a",
"nested",
"embedded",
"field",
"."
] | train | https://github.com/sai-pullabhotla/catatumbo/blob/96d4c6dce3a5009624f7112a398406914dd19165/src/main/java/com/jmethods/catatumbo/impl/EmbeddableIntrospector.java#L114-L127 |
Azure/azure-sdk-for-java | appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServicePlansInner.java | AppServicePlansInner.getHybridConnectionPlanLimit | public HybridConnectionLimitsInner getHybridConnectionPlanLimit(String resourceGroupName, String name) {
"""
Get the maximum number of Hybrid Connections allowed in an App Service plan.
Get the maximum number of Hybrid Connections allowed in an App Service plan.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service plan.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the HybridConnectionLimitsInner object if successful.
"""
return getHybridConnectionPlanLimitWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().body();
} | java | public HybridConnectionLimitsInner getHybridConnectionPlanLimit(String resourceGroupName, String name) {
return getHybridConnectionPlanLimitWithServiceResponseAsync(resourceGroupName, name).toBlocking().single().body();
} | [
"public",
"HybridConnectionLimitsInner",
"getHybridConnectionPlanLimit",
"(",
"String",
"resourceGroupName",
",",
"String",
"name",
")",
"{",
"return",
"getHybridConnectionPlanLimitWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"name",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Get the maximum number of Hybrid Connections allowed in an App Service plan.
Get the maximum number of Hybrid Connections allowed in an App Service plan.
@param resourceGroupName Name of the resource group to which the resource belongs.
@param name Name of the App Service plan.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the HybridConnectionLimitsInner object if successful. | [
"Get",
"the",
"maximum",
"number",
"of",
"Hybrid",
"Connections",
"allowed",
"in",
"an",
"App",
"Service",
"plan",
".",
"Get",
"the",
"maximum",
"number",
"of",
"Hybrid",
"Connections",
"allowed",
"in",
"an",
"App",
"Service",
"plan",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/appservice/resource-manager/v2016_09_01/src/main/java/com/microsoft/azure/management/appservice/v2016_09_01/implementation/AppServicePlansInner.java#L1589-L1591 |
apache/flink | flink-filesystems/flink-s3-fs-base/src/main/java/org/apache/flink/fs/s3/common/utils/RefCountedTmpFileCreator.java | RefCountedTmpFileCreator.apply | @Override
public RefCountedFile apply(File file) throws IOException {
"""
Gets the next temp file and stream to temp file.
This creates the temp file atomically, making sure no previous file is overwritten.
<p>This method is safe against concurrent use.
@return A pair of temp file and output stream to that temp file.
@throws IOException Thrown, if the stream to the temp file could not be opened.
"""
final File directory = tempDirectories[nextIndex()];
while (true) {
try {
if (file == null) {
final File newFile = new File(directory, ".tmp_" + UUID.randomUUID());
final OutputStream out = Files.newOutputStream(newFile.toPath(), StandardOpenOption.CREATE_NEW);
return RefCountedFile.newFile(newFile, out);
} else {
final OutputStream out = Files.newOutputStream(file.toPath(), StandardOpenOption.APPEND);
return RefCountedFile.restoredFile(file, out, file.length());
}
} catch (FileAlreadyExistsException ignored) {
// fall through the loop and retry
}
}
} | java | @Override
public RefCountedFile apply(File file) throws IOException {
final File directory = tempDirectories[nextIndex()];
while (true) {
try {
if (file == null) {
final File newFile = new File(directory, ".tmp_" + UUID.randomUUID());
final OutputStream out = Files.newOutputStream(newFile.toPath(), StandardOpenOption.CREATE_NEW);
return RefCountedFile.newFile(newFile, out);
} else {
final OutputStream out = Files.newOutputStream(file.toPath(), StandardOpenOption.APPEND);
return RefCountedFile.restoredFile(file, out, file.length());
}
} catch (FileAlreadyExistsException ignored) {
// fall through the loop and retry
}
}
} | [
"@",
"Override",
"public",
"RefCountedFile",
"apply",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"final",
"File",
"directory",
"=",
"tempDirectories",
"[",
"nextIndex",
"(",
")",
"]",
";",
"while",
"(",
"true",
")",
"{",
"try",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"final",
"File",
"newFile",
"=",
"new",
"File",
"(",
"directory",
",",
"\".tmp_\"",
"+",
"UUID",
".",
"randomUUID",
"(",
")",
")",
";",
"final",
"OutputStream",
"out",
"=",
"Files",
".",
"newOutputStream",
"(",
"newFile",
".",
"toPath",
"(",
")",
",",
"StandardOpenOption",
".",
"CREATE_NEW",
")",
";",
"return",
"RefCountedFile",
".",
"newFile",
"(",
"newFile",
",",
"out",
")",
";",
"}",
"else",
"{",
"final",
"OutputStream",
"out",
"=",
"Files",
".",
"newOutputStream",
"(",
"file",
".",
"toPath",
"(",
")",
",",
"StandardOpenOption",
".",
"APPEND",
")",
";",
"return",
"RefCountedFile",
".",
"restoredFile",
"(",
"file",
",",
"out",
",",
"file",
".",
"length",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"FileAlreadyExistsException",
"ignored",
")",
"{",
"// fall through the loop and retry",
"}",
"}",
"}"
] | Gets the next temp file and stream to temp file.
This creates the temp file atomically, making sure no previous file is overwritten.
<p>This method is safe against concurrent use.
@return A pair of temp file and output stream to that temp file.
@throws IOException Thrown, if the stream to the temp file could not be opened. | [
"Gets",
"the",
"next",
"temp",
"file",
"and",
"stream",
"to",
"temp",
"file",
".",
"This",
"creates",
"the",
"temp",
"file",
"atomically",
"making",
"sure",
"no",
"previous",
"file",
"is",
"overwritten",
"."
] | train | https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-filesystems/flink-s3-fs-base/src/main/java/org/apache/flink/fs/s3/common/utils/RefCountedTmpFileCreator.java#L72-L90 |
OpenLiberty/open-liberty | dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/connmgmt/ConnectionHandle.java | ConnectionHandle.setConnectionHandle | public static void setConnectionHandle(VirtualConnection vc, ConnectionHandle handle) {
"""
Set the connection handle on the virtual connection.
@param vc
VirtualConnection containing simple state for this connection
@param handle
ConnectionHandle for the VirtualConnection
"""
if (vc == null || handle == null) {
return;
}
Map<Object, Object> map = vc.getStateMap();
// set connection handle into VC
Object vcLock = vc.getLockObject();
synchronized (vcLock) {
Object tmpHandle = map.get(CONNECTION_HANDLE_VC_KEY);
// If this connection already has a unique handle when we get here,
// something went wrong.
if (tmpHandle != null) {
throw new IllegalStateException("Connection " + tmpHandle + " has already been created");
}
map.put(CONNECTION_HANDLE_VC_KEY, handle);
}
} | java | public static void setConnectionHandle(VirtualConnection vc, ConnectionHandle handle) {
if (vc == null || handle == null) {
return;
}
Map<Object, Object> map = vc.getStateMap();
// set connection handle into VC
Object vcLock = vc.getLockObject();
synchronized (vcLock) {
Object tmpHandle = map.get(CONNECTION_HANDLE_VC_KEY);
// If this connection already has a unique handle when we get here,
// something went wrong.
if (tmpHandle != null) {
throw new IllegalStateException("Connection " + tmpHandle + " has already been created");
}
map.put(CONNECTION_HANDLE_VC_KEY, handle);
}
} | [
"public",
"static",
"void",
"setConnectionHandle",
"(",
"VirtualConnection",
"vc",
",",
"ConnectionHandle",
"handle",
")",
"{",
"if",
"(",
"vc",
"==",
"null",
"||",
"handle",
"==",
"null",
")",
"{",
"return",
";",
"}",
"Map",
"<",
"Object",
",",
"Object",
">",
"map",
"=",
"vc",
".",
"getStateMap",
"(",
")",
";",
"// set connection handle into VC",
"Object",
"vcLock",
"=",
"vc",
".",
"getLockObject",
"(",
")",
";",
"synchronized",
"(",
"vcLock",
")",
"{",
"Object",
"tmpHandle",
"=",
"map",
".",
"get",
"(",
"CONNECTION_HANDLE_VC_KEY",
")",
";",
"// If this connection already has a unique handle when we get here,",
"// something went wrong.",
"if",
"(",
"tmpHandle",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Connection \"",
"+",
"tmpHandle",
"+",
"\" has already been created\"",
")",
";",
"}",
"map",
".",
"put",
"(",
"CONNECTION_HANDLE_VC_KEY",
",",
"handle",
")",
";",
"}",
"}"
] | Set the connection handle on the virtual connection.
@param vc
VirtualConnection containing simple state for this connection
@param handle
ConnectionHandle for the VirtualConnection | [
"Set",
"the",
"connection",
"handle",
"on",
"the",
"virtual",
"connection",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/connmgmt/ConnectionHandle.java#L107-L126 |
sarl/sarl | main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/quickfix/SARLQuickfixProvider.java | SARLQuickfixProvider.getOffsetForPattern | public int getOffsetForPattern(IXtextDocument document, int startOffset, String pattern) {
"""
Replies the offset that corresponds to the given regular expression pattern.
@param document the document to parse.
@param startOffset the offset in the text at which the pattern must be recognized.
@param pattern the regular expression pattern.
@return the offset (greater or equal to the startOffset), or <code>-1</code> if the pattern
cannot be recognized.
"""
final Pattern compiledPattern = Pattern.compile(pattern);
final Matcher matcher = compiledPattern.matcher(document.get());
if (matcher.find(startOffset)) {
final int end = matcher.end();
return end;
}
return -1;
} | java | public int getOffsetForPattern(IXtextDocument document, int startOffset, String pattern) {
final Pattern compiledPattern = Pattern.compile(pattern);
final Matcher matcher = compiledPattern.matcher(document.get());
if (matcher.find(startOffset)) {
final int end = matcher.end();
return end;
}
return -1;
} | [
"public",
"int",
"getOffsetForPattern",
"(",
"IXtextDocument",
"document",
",",
"int",
"startOffset",
",",
"String",
"pattern",
")",
"{",
"final",
"Pattern",
"compiledPattern",
"=",
"Pattern",
".",
"compile",
"(",
"pattern",
")",
";",
"final",
"Matcher",
"matcher",
"=",
"compiledPattern",
".",
"matcher",
"(",
"document",
".",
"get",
"(",
")",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
"startOffset",
")",
")",
"{",
"final",
"int",
"end",
"=",
"matcher",
".",
"end",
"(",
")",
";",
"return",
"end",
";",
"}",
"return",
"-",
"1",
";",
"}"
] | Replies the offset that corresponds to the given regular expression pattern.
@param document the document to parse.
@param startOffset the offset in the text at which the pattern must be recognized.
@param pattern the regular expression pattern.
@return the offset (greater or equal to the startOffset), or <code>-1</code> if the pattern
cannot be recognized. | [
"Replies",
"the",
"offset",
"that",
"corresponds",
"to",
"the",
"given",
"regular",
"expression",
"pattern",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang.ui/src/io/sarl/lang/ui/quickfix/SARLQuickfixProvider.java#L558-L566 |
spotbugs/spotbugs | spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/SorterDialog.java | SorterDialog.createSorterPane | private JPanel createSorterPane() {
"""
Creates JPanel with checkboxes of different things to sort by. List is:
priority, class, package, category, bugcode, status, and type.
"""
JPanel insidePanel = new JPanel();
insidePanel.setLayout(new GridBagLayout());
preview = new JTableHeader();
Sortables[] sortables = MainFrame.getInstance().getAvailableSortables();
preview.setColumnModel(new SorterTableColumnModel(sortables));
for (Sortables s : sortables) {
if (s != Sortables.DIVIDER) {
checkBoxSortList.add(new SortableCheckBox(s));
}
}
setSorterCheckBoxes();
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 1;
gbc.insets = new Insets(2,5,2,5);
insidePanel.add(new JLabel("<html><h2>1. Choose bug properties"), gbc);
insidePanel.add(new CheckBoxList<>(checkBoxSortList.toArray(new JCheckBox[checkBoxSortList.size()])), gbc);
JTable t = new JTable(new DefaultTableModel(0, sortables.length));
t.setTableHeader(preview);
preview.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
insidePanel.add(new JLabel("<html><h2>2. Drag and drop to change grouping priority"), gbc);
insidePanel.add(createAppropriatelySizedScrollPane(t), gbc);
sortApply = new JButton(edu.umd.cs.findbugs.L10N.getLocalString("dlg.apply_btn", "Apply"));
sortApply.addActionListener(e -> {
MainFrame.getInstance().getSorter().createFrom((SorterTableColumnModel) preview.getColumnModel());
((BugTreeModel) MainFrame.getInstance().getTree().getModel()).checkSorter();
SorterDialog.this.dispose();
});
gbc.fill = GridBagConstraints.NONE;
insidePanel.add(sortApply, gbc);
JPanel sorter = new JPanel();
sorter.setLayout(new BorderLayout());
sorter.add(new JScrollPane(insidePanel), BorderLayout.CENTER);
return sorter;
} | java | private JPanel createSorterPane() {
JPanel insidePanel = new JPanel();
insidePanel.setLayout(new GridBagLayout());
preview = new JTableHeader();
Sortables[] sortables = MainFrame.getInstance().getAvailableSortables();
preview.setColumnModel(new SorterTableColumnModel(sortables));
for (Sortables s : sortables) {
if (s != Sortables.DIVIDER) {
checkBoxSortList.add(new SortableCheckBox(s));
}
}
setSorterCheckBoxes();
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 1;
gbc.insets = new Insets(2,5,2,5);
insidePanel.add(new JLabel("<html><h2>1. Choose bug properties"), gbc);
insidePanel.add(new CheckBoxList<>(checkBoxSortList.toArray(new JCheckBox[checkBoxSortList.size()])), gbc);
JTable t = new JTable(new DefaultTableModel(0, sortables.length));
t.setTableHeader(preview);
preview.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
insidePanel.add(new JLabel("<html><h2>2. Drag and drop to change grouping priority"), gbc);
insidePanel.add(createAppropriatelySizedScrollPane(t), gbc);
sortApply = new JButton(edu.umd.cs.findbugs.L10N.getLocalString("dlg.apply_btn", "Apply"));
sortApply.addActionListener(e -> {
MainFrame.getInstance().getSorter().createFrom((SorterTableColumnModel) preview.getColumnModel());
((BugTreeModel) MainFrame.getInstance().getTree().getModel()).checkSorter();
SorterDialog.this.dispose();
});
gbc.fill = GridBagConstraints.NONE;
insidePanel.add(sortApply, gbc);
JPanel sorter = new JPanel();
sorter.setLayout(new BorderLayout());
sorter.add(new JScrollPane(insidePanel), BorderLayout.CENTER);
return sorter;
} | [
"private",
"JPanel",
"createSorterPane",
"(",
")",
"{",
"JPanel",
"insidePanel",
"=",
"new",
"JPanel",
"(",
")",
";",
"insidePanel",
".",
"setLayout",
"(",
"new",
"GridBagLayout",
"(",
")",
")",
";",
"preview",
"=",
"new",
"JTableHeader",
"(",
")",
";",
"Sortables",
"[",
"]",
"sortables",
"=",
"MainFrame",
".",
"getInstance",
"(",
")",
".",
"getAvailableSortables",
"(",
")",
";",
"preview",
".",
"setColumnModel",
"(",
"new",
"SorterTableColumnModel",
"(",
"sortables",
")",
")",
";",
"for",
"(",
"Sortables",
"s",
":",
"sortables",
")",
"{",
"if",
"(",
"s",
"!=",
"Sortables",
".",
"DIVIDER",
")",
"{",
"checkBoxSortList",
".",
"add",
"(",
"new",
"SortableCheckBox",
"(",
"s",
")",
")",
";",
"}",
"}",
"setSorterCheckBoxes",
"(",
")",
";",
"GridBagConstraints",
"gbc",
"=",
"new",
"GridBagConstraints",
"(",
")",
";",
"gbc",
".",
"fill",
"=",
"GridBagConstraints",
".",
"BOTH",
";",
"gbc",
".",
"gridx",
"=",
"1",
";",
"gbc",
".",
"insets",
"=",
"new",
"Insets",
"(",
"2",
",",
"5",
",",
"2",
",",
"5",
")",
";",
"insidePanel",
".",
"add",
"(",
"new",
"JLabel",
"(",
"\"<html><h2>1. Choose bug properties\"",
")",
",",
"gbc",
")",
";",
"insidePanel",
".",
"add",
"(",
"new",
"CheckBoxList",
"<>",
"(",
"checkBoxSortList",
".",
"toArray",
"(",
"new",
"JCheckBox",
"[",
"checkBoxSortList",
".",
"size",
"(",
")",
"]",
")",
")",
",",
"gbc",
")",
";",
"JTable",
"t",
"=",
"new",
"JTable",
"(",
"new",
"DefaultTableModel",
"(",
"0",
",",
"sortables",
".",
"length",
")",
")",
";",
"t",
".",
"setTableHeader",
"(",
"preview",
")",
";",
"preview",
".",
"setCursor",
"(",
"Cursor",
".",
"getPredefinedCursor",
"(",
"Cursor",
".",
"W_RESIZE_CURSOR",
")",
")",
";",
"insidePanel",
".",
"add",
"(",
"new",
"JLabel",
"(",
"\"<html><h2>2. Drag and drop to change grouping priority\"",
")",
",",
"gbc",
")",
";",
"insidePanel",
".",
"add",
"(",
"createAppropriatelySizedScrollPane",
"(",
"t",
")",
",",
"gbc",
")",
";",
"sortApply",
"=",
"new",
"JButton",
"(",
"edu",
".",
"umd",
".",
"cs",
".",
"findbugs",
".",
"L10N",
".",
"getLocalString",
"(",
"\"dlg.apply_btn\"",
",",
"\"Apply\"",
")",
")",
";",
"sortApply",
".",
"addActionListener",
"(",
"e",
"->",
"{",
"MainFrame",
".",
"getInstance",
"(",
")",
".",
"getSorter",
"(",
")",
".",
"createFrom",
"(",
"(",
"SorterTableColumnModel",
")",
"preview",
".",
"getColumnModel",
"(",
")",
")",
";",
"(",
"(",
"BugTreeModel",
")",
"MainFrame",
".",
"getInstance",
"(",
")",
".",
"getTree",
"(",
")",
".",
"getModel",
"(",
")",
")",
".",
"checkSorter",
"(",
")",
";",
"SorterDialog",
".",
"this",
".",
"dispose",
"(",
")",
";",
"}",
")",
";",
"gbc",
".",
"fill",
"=",
"GridBagConstraints",
".",
"NONE",
";",
"insidePanel",
".",
"add",
"(",
"sortApply",
",",
"gbc",
")",
";",
"JPanel",
"sorter",
"=",
"new",
"JPanel",
"(",
")",
";",
"sorter",
".",
"setLayout",
"(",
"new",
"BorderLayout",
"(",
")",
")",
";",
"sorter",
".",
"add",
"(",
"new",
"JScrollPane",
"(",
"insidePanel",
")",
",",
"BorderLayout",
".",
"CENTER",
")",
";",
"return",
"sorter",
";",
"}"
] | Creates JPanel with checkboxes of different things to sort by. List is:
priority, class, package, category, bugcode, status, and type. | [
"Creates",
"JPanel",
"with",
"checkboxes",
"of",
"different",
"things",
"to",
"sort",
"by",
".",
"List",
"is",
":",
"priority",
"class",
"package",
"category",
"bugcode",
"status",
"and",
"type",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/gui/main/edu/umd/cs/findbugs/gui2/SorterDialog.java#L96-L138 |
liferay/com-liferay-commerce | commerce-wish-list-service/src/main/java/com/liferay/commerce/wish/list/service/persistence/impl/CommerceWishListItemPersistenceImpl.java | CommerceWishListItemPersistenceImpl.findAll | @Override
public List<CommerceWishListItem> findAll(int start, int end) {
"""
Returns a range of all the commerce wish list items.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceWishListItemModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce wish list items
@param end the upper bound of the range of commerce wish list items (not inclusive)
@return the range of commerce wish list items
"""
return findAll(start, end, null);
} | java | @Override
public List<CommerceWishListItem> findAll(int start, int end) {
return findAll(start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceWishListItem",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the commerce wish list items.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceWishListItemModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce wish list items
@param end the upper bound of the range of commerce wish list items (not inclusive)
@return the range of commerce wish list items | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"wish",
"list",
"items",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-wish-list-service/src/main/java/com/liferay/commerce/wish/list/service/persistence/impl/CommerceWishListItemPersistenceImpl.java#L3850-L3853 |
wigforss/Ka-Commons-Reflection | src/main/java/org/kasource/commons/reflection/util/AnnotationScanner.java | AnnotationScanner.addClass | @SuppressWarnings("unchecked")
private <T> void addClass(Set<Class<? extends T>> classes,
String includeRegExp,
String className,
Class<T> ofType,
Class<? extends Annotation> annotationClass) {
"""
Created and adds the event to the eventsFound set, if its package matches the includeRegExp.
@param eventBuilderFactory Event Factory used to create the EventConfig instance with.
@param eventsFound Set of events found, to add the newly created EventConfig to.
@param includeRegExp Regular expression to test eventClassName with.
@param eventClassName Name of the class.
"""
if (className.matches(includeRegExp)) {
try {
Class<?> matchingClass = Class.forName(className);
matchingClass.asSubclass(ofType);
classes.add((Class<T>) matchingClass);
} catch (ClassNotFoundException cnfe) {
throw new IllegalStateException("Scannotation found a class that does not exist " + className + " !", cnfe);
} catch (ClassCastException cce) {
throw new IllegalStateException("Class " + className
+ " is annoted with @"+annotationClass+" but does not extend or implement "+ofType);
}
}
} | java | @SuppressWarnings("unchecked")
private <T> void addClass(Set<Class<? extends T>> classes,
String includeRegExp,
String className,
Class<T> ofType,
Class<? extends Annotation> annotationClass) {
if (className.matches(includeRegExp)) {
try {
Class<?> matchingClass = Class.forName(className);
matchingClass.asSubclass(ofType);
classes.add((Class<T>) matchingClass);
} catch (ClassNotFoundException cnfe) {
throw new IllegalStateException("Scannotation found a class that does not exist " + className + " !", cnfe);
} catch (ClassCastException cce) {
throw new IllegalStateException("Class " + className
+ " is annoted with @"+annotationClass+" but does not extend or implement "+ofType);
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"<",
"T",
">",
"void",
"addClass",
"(",
"Set",
"<",
"Class",
"<",
"?",
"extends",
"T",
">",
">",
"classes",
",",
"String",
"includeRegExp",
",",
"String",
"className",
",",
"Class",
"<",
"T",
">",
"ofType",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"annotationClass",
")",
"{",
"if",
"(",
"className",
".",
"matches",
"(",
"includeRegExp",
")",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"matchingClass",
"=",
"Class",
".",
"forName",
"(",
"className",
")",
";",
"matchingClass",
".",
"asSubclass",
"(",
"ofType",
")",
";",
"classes",
".",
"add",
"(",
"(",
"Class",
"<",
"T",
">",
")",
"matchingClass",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"cnfe",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Scannotation found a class that does not exist \"",
"+",
"className",
"+",
"\" !\"",
",",
"cnfe",
")",
";",
"}",
"catch",
"(",
"ClassCastException",
"cce",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Class \"",
"+",
"className",
"+",
"\" is annoted with @\"",
"+",
"annotationClass",
"+",
"\" but does not extend or implement \"",
"+",
"ofType",
")",
";",
"}",
"}",
"}"
] | Created and adds the event to the eventsFound set, if its package matches the includeRegExp.
@param eventBuilderFactory Event Factory used to create the EventConfig instance with.
@param eventsFound Set of events found, to add the newly created EventConfig to.
@param includeRegExp Regular expression to test eventClassName with.
@param eventClassName Name of the class. | [
"Created",
"and",
"adds",
"the",
"event",
"to",
"the",
"eventsFound",
"set",
"if",
"its",
"package",
"matches",
"the",
"includeRegExp",
"."
] | train | https://github.com/wigforss/Ka-Commons-Reflection/blob/a80f7a164cd800089e4f4dd948ca6f0e7badcf33/src/main/java/org/kasource/commons/reflection/util/AnnotationScanner.java#L70-L89 |
Faylixe/googlecodejam-client | src/main/java/fr/faylixe/googlecodejam/client/executor/HttpRequestExecutor.java | HttpRequestExecutor.readResolve | private Object readResolve() throws ObjectStreamException {
"""
Custom deserialization processing method that
create a new valid {@link HttpRequestExecutor}
instance from the internally stored cookie value.
@return Valid {@link HttpRequestExecutor} instance.
@throws ObjectStreamException If any error occurs during deserialization process.
"""
try {
return create(hostname, cookieValue);
}
catch (final IOException | GeneralSecurityException e) {
throw new ObjectStreamException(e.getMessage()) {
/** Serialization index. **/
private static final long serialVersionUID = 1L;
};
}
} | java | private Object readResolve() throws ObjectStreamException {
try {
return create(hostname, cookieValue);
}
catch (final IOException | GeneralSecurityException e) {
throw new ObjectStreamException(e.getMessage()) {
/** Serialization index. **/
private static final long serialVersionUID = 1L;
};
}
} | [
"private",
"Object",
"readResolve",
"(",
")",
"throws",
"ObjectStreamException",
"{",
"try",
"{",
"return",
"create",
"(",
"hostname",
",",
"cookieValue",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"|",
"GeneralSecurityException",
"e",
")",
"{",
"throw",
"new",
"ObjectStreamException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
"{",
"/** Serialization index. **/",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"}",
";",
"}",
"}"
] | Custom deserialization processing method that
create a new valid {@link HttpRequestExecutor}
instance from the internally stored cookie value.
@return Valid {@link HttpRequestExecutor} instance.
@throws ObjectStreamException If any error occurs during deserialization process. | [
"Custom",
"deserialization",
"processing",
"method",
"that",
"create",
"a",
"new",
"valid",
"{",
"@link",
"HttpRequestExecutor",
"}",
"instance",
"from",
"the",
"internally",
"stored",
"cookie",
"value",
"."
] | train | https://github.com/Faylixe/googlecodejam-client/blob/84a5fed4e049dca48994dc3f70213976aaff4bd3/src/main/java/fr/faylixe/googlecodejam/client/executor/HttpRequestExecutor.java#L164-L176 |
rythmengine/spring-rythm | src/main/java/org/rythmengine/spring/RythmEngineFactory.java | RythmEngineFactory.setEngineConfigMap | public void setEngineConfigMap(Map<String, Object> engineConfigMap) {
"""
Set Rythm properties as Map, to allow for non-String values
like "ds.resource.loader.instance".
@see #setEngineConfig
"""
if (engineConfigMap != null) {
this.engineConfig.putAll(engineConfigMap);
}
} | java | public void setEngineConfigMap(Map<String, Object> engineConfigMap) {
if (engineConfigMap != null) {
this.engineConfig.putAll(engineConfigMap);
}
} | [
"public",
"void",
"setEngineConfigMap",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"engineConfigMap",
")",
"{",
"if",
"(",
"engineConfigMap",
"!=",
"null",
")",
"{",
"this",
".",
"engineConfig",
".",
"putAll",
"(",
"engineConfigMap",
")",
";",
"}",
"}"
] | Set Rythm properties as Map, to allow for non-String values
like "ds.resource.loader.instance".
@see #setEngineConfig | [
"Set",
"Rythm",
"properties",
"as",
"Map",
"to",
"allow",
"for",
"non",
"-",
"String",
"values",
"like",
"ds",
".",
"resource",
".",
"loader",
".",
"instance",
"."
] | train | https://github.com/rythmengine/spring-rythm/blob/a654016371c72dabaea50ac9a57626da7614d236/src/main/java/org/rythmengine/spring/RythmEngineFactory.java#L115-L119 |
micronaut-projects/micronaut-core | cli/src/main/groovy/io/micronaut/cli/io/support/SpringIOUtils.java | SpringIOUtils.copyAll | public static void copyAll(Resource base, Resource[] resources, File targetDir) throws IOException {
"""
Copies all the resources for the given target directory. The base resource serves to calculate the relative
path such that the directory structure is maintained.
@param base The base resource
@param resources The resources to copy
@param targetDir The target directory
@throws IOException if there is an error
"""
final URL baseUrl = base.getURL();
for (Resource resource : resources) {
final InputStream input = resource.getInputStream();
final File target = new File(targetDir, resource.getURL().toString().substring(baseUrl.toString().length()));
copy(new BufferedInputStream(input), new BufferedOutputStream(Files.newOutputStream(target.toPath())));
}
} | java | public static void copyAll(Resource base, Resource[] resources, File targetDir) throws IOException {
final URL baseUrl = base.getURL();
for (Resource resource : resources) {
final InputStream input = resource.getInputStream();
final File target = new File(targetDir, resource.getURL().toString().substring(baseUrl.toString().length()));
copy(new BufferedInputStream(input), new BufferedOutputStream(Files.newOutputStream(target.toPath())));
}
} | [
"public",
"static",
"void",
"copyAll",
"(",
"Resource",
"base",
",",
"Resource",
"[",
"]",
"resources",
",",
"File",
"targetDir",
")",
"throws",
"IOException",
"{",
"final",
"URL",
"baseUrl",
"=",
"base",
".",
"getURL",
"(",
")",
";",
"for",
"(",
"Resource",
"resource",
":",
"resources",
")",
"{",
"final",
"InputStream",
"input",
"=",
"resource",
".",
"getInputStream",
"(",
")",
";",
"final",
"File",
"target",
"=",
"new",
"File",
"(",
"targetDir",
",",
"resource",
".",
"getURL",
"(",
")",
".",
"toString",
"(",
")",
".",
"substring",
"(",
"baseUrl",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
")",
")",
";",
"copy",
"(",
"new",
"BufferedInputStream",
"(",
"input",
")",
",",
"new",
"BufferedOutputStream",
"(",
"Files",
".",
"newOutputStream",
"(",
"target",
".",
"toPath",
"(",
")",
")",
")",
")",
";",
"}",
"}"
] | Copies all the resources for the given target directory. The base resource serves to calculate the relative
path such that the directory structure is maintained.
@param base The base resource
@param resources The resources to copy
@param targetDir The target directory
@throws IOException if there is an error | [
"Copies",
"all",
"the",
"resources",
"for",
"the",
"given",
"target",
"directory",
".",
"The",
"base",
"resource",
"serves",
"to",
"calculate",
"the",
"relative",
"path",
"such",
"that",
"the",
"directory",
"structure",
"is",
"maintained",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/cli/src/main/groovy/io/micronaut/cli/io/support/SpringIOUtils.java#L181-L188 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/viterbi/ViterbiBuilder.java | ViterbiBuilder.isAcceptableCandidate | private boolean isAcceptableCandidate(int targetLength, ViterbiNode glueBase, ViterbiNode candidate) {
"""
Check whether a candidate for a glue node is acceptable.
The candidate should be as short as possible, but long enough to overlap with the inserted user entry
@param targetLength
@param glueBase
@param candidate
@return whether candidate is acceptable
"""
return (glueBase == null || candidate.getSurface().length() < glueBase.getSurface().length())
&& candidate.getSurface().length() >= targetLength;
} | java | private boolean isAcceptableCandidate(int targetLength, ViterbiNode glueBase, ViterbiNode candidate) {
return (glueBase == null || candidate.getSurface().length() < glueBase.getSurface().length())
&& candidate.getSurface().length() >= targetLength;
} | [
"private",
"boolean",
"isAcceptableCandidate",
"(",
"int",
"targetLength",
",",
"ViterbiNode",
"glueBase",
",",
"ViterbiNode",
"candidate",
")",
"{",
"return",
"(",
"glueBase",
"==",
"null",
"||",
"candidate",
".",
"getSurface",
"(",
")",
".",
"length",
"(",
")",
"<",
"glueBase",
".",
"getSurface",
"(",
")",
".",
"length",
"(",
")",
")",
"&&",
"candidate",
".",
"getSurface",
"(",
")",
".",
"length",
"(",
")",
">=",
"targetLength",
";",
"}"
] | Check whether a candidate for a glue node is acceptable.
The candidate should be as short as possible, but long enough to overlap with the inserted user entry
@param targetLength
@param glueBase
@param candidate
@return whether candidate is acceptable | [
"Check",
"whether",
"a",
"candidate",
"for",
"a",
"glue",
"node",
"is",
"acceptable",
".",
"The",
"candidate",
"should",
"be",
"as",
"short",
"as",
"possible",
"but",
"long",
"enough",
"to",
"overlap",
"with",
"the",
"inserted",
"user",
"entry"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/viterbi/ViterbiBuilder.java#L319-L322 |
google/j2objc | jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCaseProps.java | UCaseProps.strcmpMax | private final int strcmpMax(String s, int unfoldOffset, int max) {
"""
/*
compare s, which has a length, with t=unfold[unfoldOffset..], which has a maximum length or is NUL-terminated
must be s.length()>0 and max>0 and s.length()<=max
"""
int i1, length, c1, c2;
length=s.length();
max-=length; /* we require length<=max, so no need to decrement max in the loop */
i1=0;
do {
c1=s.charAt(i1++);
c2=unfold[unfoldOffset++];
if(c2==0) {
return 1; /* reached the end of t but not of s */
}
c1-=c2;
if(c1!=0) {
return c1; /* return difference result */
}
} while(--length>0);
/* ends with length==0 */
if(max==0 || unfold[unfoldOffset]==0) {
return 0; /* equal to length of both strings */
} else {
return -max; /* return lengh difference */
}
} | java | private final int strcmpMax(String s, int unfoldOffset, int max) {
int i1, length, c1, c2;
length=s.length();
max-=length; /* we require length<=max, so no need to decrement max in the loop */
i1=0;
do {
c1=s.charAt(i1++);
c2=unfold[unfoldOffset++];
if(c2==0) {
return 1; /* reached the end of t but not of s */
}
c1-=c2;
if(c1!=0) {
return c1; /* return difference result */
}
} while(--length>0);
/* ends with length==0 */
if(max==0 || unfold[unfoldOffset]==0) {
return 0; /* equal to length of both strings */
} else {
return -max; /* return lengh difference */
}
} | [
"private",
"final",
"int",
"strcmpMax",
"(",
"String",
"s",
",",
"int",
"unfoldOffset",
",",
"int",
"max",
")",
"{",
"int",
"i1",
",",
"length",
",",
"c1",
",",
"c2",
";",
"length",
"=",
"s",
".",
"length",
"(",
")",
";",
"max",
"-=",
"length",
";",
"/* we require length<=max, so no need to decrement max in the loop */",
"i1",
"=",
"0",
";",
"do",
"{",
"c1",
"=",
"s",
".",
"charAt",
"(",
"i1",
"++",
")",
";",
"c2",
"=",
"unfold",
"[",
"unfoldOffset",
"++",
"]",
";",
"if",
"(",
"c2",
"==",
"0",
")",
"{",
"return",
"1",
";",
"/* reached the end of t but not of s */",
"}",
"c1",
"-=",
"c2",
";",
"if",
"(",
"c1",
"!=",
"0",
")",
"{",
"return",
"c1",
";",
"/* return difference result */",
"}",
"}",
"while",
"(",
"--",
"length",
">",
"0",
")",
";",
"/* ends with length==0 */",
"if",
"(",
"max",
"==",
"0",
"||",
"unfold",
"[",
"unfoldOffset",
"]",
"==",
"0",
")",
"{",
"return",
"0",
";",
"/* equal to length of both strings */",
"}",
"else",
"{",
"return",
"-",
"max",
";",
"/* return lengh difference */",
"}",
"}"
] | /*
compare s, which has a length, with t=unfold[unfoldOffset..], which has a maximum length or is NUL-terminated
must be s.length()>0 and max>0 and s.length()<=max | [
"/",
"*",
"compare",
"s",
"which",
"has",
"a",
"length",
"with",
"t",
"=",
"unfold",
"[",
"unfoldOffset",
"..",
"]",
"which",
"has",
"a",
"maximum",
"length",
"or",
"is",
"NUL",
"-",
"terminated",
"must",
"be",
"s",
".",
"length",
"()",
">",
"0",
"and",
"max",
">",
"0",
"and",
"s",
".",
"length",
"()",
"<",
"=",
"max"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/UCaseProps.java#L368-L392 |
Harium/keel | src/main/java/com/harium/keel/catalano/math/Tools.java | Tools.Angle | public static float Angle(float x, float y) {
"""
Gets the angle formed by the vector [x,y].
@param x X axis coordinate.
@param y Y axis coordinate.
@return Angle formed by the vector.
"""
if (y >= 0) {
if (x >= 0)
return (float) Math.atan(y / x);
return (float) (Math.PI - Math.atan(-y / x));
} else {
if (x >= 0)
return (float) (2 * Math.PI - Math.atan(-y / x));
return (float) (Math.PI + Math.atan(y / x));
}
} | java | public static float Angle(float x, float y) {
if (y >= 0) {
if (x >= 0)
return (float) Math.atan(y / x);
return (float) (Math.PI - Math.atan(-y / x));
} else {
if (x >= 0)
return (float) (2 * Math.PI - Math.atan(-y / x));
return (float) (Math.PI + Math.atan(y / x));
}
} | [
"public",
"static",
"float",
"Angle",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"if",
"(",
"y",
">=",
"0",
")",
"{",
"if",
"(",
"x",
">=",
"0",
")",
"return",
"(",
"float",
")",
"Math",
".",
"atan",
"(",
"y",
"/",
"x",
")",
";",
"return",
"(",
"float",
")",
"(",
"Math",
".",
"PI",
"-",
"Math",
".",
"atan",
"(",
"-",
"y",
"/",
"x",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"x",
">=",
"0",
")",
"return",
"(",
"float",
")",
"(",
"2",
"*",
"Math",
".",
"PI",
"-",
"Math",
".",
"atan",
"(",
"-",
"y",
"/",
"x",
")",
")",
";",
"return",
"(",
"float",
")",
"(",
"Math",
".",
"PI",
"+",
"Math",
".",
"atan",
"(",
"y",
"/",
"x",
")",
")",
";",
"}",
"}"
] | Gets the angle formed by the vector [x,y].
@param x X axis coordinate.
@param y Y axis coordinate.
@return Angle formed by the vector. | [
"Gets",
"the",
"angle",
"formed",
"by",
"the",
"vector",
"[",
"x",
"y",
"]",
"."
] | train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/Tools.java#L85-L95 |
amzn/ion-java | src/com/amazon/ion/impl/lite/IonStructLite.java | IonStructLite._add | private void _add(String fieldName, IonValueLite child) {
"""
Validates the child and checks locks.
@param fieldName may be null
@param child must be validated and have field name or id set
"""
hasNullFieldName |= fieldName == null;
int size = get_child_count();
// add this to the Container child collection
add(size, child);
// if we have a hash map we need to update it now
if (_field_map != null) {
add_field(fieldName, child._elementid());
}
} | java | private void _add(String fieldName, IonValueLite child)
{
hasNullFieldName |= fieldName == null;
int size = get_child_count();
// add this to the Container child collection
add(size, child);
// if we have a hash map we need to update it now
if (_field_map != null) {
add_field(fieldName, child._elementid());
}
} | [
"private",
"void",
"_add",
"(",
"String",
"fieldName",
",",
"IonValueLite",
"child",
")",
"{",
"hasNullFieldName",
"|=",
"fieldName",
"==",
"null",
";",
"int",
"size",
"=",
"get_child_count",
"(",
")",
";",
"// add this to the Container child collection",
"add",
"(",
"size",
",",
"child",
")",
";",
"// if we have a hash map we need to update it now",
"if",
"(",
"_field_map",
"!=",
"null",
")",
"{",
"add_field",
"(",
"fieldName",
",",
"child",
".",
"_elementid",
"(",
")",
")",
";",
"}",
"}"
] | Validates the child and checks locks.
@param fieldName may be null
@param child must be validated and have field name or id set | [
"Validates",
"the",
"child",
"and",
"checks",
"locks",
"."
] | train | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/lite/IonStructLite.java#L480-L492 |
sarxos/webcam-capture | webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java | Webcam.setParameters | public void setParameters(Map<String, ?> parameters) {
"""
If the underlying device implements Configurable interface, specified parameters are passed
to it. May be called before the open method or later in dependence of the device
implementation.
@param parameters - Map of parameters changing device defaults
@see Configurable
"""
WebcamDevice device = getDevice();
if (device instanceof Configurable) {
((Configurable) device).setParameters(parameters);
} else {
LOG.debug("Webcam device {} is not configurable", device);
}
} | java | public void setParameters(Map<String, ?> parameters) {
WebcamDevice device = getDevice();
if (device instanceof Configurable) {
((Configurable) device).setParameters(parameters);
} else {
LOG.debug("Webcam device {} is not configurable", device);
}
} | [
"public",
"void",
"setParameters",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"parameters",
")",
"{",
"WebcamDevice",
"device",
"=",
"getDevice",
"(",
")",
";",
"if",
"(",
"device",
"instanceof",
"Configurable",
")",
"{",
"(",
"(",
"Configurable",
")",
"device",
")",
".",
"setParameters",
"(",
"parameters",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"debug",
"(",
"\"Webcam device {} is not configurable\"",
",",
"device",
")",
";",
"}",
"}"
] | If the underlying device implements Configurable interface, specified parameters are passed
to it. May be called before the open method or later in dependence of the device
implementation.
@param parameters - Map of parameters changing device defaults
@see Configurable | [
"If",
"the",
"underlying",
"device",
"implements",
"Configurable",
"interface",
"specified",
"parameters",
"are",
"passed",
"to",
"it",
".",
"May",
"be",
"called",
"before",
"the",
"open",
"method",
"or",
"later",
"in",
"dependence",
"of",
"the",
"device",
"implementation",
"."
] | train | https://github.com/sarxos/webcam-capture/blob/efbdae04f9ba48db9ec621e94a9bcd6f031882c8/webcam-capture/src/main/java/com/github/sarxos/webcam/Webcam.java#L796-L803 |
FedericoPecora/meta-csp-framework | src/main/java/org/metacsp/multi/spatioTemporal/paths/Pose.java | Pose.interpolate | public Pose interpolate(Pose p2, double ratio) {
"""
Computes the {@link Pose} between this {@link Pose} and a given {@link Pose} via bilinear interpolation.
@param p2 The second {@link Pose} used for interpolation.
@param ratio Parameter in [0,1] used for bilinear interpolation.
@return The {@link Pose} between this {@link Pose} and a given {@link Pose} via bilinear interpolation.
"""
double newX = lerp(getX(),p2.getX(),ratio);
double newY = lerp(getY(),p2.getY(),ratio);
if (Double.isNaN(this.z)) {
double newTheta = lerpDegrees(getTheta(),p2.getTheta(),ratio);
return new Pose(newX,newY,newTheta);
}
double newZ = lerp(getZ(),p2.getZ(),ratio);
double newRoll = lerpDegrees(getRoll(),p2.getRoll(),ratio);
double newPitch = lerpDegrees(getPitch(),p2.getPitch(),ratio);
double newYaw = lerpDegrees(getYaw(),p2.getYaw(),ratio);
return new Pose(newX,newY,newZ,newRoll,newPitch,newYaw);
} | java | public Pose interpolate(Pose p2, double ratio) {
double newX = lerp(getX(),p2.getX(),ratio);
double newY = lerp(getY(),p2.getY(),ratio);
if (Double.isNaN(this.z)) {
double newTheta = lerpDegrees(getTheta(),p2.getTheta(),ratio);
return new Pose(newX,newY,newTheta);
}
double newZ = lerp(getZ(),p2.getZ(),ratio);
double newRoll = lerpDegrees(getRoll(),p2.getRoll(),ratio);
double newPitch = lerpDegrees(getPitch(),p2.getPitch(),ratio);
double newYaw = lerpDegrees(getYaw(),p2.getYaw(),ratio);
return new Pose(newX,newY,newZ,newRoll,newPitch,newYaw);
} | [
"public",
"Pose",
"interpolate",
"(",
"Pose",
"p2",
",",
"double",
"ratio",
")",
"{",
"double",
"newX",
"=",
"lerp",
"(",
"getX",
"(",
")",
",",
"p2",
".",
"getX",
"(",
")",
",",
"ratio",
")",
";",
"double",
"newY",
"=",
"lerp",
"(",
"getY",
"(",
")",
",",
"p2",
".",
"getY",
"(",
")",
",",
"ratio",
")",
";",
"if",
"(",
"Double",
".",
"isNaN",
"(",
"this",
".",
"z",
")",
")",
"{",
"double",
"newTheta",
"=",
"lerpDegrees",
"(",
"getTheta",
"(",
")",
",",
"p2",
".",
"getTheta",
"(",
")",
",",
"ratio",
")",
";",
"return",
"new",
"Pose",
"(",
"newX",
",",
"newY",
",",
"newTheta",
")",
";",
"}",
"double",
"newZ",
"=",
"lerp",
"(",
"getZ",
"(",
")",
",",
"p2",
".",
"getZ",
"(",
")",
",",
"ratio",
")",
";",
"double",
"newRoll",
"=",
"lerpDegrees",
"(",
"getRoll",
"(",
")",
",",
"p2",
".",
"getRoll",
"(",
")",
",",
"ratio",
")",
";",
"double",
"newPitch",
"=",
"lerpDegrees",
"(",
"getPitch",
"(",
")",
",",
"p2",
".",
"getPitch",
"(",
")",
",",
"ratio",
")",
";",
"double",
"newYaw",
"=",
"lerpDegrees",
"(",
"getYaw",
"(",
")",
",",
"p2",
".",
"getYaw",
"(",
")",
",",
"ratio",
")",
";",
"return",
"new",
"Pose",
"(",
"newX",
",",
"newY",
",",
"newZ",
",",
"newRoll",
",",
"newPitch",
",",
"newYaw",
")",
";",
"}"
] | Computes the {@link Pose} between this {@link Pose} and a given {@link Pose} via bilinear interpolation.
@param p2 The second {@link Pose} used for interpolation.
@param ratio Parameter in [0,1] used for bilinear interpolation.
@return The {@link Pose} between this {@link Pose} and a given {@link Pose} via bilinear interpolation. | [
"Computes",
"the",
"{"
] | train | https://github.com/FedericoPecora/meta-csp-framework/blob/42aaef2e2b76d0f738427f0dd9653c4f62b40517/src/main/java/org/metacsp/multi/spatioTemporal/paths/Pose.java#L152-L164 |
padrig64/ValidationFramework | validationframework-swing/src/main/java/com/google/code/validationframework/swing/decoration/IconComponentDecoration.java | IconComponentDecoration.createToolTipDialogIfNeeded | private void createToolTipDialogIfNeeded() {
"""
Creates the dialog showing the tooltip if it is not created yet.
<p>
We do this only here to make sure that we have a parent and to make sure that we actually have a window
ancestor.
<p>
If we create the dialog before having a window ancestor, it will have no owner (see {@link
ToolTipDialog#ToolTipDialog(JComponent, AnchorLink)} and that will result in having the tooltip behind the
other windows of the application.
"""
// Not need to create the dialog if there is not text to show
if ((toolTipDialog == null) && (toolTipText != null) && !toolTipText.isEmpty()) {
toolTipDialog = new ToolTipDialog(decorationPainter, anchorLinkWithToolTip);
toolTipDialog.addMouseListener(toolTipVisibilityAdapter);
toolTipDialog.addMouseMotionListener(toolTipVisibilityAdapter);
toolTipDialog.addComponentListener(toolTipVisibilityAdapter);
}
// But if there is (already) a dialog, update it with the text
if (toolTipDialog != null) {
toolTipDialog.setText(toolTipText);
}
} | java | private void createToolTipDialogIfNeeded() {
// Not need to create the dialog if there is not text to show
if ((toolTipDialog == null) && (toolTipText != null) && !toolTipText.isEmpty()) {
toolTipDialog = new ToolTipDialog(decorationPainter, anchorLinkWithToolTip);
toolTipDialog.addMouseListener(toolTipVisibilityAdapter);
toolTipDialog.addMouseMotionListener(toolTipVisibilityAdapter);
toolTipDialog.addComponentListener(toolTipVisibilityAdapter);
}
// But if there is (already) a dialog, update it with the text
if (toolTipDialog != null) {
toolTipDialog.setText(toolTipText);
}
} | [
"private",
"void",
"createToolTipDialogIfNeeded",
"(",
")",
"{",
"// Not need to create the dialog if there is not text to show",
"if",
"(",
"(",
"toolTipDialog",
"==",
"null",
")",
"&&",
"(",
"toolTipText",
"!=",
"null",
")",
"&&",
"!",
"toolTipText",
".",
"isEmpty",
"(",
")",
")",
"{",
"toolTipDialog",
"=",
"new",
"ToolTipDialog",
"(",
"decorationPainter",
",",
"anchorLinkWithToolTip",
")",
";",
"toolTipDialog",
".",
"addMouseListener",
"(",
"toolTipVisibilityAdapter",
")",
";",
"toolTipDialog",
".",
"addMouseMotionListener",
"(",
"toolTipVisibilityAdapter",
")",
";",
"toolTipDialog",
".",
"addComponentListener",
"(",
"toolTipVisibilityAdapter",
")",
";",
"}",
"// But if there is (already) a dialog, update it with the text",
"if",
"(",
"toolTipDialog",
"!=",
"null",
")",
"{",
"toolTipDialog",
".",
"setText",
"(",
"toolTipText",
")",
";",
"}",
"}"
] | Creates the dialog showing the tooltip if it is not created yet.
<p>
We do this only here to make sure that we have a parent and to make sure that we actually have a window
ancestor.
<p>
If we create the dialog before having a window ancestor, it will have no owner (see {@link
ToolTipDialog#ToolTipDialog(JComponent, AnchorLink)} and that will result in having the tooltip behind the
other windows of the application. | [
"Creates",
"the",
"dialog",
"showing",
"the",
"tooltip",
"if",
"it",
"is",
"not",
"created",
"yet",
".",
"<p",
">",
"We",
"do",
"this",
"only",
"here",
"to",
"make",
"sure",
"that",
"we",
"have",
"a",
"parent",
"and",
"to",
"make",
"sure",
"that",
"we",
"actually",
"have",
"a",
"window",
"ancestor",
".",
"<p",
">",
"If",
"we",
"create",
"the",
"dialog",
"before",
"having",
"a",
"window",
"ancestor",
"it",
"will",
"have",
"no",
"owner",
"(",
"see",
"{"
] | train | https://github.com/padrig64/ValidationFramework/blob/2dd3c7b3403993db366d24a927645f467ccd1dda/validationframework-swing/src/main/java/com/google/code/validationframework/swing/decoration/IconComponentDecoration.java#L356-L369 |
mikepenz/Android-Iconics | library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java | IconicsDrawable.contourColorListRes | @NonNull
public IconicsDrawable contourColorListRes(@ColorRes int colorResId) {
"""
Set contour colors from color res.
@return The current IconicsDrawable for chaining.
"""
return contourColor(ContextCompat.getColorStateList(mContext, colorResId));
} | java | @NonNull
public IconicsDrawable contourColorListRes(@ColorRes int colorResId) {
return contourColor(ContextCompat.getColorStateList(mContext, colorResId));
} | [
"@",
"NonNull",
"public",
"IconicsDrawable",
"contourColorListRes",
"(",
"@",
"ColorRes",
"int",
"colorResId",
")",
"{",
"return",
"contourColor",
"(",
"ContextCompat",
".",
"getColorStateList",
"(",
"mContext",
",",
"colorResId",
")",
")",
";",
"}"
] | Set contour colors from color res.
@return The current IconicsDrawable for chaining. | [
"Set",
"contour",
"colors",
"from",
"color",
"res",
"."
] | train | https://github.com/mikepenz/Android-Iconics/blob/0b2c8f7d07b6d2715a417563c66311e7e1fcc7d8/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java#L812-L815 |
apereo/cas | core/cas-server-core-web-api/src/main/java/org/apereo/cas/services/web/view/AbstractCasView.java | AbstractCasView.getErrorDescriptionFrom | protected String getErrorDescriptionFrom(final Map<String, Object> model) {
"""
Gets error description from.
@param model the model
@return the error description from
"""
return model.get(CasViewConstants.MODEL_ATTRIBUTE_NAME_ERROR_DESCRIPTION).toString();
} | java | protected String getErrorDescriptionFrom(final Map<String, Object> model) {
return model.get(CasViewConstants.MODEL_ATTRIBUTE_NAME_ERROR_DESCRIPTION).toString();
} | [
"protected",
"String",
"getErrorDescriptionFrom",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"model",
")",
"{",
"return",
"model",
".",
"get",
"(",
"CasViewConstants",
".",
"MODEL_ATTRIBUTE_NAME_ERROR_DESCRIPTION",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Gets error description from.
@param model the model
@return the error description from | [
"Gets",
"error",
"description",
"from",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-web-api/src/main/java/org/apereo/cas/services/web/view/AbstractCasView.java#L96-L98 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/backend/MBeanServerHandler.java | MBeanServerHandler.initServerHandle | private void initServerHandle(Configuration pConfig, LogHandler pLogHandler, List<ServerDetector> pDetectors) {
"""
Initialize the server handle.
@param pConfig configuration passed through to the server detectors
@param pLogHandler used for putting out diagnostic messags
@param pDetectors all detectors known
"""
serverHandle = detectServers(pDetectors, pLogHandler);
if (serverHandle != null) {
serverHandle.postDetect(mBeanServerManager, pConfig, pLogHandler);
}
} | java | private void initServerHandle(Configuration pConfig, LogHandler pLogHandler, List<ServerDetector> pDetectors) {
serverHandle = detectServers(pDetectors, pLogHandler);
if (serverHandle != null) {
serverHandle.postDetect(mBeanServerManager, pConfig, pLogHandler);
}
} | [
"private",
"void",
"initServerHandle",
"(",
"Configuration",
"pConfig",
",",
"LogHandler",
"pLogHandler",
",",
"List",
"<",
"ServerDetector",
">",
"pDetectors",
")",
"{",
"serverHandle",
"=",
"detectServers",
"(",
"pDetectors",
",",
"pLogHandler",
")",
";",
"if",
"(",
"serverHandle",
"!=",
"null",
")",
"{",
"serverHandle",
".",
"postDetect",
"(",
"mBeanServerManager",
",",
"pConfig",
",",
"pLogHandler",
")",
";",
"}",
"}"
] | Initialize the server handle.
@param pConfig configuration passed through to the server detectors
@param pLogHandler used for putting out diagnostic messags
@param pDetectors all detectors known | [
"Initialize",
"the",
"server",
"handle",
"."
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/backend/MBeanServerHandler.java#L137-L142 |
netty/netty | codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java | HttpUtil.getContentLength | public static long getContentLength(HttpMessage message, long defaultValue) {
"""
Returns the length of the content or the specified default value if the message does not have the {@code
"Content-Length" header}. Please note that this value is not retrieved from {@link HttpContent#content()} but
from the {@code "Content-Length"} header, and thus they are independent from each other.
@param message the message
@param defaultValue the default value
@return the content length or the specified default value
@throws NumberFormatException if the {@code "Content-Length"} header does not parse as a long
"""
String value = message.headers().get(HttpHeaderNames.CONTENT_LENGTH);
if (value != null) {
return Long.parseLong(value);
}
// We know the content length if it's a Web Socket message even if
// Content-Length header is missing.
long webSocketContentLength = getWebSocketContentLength(message);
if (webSocketContentLength >= 0) {
return webSocketContentLength;
}
// Otherwise we don't.
return defaultValue;
} | java | public static long getContentLength(HttpMessage message, long defaultValue) {
String value = message.headers().get(HttpHeaderNames.CONTENT_LENGTH);
if (value != null) {
return Long.parseLong(value);
}
// We know the content length if it's a Web Socket message even if
// Content-Length header is missing.
long webSocketContentLength = getWebSocketContentLength(message);
if (webSocketContentLength >= 0) {
return webSocketContentLength;
}
// Otherwise we don't.
return defaultValue;
} | [
"public",
"static",
"long",
"getContentLength",
"(",
"HttpMessage",
"message",
",",
"long",
"defaultValue",
")",
"{",
"String",
"value",
"=",
"message",
".",
"headers",
"(",
")",
".",
"get",
"(",
"HttpHeaderNames",
".",
"CONTENT_LENGTH",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"return",
"Long",
".",
"parseLong",
"(",
"value",
")",
";",
"}",
"// We know the content length if it's a Web Socket message even if",
"// Content-Length header is missing.",
"long",
"webSocketContentLength",
"=",
"getWebSocketContentLength",
"(",
"message",
")",
";",
"if",
"(",
"webSocketContentLength",
">=",
"0",
")",
"{",
"return",
"webSocketContentLength",
";",
"}",
"// Otherwise we don't.",
"return",
"defaultValue",
";",
"}"
] | Returns the length of the content or the specified default value if the message does not have the {@code
"Content-Length" header}. Please note that this value is not retrieved from {@link HttpContent#content()} but
from the {@code "Content-Length"} header, and thus they are independent from each other.
@param message the message
@param defaultValue the default value
@return the content length or the specified default value
@throws NumberFormatException if the {@code "Content-Length"} header does not parse as a long | [
"Returns",
"the",
"length",
"of",
"the",
"content",
"or",
"the",
"specified",
"default",
"value",
"if",
"the",
"message",
"does",
"not",
"have",
"the",
"{",
"@code",
"Content",
"-",
"Length",
"header",
"}",
".",
"Please",
"note",
"that",
"this",
"value",
"is",
"not",
"retrieved",
"from",
"{",
"@link",
"HttpContent#content",
"()",
"}",
"but",
"from",
"the",
"{",
"@code",
"Content",
"-",
"Length",
"}",
"header",
"and",
"thus",
"they",
"are",
"independent",
"from",
"each",
"other",
"."
] | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec-http/src/main/java/io/netty/handler/codec/http/HttpUtil.java#L171-L186 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/util/ArrayUtil.java | ArrayUtil.readInt | public static int readInt(byte b[], int offset) {
"""
Unserializes an int from a byte array at a specific offset in big-endian order
@param b byte array from which to read an int value.
@param offset offset within byte array to start reading.
@return int read from byte array.
"""
int retValue;
retValue = ((int)b[offset++]) << 24;
retValue |= ((int)b[offset++] & 0xff) << 16;
retValue |= ((int)b[offset++] & 0xff) << 8;
retValue |= (int)b[offset] & 0xff;
return retValue;
} | java | public static int readInt(byte b[], int offset) {
int retValue;
retValue = ((int)b[offset++]) << 24;
retValue |= ((int)b[offset++] & 0xff) << 16;
retValue |= ((int)b[offset++] & 0xff) << 8;
retValue |= (int)b[offset] & 0xff;
return retValue;
} | [
"public",
"static",
"int",
"readInt",
"(",
"byte",
"b",
"[",
"]",
",",
"int",
"offset",
")",
"{",
"int",
"retValue",
";",
"retValue",
"=",
"(",
"(",
"int",
")",
"b",
"[",
"offset",
"++",
"]",
")",
"<<",
"24",
";",
"retValue",
"|=",
"(",
"(",
"int",
")",
"b",
"[",
"offset",
"++",
"]",
"&",
"0xff",
")",
"<<",
"16",
";",
"retValue",
"|=",
"(",
"(",
"int",
")",
"b",
"[",
"offset",
"++",
"]",
"&",
"0xff",
")",
"<<",
"8",
";",
"retValue",
"|=",
"(",
"int",
")",
"b",
"[",
"offset",
"]",
"&",
"0xff",
";",
"return",
"retValue",
";",
"}"
] | Unserializes an int from a byte array at a specific offset in big-endian order
@param b byte array from which to read an int value.
@param offset offset within byte array to start reading.
@return int read from byte array. | [
"Unserializes",
"an",
"int",
"from",
"a",
"byte",
"array",
"at",
"a",
"specific",
"offset",
"in",
"big",
"-",
"endian",
"order"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.common/src/com/ibm/ws/sib/mfp/util/ArrayUtil.java#L86-L95 |
FaritorKang/unmz-common-util | src/main/java/net/unmz/java/util/http/Img2Base64Utils.java | Img2Base64Utils.generateImage | public static boolean generateImage(String imgStr, String imgFilePath) {
"""
对字节数组字符串进行Base64解码并生成图片
@param imgStr 图片数据
@param imgFilePath 保存图片全路径地址
@return
"""
if (imgStr == null) //图像数据为空
return false;
try {
//Base64解码
byte[] b = Base64.decodeBase64(imgStr);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {//调整异常数据
b[i] += 256;
}
}
//生成jpeg图片
OutputStream out = new FileOutputStream(imgFilePath);
out.write(b);
out.flush();
out.close();
return true;
} catch (Exception e) {
return false;
}
} | java | public static boolean generateImage(String imgStr, String imgFilePath) {
if (imgStr == null) //图像数据为空
return false;
try {
//Base64解码
byte[] b = Base64.decodeBase64(imgStr);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {//调整异常数据
b[i] += 256;
}
}
//生成jpeg图片
OutputStream out = new FileOutputStream(imgFilePath);
out.write(b);
out.flush();
out.close();
return true;
} catch (Exception e) {
return false;
}
} | [
"public",
"static",
"boolean",
"generateImage",
"(",
"String",
"imgStr",
",",
"String",
"imgFilePath",
")",
"{",
"if",
"(",
"imgStr",
"==",
"null",
")",
"//图像数据为空",
"return",
"false",
";",
"try",
"{",
"//Base64解码",
"byte",
"[",
"]",
"b",
"=",
"Base64",
".",
"decodeBase64",
"(",
"imgStr",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"b",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"b",
"[",
"i",
"]",
"<",
"0",
")",
"{",
"//调整异常数据",
"b",
"[",
"i",
"]",
"+=",
"256",
";",
"}",
"}",
"//生成jpeg图片",
"OutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"imgFilePath",
")",
";",
"out",
".",
"write",
"(",
"b",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | 对字节数组字符串进行Base64解码并生成图片
@param imgStr 图片数据
@param imgFilePath 保存图片全路径地址
@return | [
"对字节数组字符串进行Base64解码并生成图片"
] | train | https://github.com/FaritorKang/unmz-common-util/blob/2912b8889b85ed910d536f85b24b6fa68035814a/src/main/java/net/unmz/java/util/http/Img2Base64Utils.java#L62-L83 |
BreizhBeans/ThriftMongoBridge | src/main/java/org/breizhbeans/thrift/tools/thriftmongobridge/TBSONDeserializer.java | TBSONDeserializer.partialDeserialize | public void partialDeserialize(TBase<?,?> base, DBObject dbObject, TFieldIdEnum... fieldIds) throws TException {
"""
Deserialize only a single Thrift object
from a byte record.
@param base The object to read into
@param dbObject The serialized object to read from
@param fieldIds The FieldId's to extract
@throws TException
"""
try {
protocol_.setDBOject(dbObject);
protocol_.setBaseObject( base );
protocol_.setFieldIdsFilter(base, fieldIds);
base.read(protocol_);
} finally {
protocol_.reset();
}
} | java | public void partialDeserialize(TBase<?,?> base, DBObject dbObject, TFieldIdEnum... fieldIds) throws TException {
try {
protocol_.setDBOject(dbObject);
protocol_.setBaseObject( base );
protocol_.setFieldIdsFilter(base, fieldIds);
base.read(protocol_);
} finally {
protocol_.reset();
}
} | [
"public",
"void",
"partialDeserialize",
"(",
"TBase",
"<",
"?",
",",
"?",
">",
"base",
",",
"DBObject",
"dbObject",
",",
"TFieldIdEnum",
"...",
"fieldIds",
")",
"throws",
"TException",
"{",
"try",
"{",
"protocol_",
".",
"setDBOject",
"(",
"dbObject",
")",
";",
"protocol_",
".",
"setBaseObject",
"(",
"base",
")",
";",
"protocol_",
".",
"setFieldIdsFilter",
"(",
"base",
",",
"fieldIds",
")",
";",
"base",
".",
"read",
"(",
"protocol_",
")",
";",
"}",
"finally",
"{",
"protocol_",
".",
"reset",
"(",
")",
";",
"}",
"}"
] | Deserialize only a single Thrift object
from a byte record.
@param base The object to read into
@param dbObject The serialized object to read from
@param fieldIds The FieldId's to extract
@throws TException | [
"Deserialize",
"only",
"a",
"single",
"Thrift",
"object",
"from",
"a",
"byte",
"record",
"."
] | train | https://github.com/BreizhBeans/ThriftMongoBridge/blob/0b86606601a818b6c2489f6920c3780beda3e8c8/src/main/java/org/breizhbeans/thrift/tools/thriftmongobridge/TBSONDeserializer.java#L62-L72 |
guardtime/ksi-java-sdk | ksi-service-ha/src/main/java/com/guardtime/ksi/service/ha/HAConfUtil.java | HAConfUtil.isSmaller | static boolean isSmaller(Long a, Long b) {
"""
Is value of b smaller than value of a.
@return True, if b is smaller than a. Always true, if value of a is null.
"""
return a == null || (b != null && b < a);
} | java | static boolean isSmaller(Long a, Long b) {
return a == null || (b != null && b < a);
} | [
"static",
"boolean",
"isSmaller",
"(",
"Long",
"a",
",",
"Long",
"b",
")",
"{",
"return",
"a",
"==",
"null",
"||",
"(",
"b",
"!=",
"null",
"&&",
"b",
"<",
"a",
")",
";",
"}"
] | Is value of b smaller than value of a.
@return True, if b is smaller than a. Always true, if value of a is null. | [
"Is",
"value",
"of",
"b",
"smaller",
"than",
"value",
"of",
"a",
"."
] | train | https://github.com/guardtime/ksi-java-sdk/blob/b2cd877050f0f392657c724452318d10a1002171/ksi-service-ha/src/main/java/com/guardtime/ksi/service/ha/HAConfUtil.java#L43-L45 |
OpenLiberty/open-liberty | dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/view/ViewDeclarationLanguageBase.java | ViewDeclarationLanguageBase.createView | public UIViewRoot createView(FacesContext context, String viewId) {
"""
Process the specification required algorithm that is generic to all PDL.
@param context
@param viewId
"""
checkNull(context, "context");
//checkNull(viewId, "viewId");
try
{
viewId = calculateViewId(context, viewId);
Application application = context.getApplication();
// Create a new UIViewRoot object instance using Application.createComponent(UIViewRoot.COMPONENT_TYPE).
UIViewRoot newViewRoot = (UIViewRoot) application.createComponent(
context, UIViewRoot.COMPONENT_TYPE, null);
UIViewRoot oldViewRoot = context.getViewRoot();
if (oldViewRoot == null)
{
// If not, this method must call calculateLocale() and calculateRenderKitId(), and store the results
// as the values of the locale and renderKitId, proeprties, respectively, of the newly created
// UIViewRoot.
ViewHandler handler = application.getViewHandler();
newViewRoot.setLocale(handler.calculateLocale(context));
newViewRoot.setRenderKitId(handler.calculateRenderKitId(context));
}
else
{
// If there is an existing UIViewRoot available on the FacesContext, this method must copy its locale
// and renderKitId to this new view root
newViewRoot.setLocale(oldViewRoot.getLocale());
newViewRoot.setRenderKitId(oldViewRoot.getRenderKitId());
}
// TODO: VALIDATE - The spec is silent on the following line, but I feel bad if I don't set it
newViewRoot.setViewId(viewId);
return newViewRoot;
}
catch (InvalidViewIdException e)
{
// If no viewId could be identified, or the viewId is exactly equal to the servlet mapping,
// send the response error code SC_NOT_FOUND with a suitable message to the client.
sendSourceNotFound(context, e.getMessage());
// TODO: VALIDATE - Spec is silent on the return value when an error was sent
return null;
}
} | java | public UIViewRoot createView(FacesContext context, String viewId)
{
checkNull(context, "context");
//checkNull(viewId, "viewId");
try
{
viewId = calculateViewId(context, viewId);
Application application = context.getApplication();
// Create a new UIViewRoot object instance using Application.createComponent(UIViewRoot.COMPONENT_TYPE).
UIViewRoot newViewRoot = (UIViewRoot) application.createComponent(
context, UIViewRoot.COMPONENT_TYPE, null);
UIViewRoot oldViewRoot = context.getViewRoot();
if (oldViewRoot == null)
{
// If not, this method must call calculateLocale() and calculateRenderKitId(), and store the results
// as the values of the locale and renderKitId, proeprties, respectively, of the newly created
// UIViewRoot.
ViewHandler handler = application.getViewHandler();
newViewRoot.setLocale(handler.calculateLocale(context));
newViewRoot.setRenderKitId(handler.calculateRenderKitId(context));
}
else
{
// If there is an existing UIViewRoot available on the FacesContext, this method must copy its locale
// and renderKitId to this new view root
newViewRoot.setLocale(oldViewRoot.getLocale());
newViewRoot.setRenderKitId(oldViewRoot.getRenderKitId());
}
// TODO: VALIDATE - The spec is silent on the following line, but I feel bad if I don't set it
newViewRoot.setViewId(viewId);
return newViewRoot;
}
catch (InvalidViewIdException e)
{
// If no viewId could be identified, or the viewId is exactly equal to the servlet mapping,
// send the response error code SC_NOT_FOUND with a suitable message to the client.
sendSourceNotFound(context, e.getMessage());
// TODO: VALIDATE - Spec is silent on the return value when an error was sent
return null;
}
} | [
"public",
"UIViewRoot",
"createView",
"(",
"FacesContext",
"context",
",",
"String",
"viewId",
")",
"{",
"checkNull",
"(",
"context",
",",
"\"context\"",
")",
";",
"//checkNull(viewId, \"viewId\");",
"try",
"{",
"viewId",
"=",
"calculateViewId",
"(",
"context",
",",
"viewId",
")",
";",
"Application",
"application",
"=",
"context",
".",
"getApplication",
"(",
")",
";",
"// Create a new UIViewRoot object instance using Application.createComponent(UIViewRoot.COMPONENT_TYPE).",
"UIViewRoot",
"newViewRoot",
"=",
"(",
"UIViewRoot",
")",
"application",
".",
"createComponent",
"(",
"context",
",",
"UIViewRoot",
".",
"COMPONENT_TYPE",
",",
"null",
")",
";",
"UIViewRoot",
"oldViewRoot",
"=",
"context",
".",
"getViewRoot",
"(",
")",
";",
"if",
"(",
"oldViewRoot",
"==",
"null",
")",
"{",
"// If not, this method must call calculateLocale() and calculateRenderKitId(), and store the results",
"// as the values of the locale and renderKitId, proeprties, respectively, of the newly created",
"// UIViewRoot.",
"ViewHandler",
"handler",
"=",
"application",
".",
"getViewHandler",
"(",
")",
";",
"newViewRoot",
".",
"setLocale",
"(",
"handler",
".",
"calculateLocale",
"(",
"context",
")",
")",
";",
"newViewRoot",
".",
"setRenderKitId",
"(",
"handler",
".",
"calculateRenderKitId",
"(",
"context",
")",
")",
";",
"}",
"else",
"{",
"// If there is an existing UIViewRoot available on the FacesContext, this method must copy its locale",
"// and renderKitId to this new view root",
"newViewRoot",
".",
"setLocale",
"(",
"oldViewRoot",
".",
"getLocale",
"(",
")",
")",
";",
"newViewRoot",
".",
"setRenderKitId",
"(",
"oldViewRoot",
".",
"getRenderKitId",
"(",
")",
")",
";",
"}",
"// TODO: VALIDATE - The spec is silent on the following line, but I feel bad if I don't set it",
"newViewRoot",
".",
"setViewId",
"(",
"viewId",
")",
";",
"return",
"newViewRoot",
";",
"}",
"catch",
"(",
"InvalidViewIdException",
"e",
")",
"{",
"// If no viewId could be identified, or the viewId is exactly equal to the servlet mapping, ",
"// send the response error code SC_NOT_FOUND with a suitable message to the client.",
"sendSourceNotFound",
"(",
"context",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"// TODO: VALIDATE - Spec is silent on the return value when an error was sent",
"return",
"null",
";",
"}",
"}"
] | Process the specification required algorithm that is generic to all PDL.
@param context
@param viewId | [
"Process",
"the",
"specification",
"required",
"algorithm",
"that",
"is",
"generic",
"to",
"all",
"PDL",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.jsf.2.2/src/org/apache/myfaces/shared/view/ViewDeclarationLanguageBase.java#L41-L87 |
davetcc/tcMenu | tcMenuJavaApi/src/main/java/com/thecoderscorner/menu/domain/AnalogMenuItem.java | AnalogMenuItem.newMenuState | @Override
public MenuState<Integer> newMenuState(Integer value, boolean changed, boolean active) {
"""
returns a new state object that represents the current value for the menu. Current values are
held separately to the items, see MenuTree
@param value the new value
@param changed if the value has changed
@param active if the menu item is active, can be used for your own purposes.
@return
"""
return new IntegerMenuState(changed, active, value);
} | java | @Override
public MenuState<Integer> newMenuState(Integer value, boolean changed, boolean active) {
return new IntegerMenuState(changed, active, value);
} | [
"@",
"Override",
"public",
"MenuState",
"<",
"Integer",
">",
"newMenuState",
"(",
"Integer",
"value",
",",
"boolean",
"changed",
",",
"boolean",
"active",
")",
"{",
"return",
"new",
"IntegerMenuState",
"(",
"changed",
",",
"active",
",",
"value",
")",
";",
"}"
] | returns a new state object that represents the current value for the menu. Current values are
held separately to the items, see MenuTree
@param value the new value
@param changed if the value has changed
@param active if the menu item is active, can be used for your own purposes.
@return | [
"returns",
"a",
"new",
"state",
"object",
"that",
"represents",
"the",
"current",
"value",
"for",
"the",
"menu",
".",
"Current",
"values",
"are",
"held",
"separately",
"to",
"the",
"items",
"see",
"MenuTree"
] | train | https://github.com/davetcc/tcMenu/blob/61546e4b982b25ceaff384073fe9ec1fff55e64a/tcMenuJavaApi/src/main/java/com/thecoderscorner/menu/domain/AnalogMenuItem.java#L85-L88 |
alkacon/opencms-core | src/org/opencms/jsp/CmsJspTagHeadIncludes.java | CmsJspTagHeadIncludes.getInlineData | protected static String getInlineData(I_CmsFormatterBean formatter, String type) {
"""
Gets the inline CSS/Javascrip for the given formatter bean.<p>
@param formatter the formatter bean
@param type the type (CSS or Javascript)
@return the inline data for the given formatter bean
"""
if (TYPE_CSS.equals(type)) {
return formatter.getInlineCss();
} else if (TYPE_JAVASCRIPT.equals(type)) {
return formatter.getInlineJavascript();
}
return null;
} | java | protected static String getInlineData(I_CmsFormatterBean formatter, String type) {
if (TYPE_CSS.equals(type)) {
return formatter.getInlineCss();
} else if (TYPE_JAVASCRIPT.equals(type)) {
return formatter.getInlineJavascript();
}
return null;
} | [
"protected",
"static",
"String",
"getInlineData",
"(",
"I_CmsFormatterBean",
"formatter",
",",
"String",
"type",
")",
"{",
"if",
"(",
"TYPE_CSS",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"formatter",
".",
"getInlineCss",
"(",
")",
";",
"}",
"else",
"if",
"(",
"TYPE_JAVASCRIPT",
".",
"equals",
"(",
"type",
")",
")",
"{",
"return",
"formatter",
".",
"getInlineJavascript",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Gets the inline CSS/Javascrip for the given formatter bean.<p>
@param formatter the formatter bean
@param type the type (CSS or Javascript)
@return the inline data for the given formatter bean | [
"Gets",
"the",
"inline",
"CSS",
"/",
"Javascrip",
"for",
"the",
"given",
"formatter",
"bean",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/jsp/CmsJspTagHeadIncludes.java#L172-L180 |
lucee/Lucee | core/src/main/java/lucee/commons/collection/HashMapPro.java | HashMapPro.put | @Override
public V put(K key, V value) {
"""
Associates the specified value with the specified key in this map. If the map previously
contained a mapping for the key, the old value is replaced.
@param key key with which the specified value is to be associated
@param value value to be associated with the specified key
@return the previous value associated with <tt>key</tt>, or <tt>null</tt> if there was no mapping
for <tt>key</tt>. (A <tt>null</tt> return can also indicate that the map previously
associated <tt>null</tt> with <tt>key</tt>.)
"""
if (key == null) return putForNullKey(value);
int hash = hash(key);
int i = indexFor(hash, table.length);
for (Entry<K, V> e = table[i]; e != null; e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || key.equals(k))) {
V oldValue = e.value;
e.value = value;
e.recordAccess(this);
return oldValue;
}
}
modCount++;
addEntry(hash, key, value, i);
return null;
} | java | @Override
public V put(K key, V value) {
if (key == null) return putForNullKey(value);
int hash = hash(key);
int i = indexFor(hash, table.length);
for (Entry<K, V> e = table[i]; e != null; e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || key.equals(k))) {
V oldValue = e.value;
e.value = value;
e.recordAccess(this);
return oldValue;
}
}
modCount++;
addEntry(hash, key, value, i);
return null;
} | [
"@",
"Override",
"public",
"V",
"put",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"return",
"putForNullKey",
"(",
"value",
")",
";",
"int",
"hash",
"=",
"hash",
"(",
"key",
")",
";",
"int",
"i",
"=",
"indexFor",
"(",
"hash",
",",
"table",
".",
"length",
")",
";",
"for",
"(",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
"=",
"table",
"[",
"i",
"]",
";",
"e",
"!=",
"null",
";",
"e",
"=",
"e",
".",
"next",
")",
"{",
"Object",
"k",
";",
"if",
"(",
"e",
".",
"hash",
"==",
"hash",
"&&",
"(",
"(",
"k",
"=",
"e",
".",
"key",
")",
"==",
"key",
"||",
"key",
".",
"equals",
"(",
"k",
")",
")",
")",
"{",
"V",
"oldValue",
"=",
"e",
".",
"value",
";",
"e",
".",
"value",
"=",
"value",
";",
"e",
".",
"recordAccess",
"(",
"this",
")",
";",
"return",
"oldValue",
";",
"}",
"}",
"modCount",
"++",
";",
"addEntry",
"(",
"hash",
",",
"key",
",",
"value",
",",
"i",
")",
";",
"return",
"null",
";",
"}"
] | Associates the specified value with the specified key in this map. If the map previously
contained a mapping for the key, the old value is replaced.
@param key key with which the specified value is to be associated
@param value value to be associated with the specified key
@return the previous value associated with <tt>key</tt>, or <tt>null</tt> if there was no mapping
for <tt>key</tt>. (A <tt>null</tt> return can also indicate that the map previously
associated <tt>null</tt> with <tt>key</tt>.) | [
"Associates",
"the",
"specified",
"value",
"with",
"the",
"specified",
"key",
"in",
"this",
"map",
".",
"If",
"the",
"map",
"previously",
"contained",
"a",
"mapping",
"for",
"the",
"key",
"the",
"old",
"value",
"is",
"replaced",
"."
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/commons/collection/HashMapPro.java#L460-L478 |
BlueBrain/bluima | modules/bluima_typesystem/src/main/java/ch/epfl/bbp/uima/types/DataTable.java | DataTable.setBody | public void setBody(int i, String v) {
"""
indexed setter for body - sets an indexed value - the body of the table that contains data
@generated
@param i index in the array to set
@param v value to set into the array
"""
if (DataTable_Type.featOkTst && ((DataTable_Type)jcasType).casFeat_body == null)
jcasType.jcas.throwFeatMissing("body", "ch.epfl.bbp.uima.types.DataTable");
jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((DataTable_Type)jcasType).casFeatCode_body), i);
jcasType.ll_cas.ll_setStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((DataTable_Type)jcasType).casFeatCode_body), i, v);} | java | public void setBody(int i, String v) {
if (DataTable_Type.featOkTst && ((DataTable_Type)jcasType).casFeat_body == null)
jcasType.jcas.throwFeatMissing("body", "ch.epfl.bbp.uima.types.DataTable");
jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((DataTable_Type)jcasType).casFeatCode_body), i);
jcasType.ll_cas.ll_setStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((DataTable_Type)jcasType).casFeatCode_body), i, v);} | [
"public",
"void",
"setBody",
"(",
"int",
"i",
",",
"String",
"v",
")",
"{",
"if",
"(",
"DataTable_Type",
".",
"featOkTst",
"&&",
"(",
"(",
"DataTable_Type",
")",
"jcasType",
")",
".",
"casFeat_body",
"==",
"null",
")",
"jcasType",
".",
"jcas",
".",
"throwFeatMissing",
"(",
"\"body\"",
",",
"\"ch.epfl.bbp.uima.types.DataTable\"",
")",
";",
"jcasType",
".",
"jcas",
".",
"checkArrayBounds",
"(",
"jcasType",
".",
"ll_cas",
".",
"ll_getRefValue",
"(",
"addr",
",",
"(",
"(",
"DataTable_Type",
")",
"jcasType",
")",
".",
"casFeatCode_body",
")",
",",
"i",
")",
";",
"jcasType",
".",
"ll_cas",
".",
"ll_setStringArrayValue",
"(",
"jcasType",
".",
"ll_cas",
".",
"ll_getRefValue",
"(",
"addr",
",",
"(",
"(",
"DataTable_Type",
")",
"jcasType",
")",
".",
"casFeatCode_body",
")",
",",
"i",
",",
"v",
")",
";",
"}"
] | indexed setter for body - sets an indexed value - the body of the table that contains data
@generated
@param i index in the array to set
@param v value to set into the array | [
"indexed",
"setter",
"for",
"body",
"-",
"sets",
"an",
"indexed",
"value",
"-",
"the",
"body",
"of",
"the",
"table",
"that",
"contains",
"data"
] | train | https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_typesystem/src/main/java/ch/epfl/bbp/uima/types/DataTable.java#L249-L253 |
sarl/sarl | main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java | SARLJvmModelInferrer.copyAndCleanDocumentationTo | protected boolean copyAndCleanDocumentationTo(JvmExecutable sourceOperation, JvmExecutable targetOperation) {
"""
Copy and clean the given documentation by removing any unnecessary <code>@param</code>.
@param sourceOperation the source for the documentation.
@param targetOperation the target for the documentation.
@return <code>true</code> if a documentation was added.
"""
assert sourceOperation != null;
assert targetOperation != null;
String comment = SARLJvmModelInferrer.this.typeBuilder.getDocumentation(sourceOperation);
if (Strings.isNullOrEmpty(comment)) {
return false;
}
comment = cleanDocumentation(comment,
Iterables.transform(sourceOperation.getParameters(), it -> it.getSimpleName()),
Iterables.transform(targetOperation.getParameters(), it -> it.getSimpleName()));
SARLJvmModelInferrer.this.typeBuilder.setDocumentation(targetOperation, comment);
return true;
} | java | protected boolean copyAndCleanDocumentationTo(JvmExecutable sourceOperation, JvmExecutable targetOperation) {
assert sourceOperation != null;
assert targetOperation != null;
String comment = SARLJvmModelInferrer.this.typeBuilder.getDocumentation(sourceOperation);
if (Strings.isNullOrEmpty(comment)) {
return false;
}
comment = cleanDocumentation(comment,
Iterables.transform(sourceOperation.getParameters(), it -> it.getSimpleName()),
Iterables.transform(targetOperation.getParameters(), it -> it.getSimpleName()));
SARLJvmModelInferrer.this.typeBuilder.setDocumentation(targetOperation, comment);
return true;
} | [
"protected",
"boolean",
"copyAndCleanDocumentationTo",
"(",
"JvmExecutable",
"sourceOperation",
",",
"JvmExecutable",
"targetOperation",
")",
"{",
"assert",
"sourceOperation",
"!=",
"null",
";",
"assert",
"targetOperation",
"!=",
"null",
";",
"String",
"comment",
"=",
"SARLJvmModelInferrer",
".",
"this",
".",
"typeBuilder",
".",
"getDocumentation",
"(",
"sourceOperation",
")",
";",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"comment",
")",
")",
"{",
"return",
"false",
";",
"}",
"comment",
"=",
"cleanDocumentation",
"(",
"comment",
",",
"Iterables",
".",
"transform",
"(",
"sourceOperation",
".",
"getParameters",
"(",
")",
",",
"it",
"->",
"it",
".",
"getSimpleName",
"(",
")",
")",
",",
"Iterables",
".",
"transform",
"(",
"targetOperation",
".",
"getParameters",
"(",
")",
",",
"it",
"->",
"it",
".",
"getSimpleName",
"(",
")",
")",
")",
";",
"SARLJvmModelInferrer",
".",
"this",
".",
"typeBuilder",
".",
"setDocumentation",
"(",
"targetOperation",
",",
"comment",
")",
";",
"return",
"true",
";",
"}"
] | Copy and clean the given documentation by removing any unnecessary <code>@param</code>.
@param sourceOperation the source for the documentation.
@param targetOperation the target for the documentation.
@return <code>true</code> if a documentation was added. | [
"Copy",
"and",
"clean",
"the",
"given",
"documentation",
"by",
"removing",
"any",
"unnecessary",
"<code",
">",
"@param<",
"/",
"code",
">",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src/io/sarl/lang/jvmmodel/SARLJvmModelInferrer.java#L3353-L3368 |
k3po/k3po | driver/src/main/java/org/kaazing/k3po/driver/internal/netty/channel/Channels.java | Channels.shutdownOutput | public static void shutdownOutput(ChannelHandlerContext ctx, ChannelFuture future) {
"""
Sends a {@code "shutdownOutput"} request to the
{@link ChannelDownstreamHandler} which is placed in the closest
downstream from the handler associated with the specified
{@link ChannelHandlerContext}.
@param ctx the context
@param future the future which will be notified when the shutdownOutput
operation is done
"""
ctx.sendDownstream(
new DownstreamShutdownOutputEvent(ctx.getChannel(), future));
} | java | public static void shutdownOutput(ChannelHandlerContext ctx, ChannelFuture future) {
ctx.sendDownstream(
new DownstreamShutdownOutputEvent(ctx.getChannel(), future));
} | [
"public",
"static",
"void",
"shutdownOutput",
"(",
"ChannelHandlerContext",
"ctx",
",",
"ChannelFuture",
"future",
")",
"{",
"ctx",
".",
"sendDownstream",
"(",
"new",
"DownstreamShutdownOutputEvent",
"(",
"ctx",
".",
"getChannel",
"(",
")",
",",
"future",
")",
")",
";",
"}"
] | Sends a {@code "shutdownOutput"} request to the
{@link ChannelDownstreamHandler} which is placed in the closest
downstream from the handler associated with the specified
{@link ChannelHandlerContext}.
@param ctx the context
@param future the future which will be notified when the shutdownOutput
operation is done | [
"Sends",
"a",
"{",
"@code",
"shutdownOutput",
"}",
"request",
"to",
"the",
"{",
"@link",
"ChannelDownstreamHandler",
"}",
"which",
"is",
"placed",
"in",
"the",
"closest",
"downstream",
"from",
"the",
"handler",
"associated",
"with",
"the",
"specified",
"{",
"@link",
"ChannelHandlerContext",
"}",
"."
] | train | https://github.com/k3po/k3po/blob/3ca4fd31ab4a397893aa640c62ada0e485c8bbd4/driver/src/main/java/org/kaazing/k3po/driver/internal/netty/channel/Channels.java#L142-L145 |
ops4j/org.ops4j.pax.exam2 | core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/war/ZipBuilder.java | ZipBuilder.addDirectory | private void addDirectory(File root, File directory, String targetPath, ZipOutputStream zos) throws IOException {
"""
Recursively adds the contents of the given directory and all subdirectories to the given ZIP
output stream.
@param root
an ancestor of {@code directory}, used to determine the relative path within the
archive
@param directory
current directory to be added
@param zos
ZIP output stream
@throws IOException
"""
String prefix = targetPath;
if (!prefix.isEmpty() && !prefix.endsWith("/")) {
prefix += "/";
}
// directory entries are required, or else bundle classpath may be
// broken
if (!directory.equals(root)) {
String path = normalizePath(root, directory);
ZipEntry jarEntry = new ZipEntry(prefix + path + "/");
jarOutputStream.putNextEntry(jarEntry);
}
File[] children = directory.listFiles();
// loop through dirList, and zip the files
for (File child : children) {
if (child.isDirectory()) {
addDirectory(root, child, prefix, jarOutputStream);
}
else {
addFile(root, child, prefix, jarOutputStream);
}
}
} | java | private void addDirectory(File root, File directory, String targetPath, ZipOutputStream zos) throws IOException {
String prefix = targetPath;
if (!prefix.isEmpty() && !prefix.endsWith("/")) {
prefix += "/";
}
// directory entries are required, or else bundle classpath may be
// broken
if (!directory.equals(root)) {
String path = normalizePath(root, directory);
ZipEntry jarEntry = new ZipEntry(prefix + path + "/");
jarOutputStream.putNextEntry(jarEntry);
}
File[] children = directory.listFiles();
// loop through dirList, and zip the files
for (File child : children) {
if (child.isDirectory()) {
addDirectory(root, child, prefix, jarOutputStream);
}
else {
addFile(root, child, prefix, jarOutputStream);
}
}
} | [
"private",
"void",
"addDirectory",
"(",
"File",
"root",
",",
"File",
"directory",
",",
"String",
"targetPath",
",",
"ZipOutputStream",
"zos",
")",
"throws",
"IOException",
"{",
"String",
"prefix",
"=",
"targetPath",
";",
"if",
"(",
"!",
"prefix",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"prefix",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"prefix",
"+=",
"\"/\"",
";",
"}",
"// directory entries are required, or else bundle classpath may be",
"// broken",
"if",
"(",
"!",
"directory",
".",
"equals",
"(",
"root",
")",
")",
"{",
"String",
"path",
"=",
"normalizePath",
"(",
"root",
",",
"directory",
")",
";",
"ZipEntry",
"jarEntry",
"=",
"new",
"ZipEntry",
"(",
"prefix",
"+",
"path",
"+",
"\"/\"",
")",
";",
"jarOutputStream",
".",
"putNextEntry",
"(",
"jarEntry",
")",
";",
"}",
"File",
"[",
"]",
"children",
"=",
"directory",
".",
"listFiles",
"(",
")",
";",
"// loop through dirList, and zip the files",
"for",
"(",
"File",
"child",
":",
"children",
")",
"{",
"if",
"(",
"child",
".",
"isDirectory",
"(",
")",
")",
"{",
"addDirectory",
"(",
"root",
",",
"child",
",",
"prefix",
",",
"jarOutputStream",
")",
";",
"}",
"else",
"{",
"addFile",
"(",
"root",
",",
"child",
",",
"prefix",
",",
"jarOutputStream",
")",
";",
"}",
"}",
"}"
] | Recursively adds the contents of the given directory and all subdirectories to the given ZIP
output stream.
@param root
an ancestor of {@code directory}, used to determine the relative path within the
archive
@param directory
current directory to be added
@param zos
ZIP output stream
@throws IOException | [
"Recursively",
"adds",
"the",
"contents",
"of",
"the",
"given",
"directory",
"and",
"all",
"subdirectories",
"to",
"the",
"given",
"ZIP",
"output",
"stream",
"."
] | train | https://github.com/ops4j/org.ops4j.pax.exam2/blob/7f83796cbbb857123d8fc7fe817a7637218d5d77/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/war/ZipBuilder.java#L141-L163 |
apache/groovy | src/main/groovy/groovy/util/FactoryBuilderSupport.java | FactoryBuilderSupport.setNodeAttributes | protected void setNodeAttributes(Object node, Map attributes) {
"""
Maps attributes key/values to properties on node.
@param node the object from the node
@param attributes the attributes to be set
"""
// set the properties
//noinspection unchecked
for (Map.Entry entry : (Set<Map.Entry>) attributes.entrySet()) {
String property = entry.getKey().toString();
Object value = entry.getValue();
InvokerHelper.setProperty(node, property, value);
}
} | java | protected void setNodeAttributes(Object node, Map attributes) {
// set the properties
//noinspection unchecked
for (Map.Entry entry : (Set<Map.Entry>) attributes.entrySet()) {
String property = entry.getKey().toString();
Object value = entry.getValue();
InvokerHelper.setProperty(node, property, value);
}
} | [
"protected",
"void",
"setNodeAttributes",
"(",
"Object",
"node",
",",
"Map",
"attributes",
")",
"{",
"// set the properties",
"//noinspection unchecked",
"for",
"(",
"Map",
".",
"Entry",
"entry",
":",
"(",
"Set",
"<",
"Map",
".",
"Entry",
">",
")",
"attributes",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"property",
"=",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
";",
"Object",
"value",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"InvokerHelper",
".",
"setProperty",
"(",
"node",
",",
"property",
",",
"value",
")",
";",
"}",
"}"
] | Maps attributes key/values to properties on node.
@param node the object from the node
@param attributes the attributes to be set | [
"Maps",
"attributes",
"key",
"/",
"values",
"to",
"properties",
"on",
"node",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L1098-L1106 |
Terracotta-OSS/offheap-store | src/main/java/org/terracotta/offheapstore/paging/UpfrontAllocatingPageSource.java | UpfrontAllocatingPageSource.addAllocationThreshold | public synchronized Runnable addAllocationThreshold(ThresholdDirection direction, long threshold, Runnable action) {
"""
Adds an allocation threshold action.
<p>
There can be only a single action associated with each unique direction
and threshold combination. If an action is already associated with the
supplied combination then the action is replaced by the new action and the
old action is returned.
<p>
Actions are fired on passing through the supplied threshold and are called
synchronously with the triggering allocation. This means care must be taken
to avoid mutating any map that uses this page source from within the action
otherwise deadlocks may result. Exceptions thrown by the action will be
caught and logged by the page source and will not be propagated on the
allocating thread.
@param direction new actions direction
@param threshold new actions threshold level
@param action fired on breaching the threshold
@return the replaced action or {@code null} if no action was present.
"""
switch (direction) {
case RISING:
return risingThresholds.put(threshold, action);
case FALLING:
return fallingThresholds.put(threshold, action);
}
throw new AssertionError();
} | java | public synchronized Runnable addAllocationThreshold(ThresholdDirection direction, long threshold, Runnable action) {
switch (direction) {
case RISING:
return risingThresholds.put(threshold, action);
case FALLING:
return fallingThresholds.put(threshold, action);
}
throw new AssertionError();
} | [
"public",
"synchronized",
"Runnable",
"addAllocationThreshold",
"(",
"ThresholdDirection",
"direction",
",",
"long",
"threshold",
",",
"Runnable",
"action",
")",
"{",
"switch",
"(",
"direction",
")",
"{",
"case",
"RISING",
":",
"return",
"risingThresholds",
".",
"put",
"(",
"threshold",
",",
"action",
")",
";",
"case",
"FALLING",
":",
"return",
"fallingThresholds",
".",
"put",
"(",
"threshold",
",",
"action",
")",
";",
"}",
"throw",
"new",
"AssertionError",
"(",
")",
";",
"}"
] | Adds an allocation threshold action.
<p>
There can be only a single action associated with each unique direction
and threshold combination. If an action is already associated with the
supplied combination then the action is replaced by the new action and the
old action is returned.
<p>
Actions are fired on passing through the supplied threshold and are called
synchronously with the triggering allocation. This means care must be taken
to avoid mutating any map that uses this page source from within the action
otherwise deadlocks may result. Exceptions thrown by the action will be
caught and logged by the page source and will not be propagated on the
allocating thread.
@param direction new actions direction
@param threshold new actions threshold level
@param action fired on breaching the threshold
@return the replaced action or {@code null} if no action was present. | [
"Adds",
"an",
"allocation",
"threshold",
"action",
".",
"<p",
">",
"There",
"can",
"be",
"only",
"a",
"single",
"action",
"associated",
"with",
"each",
"unique",
"direction",
"and",
"threshold",
"combination",
".",
"If",
"an",
"action",
"is",
"already",
"associated",
"with",
"the",
"supplied",
"combination",
"then",
"the",
"action",
"is",
"replaced",
"by",
"the",
"new",
"action",
"and",
"the",
"old",
"action",
"is",
"returned",
".",
"<p",
">",
"Actions",
"are",
"fired",
"on",
"passing",
"through",
"the",
"supplied",
"threshold",
"and",
"are",
"called",
"synchronously",
"with",
"the",
"triggering",
"allocation",
".",
"This",
"means",
"care",
"must",
"be",
"taken",
"to",
"avoid",
"mutating",
"any",
"map",
"that",
"uses",
"this",
"page",
"source",
"from",
"within",
"the",
"action",
"otherwise",
"deadlocks",
"may",
"result",
".",
"Exceptions",
"thrown",
"by",
"the",
"action",
"will",
"be",
"caught",
"and",
"logged",
"by",
"the",
"page",
"source",
"and",
"will",
"not",
"be",
"propagated",
"on",
"the",
"allocating",
"thread",
"."
] | train | https://github.com/Terracotta-OSS/offheap-store/blob/600486cddb33c0247025c0cb69eff289eb6d7d93/src/main/java/org/terracotta/offheapstore/paging/UpfrontAllocatingPageSource.java#L443-L451 |
meertensinstituut/mtas | src/main/java/mtas/solr/handler/component/util/MtasSolrCollectionResult.java | MtasSolrCollectionResult.setPost | public void setPost(long now, SimpleOrderedMap<Object> status)
throws IOException {
"""
Sets the post.
@param now the now
@param status the status
@throws IOException Signals that an I/O exception has occurred.
"""
if (action.equals(ComponentCollection.ACTION_POST)) {
this.now = now;
this.status = status;
} else {
throw new IOException("not allowed with action '" + action + "'");
}
} | java | public void setPost(long now, SimpleOrderedMap<Object> status)
throws IOException {
if (action.equals(ComponentCollection.ACTION_POST)) {
this.now = now;
this.status = status;
} else {
throw new IOException("not allowed with action '" + action + "'");
}
} | [
"public",
"void",
"setPost",
"(",
"long",
"now",
",",
"SimpleOrderedMap",
"<",
"Object",
">",
"status",
")",
"throws",
"IOException",
"{",
"if",
"(",
"action",
".",
"equals",
"(",
"ComponentCollection",
".",
"ACTION_POST",
")",
")",
"{",
"this",
".",
"now",
"=",
"now",
";",
"this",
".",
"status",
"=",
"status",
";",
"}",
"else",
"{",
"throw",
"new",
"IOException",
"(",
"\"not allowed with action '\"",
"+",
"action",
"+",
"\"'\"",
")",
";",
"}",
"}"
] | Sets the post.
@param now the now
@param status the status
@throws IOException Signals that an I/O exception has occurred. | [
"Sets",
"the",
"post",
"."
] | train | https://github.com/meertensinstituut/mtas/blob/f02ae730848616bd88b553efa7f9eddc32818e64/src/main/java/mtas/solr/handler/component/util/MtasSolrCollectionResult.java#L147-L155 |
google/error-prone-javac | src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java | HtmlDocWriter.getDocLink | public DocLink getDocLink(SectionName sectionName, String where) {
"""
Get the link.
@param sectionName The section name combined with where to which the link
will be created.
@param where The fragment combined with sectionName to which the link
will be created.
@return a DocLink object for the hyper link
"""
return DocLink.fragment(sectionName.getName() + getName(where));
} | java | public DocLink getDocLink(SectionName sectionName, String where) {
return DocLink.fragment(sectionName.getName() + getName(where));
} | [
"public",
"DocLink",
"getDocLink",
"(",
"SectionName",
"sectionName",
",",
"String",
"where",
")",
"{",
"return",
"DocLink",
".",
"fragment",
"(",
"sectionName",
".",
"getName",
"(",
")",
"+",
"getName",
"(",
"where",
")",
")",
";",
"}"
] | Get the link.
@param sectionName The section name combined with where to which the link
will be created.
@param where The fragment combined with sectionName to which the link
will be created.
@return a DocLink object for the hyper link | [
"Get",
"the",
"link",
"."
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java#L155-L157 |
smartsheet-platform/smartsheet-java-sdk | src/main/java/com/smartsheet/api/internal/SheetResourcesImpl.java | SheetResourcesImpl.sortSheet | public Sheet sortSheet(long sheetId, SortSpecifier sortSpecifier, Integer level) throws SmartsheetException {
"""
Sort a sheet according to the sort criteria.
It mirrors to the following Smartsheet REST API method: POST /sheet/{sheetId}/sort
Exceptions:
- IllegalArgumentException : if any argument is null
- InvalidRequestException : if there is any problem with the REST API request
- AuthorizationException : if there is any problem with the REST API authorization(access token)
- ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
- SmartsheetRestException : if there is any other REST API related error occurred during the operation
- SmartsheetException : if there is any other error occurred during the operation
@param sheetId the sheet id
@param sortSpecifier the sort criteria
@param level compatibility level
@return the update request object
@throws SmartsheetException the smartsheet exception
"""
Util.throwIfNull(sortSpecifier);
String path = "sheets/" + sheetId + "/sort";
if (level != null) {
path += "?level=" + level;
}
HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.POST);
ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
this.smartsheet.getJsonSerializer().serialize(sortSpecifier, objectBytesStream);
HttpEntity entity = new HttpEntity();
entity.setContentType("application/json");
entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
entity.setContentLength(objectBytesStream.size());
request.setEntity(entity);
Sheet obj = null;
try {
HttpResponse response = this.smartsheet.getHttpClient().request(request);
switch (response.getStatusCode()) {
case 200: {
InputStream inputStream = response.getEntity().getContent();
try {
obj = this.smartsheet.getJsonSerializer().deserialize(Sheet.class, inputStream);
} catch (IOException e) {
throw new SmartsheetException(e);
}
break;
}
default:
handleError(response);
}
} finally {
smartsheet.getHttpClient().releaseConnection();
}
return obj;
} | java | public Sheet sortSheet(long sheetId, SortSpecifier sortSpecifier, Integer level) throws SmartsheetException {
Util.throwIfNull(sortSpecifier);
String path = "sheets/" + sheetId + "/sort";
if (level != null) {
path += "?level=" + level;
}
HttpRequest request = createHttpRequest(smartsheet.getBaseURI().resolve(path), HttpMethod.POST);
ByteArrayOutputStream objectBytesStream = new ByteArrayOutputStream();
this.smartsheet.getJsonSerializer().serialize(sortSpecifier, objectBytesStream);
HttpEntity entity = new HttpEntity();
entity.setContentType("application/json");
entity.setContent(new ByteArrayInputStream(objectBytesStream.toByteArray()));
entity.setContentLength(objectBytesStream.size());
request.setEntity(entity);
Sheet obj = null;
try {
HttpResponse response = this.smartsheet.getHttpClient().request(request);
switch (response.getStatusCode()) {
case 200: {
InputStream inputStream = response.getEntity().getContent();
try {
obj = this.smartsheet.getJsonSerializer().deserialize(Sheet.class, inputStream);
} catch (IOException e) {
throw new SmartsheetException(e);
}
break;
}
default:
handleError(response);
}
} finally {
smartsheet.getHttpClient().releaseConnection();
}
return obj;
} | [
"public",
"Sheet",
"sortSheet",
"(",
"long",
"sheetId",
",",
"SortSpecifier",
"sortSpecifier",
",",
"Integer",
"level",
")",
"throws",
"SmartsheetException",
"{",
"Util",
".",
"throwIfNull",
"(",
"sortSpecifier",
")",
";",
"String",
"path",
"=",
"\"sheets/\"",
"+",
"sheetId",
"+",
"\"/sort\"",
";",
"if",
"(",
"level",
"!=",
"null",
")",
"{",
"path",
"+=",
"\"?level=\"",
"+",
"level",
";",
"}",
"HttpRequest",
"request",
"=",
"createHttpRequest",
"(",
"smartsheet",
".",
"getBaseURI",
"(",
")",
".",
"resolve",
"(",
"path",
")",
",",
"HttpMethod",
".",
"POST",
")",
";",
"ByteArrayOutputStream",
"objectBytesStream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"this",
".",
"smartsheet",
".",
"getJsonSerializer",
"(",
")",
".",
"serialize",
"(",
"sortSpecifier",
",",
"objectBytesStream",
")",
";",
"HttpEntity",
"entity",
"=",
"new",
"HttpEntity",
"(",
")",
";",
"entity",
".",
"setContentType",
"(",
"\"application/json\"",
")",
";",
"entity",
".",
"setContent",
"(",
"new",
"ByteArrayInputStream",
"(",
"objectBytesStream",
".",
"toByteArray",
"(",
")",
")",
")",
";",
"entity",
".",
"setContentLength",
"(",
"objectBytesStream",
".",
"size",
"(",
")",
")",
";",
"request",
".",
"setEntity",
"(",
"entity",
")",
";",
"Sheet",
"obj",
"=",
"null",
";",
"try",
"{",
"HttpResponse",
"response",
"=",
"this",
".",
"smartsheet",
".",
"getHttpClient",
"(",
")",
".",
"request",
"(",
"request",
")",
";",
"switch",
"(",
"response",
".",
"getStatusCode",
"(",
")",
")",
"{",
"case",
"200",
":",
"{",
"InputStream",
"inputStream",
"=",
"response",
".",
"getEntity",
"(",
")",
".",
"getContent",
"(",
")",
";",
"try",
"{",
"obj",
"=",
"this",
".",
"smartsheet",
".",
"getJsonSerializer",
"(",
")",
".",
"deserialize",
"(",
"Sheet",
".",
"class",
",",
"inputStream",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"SmartsheetException",
"(",
"e",
")",
";",
"}",
"break",
";",
"}",
"default",
":",
"handleError",
"(",
"response",
")",
";",
"}",
"}",
"finally",
"{",
"smartsheet",
".",
"getHttpClient",
"(",
")",
".",
"releaseConnection",
"(",
")",
";",
"}",
"return",
"obj",
";",
"}"
] | Sort a sheet according to the sort criteria.
It mirrors to the following Smartsheet REST API method: POST /sheet/{sheetId}/sort
Exceptions:
- IllegalArgumentException : if any argument is null
- InvalidRequestException : if there is any problem with the REST API request
- AuthorizationException : if there is any problem with the REST API authorization(access token)
- ServiceUnavailableException : if the REST API service is not available (possibly due to rate limiting)
- SmartsheetRestException : if there is any other REST API related error occurred during the operation
- SmartsheetException : if there is any other error occurred during the operation
@param sheetId the sheet id
@param sortSpecifier the sort criteria
@param level compatibility level
@return the update request object
@throws SmartsheetException the smartsheet exception | [
"Sort",
"a",
"sheet",
"according",
"to",
"the",
"sort",
"criteria",
"."
] | train | https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/f60e264412076271f83b65889ef9b891fad83df8/src/main/java/com/smartsheet/api/internal/SheetResourcesImpl.java#L1161-L1200 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java | AbstractBundleLinkRenderer.performGlobalBundleLinksRendering | protected void performGlobalBundleLinksRendering(BundleRendererContext ctx, Writer out, boolean debugOn)
throws IOException {
"""
Performs the global bundle rendering
@param ctx
the context
@param out
the writer
@param debugOn
the flag indicating if we are in debug mode or not
@throws IOException
if an IO exception occurs
"""
ResourceBundlePathsIterator resourceBundleIterator = bundler.getGlobalResourceBundlePaths(getDebugMode(debugOn),
new ConditionalCommentRenderer(out), ctx.getVariants());
renderBundleLinks(resourceBundleIterator, ctx, debugOn, out);
} | java | protected void performGlobalBundleLinksRendering(BundleRendererContext ctx, Writer out, boolean debugOn)
throws IOException {
ResourceBundlePathsIterator resourceBundleIterator = bundler.getGlobalResourceBundlePaths(getDebugMode(debugOn),
new ConditionalCommentRenderer(out), ctx.getVariants());
renderBundleLinks(resourceBundleIterator, ctx, debugOn, out);
} | [
"protected",
"void",
"performGlobalBundleLinksRendering",
"(",
"BundleRendererContext",
"ctx",
",",
"Writer",
"out",
",",
"boolean",
"debugOn",
")",
"throws",
"IOException",
"{",
"ResourceBundlePathsIterator",
"resourceBundleIterator",
"=",
"bundler",
".",
"getGlobalResourceBundlePaths",
"(",
"getDebugMode",
"(",
"debugOn",
")",
",",
"new",
"ConditionalCommentRenderer",
"(",
"out",
")",
",",
"ctx",
".",
"getVariants",
"(",
")",
")",
";",
"renderBundleLinks",
"(",
"resourceBundleIterator",
",",
"ctx",
",",
"debugOn",
",",
"out",
")",
";",
"}"
] | Performs the global bundle rendering
@param ctx
the context
@param out
the writer
@param debugOn
the flag indicating if we are in debug mode or not
@throws IOException
if an IO exception occurs | [
"Performs",
"the",
"global",
"bundle",
"rendering"
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/renderer/AbstractBundleLinkRenderer.java#L221-L227 |
NoraUi/NoraUi | src/main/java/com/github/noraui/application/steps/FileSteps.java | FileSteps.removefileInDownloadDirectory | @Conditioned
@Lorsque("Je supprime le fichier '(.*)' dans repertoire des téléchargements[\\.|\\?]")
@Given("I remove '(.*)' file in download directory[\\.|\\?]")
public void removefileInDownloadDirectory(String file, List<GherkinStepCondition> conditions) throws IOException {
"""
Remove a file in the default downloaded files folder
@param file
The name of the file removed.
@param conditions
List of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
@throws IOException
"""
FileUtils.forceDelete(new File(System.getProperty(USER_DIR) + File.separator + DOWNLOADED_FILES_FOLDER + File.separator + file));
} | java | @Conditioned
@Lorsque("Je supprime le fichier '(.*)' dans repertoire des téléchargements[\\.|\\?]")
@Given("I remove '(.*)' file in download directory[\\.|\\?]")
public void removefileInDownloadDirectory(String file, List<GherkinStepCondition> conditions) throws IOException {
FileUtils.forceDelete(new File(System.getProperty(USER_DIR) + File.separator + DOWNLOADED_FILES_FOLDER + File.separator + file));
} | [
"@",
"Conditioned",
"@",
"Lorsque",
"(",
"\"Je supprime le fichier '(.*)' dans repertoire des téléchargements[\\\\.|\\\\?]\")",
"",
"@",
"Given",
"(",
"\"I remove '(.*)' file in download directory[\\\\.|\\\\?]\"",
")",
"public",
"void",
"removefileInDownloadDirectory",
"(",
"String",
"file",
",",
"List",
"<",
"GherkinStepCondition",
">",
"conditions",
")",
"throws",
"IOException",
"{",
"FileUtils",
".",
"forceDelete",
"(",
"new",
"File",
"(",
"System",
".",
"getProperty",
"(",
"USER_DIR",
")",
"+",
"File",
".",
"separator",
"+",
"DOWNLOADED_FILES_FOLDER",
"+",
"File",
".",
"separator",
"+",
"file",
")",
")",
";",
"}"
] | Remove a file in the default downloaded files folder
@param file
The name of the file removed.
@param conditions
List of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
@throws IOException | [
"Remove",
"a",
"file",
"in",
"the",
"default",
"downloaded",
"files",
"folder"
] | train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/application/steps/FileSteps.java#L74-L79 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_ovhPabx_serviceName_tts_POST | public void billingAccount_ovhPabx_serviceName_tts_POST(String billingAccount, String serviceName, String text, OvhOvhPabxTtsVoiceEnum voice) throws IOException {
"""
Create a new text to speech
REST: POST /telephony/{billingAccount}/ovhPabx/{serviceName}/tts
@param text [required]
@param voice [required]
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
"""
String qPath = "/telephony/{billingAccount}/ovhPabx/{serviceName}/tts";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "text", text);
addBody(o, "voice", voice);
exec(qPath, "POST", sb.toString(), o);
} | java | public void billingAccount_ovhPabx_serviceName_tts_POST(String billingAccount, String serviceName, String text, OvhOvhPabxTtsVoiceEnum voice) throws IOException {
String qPath = "/telephony/{billingAccount}/ovhPabx/{serviceName}/tts";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "text", text);
addBody(o, "voice", voice);
exec(qPath, "POST", sb.toString(), o);
} | [
"public",
"void",
"billingAccount_ovhPabx_serviceName_tts_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"String",
"text",
",",
"OvhOvhPabxTtsVoiceEnum",
"voice",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/ovhPabx/{serviceName}/tts\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
",",
"serviceName",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"text\"",
",",
"text",
")",
";",
"addBody",
"(",
"o",
",",
"\"voice\"",
",",
"voice",
")",
";",
"exec",
"(",
"qPath",
",",
"\"POST\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"}"
] | Create a new text to speech
REST: POST /telephony/{billingAccount}/ovhPabx/{serviceName}/tts
@param text [required]
@param voice [required]
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] | [
"Create",
"a",
"new",
"text",
"to",
"speech"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L7680-L7687 |
Impetus/Kundera | src/jpa-engine/core/src/main/java/com/impetus/kundera/query/QueryImpl.java | QueryImpl.populateUsingElasticSearch | private List populateUsingElasticSearch(Client client, EntityMetadata m) {
"""
Populate using elastic search.
@param client
the client
@param EntityMetadata
the m
@return Result list by fetching from ES
"""
Map<String, Object> searchFilter = client.getIndexManager().search(kunderaMetadata, kunderaQuery,
persistenceDelegeator, m, this.firstResult, this.maxResult);
Object[] primaryKeys = ((Map<String, Object>) searchFilter.get(Constants.PRIMARY_KEYS)).values().toArray(
new Object[] {});
Map<String, Object> aggregations = (Map<String, Object>) searchFilter.get(Constants.AGGREGATIONS);
Iterable<Expression> resultOrderIterable = (Iterable<Expression>) searchFilter
.get(Constants.SELECT_EXPRESSION_ORDER);
List<Object> results = new ArrayList<Object>();
if (!kunderaQuery.isAggregated())
{
results.addAll(findUsingLucene(m, client, primaryKeys));
}
else
{
if (KunderaQueryUtils.hasGroupBy(kunderaQuery.getJpqlExpression()))
{
populateGroupByResponse(aggregations, resultOrderIterable, results, client, m);
}
else
{
Iterator<Expression> resultOrder = resultOrderIterable.iterator();
while (resultOrder.hasNext())
{
Expression expression = (Expression) resultOrder.next();
if (AggregateFunction.class.isAssignableFrom(expression.getClass()))
{
if (aggregations.get(expression.toParsedText()) != null)
{
results.add(aggregations.get(expression.toParsedText()));
}
}
else
{
results.addAll(findUsingLucene(m, client, new Object[] { primaryKeys[0] }));
}
}
}
}
return results;
} | java | private List populateUsingElasticSearch(Client client, EntityMetadata m)
{
Map<String, Object> searchFilter = client.getIndexManager().search(kunderaMetadata, kunderaQuery,
persistenceDelegeator, m, this.firstResult, this.maxResult);
Object[] primaryKeys = ((Map<String, Object>) searchFilter.get(Constants.PRIMARY_KEYS)).values().toArray(
new Object[] {});
Map<String, Object> aggregations = (Map<String, Object>) searchFilter.get(Constants.AGGREGATIONS);
Iterable<Expression> resultOrderIterable = (Iterable<Expression>) searchFilter
.get(Constants.SELECT_EXPRESSION_ORDER);
List<Object> results = new ArrayList<Object>();
if (!kunderaQuery.isAggregated())
{
results.addAll(findUsingLucene(m, client, primaryKeys));
}
else
{
if (KunderaQueryUtils.hasGroupBy(kunderaQuery.getJpqlExpression()))
{
populateGroupByResponse(aggregations, resultOrderIterable, results, client, m);
}
else
{
Iterator<Expression> resultOrder = resultOrderIterable.iterator();
while (resultOrder.hasNext())
{
Expression expression = (Expression) resultOrder.next();
if (AggregateFunction.class.isAssignableFrom(expression.getClass()))
{
if (aggregations.get(expression.toParsedText()) != null)
{
results.add(aggregations.get(expression.toParsedText()));
}
}
else
{
results.addAll(findUsingLucene(m, client, new Object[] { primaryKeys[0] }));
}
}
}
}
return results;
} | [
"private",
"List",
"populateUsingElasticSearch",
"(",
"Client",
"client",
",",
"EntityMetadata",
"m",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"searchFilter",
"=",
"client",
".",
"getIndexManager",
"(",
")",
".",
"search",
"(",
"kunderaMetadata",
",",
"kunderaQuery",
",",
"persistenceDelegeator",
",",
"m",
",",
"this",
".",
"firstResult",
",",
"this",
".",
"maxResult",
")",
";",
"Object",
"[",
"]",
"primaryKeys",
"=",
"(",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"searchFilter",
".",
"get",
"(",
"Constants",
".",
"PRIMARY_KEYS",
")",
")",
".",
"values",
"(",
")",
".",
"toArray",
"(",
"new",
"Object",
"[",
"]",
"{",
"}",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"aggregations",
"=",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"searchFilter",
".",
"get",
"(",
"Constants",
".",
"AGGREGATIONS",
")",
";",
"Iterable",
"<",
"Expression",
">",
"resultOrderIterable",
"=",
"(",
"Iterable",
"<",
"Expression",
">",
")",
"searchFilter",
".",
"get",
"(",
"Constants",
".",
"SELECT_EXPRESSION_ORDER",
")",
";",
"List",
"<",
"Object",
">",
"results",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"if",
"(",
"!",
"kunderaQuery",
".",
"isAggregated",
"(",
")",
")",
"{",
"results",
".",
"addAll",
"(",
"findUsingLucene",
"(",
"m",
",",
"client",
",",
"primaryKeys",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"KunderaQueryUtils",
".",
"hasGroupBy",
"(",
"kunderaQuery",
".",
"getJpqlExpression",
"(",
")",
")",
")",
"{",
"populateGroupByResponse",
"(",
"aggregations",
",",
"resultOrderIterable",
",",
"results",
",",
"client",
",",
"m",
")",
";",
"}",
"else",
"{",
"Iterator",
"<",
"Expression",
">",
"resultOrder",
"=",
"resultOrderIterable",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"resultOrder",
".",
"hasNext",
"(",
")",
")",
"{",
"Expression",
"expression",
"=",
"(",
"Expression",
")",
"resultOrder",
".",
"next",
"(",
")",
";",
"if",
"(",
"AggregateFunction",
".",
"class",
".",
"isAssignableFrom",
"(",
"expression",
".",
"getClass",
"(",
")",
")",
")",
"{",
"if",
"(",
"aggregations",
".",
"get",
"(",
"expression",
".",
"toParsedText",
"(",
")",
")",
"!=",
"null",
")",
"{",
"results",
".",
"add",
"(",
"aggregations",
".",
"get",
"(",
"expression",
".",
"toParsedText",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"results",
".",
"addAll",
"(",
"findUsingLucene",
"(",
"m",
",",
"client",
",",
"new",
"Object",
"[",
"]",
"{",
"primaryKeys",
"[",
"0",
"]",
"}",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"results",
";",
"}"
] | Populate using elastic search.
@param client
the client
@param EntityMetadata
the m
@return Result list by fetching from ES | [
"Populate",
"using",
"elastic",
"search",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/query/QueryImpl.java#L461-L506 |
marcos-garcia/smartsantanderdataanalysis | ssjsonformatterinterceptor/src/main/java/com/marcosgarciacasado/ssjsonformatterinterceptor/MeasureExtractor.java | MeasureExtractor.fillMeasures | public void fillMeasures(String measure, JSONObject jsonContent, Pattern pattern, HashMap<String,Double> i) {
"""
Extracts a pattern from a measure value located in a JSONObject and stores it in a HashMap whether finds it.
@author Marcos García Casado
"""
String tem = (String)jsonContent.get(measure);
if(tem != null){
Matcher tM = pattern.matcher(tem);
if(tM.find() && !tM.group(1).isEmpty()){
try{
i.put(measure, Double.valueOf(tM.group(1)));
}catch(NumberFormatException e){
e.printStackTrace();
}
}
}
} | java | public void fillMeasures(String measure, JSONObject jsonContent, Pattern pattern, HashMap<String,Double> i){
String tem = (String)jsonContent.get(measure);
if(tem != null){
Matcher tM = pattern.matcher(tem);
if(tM.find() && !tM.group(1).isEmpty()){
try{
i.put(measure, Double.valueOf(tM.group(1)));
}catch(NumberFormatException e){
e.printStackTrace();
}
}
}
} | [
"public",
"void",
"fillMeasures",
"(",
"String",
"measure",
",",
"JSONObject",
"jsonContent",
",",
"Pattern",
"pattern",
",",
"HashMap",
"<",
"String",
",",
"Double",
">",
"i",
")",
"{",
"String",
"tem",
"=",
"(",
"String",
")",
"jsonContent",
".",
"get",
"(",
"measure",
")",
";",
"if",
"(",
"tem",
"!=",
"null",
")",
"{",
"Matcher",
"tM",
"=",
"pattern",
".",
"matcher",
"(",
"tem",
")",
";",
"if",
"(",
"tM",
".",
"find",
"(",
")",
"&&",
"!",
"tM",
".",
"group",
"(",
"1",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"try",
"{",
"i",
".",
"put",
"(",
"measure",
",",
"Double",
".",
"valueOf",
"(",
"tM",
".",
"group",
"(",
"1",
")",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Extracts a pattern from a measure value located in a JSONObject and stores it in a HashMap whether finds it.
@author Marcos García Casado | [
"Extracts",
"a",
"pattern",
"from",
"a",
"measure",
"value",
"located",
"in",
"a",
"JSONObject",
"and",
"stores",
"it",
"in",
"a",
"HashMap",
"whether",
"finds",
"it",
"."
] | train | https://github.com/marcos-garcia/smartsantanderdataanalysis/blob/dc259618887886e294c839a905b18994171d21ef/ssjsonformatterinterceptor/src/main/java/com/marcosgarciacasado/ssjsonformatterinterceptor/MeasureExtractor.java#L72-L84 |
cdapio/tigon | tigon-flow/src/main/java/co/cask/tigon/internal/app/runtime/distributed/ProgramRunnableResourceReporter.java | ProgramRunnableResourceReporter.getMetricContext | private String getMetricContext(Program program, TwillContext context) {
"""
Returns the metric context. A metric context is of the form {flowY}.{flowletZ}.
"""
String metricContext = program.getName();
metricContext += "." + context.getSpecification().getName() + "." + context.getInstanceId();
return metricContext;
} | java | private String getMetricContext(Program program, TwillContext context) {
String metricContext = program.getName();
metricContext += "." + context.getSpecification().getName() + "." + context.getInstanceId();
return metricContext;
} | [
"private",
"String",
"getMetricContext",
"(",
"Program",
"program",
",",
"TwillContext",
"context",
")",
"{",
"String",
"metricContext",
"=",
"program",
".",
"getName",
"(",
")",
";",
"metricContext",
"+=",
"\".\"",
"+",
"context",
".",
"getSpecification",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".\"",
"+",
"context",
".",
"getInstanceId",
"(",
")",
";",
"return",
"metricContext",
";",
"}"
] | Returns the metric context. A metric context is of the form {flowY}.{flowletZ}. | [
"Returns",
"the",
"metric",
"context",
".",
"A",
"metric",
"context",
"is",
"of",
"the",
"form",
"{",
"flowY",
"}",
".",
"{",
"flowletZ",
"}",
"."
] | train | https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-flow/src/main/java/co/cask/tigon/internal/app/runtime/distributed/ProgramRunnableResourceReporter.java#L49-L53 |
cchantep/acolyte | jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java | ParameterMetaData.Double | public static ParameterDef Double(final double d) {
"""
Double constructor.
@param d the double precision value for the parameter
@return Parameter definition for given double precision value
"""
final BigDecimal bd = new BigDecimal(String.format(Locale.US, "%f", d)).
stripTrailingZeros();
return Scaled(Types.DOUBLE, bd.scale());
} | java | public static ParameterDef Double(final double d) {
final BigDecimal bd = new BigDecimal(String.format(Locale.US, "%f", d)).
stripTrailingZeros();
return Scaled(Types.DOUBLE, bd.scale());
} | [
"public",
"static",
"ParameterDef",
"Double",
"(",
"final",
"double",
"d",
")",
"{",
"final",
"BigDecimal",
"bd",
"=",
"new",
"BigDecimal",
"(",
"String",
".",
"format",
"(",
"Locale",
".",
"US",
",",
"\"%f\"",
",",
"d",
")",
")",
".",
"stripTrailingZeros",
"(",
")",
";",
"return",
"Scaled",
"(",
"Types",
".",
"DOUBLE",
",",
"bd",
".",
"scale",
"(",
")",
")",
";",
"}"
] | Double constructor.
@param d the double precision value for the parameter
@return Parameter definition for given double precision value | [
"Double",
"constructor",
"."
] | train | https://github.com/cchantep/acolyte/blob/a383dff20fadc08ec9306f2f1f24b2a7e0047449/jdbc-driver/src/main/java/acolyte/jdbc/ParameterMetaData.java#L290-L295 |
unbescape/unbescape | src/main/java/org/unbescape/xml/XmlEscape.java | XmlEscape.escapeXml10 | public static void escapeXml10(final String text, final Writer writer, final XmlEscapeType type, final XmlEscapeLevel level)
throws IOException {
"""
<p>
Perform a (configurable) XML 1.0 <strong>escape</strong> operation on a <tt>String</tt> input,
writing results to a <tt>Writer</tt>.
</p>
<p>
This method will perform an escape operation according to the specified
{@link org.unbescape.xml.XmlEscapeType} and {@link org.unbescape.xml.XmlEscapeLevel}
argument values.
</p>
<p>
All other <tt>String</tt>/<tt>Writer</tt>-based <tt>escapeXml10*(...)</tt> methods call this one with preconfigured
<tt>type</tt> and <tt>level</tt> values.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>String</tt> to be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@param type the type of escape operation to be performed, see {@link org.unbescape.xml.XmlEscapeType}.
@param level the escape level to be applied, see {@link org.unbescape.xml.XmlEscapeLevel}.
@throws IOException if an input/output exception occurs
@since 1.1.2
"""
escapeXml(text, writer, XmlEscapeSymbols.XML10_SYMBOLS, type, level);
} | java | public static void escapeXml10(final String text, final Writer writer, final XmlEscapeType type, final XmlEscapeLevel level)
throws IOException {
escapeXml(text, writer, XmlEscapeSymbols.XML10_SYMBOLS, type, level);
} | [
"public",
"static",
"void",
"escapeXml10",
"(",
"final",
"String",
"text",
",",
"final",
"Writer",
"writer",
",",
"final",
"XmlEscapeType",
"type",
",",
"final",
"XmlEscapeLevel",
"level",
")",
"throws",
"IOException",
"{",
"escapeXml",
"(",
"text",
",",
"writer",
",",
"XmlEscapeSymbols",
".",
"XML10_SYMBOLS",
",",
"type",
",",
"level",
")",
";",
"}"
] | <p>
Perform a (configurable) XML 1.0 <strong>escape</strong> operation on a <tt>String</tt> input,
writing results to a <tt>Writer</tt>.
</p>
<p>
This method will perform an escape operation according to the specified
{@link org.unbescape.xml.XmlEscapeType} and {@link org.unbescape.xml.XmlEscapeLevel}
argument values.
</p>
<p>
All other <tt>String</tt>/<tt>Writer</tt>-based <tt>escapeXml10*(...)</tt> methods call this one with preconfigured
<tt>type</tt> and <tt>level</tt> values.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>String</tt> to be escaped.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@param type the type of escape operation to be performed, see {@link org.unbescape.xml.XmlEscapeType}.
@param level the escape level to be applied, see {@link org.unbescape.xml.XmlEscapeLevel}.
@throws IOException if an input/output exception occurs
@since 1.1.2 | [
"<p",
">",
"Perform",
"a",
"(",
"configurable",
")",
"XML",
"1",
".",
"0",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"String<",
"/",
"tt",
">",
"input",
"writing",
"results",
"to",
"a",
"<tt",
">",
"Writer<",
"/",
"tt",
">",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"will",
"perform",
"an",
"escape",
"operation",
"according",
"to",
"the",
"specified",
"{",
"@link",
"org",
".",
"unbescape",
".",
"xml",
".",
"XmlEscapeType",
"}",
"and",
"{",
"@link",
"org",
".",
"unbescape",
".",
"xml",
".",
"XmlEscapeLevel",
"}",
"argument",
"values",
".",
"<",
"/",
"p",
">",
"<p",
">",
"All",
"other",
"<tt",
">",
"String<",
"/",
"tt",
">",
"/",
"<tt",
">",
"Writer<",
"/",
"tt",
">",
"-",
"based",
"<tt",
">",
"escapeXml10",
"*",
"(",
"...",
")",
"<",
"/",
"tt",
">",
"methods",
"call",
"this",
"one",
"with",
"preconfigured",
"<tt",
">",
"type<",
"/",
"tt",
">",
"and",
"<tt",
">",
"level<",
"/",
"tt",
">",
"values",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"method",
"is",
"<strong",
">",
"thread",
"-",
"safe<",
"/",
"strong",
">",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/xml/XmlEscape.java#L1055-L1058 |
mygreen/excel-cellformatter | src/main/java/com/github/mygreen/cellformatter/lang/MessageResolver.java | MessageResolver.getMessage | public String getMessage(final MSLocale locale, final String key, final String defaultValue) {
"""
ロケールとキーを指定してメッセージを取得する。
@param locale ロケール
@param key メッセージキー
@param defaultValue
@return 該当するロケールのメッセージが見つからない場合は、引数で指定した'defaultValue'の値を返す。
"""
String message = getMessage(locale, key);
return message == null ? defaultValue : message;
} | java | public String getMessage(final MSLocale locale, final String key, final String defaultValue) {
String message = getMessage(locale, key);
return message == null ? defaultValue : message;
} | [
"public",
"String",
"getMessage",
"(",
"final",
"MSLocale",
"locale",
",",
"final",
"String",
"key",
",",
"final",
"String",
"defaultValue",
")",
"{",
"String",
"message",
"=",
"getMessage",
"(",
"locale",
",",
"key",
")",
";",
"return",
"message",
"==",
"null",
"?",
"defaultValue",
":",
"message",
";",
"}"
] | ロケールとキーを指定してメッセージを取得する。
@param locale ロケール
@param key メッセージキー
@param defaultValue
@return 該当するロケールのメッセージが見つからない場合は、引数で指定した'defaultValue'の値を返す。 | [
"ロケールとキーを指定してメッセージを取得する。"
] | train | https://github.com/mygreen/excel-cellformatter/blob/e802af273d49889500591e03799c9262cbf29185/src/main/java/com/github/mygreen/cellformatter/lang/MessageResolver.java#L300-L303 |
io7m/ieee754b16 | com.io7m.ieee754b16.core/src/main/java/com/io7m/ieee754b16/Binary16.java | Binary16.unpackFloat | public static float unpackFloat(
final char k) {
"""
<p>
Convert a packed {@code binary16} value {@code k} to a
single-precision floating point value.
</p>
<p>
The function returns:
</p>
<ul>
<li>{@code NaN} iff {@code isNaN(k)}</li>
<li>{@link Double#POSITIVE_INFINITY} iff
<code>k == {@link #POSITIVE_INFINITY}</code></li>
<li>{@link Double#NEGATIVE_INFINITY} iff
<code>k == {@link #NEGATIVE_INFINITY}</code></li>
<li>{@code -0.0} iff <code>k == {@link #NEGATIVE_ZERO}</code></li>
<li>{@code 0.0} iff <code>k == {@link #POSITIVE_ZERO}</code></li>
<li>{@code (-1.0 * n) * (2 ^ e) * 1.s}, for the decoded sign
{@code n} of {@code k}, the decoded exponent {@code e} of
{@code k}, and the decoded significand {@code s} of
{@code k}.</li>
</ul>
@param k A packed {@code binary16} value
@return A floating point value
@see #packDouble(double)
"""
final int f16_mantissa = (int) k & MASK_MANTISSA;
final int f16_exponent = (int) k & MASK_EXPONENT;
final int f16_sign = (int) k & MASK_SIGN;
/*
* If the exponent is zero, and the mantissa is zero, the number is zero.
* The sign is preserved.
*/
if (f16_exponent == 0 && f16_mantissa == 0) {
return unpackFloatZero(f16_sign);
}
/*
* If the exponent indicates that the number is infinite or NaN,
* then return a similar infinite or NaN.
*/
if (f16_exponent == MASK_EXPONENT) {
return unpackFloatInfiniteNaN(f16_mantissa, f16_sign);
}
/*
* If the exponent is nonzero, then the number is normal in 16 bits and can
* therefore be translated to a normal value in 32 bits.
*/
if (f16_exponent != 0) {
return unpackFloatNormal(f16_mantissa, f16_exponent, f16_sign);
}
/*
* If the exponent is zero, and the mantissa not zero, the number is
* a 16-bit subnormal but can be transformed to a 32-bit normal.
*/
return unpackFloatSubnormal(f16_mantissa, f16_sign);
} | java | public static float unpackFloat(
final char k)
{
final int f16_mantissa = (int) k & MASK_MANTISSA;
final int f16_exponent = (int) k & MASK_EXPONENT;
final int f16_sign = (int) k & MASK_SIGN;
/*
* If the exponent is zero, and the mantissa is zero, the number is zero.
* The sign is preserved.
*/
if (f16_exponent == 0 && f16_mantissa == 0) {
return unpackFloatZero(f16_sign);
}
/*
* If the exponent indicates that the number is infinite or NaN,
* then return a similar infinite or NaN.
*/
if (f16_exponent == MASK_EXPONENT) {
return unpackFloatInfiniteNaN(f16_mantissa, f16_sign);
}
/*
* If the exponent is nonzero, then the number is normal in 16 bits and can
* therefore be translated to a normal value in 32 bits.
*/
if (f16_exponent != 0) {
return unpackFloatNormal(f16_mantissa, f16_exponent, f16_sign);
}
/*
* If the exponent is zero, and the mantissa not zero, the number is
* a 16-bit subnormal but can be transformed to a 32-bit normal.
*/
return unpackFloatSubnormal(f16_mantissa, f16_sign);
} | [
"public",
"static",
"float",
"unpackFloat",
"(",
"final",
"char",
"k",
")",
"{",
"final",
"int",
"f16_mantissa",
"=",
"(",
"int",
")",
"k",
"&",
"MASK_MANTISSA",
";",
"final",
"int",
"f16_exponent",
"=",
"(",
"int",
")",
"k",
"&",
"MASK_EXPONENT",
";",
"final",
"int",
"f16_sign",
"=",
"(",
"int",
")",
"k",
"&",
"MASK_SIGN",
";",
"/*\n * If the exponent is zero, and the mantissa is zero, the number is zero.\n * The sign is preserved.\n */",
"if",
"(",
"f16_exponent",
"==",
"0",
"&&",
"f16_mantissa",
"==",
"0",
")",
"{",
"return",
"unpackFloatZero",
"(",
"f16_sign",
")",
";",
"}",
"/*\n * If the exponent indicates that the number is infinite or NaN,\n * then return a similar infinite or NaN.\n */",
"if",
"(",
"f16_exponent",
"==",
"MASK_EXPONENT",
")",
"{",
"return",
"unpackFloatInfiniteNaN",
"(",
"f16_mantissa",
",",
"f16_sign",
")",
";",
"}",
"/*\n * If the exponent is nonzero, then the number is normal in 16 bits and can\n * therefore be translated to a normal value in 32 bits.\n */",
"if",
"(",
"f16_exponent",
"!=",
"0",
")",
"{",
"return",
"unpackFloatNormal",
"(",
"f16_mantissa",
",",
"f16_exponent",
",",
"f16_sign",
")",
";",
"}",
"/*\n * If the exponent is zero, and the mantissa not zero, the number is\n * a 16-bit subnormal but can be transformed to a 32-bit normal.\n */",
"return",
"unpackFloatSubnormal",
"(",
"f16_mantissa",
",",
"f16_sign",
")",
";",
"}"
] | <p>
Convert a packed {@code binary16} value {@code k} to a
single-precision floating point value.
</p>
<p>
The function returns:
</p>
<ul>
<li>{@code NaN} iff {@code isNaN(k)}</li>
<li>{@link Double#POSITIVE_INFINITY} iff
<code>k == {@link #POSITIVE_INFINITY}</code></li>
<li>{@link Double#NEGATIVE_INFINITY} iff
<code>k == {@link #NEGATIVE_INFINITY}</code></li>
<li>{@code -0.0} iff <code>k == {@link #NEGATIVE_ZERO}</code></li>
<li>{@code 0.0} iff <code>k == {@link #POSITIVE_ZERO}</code></li>
<li>{@code (-1.0 * n) * (2 ^ e) * 1.s}, for the decoded sign
{@code n} of {@code k}, the decoded exponent {@code e} of
{@code k}, and the decoded significand {@code s} of
{@code k}.</li>
</ul>
@param k A packed {@code binary16} value
@return A floating point value
@see #packDouble(double) | [
"<p",
">",
"Convert",
"a",
"packed",
"{",
"@code",
"binary16",
"}",
"value",
"{",
"@code",
"k",
"}",
"to",
"a",
"single",
"-",
"precision",
"floating",
"point",
"value",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"function",
"returns",
":",
"<",
"/",
"p",
">",
"<ul",
">",
"<li",
">",
"{",
"@code",
"NaN",
"}",
"iff",
"{",
"@code",
"isNaN",
"(",
"k",
")",
"}",
"<",
"/",
"li",
">",
"<li",
">",
"{",
"@link",
"Double#POSITIVE_INFINITY",
"}",
"iff",
"<code",
">",
"k",
"==",
"{",
"@link",
"#POSITIVE_INFINITY",
"}",
"<",
"/",
"code",
">",
"<",
"/",
"li",
">",
"<li",
">",
"{",
"@link",
"Double#NEGATIVE_INFINITY",
"}",
"iff",
"<code",
">",
"k",
"==",
"{",
"@link",
"#NEGATIVE_INFINITY",
"}",
"<",
"/",
"code",
">",
"<",
"/",
"li",
">",
"<li",
">",
"{",
"@code",
"-",
"0",
".",
"0",
"}",
"iff",
"<code",
">",
"k",
"==",
"{",
"@link",
"#NEGATIVE_ZERO",
"}",
"<",
"/",
"code",
">",
"<",
"/",
"li",
">",
"<li",
">",
"{",
"@code",
"0",
".",
"0",
"}",
"iff",
"<code",
">",
"k",
"==",
"{",
"@link",
"#POSITIVE_ZERO",
"}",
"<",
"/",
"code",
">",
"<",
"/",
"li",
">",
"<li",
">",
"{",
"@code",
"(",
"-",
"1",
".",
"0",
"*",
"n",
")",
"*",
"(",
"2",
"^",
"e",
")",
"*",
"1",
".",
"s",
"}",
"for",
"the",
"decoded",
"sign",
"{",
"@code",
"n",
"}",
"of",
"{",
"@code",
"k",
"}",
"the",
"decoded",
"exponent",
"{",
"@code",
"e",
"}",
"of",
"{",
"@code",
"k",
"}",
"and",
"the",
"decoded",
"significand",
"{",
"@code",
"s",
"}",
"of",
"{",
"@code",
"k",
"}",
".",
"<",
"/",
"li",
">",
"<",
"/",
"ul",
">"
] | train | https://github.com/io7m/ieee754b16/blob/39474026e6d069695adf5a14c5c326aadb7b4cf4/com.io7m.ieee754b16.core/src/main/java/com/io7m/ieee754b16/Binary16.java#L231-L271 |
rey5137/material | material/src/main/java/com/rey/material/widget/EditText.java | EditText.onSelectionChanged | protected void onSelectionChanged(int selStart, int selEnd) {
"""
This method is called when the selection has changed, in case any
subclasses would like to know.
@param selStart The new selection start location.
@param selEnd The new selection end location.
"""
if(mInputView == null)
return;
if(mInputView instanceof InternalEditText)
((InternalEditText)mInputView).superOnSelectionChanged(selStart, selEnd);
else if(mInputView instanceof InternalAutoCompleteTextView)
((InternalAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);
else
((InternalMultiAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);
if(mOnSelectionChangedListener != null)
mOnSelectionChangedListener.onSelectionChanged(this, selStart, selEnd);
} | java | protected void onSelectionChanged(int selStart, int selEnd) {
if(mInputView == null)
return;
if(mInputView instanceof InternalEditText)
((InternalEditText)mInputView).superOnSelectionChanged(selStart, selEnd);
else if(mInputView instanceof InternalAutoCompleteTextView)
((InternalAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);
else
((InternalMultiAutoCompleteTextView)mInputView).superOnSelectionChanged(selStart, selEnd);
if(mOnSelectionChangedListener != null)
mOnSelectionChangedListener.onSelectionChanged(this, selStart, selEnd);
} | [
"protected",
"void",
"onSelectionChanged",
"(",
"int",
"selStart",
",",
"int",
"selEnd",
")",
"{",
"if",
"(",
"mInputView",
"==",
"null",
")",
"return",
";",
"if",
"(",
"mInputView",
"instanceof",
"InternalEditText",
")",
"(",
"(",
"InternalEditText",
")",
"mInputView",
")",
".",
"superOnSelectionChanged",
"(",
"selStart",
",",
"selEnd",
")",
";",
"else",
"if",
"(",
"mInputView",
"instanceof",
"InternalAutoCompleteTextView",
")",
"(",
"(",
"InternalAutoCompleteTextView",
")",
"mInputView",
")",
".",
"superOnSelectionChanged",
"(",
"selStart",
",",
"selEnd",
")",
";",
"else",
"(",
"(",
"InternalMultiAutoCompleteTextView",
")",
"mInputView",
")",
".",
"superOnSelectionChanged",
"(",
"selStart",
",",
"selEnd",
")",
";",
"if",
"(",
"mOnSelectionChangedListener",
"!=",
"null",
")",
"mOnSelectionChangedListener",
".",
"onSelectionChanged",
"(",
"this",
",",
"selStart",
",",
"selEnd",
")",
";",
"}"
] | This method is called when the selection has changed, in case any
subclasses would like to know.
@param selStart The new selection start location.
@param selEnd The new selection end location. | [
"This",
"method",
"is",
"called",
"when",
"the",
"selection",
"has",
"changed",
"in",
"case",
"any",
"subclasses",
"would",
"like",
"to",
"know",
"."
] | train | https://github.com/rey5137/material/blob/1bbcac2686a0023ef7720d3fe455bb116d115af8/material/src/main/java/com/rey/material/widget/EditText.java#L2609-L2622 |
paypal/SeLion | common/src/main/java/com/paypal/selion/platform/web/PageFactory.java | PageFactory.getPage | public static Page getPage(InputStream in) throws IOException {
"""
Creates a instance of a {@link Page}.
@param in
input stream of the Yaml File
@return an instance of the Page object
@throws IOException
if unable to read from the {@link InputStream}. Does not close the {@link InputStream} when this
occurs.
"""
Constructor constructor = new Constructor(Page.class);
TypeDescription typeDesc = new TypeDescription(Page.class);
typeDesc.putListPropertyType("pageValidators", String.class);
typeDesc.putListPropertyType("pageLoadingValidators", String.class);
typeDesc.putMapPropertyType("elements", String.class, GUIElement.class);
constructor.addTypeDescription(typeDesc);
Yaml yamlFile = new Yaml(constructor);
Page page = (Page) yamlFile.load(new BufferedReader(new InputStreamReader(in, "UTF-8")));
try {
in.close();
} catch (IOException e) {
// NOSONAR Do Nothing
}
return page;
} | java | public static Page getPage(InputStream in) throws IOException {
Constructor constructor = new Constructor(Page.class);
TypeDescription typeDesc = new TypeDescription(Page.class);
typeDesc.putListPropertyType("pageValidators", String.class);
typeDesc.putListPropertyType("pageLoadingValidators", String.class);
typeDesc.putMapPropertyType("elements", String.class, GUIElement.class);
constructor.addTypeDescription(typeDesc);
Yaml yamlFile = new Yaml(constructor);
Page page = (Page) yamlFile.load(new BufferedReader(new InputStreamReader(in, "UTF-8")));
try {
in.close();
} catch (IOException e) {
// NOSONAR Do Nothing
}
return page;
} | [
"public",
"static",
"Page",
"getPage",
"(",
"InputStream",
"in",
")",
"throws",
"IOException",
"{",
"Constructor",
"constructor",
"=",
"new",
"Constructor",
"(",
"Page",
".",
"class",
")",
";",
"TypeDescription",
"typeDesc",
"=",
"new",
"TypeDescription",
"(",
"Page",
".",
"class",
")",
";",
"typeDesc",
".",
"putListPropertyType",
"(",
"\"pageValidators\"",
",",
"String",
".",
"class",
")",
";",
"typeDesc",
".",
"putListPropertyType",
"(",
"\"pageLoadingValidators\"",
",",
"String",
".",
"class",
")",
";",
"typeDesc",
".",
"putMapPropertyType",
"(",
"\"elements\"",
",",
"String",
".",
"class",
",",
"GUIElement",
".",
"class",
")",
";",
"constructor",
".",
"addTypeDescription",
"(",
"typeDesc",
")",
";",
"Yaml",
"yamlFile",
"=",
"new",
"Yaml",
"(",
"constructor",
")",
";",
"Page",
"page",
"=",
"(",
"Page",
")",
"yamlFile",
".",
"load",
"(",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"in",
",",
"\"UTF-8\"",
")",
")",
")",
";",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// NOSONAR Do Nothing",
"}",
"return",
"page",
";",
"}"
] | Creates a instance of a {@link Page}.
@param in
input stream of the Yaml File
@return an instance of the Page object
@throws IOException
if unable to read from the {@link InputStream}. Does not close the {@link InputStream} when this
occurs. | [
"Creates",
"a",
"instance",
"of",
"a",
"{",
"@link",
"Page",
"}",
"."
] | train | https://github.com/paypal/SeLion/blob/694d12d0df76db48d0360b16192770c6a4fbdfd2/common/src/main/java/com/paypal/selion/platform/web/PageFactory.java#L46-L65 |
azkaban/azkaban | az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java | HadoopJobUtils.javaOptStringFromAzkabanProps | public static String javaOptStringFromAzkabanProps(Props props, String key) {
"""
<pre>
constructions a javaOpts string based on the Props, and the key given, will return
String.format("-D%s=%s", key, value);
</pre>
@return will return String.format("-D%s=%s", key, value). Throws RuntimeException if props not
present
"""
String value = props.get(key);
if (value == null) {
throw new RuntimeException(String.format("Cannot find property [%s], in azkaban props: [%s]",
key, value));
}
return String.format("-D%s=%s", key, value);
} | java | public static String javaOptStringFromAzkabanProps(Props props, String key) {
String value = props.get(key);
if (value == null) {
throw new RuntimeException(String.format("Cannot find property [%s], in azkaban props: [%s]",
key, value));
}
return String.format("-D%s=%s", key, value);
} | [
"public",
"static",
"String",
"javaOptStringFromAzkabanProps",
"(",
"Props",
"props",
",",
"String",
"key",
")",
"{",
"String",
"value",
"=",
"props",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"String",
".",
"format",
"(",
"\"Cannot find property [%s], in azkaban props: [%s]\"",
",",
"key",
",",
"value",
")",
")",
";",
"}",
"return",
"String",
".",
"format",
"(",
"\"-D%s=%s\"",
",",
"key",
",",
"value",
")",
";",
"}"
] | <pre>
constructions a javaOpts string based on the Props, and the key given, will return
String.format("-D%s=%s", key, value);
</pre>
@return will return String.format("-D%s=%s", key, value). Throws RuntimeException if props not
present | [
"<pre",
">",
"constructions",
"a",
"javaOpts",
"string",
"based",
"on",
"the",
"Props",
"and",
"the",
"key",
"given",
"will",
"return",
"String",
".",
"format",
"(",
"-",
"D%s",
"=",
"%s",
"key",
"value",
")",
";",
"<",
"/",
"pre",
">"
] | train | https://github.com/azkaban/azkaban/blob/d258ea7d6e66807c6eff79c5325d6d3443618dff/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java#L520-L527 |
EsotericSoftware/kryo | src/com/esotericsoftware/kryo/unsafe/UnsafeByteBufferOutput.java | UnsafeByteBufferOutput.writeBytes | public void writeBytes (Object from, long offset, int count) throws KryoException {
"""
Write count bytes to the byte buffer, reading from the given offset inside the in-memory representation of the object.
"""
int copyCount = Math.min(capacity - position, count);
while (true) {
unsafe.copyMemory(from, offset, null, bufferAddress + position, copyCount);
position += copyCount;
count -= copyCount;
if (count == 0) break;
offset += copyCount;
copyCount = Math.min(capacity, count);
require(copyCount);
}
byteBuffer.position(position);
} | java | public void writeBytes (Object from, long offset, int count) throws KryoException {
int copyCount = Math.min(capacity - position, count);
while (true) {
unsafe.copyMemory(from, offset, null, bufferAddress + position, copyCount);
position += copyCount;
count -= copyCount;
if (count == 0) break;
offset += copyCount;
copyCount = Math.min(capacity, count);
require(copyCount);
}
byteBuffer.position(position);
} | [
"public",
"void",
"writeBytes",
"(",
"Object",
"from",
",",
"long",
"offset",
",",
"int",
"count",
")",
"throws",
"KryoException",
"{",
"int",
"copyCount",
"=",
"Math",
".",
"min",
"(",
"capacity",
"-",
"position",
",",
"count",
")",
";",
"while",
"(",
"true",
")",
"{",
"unsafe",
".",
"copyMemory",
"(",
"from",
",",
"offset",
",",
"null",
",",
"bufferAddress",
"+",
"position",
",",
"copyCount",
")",
";",
"position",
"+=",
"copyCount",
";",
"count",
"-=",
"copyCount",
";",
"if",
"(",
"count",
"==",
"0",
")",
"break",
";",
"offset",
"+=",
"copyCount",
";",
"copyCount",
"=",
"Math",
".",
"min",
"(",
"capacity",
",",
"count",
")",
";",
"require",
"(",
"copyCount",
")",
";",
"}",
"byteBuffer",
".",
"position",
"(",
"position",
")",
";",
"}"
] | Write count bytes to the byte buffer, reading from the given offset inside the in-memory representation of the object. | [
"Write",
"count",
"bytes",
"to",
"the",
"byte",
"buffer",
"reading",
"from",
"the",
"given",
"offset",
"inside",
"the",
"in",
"-",
"memory",
"representation",
"of",
"the",
"object",
"."
] | train | https://github.com/EsotericSoftware/kryo/blob/a8be1ab26f347f299a3c3f7171d6447dd5390845/src/com/esotericsoftware/kryo/unsafe/UnsafeByteBufferOutput.java#L215-L227 |
threerings/narya | core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java | PlaceRegistry.createPlace | public PlaceManager createPlace (PlaceConfig config)
throws InstantiationException, InvocationException {
"""
Creates and registers a new place manager with no delegates.
@see #createPlace(PlaceConfig,List)
"""
return createPlace(config, null, null);
} | java | public PlaceManager createPlace (PlaceConfig config)
throws InstantiationException, InvocationException
{
return createPlace(config, null, null);
} | [
"public",
"PlaceManager",
"createPlace",
"(",
"PlaceConfig",
"config",
")",
"throws",
"InstantiationException",
",",
"InvocationException",
"{",
"return",
"createPlace",
"(",
"config",
",",
"null",
",",
"null",
")",
";",
"}"
] | Creates and registers a new place manager with no delegates.
@see #createPlace(PlaceConfig,List) | [
"Creates",
"and",
"registers",
"a",
"new",
"place",
"manager",
"with",
"no",
"delegates",
"."
] | train | https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/crowd/server/PlaceRegistry.java#L82-L86 |
xcesco/kripton | kripton-core/src/main/java/com/abubusoft/kripton/common/DynamicByteBufferHelper.java | DynamicByteBufferHelper.addDouble | public static byte[] addDouble(byte[] array, double value) {
"""
Adds the double.
@param array the array
@param value the value
@return the byte[]
"""
byte[] holder = new byte[4];
doubleTo(holder, 0, value);
return add(array, holder);
} | java | public static byte[] addDouble(byte[] array, double value) {
byte[] holder = new byte[4];
doubleTo(holder, 0, value);
return add(array, holder);
} | [
"public",
"static",
"byte",
"[",
"]",
"addDouble",
"(",
"byte",
"[",
"]",
"array",
",",
"double",
"value",
")",
"{",
"byte",
"[",
"]",
"holder",
"=",
"new",
"byte",
"[",
"4",
"]",
";",
"doubleTo",
"(",
"holder",
",",
"0",
",",
"value",
")",
";",
"return",
"add",
"(",
"array",
",",
"holder",
")",
";",
"}"
] | Adds the double.
@param array the array
@param value the value
@return the byte[] | [
"Adds",
"the",
"double",
"."
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-core/src/main/java/com/abubusoft/kripton/common/DynamicByteBufferHelper.java#L912-L917 |
haraldk/TwelveMonkeys | sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/ResourceMonitor.java | ResourceMonitor.removeResourceChangeListener | public void removeResourceChangeListener(ResourceChangeListener pListener, Object pResourceId) {
"""
Remove the {@code ResourceChangeListener} from the notification list.
@param pListener the pListener to be removed.
@param pResourceId name of the resource to monitor.
"""
synchronized (timerEntries) {
removeListenerInternal(getResourceId(pResourceId, pListener));
}
} | java | public void removeResourceChangeListener(ResourceChangeListener pListener, Object pResourceId) {
synchronized (timerEntries) {
removeListenerInternal(getResourceId(pResourceId, pListener));
}
} | [
"public",
"void",
"removeResourceChangeListener",
"(",
"ResourceChangeListener",
"pListener",
",",
"Object",
"pResourceId",
")",
"{",
"synchronized",
"(",
"timerEntries",
")",
"{",
"removeListenerInternal",
"(",
"getResourceId",
"(",
"pResourceId",
",",
"pListener",
")",
")",
";",
"}",
"}"
] | Remove the {@code ResourceChangeListener} from the notification list.
@param pListener the pListener to be removed.
@param pResourceId name of the resource to monitor. | [
"Remove",
"the",
"{",
"@code",
"ResourceChangeListener",
"}",
"from",
"the",
"notification",
"list",
"."
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/ResourceMonitor.java#L112-L116 |
albfernandez/itext2 | src/main/java/com/lowagie/text/Document.java | Document.addCreationDate | public boolean addCreationDate() {
"""
Adds the current date and time to a Document.
@return <CODE>true</CODE> if successful, <CODE>false</CODE> otherwise
"""
try {
/* bugfix by 'taqua' (Thomas) */
final SimpleDateFormat sdf = new SimpleDateFormat(
"EEE MMM dd HH:mm:ss zzz yyyy");
return add(new Meta(Element.CREATIONDATE, sdf.format(new Date())));
} catch (DocumentException de) {
throw new ExceptionConverter(de);
}
} | java | public boolean addCreationDate() {
try {
/* bugfix by 'taqua' (Thomas) */
final SimpleDateFormat sdf = new SimpleDateFormat(
"EEE MMM dd HH:mm:ss zzz yyyy");
return add(new Meta(Element.CREATIONDATE, sdf.format(new Date())));
} catch (DocumentException de) {
throw new ExceptionConverter(de);
}
} | [
"public",
"boolean",
"addCreationDate",
"(",
")",
"{",
"try",
"{",
"/* bugfix by 'taqua' (Thomas) */",
"final",
"SimpleDateFormat",
"sdf",
"=",
"new",
"SimpleDateFormat",
"(",
"\"EEE MMM dd HH:mm:ss zzz yyyy\"",
")",
";",
"return",
"add",
"(",
"new",
"Meta",
"(",
"Element",
".",
"CREATIONDATE",
",",
"sdf",
".",
"format",
"(",
"new",
"Date",
"(",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"DocumentException",
"de",
")",
"{",
"throw",
"new",
"ExceptionConverter",
"(",
"de",
")",
";",
"}",
"}"
] | Adds the current date and time to a Document.
@return <CODE>true</CODE> if successful, <CODE>false</CODE> otherwise | [
"Adds",
"the",
"current",
"date",
"and",
"time",
"to",
"a",
"Document",
"."
] | train | https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/Document.java#L620-L629 |
paypal/SeLion | client/src/main/java/com/paypal/selion/internal/reports/runtimereport/JsonRuntimeReporterHelper.java | JsonRuntimeReporterHelper.generateLocalConfigSummary | public void generateLocalConfigSummary(String suiteName, String testName) {
"""
This method will generate local Configuration summary by fetching the details from ReportDataGenerator
@param suiteName
suite name of the test method.
@param testName
test name of the test method.
"""
logger.entering(new Object[] { suiteName, testName });
try {
Map<String, String> testLocalConfigValues = ConfigSummaryData.getLocalConfigSummary(testName);
JsonObject json = new JsonObject();
if (testLocalConfigValues == null) {
json.addProperty(ReporterDateFormatter.CURRENTDATE, ReporterDateFormatter.getISO8601String(new Date()));
} else {
for (Entry<String, String> temp : testLocalConfigValues.entrySet()) {
json.addProperty(temp.getKey(), temp.getValue());
}
}
json.addProperty("suite", suiteName);
json.addProperty("test", testName);
// Sometimes json objects getting null value when data provider parallelism enabled
// To solve this added synchronized block
synchronized (this) {
this.testJsonLocalConfigSummary.add(json);
}
} catch (JsonParseException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
throw new ReporterException(e);
}
logger.exiting();
} | java | public void generateLocalConfigSummary(String suiteName, String testName) {
logger.entering(new Object[] { suiteName, testName });
try {
Map<String, String> testLocalConfigValues = ConfigSummaryData.getLocalConfigSummary(testName);
JsonObject json = new JsonObject();
if (testLocalConfigValues == null) {
json.addProperty(ReporterDateFormatter.CURRENTDATE, ReporterDateFormatter.getISO8601String(new Date()));
} else {
for (Entry<String, String> temp : testLocalConfigValues.entrySet()) {
json.addProperty(temp.getKey(), temp.getValue());
}
}
json.addProperty("suite", suiteName);
json.addProperty("test", testName);
// Sometimes json objects getting null value when data provider parallelism enabled
// To solve this added synchronized block
synchronized (this) {
this.testJsonLocalConfigSummary.add(json);
}
} catch (JsonParseException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
throw new ReporterException(e);
}
logger.exiting();
} | [
"public",
"void",
"generateLocalConfigSummary",
"(",
"String",
"suiteName",
",",
"String",
"testName",
")",
"{",
"logger",
".",
"entering",
"(",
"new",
"Object",
"[",
"]",
"{",
"suiteName",
",",
"testName",
"}",
")",
";",
"try",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"testLocalConfigValues",
"=",
"ConfigSummaryData",
".",
"getLocalConfigSummary",
"(",
"testName",
")",
";",
"JsonObject",
"json",
"=",
"new",
"JsonObject",
"(",
")",
";",
"if",
"(",
"testLocalConfigValues",
"==",
"null",
")",
"{",
"json",
".",
"addProperty",
"(",
"ReporterDateFormatter",
".",
"CURRENTDATE",
",",
"ReporterDateFormatter",
".",
"getISO8601String",
"(",
"new",
"Date",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"temp",
":",
"testLocalConfigValues",
".",
"entrySet",
"(",
")",
")",
"{",
"json",
".",
"addProperty",
"(",
"temp",
".",
"getKey",
"(",
")",
",",
"temp",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"json",
".",
"addProperty",
"(",
"\"suite\"",
",",
"suiteName",
")",
";",
"json",
".",
"addProperty",
"(",
"\"test\"",
",",
"testName",
")",
";",
"// Sometimes json objects getting null value when data provider parallelism enabled",
"// To solve this added synchronized block",
"synchronized",
"(",
"this",
")",
"{",
"this",
".",
"testJsonLocalConfigSummary",
".",
"add",
"(",
"json",
")",
";",
"}",
"}",
"catch",
"(",
"JsonParseException",
"e",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"ReporterException",
"(",
"e",
")",
";",
"}",
"logger",
".",
"exiting",
"(",
")",
";",
"}"
] | This method will generate local Configuration summary by fetching the details from ReportDataGenerator
@param suiteName
suite name of the test method.
@param testName
test name of the test method. | [
"This",
"method",
"will",
"generate",
"local",
"Configuration",
"summary",
"by",
"fetching",
"the",
"details",
"from",
"ReportDataGenerator"
] | train | https://github.com/paypal/SeLion/blob/694d12d0df76db48d0360b16192770c6a4fbdfd2/client/src/main/java/com/paypal/selion/internal/reports/runtimereport/JsonRuntimeReporterHelper.java#L124-L152 |
OpenLiberty/open-liberty | dev/com.ibm.ws.kernel.filemonitor/src/com/ibm/ws/kernel/filemonitor/internal/UpdateMonitor.java | UpdateMonitor.getMonitor | public static UpdateMonitor getMonitor(File monitoredFile, MonitorType type, String filter) {
"""
Obtain an instance of an update monitor that uses the specified cache location, and
monitors the specified resource with the specified properties. Caller must call {@link #init()} on
this monitor before the first scheduled scan.
@param monitoredFile
The name of the resource to monitor (file or directory, may or may not exist)
@param filter A regex filter limiting the types of resources that will be monitored.
Only applicable if the primary monitored file is a directory
@param recurse
If true, all resources in all subdirectories will be monitored
@return an instance of the UpdateMonitor appropriate for the monitored resource (e.g. File, Directory, or non-existant)
"""
if (monitoredFile == null)
throw new NullPointerException("MonitoredFile must be non-null");
if (type == null)
throw new NullPointerException("MonitorType must be non-null");
switch (type) {
case DIRECTORY:
case DIRECTORY_RECURSE:
case DIRECTORY_SELF:
case DIRECTORY_RECURSE_SELF:
return new DirectoryUpdateMonitor(monitoredFile, type, filter);
case FILE:
return new FileUpdateMonitor(monitoredFile);
default:
throw new IllegalArgumentException("Unknown monitor type: " + type);
}
} | java | public static UpdateMonitor getMonitor(File monitoredFile, MonitorType type, String filter) {
if (monitoredFile == null)
throw new NullPointerException("MonitoredFile must be non-null");
if (type == null)
throw new NullPointerException("MonitorType must be non-null");
switch (type) {
case DIRECTORY:
case DIRECTORY_RECURSE:
case DIRECTORY_SELF:
case DIRECTORY_RECURSE_SELF:
return new DirectoryUpdateMonitor(monitoredFile, type, filter);
case FILE:
return new FileUpdateMonitor(monitoredFile);
default:
throw new IllegalArgumentException("Unknown monitor type: " + type);
}
} | [
"public",
"static",
"UpdateMonitor",
"getMonitor",
"(",
"File",
"monitoredFile",
",",
"MonitorType",
"type",
",",
"String",
"filter",
")",
"{",
"if",
"(",
"monitoredFile",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"MonitoredFile must be non-null\"",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"MonitorType must be non-null\"",
")",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"DIRECTORY",
":",
"case",
"DIRECTORY_RECURSE",
":",
"case",
"DIRECTORY_SELF",
":",
"case",
"DIRECTORY_RECURSE_SELF",
":",
"return",
"new",
"DirectoryUpdateMonitor",
"(",
"monitoredFile",
",",
"type",
",",
"filter",
")",
";",
"case",
"FILE",
":",
"return",
"new",
"FileUpdateMonitor",
"(",
"monitoredFile",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown monitor type: \"",
"+",
"type",
")",
";",
"}",
"}"
] | Obtain an instance of an update monitor that uses the specified cache location, and
monitors the specified resource with the specified properties. Caller must call {@link #init()} on
this monitor before the first scheduled scan.
@param monitoredFile
The name of the resource to monitor (file or directory, may or may not exist)
@param filter A regex filter limiting the types of resources that will be monitored.
Only applicable if the primary monitored file is a directory
@param recurse
If true, all resources in all subdirectories will be monitored
@return an instance of the UpdateMonitor appropriate for the monitored resource (e.g. File, Directory, or non-existant) | [
"Obtain",
"an",
"instance",
"of",
"an",
"update",
"monitor",
"that",
"uses",
"the",
"specified",
"cache",
"location",
"and",
"monitors",
"the",
"specified",
"resource",
"with",
"the",
"specified",
"properties",
".",
"Caller",
"must",
"call",
"{",
"@link",
"#init",
"()",
"}",
"on",
"this",
"monitor",
"before",
"the",
"first",
"scheduled",
"scan",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.filemonitor/src/com/ibm/ws/kernel/filemonitor/internal/UpdateMonitor.java#L53-L71 |
burberius/eve-esi | src/main/java/net/troja/eve/esi/api/MailApi.java | MailApi.postCharactersCharacterIdMail | public Integer postCharactersCharacterIdMail(Integer characterId, String datasource, String token, Mail mail)
throws ApiException {
"""
Send a new mail Create and send a new mail --- SSO Scope:
esi-mail.send_mail.v1
@param characterId
An EVE character ID (required)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param token
Access token to use if unable to set a header (optional)
@param mail
(optional)
@return Integer
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body
"""
ApiResponse<Integer> resp = postCharactersCharacterIdMailWithHttpInfo(characterId, datasource, token, mail);
return resp.getData();
} | java | public Integer postCharactersCharacterIdMail(Integer characterId, String datasource, String token, Mail mail)
throws ApiException {
ApiResponse<Integer> resp = postCharactersCharacterIdMailWithHttpInfo(characterId, datasource, token, mail);
return resp.getData();
} | [
"public",
"Integer",
"postCharactersCharacterIdMail",
"(",
"Integer",
"characterId",
",",
"String",
"datasource",
",",
"String",
"token",
",",
"Mail",
"mail",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"Integer",
">",
"resp",
"=",
"postCharactersCharacterIdMailWithHttpInfo",
"(",
"characterId",
",",
"datasource",
",",
"token",
",",
"mail",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Send a new mail Create and send a new mail --- SSO Scope:
esi-mail.send_mail.v1
@param characterId
An EVE character ID (required)
@param datasource
The server name you would like data from (optional, default to
tranquility)
@param token
Access token to use if unable to set a header (optional)
@param mail
(optional)
@return Integer
@throws ApiException
If fail to call the API, e.g. server error or cannot
deserialize the response body | [
"Send",
"a",
"new",
"mail",
"Create",
"and",
"send",
"a",
"new",
"mail",
"---",
"SSO",
"Scope",
":",
"esi",
"-",
"mail",
".",
"send_mail",
".",
"v1"
] | train | https://github.com/burberius/eve-esi/blob/24a941c592cfc15f23471ef849b282fbc582ca13/src/main/java/net/troja/eve/esi/api/MailApi.java#L1175-L1179 |
greese/dasein-persist | src/main/java/org/dasein/persist/RelationalHSCache.java | RelationalHSCache.list | @Override
public Collection<T> list() throws PersistenceException {
"""
Loads all elements of this class from the data store. Use this method only when you know
exactly what you are doing. Otherwise, you will pull a lot of data.
@return all objects from the database
@throws PersistenceException an error occurred executing the query
"""
logger.debug("enter - list()");
try {
return find(null, null, false);
}
finally {
logger.debug("exit - list()");
}
} | java | @Override
public Collection<T> list() throws PersistenceException {
logger.debug("enter - list()");
try {
return find(null, null, false);
}
finally {
logger.debug("exit - list()");
}
} | [
"@",
"Override",
"public",
"Collection",
"<",
"T",
">",
"list",
"(",
")",
"throws",
"PersistenceException",
"{",
"logger",
".",
"debug",
"(",
"\"enter - list()\"",
")",
";",
"try",
"{",
"return",
"find",
"(",
"null",
",",
"null",
",",
"false",
")",
";",
"}",
"finally",
"{",
"logger",
".",
"debug",
"(",
"\"exit - list()\"",
")",
";",
"}",
"}"
] | Loads all elements of this class from the data store. Use this method only when you know
exactly what you are doing. Otherwise, you will pull a lot of data.
@return all objects from the database
@throws PersistenceException an error occurred executing the query | [
"Loads",
"all",
"elements",
"of",
"this",
"class",
"from",
"the",
"data",
"store",
".",
"Use",
"this",
"method",
"only",
"when",
"you",
"know",
"exactly",
"what",
"you",
"are",
"doing",
".",
"Otherwise",
"you",
"will",
"pull",
"a",
"lot",
"of",
"data",
"."
] | train | https://github.com/greese/dasein-persist/blob/1104621ad1670a45488b093b984ec1db4c7be781/src/main/java/org/dasein/persist/RelationalHSCache.java#L460-L469 |
codeprimate-software/cp-elements | src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java | ElementsExceptionsFactory.newAuthenticationException | public static AuthenticationException newAuthenticationException(Throwable cause, String message, Object... args) {
"""
Constructs and initializes a new {@link AuthenticationException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link AuthenticationException} was thrown.
@param message {@link String} describing the {@link AuthenticationException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link AuthenticationException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.security.AuthenticationException
"""
return new AuthenticationException(format(message, args), cause);
} | java | public static AuthenticationException newAuthenticationException(Throwable cause, String message, Object... args) {
return new AuthenticationException(format(message, args), cause);
} | [
"public",
"static",
"AuthenticationException",
"newAuthenticationException",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"AuthenticationException",
"(",
"format",
"(",
"message",
",",
"args",
")",
",",
"cause",
")",
";",
"}"
] | Constructs and initializes a new {@link AuthenticationException} with the given {@link Throwable cause}
and {@link String message} formatted with the given {@link Object[] arguments}.
@param cause {@link Throwable} identified as the reason this {@link AuthenticationException} was thrown.
@param message {@link String} describing the {@link AuthenticationException exception}.
@param args {@link Object[] arguments} used to replace format placeholders in the {@link String message}.
@return a new {@link AuthenticationException} with the given {@link Throwable cause} and {@link String message}.
@see org.cp.elements.security.AuthenticationException | [
"Constructs",
"and",
"initializes",
"a",
"new",
"{",
"@link",
"AuthenticationException",
"}",
"with",
"the",
"given",
"{",
"@link",
"Throwable",
"cause",
"}",
"and",
"{",
"@link",
"String",
"message",
"}",
"formatted",
"with",
"the",
"given",
"{",
"@link",
"Object",
"[]",
"arguments",
"}",
"."
] | train | https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ElementsExceptionsFactory.java#L599-L601 |
TheHortonMachine/hortonmachine | gears/src/main/java/oms3/Compound.java | Compound.field2in | public void field2in(Object o, String field, Object to, String to_in) {
"""
Maps a object's field to an In field
@param o the object
@param field the field name
@param to the component
@param to_in the In field.
"""
controller.mapInField(o, field, to, to_in);
} | java | public void field2in(Object o, String field, Object to, String to_in) {
controller.mapInField(o, field, to, to_in);
} | [
"public",
"void",
"field2in",
"(",
"Object",
"o",
",",
"String",
"field",
",",
"Object",
"to",
",",
"String",
"to_in",
")",
"{",
"controller",
".",
"mapInField",
"(",
"o",
",",
"field",
",",
"to",
",",
"to_in",
")",
";",
"}"
] | Maps a object's field to an In field
@param o the object
@param field the field name
@param to the component
@param to_in the In field. | [
"Maps",
"a",
"object",
"s",
"field",
"to",
"an",
"In",
"field"
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/oms3/Compound.java#L189-L191 |
tvbarthel/Cheerleader | library/src/main/java/fr/tvbarthel/cheerleader/library/helpers/SoundCloudArtworkHelper.java | SoundCloudArtworkHelper.getArtworkUrl | public static String getArtworkUrl(SoundCloudTrack track, String size) {
"""
Retrieve the artwork url of a track pointing to the requested size.
<p/>
By default, {@link fr.tvbarthel.cheerleader.library.client.SoundCloudTrack#getArtworkUrl()}
points to the {@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#LARGE}
<p/>
Available size are :
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#MINI}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#TINY}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#SMALL}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#BADGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#LARGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#XLARGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#XXLARGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#XXXLARGE}
@param track track from which artwork url should be returned.
@param size wished size.
@return artwork url or null if no artwork are available.
"""
String defaultUrl = track.getArtworkUrl();
if (defaultUrl == null) {
return null;
}
switch (size) {
case MINI:
case TINY:
case SMALL:
case BADGE:
case LARGE:
case XLARGE:
case XXLARGE:
case XXXLARGE:
return defaultUrl.replace(LARGE, size);
default:
return defaultUrl;
}
} | java | public static String getArtworkUrl(SoundCloudTrack track, String size) {
String defaultUrl = track.getArtworkUrl();
if (defaultUrl == null) {
return null;
}
switch (size) {
case MINI:
case TINY:
case SMALL:
case BADGE:
case LARGE:
case XLARGE:
case XXLARGE:
case XXXLARGE:
return defaultUrl.replace(LARGE, size);
default:
return defaultUrl;
}
} | [
"public",
"static",
"String",
"getArtworkUrl",
"(",
"SoundCloudTrack",
"track",
",",
"String",
"size",
")",
"{",
"String",
"defaultUrl",
"=",
"track",
".",
"getArtworkUrl",
"(",
")",
";",
"if",
"(",
"defaultUrl",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"switch",
"(",
"size",
")",
"{",
"case",
"MINI",
":",
"case",
"TINY",
":",
"case",
"SMALL",
":",
"case",
"BADGE",
":",
"case",
"LARGE",
":",
"case",
"XLARGE",
":",
"case",
"XXLARGE",
":",
"case",
"XXXLARGE",
":",
"return",
"defaultUrl",
".",
"replace",
"(",
"LARGE",
",",
"size",
")",
";",
"default",
":",
"return",
"defaultUrl",
";",
"}",
"}"
] | Retrieve the artwork url of a track pointing to the requested size.
<p/>
By default, {@link fr.tvbarthel.cheerleader.library.client.SoundCloudTrack#getArtworkUrl()}
points to the {@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#LARGE}
<p/>
Available size are :
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#MINI}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#TINY}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#SMALL}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#BADGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#LARGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#XLARGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#XXLARGE}
{@link fr.tvbarthel.cheerleader.library.helpers.SoundCloudArtworkHelper#XXXLARGE}
@param track track from which artwork url should be returned.
@param size wished size.
@return artwork url or null if no artwork are available. | [
"Retrieve",
"the",
"artwork",
"url",
"of",
"a",
"track",
"pointing",
"to",
"the",
"requested",
"size",
".",
"<p",
"/",
">",
"By",
"default",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"client",
".",
"SoundCloudTrack#getArtworkUrl",
"()",
"}",
"points",
"to",
"the",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"helpers",
".",
"SoundCloudArtworkHelper#LARGE",
"}",
"<p",
"/",
">",
"Available",
"size",
"are",
":",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"helpers",
".",
"SoundCloudArtworkHelper#MINI",
"}",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"helpers",
".",
"SoundCloudArtworkHelper#TINY",
"}",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"helpers",
".",
"SoundCloudArtworkHelper#SMALL",
"}",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"helpers",
".",
"SoundCloudArtworkHelper#BADGE",
"}",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"helpers",
".",
"SoundCloudArtworkHelper#LARGE",
"}",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"helpers",
".",
"SoundCloudArtworkHelper#XLARGE",
"}",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"helpers",
".",
"SoundCloudArtworkHelper#XXLARGE",
"}",
"{",
"@link",
"fr",
".",
"tvbarthel",
".",
"cheerleader",
".",
"library",
".",
"helpers",
".",
"SoundCloudArtworkHelper#XXXLARGE",
"}"
] | train | https://github.com/tvbarthel/Cheerleader/blob/f61527e4cc44fcd0ed2e1e98aca285f8c236f24e/library/src/main/java/fr/tvbarthel/cheerleader/library/helpers/SoundCloudArtworkHelper.java#L78-L96 |
Jasig/uPortal | uPortal-security/uPortal-security-permissions/src/main/java/org/apereo/portal/security/provider/AuthorizationImpl.java | AuthorizationImpl.canPrincipalManage | @Override
@RequestCache
public boolean canPrincipalManage(IAuthorizationPrincipal principal, String portletDefinitionId)
throws AuthorizationException {
"""
Answers if the principal has permission to MANAGE this Channel.
@param principal IAuthorizationPrincipal The user who wants to manage the portlet
@param portletDefinitionId The Id of the portlet being managed
@return True if the specified user is allowed to manage the specified portlet; otherwise
false
@exception AuthorizationException indicates authorization information could not be retrieved.
"""
final String owner = IPermission.PORTAL_PUBLISH;
final String target = IPermission.PORTLET_PREFIX + portletDefinitionId;
// Retrieve the indicated portlet from the portlet registry store and
// determine its current lifecycle state.
IPortletDefinition portlet =
this.portletDefinitionRegistry.getPortletDefinition(portletDefinitionId);
if (portlet == null) {
/*
* Is this what happens when a portlet is new? Shouldn't we
* be checking PORTLET_MANAGER_CREATED_ACTIVITY in that case?
*/
return doesPrincipalHavePermission(
principal, owner, IPermission.PORTLET_MANAGER_APPROVED_ACTIVITY, target);
}
/*
* The following code assumes that later lifecycle states imply permission
* for earlier lifecycle states. For example, if a user has permission to
* manage an expired channel, we assume s/he also has permission to
* create, approve, and publish channels. The following code counts
* channels with auto-publish or auto-expiration dates set as requiring
* publish or expiration permissions for management, even though the channel
* may not yet be published or expired.
*/
final IPortletLifecycleEntry highestLifecycleEntryDefined =
portlet.getLifecycle().get(portlet.getLifecycle().size() - 1);
String activity;
switch (highestLifecycleEntryDefined.getLifecycleState()) {
case CREATED:
activity = IPermission.PORTLET_MANAGER_CREATED_ACTIVITY;
break;
case APPROVED:
activity = IPermission.PORTLET_MANAGER_APPROVED_ACTIVITY;
break;
case PUBLISHED:
activity = IPermission.PORTLET_MANAGER_ACTIVITY;
break;
case EXPIRED:
activity = IPermission.PORTLET_MANAGER_EXPIRED_ACTIVITY;
break;
case MAINTENANCE:
activity = IPermission.PORTLET_MANAGER_MAINTENANCE_ACTIVITY;
break;
default:
final String msg =
"Unrecognized portlet lifecycle state: "
+ highestLifecycleEntryDefined.getLifecycleState();
throw new IllegalStateException(msg);
}
return doesPrincipalHavePermission(principal, owner, activity, target);
} | java | @Override
@RequestCache
public boolean canPrincipalManage(IAuthorizationPrincipal principal, String portletDefinitionId)
throws AuthorizationException {
final String owner = IPermission.PORTAL_PUBLISH;
final String target = IPermission.PORTLET_PREFIX + portletDefinitionId;
// Retrieve the indicated portlet from the portlet registry store and
// determine its current lifecycle state.
IPortletDefinition portlet =
this.portletDefinitionRegistry.getPortletDefinition(portletDefinitionId);
if (portlet == null) {
/*
* Is this what happens when a portlet is new? Shouldn't we
* be checking PORTLET_MANAGER_CREATED_ACTIVITY in that case?
*/
return doesPrincipalHavePermission(
principal, owner, IPermission.PORTLET_MANAGER_APPROVED_ACTIVITY, target);
}
/*
* The following code assumes that later lifecycle states imply permission
* for earlier lifecycle states. For example, if a user has permission to
* manage an expired channel, we assume s/he also has permission to
* create, approve, and publish channels. The following code counts
* channels with auto-publish or auto-expiration dates set as requiring
* publish or expiration permissions for management, even though the channel
* may not yet be published or expired.
*/
final IPortletLifecycleEntry highestLifecycleEntryDefined =
portlet.getLifecycle().get(portlet.getLifecycle().size() - 1);
String activity;
switch (highestLifecycleEntryDefined.getLifecycleState()) {
case CREATED:
activity = IPermission.PORTLET_MANAGER_CREATED_ACTIVITY;
break;
case APPROVED:
activity = IPermission.PORTLET_MANAGER_APPROVED_ACTIVITY;
break;
case PUBLISHED:
activity = IPermission.PORTLET_MANAGER_ACTIVITY;
break;
case EXPIRED:
activity = IPermission.PORTLET_MANAGER_EXPIRED_ACTIVITY;
break;
case MAINTENANCE:
activity = IPermission.PORTLET_MANAGER_MAINTENANCE_ACTIVITY;
break;
default:
final String msg =
"Unrecognized portlet lifecycle state: "
+ highestLifecycleEntryDefined.getLifecycleState();
throw new IllegalStateException(msg);
}
return doesPrincipalHavePermission(principal, owner, activity, target);
} | [
"@",
"Override",
"@",
"RequestCache",
"public",
"boolean",
"canPrincipalManage",
"(",
"IAuthorizationPrincipal",
"principal",
",",
"String",
"portletDefinitionId",
")",
"throws",
"AuthorizationException",
"{",
"final",
"String",
"owner",
"=",
"IPermission",
".",
"PORTAL_PUBLISH",
";",
"final",
"String",
"target",
"=",
"IPermission",
".",
"PORTLET_PREFIX",
"+",
"portletDefinitionId",
";",
"// Retrieve the indicated portlet from the portlet registry store and",
"// determine its current lifecycle state.",
"IPortletDefinition",
"portlet",
"=",
"this",
".",
"portletDefinitionRegistry",
".",
"getPortletDefinition",
"(",
"portletDefinitionId",
")",
";",
"if",
"(",
"portlet",
"==",
"null",
")",
"{",
"/*\n * Is this what happens when a portlet is new? Shouldn't we\n * be checking PORTLET_MANAGER_CREATED_ACTIVITY in that case?\n */",
"return",
"doesPrincipalHavePermission",
"(",
"principal",
",",
"owner",
",",
"IPermission",
".",
"PORTLET_MANAGER_APPROVED_ACTIVITY",
",",
"target",
")",
";",
"}",
"/*\n * The following code assumes that later lifecycle states imply permission\n * for earlier lifecycle states. For example, if a user has permission to\n * manage an expired channel, we assume s/he also has permission to\n * create, approve, and publish channels. The following code counts\n * channels with auto-publish or auto-expiration dates set as requiring\n * publish or expiration permissions for management, even though the channel\n * may not yet be published or expired.\n */",
"final",
"IPortletLifecycleEntry",
"highestLifecycleEntryDefined",
"=",
"portlet",
".",
"getLifecycle",
"(",
")",
".",
"get",
"(",
"portlet",
".",
"getLifecycle",
"(",
")",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"String",
"activity",
";",
"switch",
"(",
"highestLifecycleEntryDefined",
".",
"getLifecycleState",
"(",
")",
")",
"{",
"case",
"CREATED",
":",
"activity",
"=",
"IPermission",
".",
"PORTLET_MANAGER_CREATED_ACTIVITY",
";",
"break",
";",
"case",
"APPROVED",
":",
"activity",
"=",
"IPermission",
".",
"PORTLET_MANAGER_APPROVED_ACTIVITY",
";",
"break",
";",
"case",
"PUBLISHED",
":",
"activity",
"=",
"IPermission",
".",
"PORTLET_MANAGER_ACTIVITY",
";",
"break",
";",
"case",
"EXPIRED",
":",
"activity",
"=",
"IPermission",
".",
"PORTLET_MANAGER_EXPIRED_ACTIVITY",
";",
"break",
";",
"case",
"MAINTENANCE",
":",
"activity",
"=",
"IPermission",
".",
"PORTLET_MANAGER_MAINTENANCE_ACTIVITY",
";",
"break",
";",
"default",
":",
"final",
"String",
"msg",
"=",
"\"Unrecognized portlet lifecycle state: \"",
"+",
"highestLifecycleEntryDefined",
".",
"getLifecycleState",
"(",
")",
";",
"throw",
"new",
"IllegalStateException",
"(",
"msg",
")",
";",
"}",
"return",
"doesPrincipalHavePermission",
"(",
"principal",
",",
"owner",
",",
"activity",
",",
"target",
")",
";",
"}"
] | Answers if the principal has permission to MANAGE this Channel.
@param principal IAuthorizationPrincipal The user who wants to manage the portlet
@param portletDefinitionId The Id of the portlet being managed
@return True if the specified user is allowed to manage the specified portlet; otherwise
false
@exception AuthorizationException indicates authorization information could not be retrieved. | [
"Answers",
"if",
"the",
"principal",
"has",
"permission",
"to",
"MANAGE",
"this",
"Channel",
"."
] | train | https://github.com/Jasig/uPortal/blob/c1986542abb9acd214268f2df21c6305ad2f262b/uPortal-security/uPortal-security-permissions/src/main/java/org/apereo/portal/security/provider/AuthorizationImpl.java#L273-L332 |
LAW-Unimi/BUbiNG | src/it/unimi/di/law/bubing/util/Util.java | Util.toOutputStream | public static OutputStream toOutputStream(final String s, final OutputStream os) throws IOException {
"""
Writes a string to an output stream, discarding higher order bits.
<p>This method is significantly faster than those relying on character encoders, and it does not allocate any object.
@param s a string.
@param os an output stream.
@return {@code os}.
@throws AssertionError if assertions are enabled and some character of {@code s} does not fit a byte.
"""
// This needs to be fast.
final int length = s.length();
for(int i = 0; i < length; i++) {
assert s.charAt(i) < (char)0x100 : s.charAt(i);
os.write(s.charAt(i));
}
return os;
} | java | public static OutputStream toOutputStream(final String s, final OutputStream os) throws IOException {
// This needs to be fast.
final int length = s.length();
for(int i = 0; i < length; i++) {
assert s.charAt(i) < (char)0x100 : s.charAt(i);
os.write(s.charAt(i));
}
return os;
} | [
"public",
"static",
"OutputStream",
"toOutputStream",
"(",
"final",
"String",
"s",
",",
"final",
"OutputStream",
"os",
")",
"throws",
"IOException",
"{",
"// This needs to be fast.",
"final",
"int",
"length",
"=",
"s",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"assert",
"s",
".",
"charAt",
"(",
"i",
")",
"<",
"(",
"char",
")",
"0x100",
":",
"s",
".",
"charAt",
"(",
"i",
")",
";",
"os",
".",
"write",
"(",
"s",
".",
"charAt",
"(",
"i",
")",
")",
";",
"}",
"return",
"os",
";",
"}"
] | Writes a string to an output stream, discarding higher order bits.
<p>This method is significantly faster than those relying on character encoders, and it does not allocate any object.
@param s a string.
@param os an output stream.
@return {@code os}.
@throws AssertionError if assertions are enabled and some character of {@code s} does not fit a byte. | [
"Writes",
"a",
"string",
"to",
"an",
"output",
"stream",
"discarding",
"higher",
"order",
"bits",
"."
] | train | https://github.com/LAW-Unimi/BUbiNG/blob/e148acc90031a4f3967422705a9fb07ddaf155e4/src/it/unimi/di/law/bubing/util/Util.java#L211-L220 |
beihaifeiwu/dolphin | dolphin-mybatis-generator/src/main/java/com/freetmp/mbg/plugin/ContentMergePlugin.java | ContentMergePlugin.findMatchedElementIn | protected XmlElement findMatchedElementIn(Document document, org.dom4j.Element element) {
"""
从MBG生成的DOM文档结构中找到与element代表同一节点的元素对象
@param document generate xml dom tree
@param element The dom4j element
@return The xml element correspond to dom4j element
"""
org.dom4j.Attribute id = element.attribute("id");
String idName = id.getName();
String idValue = id.getValue();
for (Element me : document.getRootElement().getElements()) {
if (me instanceof XmlElement) {
XmlElement xe = (XmlElement) me;
for (Attribute ab : xe.getAttributes()) {
if (StringUtils.equals(idName, ab.getName()) && StringUtils.equals(idValue, ab.getValue())) {
return xe;
}
}
}
}
return null;
} | java | protected XmlElement findMatchedElementIn(Document document, org.dom4j.Element element) {
org.dom4j.Attribute id = element.attribute("id");
String idName = id.getName();
String idValue = id.getValue();
for (Element me : document.getRootElement().getElements()) {
if (me instanceof XmlElement) {
XmlElement xe = (XmlElement) me;
for (Attribute ab : xe.getAttributes()) {
if (StringUtils.equals(idName, ab.getName()) && StringUtils.equals(idValue, ab.getValue())) {
return xe;
}
}
}
}
return null;
} | [
"protected",
"XmlElement",
"findMatchedElementIn",
"(",
"Document",
"document",
",",
"org",
".",
"dom4j",
".",
"Element",
"element",
")",
"{",
"org",
".",
"dom4j",
".",
"Attribute",
"id",
"=",
"element",
".",
"attribute",
"(",
"\"id\"",
")",
";",
"String",
"idName",
"=",
"id",
".",
"getName",
"(",
")",
";",
"String",
"idValue",
"=",
"id",
".",
"getValue",
"(",
")",
";",
"for",
"(",
"Element",
"me",
":",
"document",
".",
"getRootElement",
"(",
")",
".",
"getElements",
"(",
")",
")",
"{",
"if",
"(",
"me",
"instanceof",
"XmlElement",
")",
"{",
"XmlElement",
"xe",
"=",
"(",
"XmlElement",
")",
"me",
";",
"for",
"(",
"Attribute",
"ab",
":",
"xe",
".",
"getAttributes",
"(",
")",
")",
"{",
"if",
"(",
"StringUtils",
".",
"equals",
"(",
"idName",
",",
"ab",
".",
"getName",
"(",
")",
")",
"&&",
"StringUtils",
".",
"equals",
"(",
"idValue",
",",
"ab",
".",
"getValue",
"(",
")",
")",
")",
"{",
"return",
"xe",
";",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | 从MBG生成的DOM文档结构中找到与element代表同一节点的元素对象
@param document generate xml dom tree
@param element The dom4j element
@return The xml element correspond to dom4j element | [
"从MBG生成的DOM文档结构中找到与element代表同一节点的元素对象"
] | train | https://github.com/beihaifeiwu/dolphin/blob/b100579cc6986dce5eba5593ebb5fbae7bad9d1a/dolphin-mybatis-generator/src/main/java/com/freetmp/mbg/plugin/ContentMergePlugin.java#L244-L259 |
googleapis/google-cloud-java | google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/RegionOperationId.java | RegionOperationId.of | public static RegionOperationId of(String region, String operation) {
"""
Returns a region operation identity given the region and operation names.
"""
return new RegionOperationId(null, region, operation);
} | java | public static RegionOperationId of(String region, String operation) {
return new RegionOperationId(null, region, operation);
} | [
"public",
"static",
"RegionOperationId",
"of",
"(",
"String",
"region",
",",
"String",
"operation",
")",
"{",
"return",
"new",
"RegionOperationId",
"(",
"null",
",",
"region",
",",
"operation",
")",
";",
"}"
] | Returns a region operation identity given the region and operation names. | [
"Returns",
"a",
"region",
"operation",
"identity",
"given",
"the",
"region",
"and",
"operation",
"names",
"."
] | train | https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/deprecated/RegionOperationId.java#L96-L98 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/LoadBalancerBackendAddressPoolsInner.java | LoadBalancerBackendAddressPoolsInner.listAsync | public Observable<Page<BackendAddressPoolInner>> listAsync(final String resourceGroupName, final String loadBalancerName) {
"""
Gets all the load balancer backed address pools.
@param resourceGroupName The name of the resource group.
@param loadBalancerName The name of the load balancer.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<BackendAddressPoolInner> object
"""
return listWithServiceResponseAsync(resourceGroupName, loadBalancerName)
.map(new Func1<ServiceResponse<Page<BackendAddressPoolInner>>, Page<BackendAddressPoolInner>>() {
@Override
public Page<BackendAddressPoolInner> call(ServiceResponse<Page<BackendAddressPoolInner>> response) {
return response.body();
}
});
} | java | public Observable<Page<BackendAddressPoolInner>> listAsync(final String resourceGroupName, final String loadBalancerName) {
return listWithServiceResponseAsync(resourceGroupName, loadBalancerName)
.map(new Func1<ServiceResponse<Page<BackendAddressPoolInner>>, Page<BackendAddressPoolInner>>() {
@Override
public Page<BackendAddressPoolInner> call(ServiceResponse<Page<BackendAddressPoolInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Page",
"<",
"BackendAddressPoolInner",
">",
">",
"listAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"loadBalancerName",
")",
"{",
"return",
"listWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"loadBalancerName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"BackendAddressPoolInner",
">",
">",
",",
"Page",
"<",
"BackendAddressPoolInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"BackendAddressPoolInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"BackendAddressPoolInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets all the load balancer backed address pools.
@param resourceGroupName The name of the resource group.
@param loadBalancerName The name of the load balancer.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<BackendAddressPoolInner> object | [
"Gets",
"all",
"the",
"load",
"balancer",
"backed",
"address",
"pools",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_04_01/src/main/java/com/microsoft/azure/management/network/v2018_04_01/implementation/LoadBalancerBackendAddressPoolsInner.java#L123-L131 |
Cleveroad/AdaptiveTableLayout | library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableManager.java | AdaptiveTableManager.getColumnByXWithShift | int getColumnByXWithShift(int x, int shiftEveryStep) {
"""
Return column number which bounds contains X
@param x coordinate
@return column number
"""
checkForInit();
int sum = 0;
// header offset
int tempX = x - mHeaderRowWidth;
if (tempX <= sum) {
return 0;
}
for (int count = mColumnWidths.length, i = 0; i < count; i++) {
int nextSum = sum + mColumnWidths[i] + shiftEveryStep;
if (tempX > sum && tempX < nextSum) {
return i;
} else if (tempX < nextSum) {
return i - 1;
}
sum = nextSum;
}
return mColumnWidths.length - 1;
} | java | int getColumnByXWithShift(int x, int shiftEveryStep) {
checkForInit();
int sum = 0;
// header offset
int tempX = x - mHeaderRowWidth;
if (tempX <= sum) {
return 0;
}
for (int count = mColumnWidths.length, i = 0; i < count; i++) {
int nextSum = sum + mColumnWidths[i] + shiftEveryStep;
if (tempX > sum && tempX < nextSum) {
return i;
} else if (tempX < nextSum) {
return i - 1;
}
sum = nextSum;
}
return mColumnWidths.length - 1;
} | [
"int",
"getColumnByXWithShift",
"(",
"int",
"x",
",",
"int",
"shiftEveryStep",
")",
"{",
"checkForInit",
"(",
")",
";",
"int",
"sum",
"=",
"0",
";",
"// header offset",
"int",
"tempX",
"=",
"x",
"-",
"mHeaderRowWidth",
";",
"if",
"(",
"tempX",
"<=",
"sum",
")",
"{",
"return",
"0",
";",
"}",
"for",
"(",
"int",
"count",
"=",
"mColumnWidths",
".",
"length",
",",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"int",
"nextSum",
"=",
"sum",
"+",
"mColumnWidths",
"[",
"i",
"]",
"+",
"shiftEveryStep",
";",
"if",
"(",
"tempX",
">",
"sum",
"&&",
"tempX",
"<",
"nextSum",
")",
"{",
"return",
"i",
";",
"}",
"else",
"if",
"(",
"tempX",
"<",
"nextSum",
")",
"{",
"return",
"i",
"-",
"1",
";",
"}",
"sum",
"=",
"nextSum",
";",
"}",
"return",
"mColumnWidths",
".",
"length",
"-",
"1",
";",
"}"
] | Return column number which bounds contains X
@param x coordinate
@return column number | [
"Return",
"column",
"number",
"which",
"bounds",
"contains",
"X"
] | train | https://github.com/Cleveroad/AdaptiveTableLayout/blob/188213b35e05e635497b03fe741799782dde7208/library/src/main/java/com/cleveroad/adaptivetablelayout/AdaptiveTableManager.java#L224-L242 |
looly/hutool | hutool-http/src/main/java/cn/hutool/http/HttpUtil.java | HttpUtil.encodeParams | public static String encodeParams(String paramsStr, Charset charset) {
"""
对URL参数做编码,只编码键和值<br>
提供的值可以是url附带参数,但是不能只是url
@param paramsStr url参数,可以包含url本身
@param charset 编码
@return 编码后的url和参数
@since 4.0.1
"""
if (StrUtil.isBlank(paramsStr)) {
return StrUtil.EMPTY;
}
String urlPart = null; // url部分,不包括问号
String paramPart; // 参数部分
int pathEndPos = paramsStr.indexOf('?');
if (pathEndPos > -1) {
// url + 参数
urlPart = StrUtil.subPre(paramsStr, pathEndPos);
paramPart = StrUtil.subSuf(paramsStr, pathEndPos + 1);
if (StrUtil.isBlank(paramPart)) {
// 无参数,返回url
return urlPart;
}
} else {
// 无URL
paramPart = paramsStr;
}
paramPart = normalizeParams(paramPart, charset);
return StrUtil.isBlank(urlPart) ? paramPart : urlPart + "?" + paramPart;
} | java | public static String encodeParams(String paramsStr, Charset charset) {
if (StrUtil.isBlank(paramsStr)) {
return StrUtil.EMPTY;
}
String urlPart = null; // url部分,不包括问号
String paramPart; // 参数部分
int pathEndPos = paramsStr.indexOf('?');
if (pathEndPos > -1) {
// url + 参数
urlPart = StrUtil.subPre(paramsStr, pathEndPos);
paramPart = StrUtil.subSuf(paramsStr, pathEndPos + 1);
if (StrUtil.isBlank(paramPart)) {
// 无参数,返回url
return urlPart;
}
} else {
// 无URL
paramPart = paramsStr;
}
paramPart = normalizeParams(paramPart, charset);
return StrUtil.isBlank(urlPart) ? paramPart : urlPart + "?" + paramPart;
} | [
"public",
"static",
"String",
"encodeParams",
"(",
"String",
"paramsStr",
",",
"Charset",
"charset",
")",
"{",
"if",
"(",
"StrUtil",
".",
"isBlank",
"(",
"paramsStr",
")",
")",
"{",
"return",
"StrUtil",
".",
"EMPTY",
";",
"}",
"String",
"urlPart",
"=",
"null",
";",
"// url部分,不包括问号\r",
"String",
"paramPart",
";",
"// 参数部分\r",
"int",
"pathEndPos",
"=",
"paramsStr",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"pathEndPos",
">",
"-",
"1",
")",
"{",
"// url + 参数\r",
"urlPart",
"=",
"StrUtil",
".",
"subPre",
"(",
"paramsStr",
",",
"pathEndPos",
")",
";",
"paramPart",
"=",
"StrUtil",
".",
"subSuf",
"(",
"paramsStr",
",",
"pathEndPos",
"+",
"1",
")",
";",
"if",
"(",
"StrUtil",
".",
"isBlank",
"(",
"paramPart",
")",
")",
"{",
"// 无参数,返回url\r",
"return",
"urlPart",
";",
"}",
"}",
"else",
"{",
"// 无URL\r",
"paramPart",
"=",
"paramsStr",
";",
"}",
"paramPart",
"=",
"normalizeParams",
"(",
"paramPart",
",",
"charset",
")",
";",
"return",
"StrUtil",
".",
"isBlank",
"(",
"urlPart",
")",
"?",
"paramPart",
":",
"urlPart",
"+",
"\"?\"",
"+",
"paramPart",
";",
"}"
] | 对URL参数做编码,只编码键和值<br>
提供的值可以是url附带参数,但是不能只是url
@param paramsStr url参数,可以包含url本身
@param charset 编码
@return 编码后的url和参数
@since 4.0.1 | [
"对URL参数做编码,只编码键和值<br",
">",
"提供的值可以是url附带参数,但是不能只是url"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-http/src/main/java/cn/hutool/http/HttpUtil.java#L436-L460 |
Harium/keel | src/main/java/com/harium/keel/catalano/math/ComplexNumber.java | ComplexNumber.Multiply | public static ComplexNumber Multiply(ComplexNumber z1, double scalar) {
"""
Multiply scalar value to a complex number.
@param z1 Complex Number.
@param scalar Scalar value.
@return Returns new ComplexNumber instance containing the multiply of specified complex number with the scalar value.
"""
return new ComplexNumber(z1.real * scalar, z1.imaginary * scalar);
} | java | public static ComplexNumber Multiply(ComplexNumber z1, double scalar) {
return new ComplexNumber(z1.real * scalar, z1.imaginary * scalar);
} | [
"public",
"static",
"ComplexNumber",
"Multiply",
"(",
"ComplexNumber",
"z1",
",",
"double",
"scalar",
")",
"{",
"return",
"new",
"ComplexNumber",
"(",
"z1",
".",
"real",
"*",
"scalar",
",",
"z1",
".",
"imaginary",
"*",
"scalar",
")",
";",
"}"
] | Multiply scalar value to a complex number.
@param z1 Complex Number.
@param scalar Scalar value.
@return Returns new ComplexNumber instance containing the multiply of specified complex number with the scalar value. | [
"Multiply",
"scalar",
"value",
"to",
"a",
"complex",
"number",
"."
] | train | https://github.com/Harium/keel/blob/0369ae674f9e664bccc5f9e161ae7e7a3b949a1e/src/main/java/com/harium/keel/catalano/math/ComplexNumber.java#L327-L329 |
twilliamson/mogwee-logging | src/main/java/com/mogwee/logging/Logger.java | Logger.debugf | public final void debugf(Throwable cause, String message, Object... args) {
"""
Logs a formatted message and stack trace if DEBUG logging is enabled.
@param cause an exception to print stack trace of
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string
"""
logf(Level.DEBUG, cause, message, args);
} | java | public final void debugf(Throwable cause, String message, Object... args)
{
logf(Level.DEBUG, cause, message, args);
} | [
"public",
"final",
"void",
"debugf",
"(",
"Throwable",
"cause",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"logf",
"(",
"Level",
".",
"DEBUG",
",",
"cause",
",",
"message",
",",
"args",
")",
";",
"}"
] | Logs a formatted message and stack trace if DEBUG logging is enabled.
@param cause an exception to print stack trace of
@param message a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax">format string</a>
@param args arguments referenced by the format specifiers in the format string | [
"Logs",
"a",
"formatted",
"message",
"and",
"stack",
"trace",
"if",
"DEBUG",
"logging",
"is",
"enabled",
"."
] | train | https://github.com/twilliamson/mogwee-logging/blob/30b99c2649de455432d956a8f6a74316de4cd62c/src/main/java/com/mogwee/logging/Logger.java#L72-L75 |
SeaCloudsEU/SeaCloudsPlatform | dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java | DeployerProxy.getEntitySensorsValue | public String getEntitySensorsValue(String brooklynId, String brooklynEntityId, String sensorId) throws IOException {
"""
Creates a proxied HTTP GET request to Apache Brooklyn to retrieve Sensors from a particular Entity
@param brooklynId of the desired application to fetch. This ID may differ from SeaClouds Application ID
@param brooklynEntityId of the desired entity. This Entity ID should be children of brooklynId
@param sensorId of the desired sensor. This Sensor ID should be children of brooklynEntityid
@return String representing the sensor value
"""
Invocation invocation = getJerseyClient().target(
getEndpoint() + "/v1/applications/" + brooklynId + "/entities/" + brooklynEntityId + "/sensors/" + sensorId + "?raw=true")
.request().buildGet();
return invocation.invoke().readEntity(String.class);
} | java | public String getEntitySensorsValue(String brooklynId, String brooklynEntityId, String sensorId) throws IOException {
Invocation invocation = getJerseyClient().target(
getEndpoint() + "/v1/applications/" + brooklynId + "/entities/" + brooklynEntityId + "/sensors/" + sensorId + "?raw=true")
.request().buildGet();
return invocation.invoke().readEntity(String.class);
} | [
"public",
"String",
"getEntitySensorsValue",
"(",
"String",
"brooklynId",
",",
"String",
"brooklynEntityId",
",",
"String",
"sensorId",
")",
"throws",
"IOException",
"{",
"Invocation",
"invocation",
"=",
"getJerseyClient",
"(",
")",
".",
"target",
"(",
"getEndpoint",
"(",
")",
"+",
"\"/v1/applications/\"",
"+",
"brooklynId",
"+",
"\"/entities/\"",
"+",
"brooklynEntityId",
"+",
"\"/sensors/\"",
"+",
"sensorId",
"+",
"\"?raw=true\"",
")",
".",
"request",
"(",
")",
".",
"buildGet",
"(",
")",
";",
"return",
"invocation",
".",
"invoke",
"(",
")",
".",
"readEntity",
"(",
"String",
".",
"class",
")",
";",
"}"
] | Creates a proxied HTTP GET request to Apache Brooklyn to retrieve Sensors from a particular Entity
@param brooklynId of the desired application to fetch. This ID may differ from SeaClouds Application ID
@param brooklynEntityId of the desired entity. This Entity ID should be children of brooklynId
@param sensorId of the desired sensor. This Sensor ID should be children of brooklynEntityid
@return String representing the sensor value | [
"Creates",
"a",
"proxied",
"HTTP",
"GET",
"request",
"to",
"Apache",
"Brooklyn",
"to",
"retrieve",
"Sensors",
"from",
"a",
"particular",
"Entity"
] | train | https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/dashboard/src/main/java/eu/seaclouds/platform/dashboard/proxy/DeployerProxy.java#L122-L128 |
Azure/azure-sdk-for-java | cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java | DatabaseAccountsInner.beginFailoverPriorityChangeAsync | public Observable<Void> beginFailoverPriorityChangeAsync(String resourceGroupName, String accountName, List<FailoverPolicy> failoverPolicies) {
"""
Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists.
@param resourceGroupName Name of an Azure resource group.
@param accountName Cosmos DB database account name.
@param failoverPolicies List of failover policies.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful.
"""
return beginFailoverPriorityChangeWithServiceResponseAsync(resourceGroupName, accountName, failoverPolicies).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> beginFailoverPriorityChangeAsync(String resourceGroupName, String accountName, List<FailoverPolicy> failoverPolicies) {
return beginFailoverPriorityChangeWithServiceResponseAsync(resourceGroupName, accountName, failoverPolicies).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"beginFailoverPriorityChangeAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"List",
"<",
"FailoverPolicy",
">",
"failoverPolicies",
")",
"{",
"return",
"beginFailoverPriorityChangeWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"accountName",
",",
"failoverPolicies",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Void",
">",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
"ServiceResponse",
"<",
"Void",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists.
@param resourceGroupName Name of an Azure resource group.
@param accountName Cosmos DB database account name.
@param failoverPolicies List of failover policies.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Changes",
"the",
"failover",
"priority",
"for",
"the",
"Azure",
"Cosmos",
"DB",
"database",
"account",
".",
"A",
"failover",
"priority",
"of",
"0",
"indicates",
"a",
"write",
"region",
".",
"The",
"maximum",
"value",
"for",
"a",
"failover",
"priority",
"=",
"(",
"total",
"number",
"of",
"regions",
"-",
"1",
")",
".",
"Failover",
"priority",
"values",
"must",
"be",
"unique",
"for",
"each",
"of",
"the",
"regions",
"in",
"which",
"the",
"database",
"account",
"exists",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cosmosdb/resource-manager/v2015_04_08/src/main/java/com/microsoft/azure/management/cosmosdb/v2015_04_08/implementation/DatabaseAccountsInner.java#L874-L881 |
tvesalainen/lpg | src/main/java/org/vesalainen/grammar/Grammar.java | Grammar.addAnonymousTerminal | public void addAnonymousTerminal(String expression, Option... options) {
"""
Adds anonymous terminal. Anonymous terminals name is 'expression'
@param expression
@param options
"""
addTerminal(null, "'"+expression+"'", expression, "", 0, 10, options);
} | java | public void addAnonymousTerminal(String expression, Option... options)
{
addTerminal(null, "'"+expression+"'", expression, "", 0, 10, options);
} | [
"public",
"void",
"addAnonymousTerminal",
"(",
"String",
"expression",
",",
"Option",
"...",
"options",
")",
"{",
"addTerminal",
"(",
"null",
",",
"\"'\"",
"+",
"expression",
"+",
"\"'\"",
",",
"expression",
",",
"\"\"",
",",
"0",
",",
"10",
",",
"options",
")",
";",
"}"
] | Adds anonymous terminal. Anonymous terminals name is 'expression'
@param expression
@param options | [
"Adds",
"anonymous",
"terminal",
".",
"Anonymous",
"terminals",
"name",
"is",
"expression"
] | train | https://github.com/tvesalainen/lpg/blob/0917b8d295e9772b9f8a0affc258a08530cd567a/src/main/java/org/vesalainen/grammar/Grammar.java#L348-L351 |
petergeneric/stdlib | guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBNamedResourceFactory.java | JAXBNamedResourceFactory.loadResourceValue | private T loadResourceValue(final URL resource) {
"""
Load from a classpath resource; reloads every time
@param resource
@return
"""
try (final InputStream is = resource.openStream())
{
cached = null; // Prevent the old value from being used
return setCached(clazz.cast(factory.getInstance(clazz).deserialise(is)));
}
catch (IOException e)
{
throw new RuntimeException("Error loading JAXB resource " + name + " " + clazz + " from " + resource, e);
}
} | java | private T loadResourceValue(final URL resource)
{
try (final InputStream is = resource.openStream())
{
cached = null; // Prevent the old value from being used
return setCached(clazz.cast(factory.getInstance(clazz).deserialise(is)));
}
catch (IOException e)
{
throw new RuntimeException("Error loading JAXB resource " + name + " " + clazz + " from " + resource, e);
}
} | [
"private",
"T",
"loadResourceValue",
"(",
"final",
"URL",
"resource",
")",
"{",
"try",
"(",
"final",
"InputStream",
"is",
"=",
"resource",
".",
"openStream",
"(",
")",
")",
"{",
"cached",
"=",
"null",
";",
"// Prevent the old value from being used",
"return",
"setCached",
"(",
"clazz",
".",
"cast",
"(",
"factory",
".",
"getInstance",
"(",
"clazz",
")",
".",
"deserialise",
"(",
"is",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error loading JAXB resource \"",
"+",
"name",
"+",
"\" \"",
"+",
"clazz",
"+",
"\" from \"",
"+",
"resource",
",",
"e",
")",
";",
"}",
"}"
] | Load from a classpath resource; reloads every time
@param resource
@return | [
"Load",
"from",
"a",
"classpath",
"resource",
";",
"reloads",
"every",
"time"
] | train | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/guice/common/src/main/java/com/peterphi/std/guice/common/serviceprops/jaxbref/JAXBNamedResourceFactory.java#L227-L239 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/FastHessianFeatureDetector.java | FastHessianFeatureDetector.detectOctave | protected void detectOctave( II integral , int skip , int ...featureSize ) {
"""
Computes feature intensities for all the specified feature sizes and finds features
inside of the middle feature sizes.
@param integral Integral image.
@param skip Pixel skip factor
@param featureSize which feature sizes should be detected.
"""
int w = integral.width/skip;
int h = integral.height/skip;
// resize the output intensity image taking in account subsampling
for( int i = 0; i < intensity.length; i++ ) {
intensity[i].reshape(w,h);
}
// compute feature intensity in each level
for( int i = 0; i < featureSize.length; i++ ) {
GIntegralImageFeatureIntensity.hessian(integral,skip,featureSize[i],intensity[spaceIndex]);
spaceIndex++;
if( spaceIndex >= 3 )
spaceIndex = 0;
// find maximum in scale space
if( i >= 2 ) {
findLocalScaleSpaceMax(featureSize,i-1,skip);
}
}
} | java | protected void detectOctave( II integral , int skip , int ...featureSize ) {
int w = integral.width/skip;
int h = integral.height/skip;
// resize the output intensity image taking in account subsampling
for( int i = 0; i < intensity.length; i++ ) {
intensity[i].reshape(w,h);
}
// compute feature intensity in each level
for( int i = 0; i < featureSize.length; i++ ) {
GIntegralImageFeatureIntensity.hessian(integral,skip,featureSize[i],intensity[spaceIndex]);
spaceIndex++;
if( spaceIndex >= 3 )
spaceIndex = 0;
// find maximum in scale space
if( i >= 2 ) {
findLocalScaleSpaceMax(featureSize,i-1,skip);
}
}
} | [
"protected",
"void",
"detectOctave",
"(",
"II",
"integral",
",",
"int",
"skip",
",",
"int",
"...",
"featureSize",
")",
"{",
"int",
"w",
"=",
"integral",
".",
"width",
"/",
"skip",
";",
"int",
"h",
"=",
"integral",
".",
"height",
"/",
"skip",
";",
"// resize the output intensity image taking in account subsampling",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"intensity",
".",
"length",
";",
"i",
"++",
")",
"{",
"intensity",
"[",
"i",
"]",
".",
"reshape",
"(",
"w",
",",
"h",
")",
";",
"}",
"// compute feature intensity in each level",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"featureSize",
".",
"length",
";",
"i",
"++",
")",
"{",
"GIntegralImageFeatureIntensity",
".",
"hessian",
"(",
"integral",
",",
"skip",
",",
"featureSize",
"[",
"i",
"]",
",",
"intensity",
"[",
"spaceIndex",
"]",
")",
";",
"spaceIndex",
"++",
";",
"if",
"(",
"spaceIndex",
">=",
"3",
")",
"spaceIndex",
"=",
"0",
";",
"// find maximum in scale space",
"if",
"(",
"i",
">=",
"2",
")",
"{",
"findLocalScaleSpaceMax",
"(",
"featureSize",
",",
"i",
"-",
"1",
",",
"skip",
")",
";",
"}",
"}",
"}"
] | Computes feature intensities for all the specified feature sizes and finds features
inside of the middle feature sizes.
@param integral Integral image.
@param skip Pixel skip factor
@param featureSize which feature sizes should be detected. | [
"Computes",
"feature",
"intensities",
"for",
"all",
"the",
"specified",
"feature",
"sizes",
"and",
"finds",
"features",
"inside",
"of",
"the",
"middle",
"feature",
"sizes",
"."
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/FastHessianFeatureDetector.java#L198-L221 |
TheCoder4eu/BootsFaces-OSP | src/main/java/net/bootsfaces/component/selectBooleanCheckbox/SelectBooleanCheckboxRenderer.java | SelectBooleanCheckboxRenderer.addLabel | protected void addLabel(ResponseWriter rw, String clientId, SelectBooleanCheckbox selectBooleanCheckbox)
throws IOException {
"""
Renders the optional label. This method is protected in order to allow
third-party frameworks to derive from it.
@param rw
the response writer
@param clientId
the id used by the label to reference the input field
@param selectBooleanCheckbox
the component to render
@throws IOException
may be thrown by the response writer
"""
if (selectBooleanCheckbox.isRenderLabel()) {
String label = selectBooleanCheckbox.getLabel();
if (label != null) {
rw.startElement("label", selectBooleanCheckbox);
generateErrorAndRequiredClass(selectBooleanCheckbox, rw, clientId, selectBooleanCheckbox.getLabelStyleClass(), Responsive.getResponsiveLabelClass(selectBooleanCheckbox), "control-label");
writeAttribute(rw, "style", selectBooleanCheckbox.getLabelStyle());
if (null != selectBooleanCheckbox.getDir()) {
rw.writeAttribute("dir", selectBooleanCheckbox.getDir(), "dir");
}
rw.writeAttribute("for", "input_" + clientId, "for");
rw.writeText(label, null);
rw.endElement("label");
}
}
} | java | protected void addLabel(ResponseWriter rw, String clientId, SelectBooleanCheckbox selectBooleanCheckbox)
throws IOException {
if (selectBooleanCheckbox.isRenderLabel()) {
String label = selectBooleanCheckbox.getLabel();
if (label != null) {
rw.startElement("label", selectBooleanCheckbox);
generateErrorAndRequiredClass(selectBooleanCheckbox, rw, clientId, selectBooleanCheckbox.getLabelStyleClass(), Responsive.getResponsiveLabelClass(selectBooleanCheckbox), "control-label");
writeAttribute(rw, "style", selectBooleanCheckbox.getLabelStyle());
if (null != selectBooleanCheckbox.getDir()) {
rw.writeAttribute("dir", selectBooleanCheckbox.getDir(), "dir");
}
rw.writeAttribute("for", "input_" + clientId, "for");
rw.writeText(label, null);
rw.endElement("label");
}
}
} | [
"protected",
"void",
"addLabel",
"(",
"ResponseWriter",
"rw",
",",
"String",
"clientId",
",",
"SelectBooleanCheckbox",
"selectBooleanCheckbox",
")",
"throws",
"IOException",
"{",
"if",
"(",
"selectBooleanCheckbox",
".",
"isRenderLabel",
"(",
")",
")",
"{",
"String",
"label",
"=",
"selectBooleanCheckbox",
".",
"getLabel",
"(",
")",
";",
"if",
"(",
"label",
"!=",
"null",
")",
"{",
"rw",
".",
"startElement",
"(",
"\"label\"",
",",
"selectBooleanCheckbox",
")",
";",
"generateErrorAndRequiredClass",
"(",
"selectBooleanCheckbox",
",",
"rw",
",",
"clientId",
",",
"selectBooleanCheckbox",
".",
"getLabelStyleClass",
"(",
")",
",",
"Responsive",
".",
"getResponsiveLabelClass",
"(",
"selectBooleanCheckbox",
")",
",",
"\"control-label\"",
")",
";",
"writeAttribute",
"(",
"rw",
",",
"\"style\"",
",",
"selectBooleanCheckbox",
".",
"getLabelStyle",
"(",
")",
")",
";",
"if",
"(",
"null",
"!=",
"selectBooleanCheckbox",
".",
"getDir",
"(",
")",
")",
"{",
"rw",
".",
"writeAttribute",
"(",
"\"dir\"",
",",
"selectBooleanCheckbox",
".",
"getDir",
"(",
")",
",",
"\"dir\"",
")",
";",
"}",
"rw",
".",
"writeAttribute",
"(",
"\"for\"",
",",
"\"input_\"",
"+",
"clientId",
",",
"\"for\"",
")",
";",
"rw",
".",
"writeText",
"(",
"label",
",",
"null",
")",
";",
"rw",
".",
"endElement",
"(",
"\"label\"",
")",
";",
"}",
"}",
"}"
] | Renders the optional label. This method is protected in order to allow
third-party frameworks to derive from it.
@param rw
the response writer
@param clientId
the id used by the label to reference the input field
@param selectBooleanCheckbox
the component to render
@throws IOException
may be thrown by the response writer | [
"Renders",
"the",
"optional",
"label",
".",
"This",
"method",
"is",
"protected",
"in",
"order",
"to",
"allow",
"third",
"-",
"party",
"frameworks",
"to",
"derive",
"from",
"it",
"."
] | train | https://github.com/TheCoder4eu/BootsFaces-OSP/blob/d1a70952bc240979b5272fa4fe1c7f100873add0/src/main/java/net/bootsfaces/component/selectBooleanCheckbox/SelectBooleanCheckboxRenderer.java#L147-L165 |
jpush/jmessage-api-java-client | src/main/java/cn/jmessage/api/sensitiveword/SensitiveWordClient.java | SensitiveWordClient.updateSensitiveWord | public ResponseWrapper updateSensitiveWord(String newWord, String oldWord)
throws APIConnectionException, APIRequestException {
"""
Update sensitive word
@param newWord new word
@param oldWord old word
@return No content
@throws APIConnectionException connect exception
@throws APIRequestException request exception
"""
Preconditions.checkArgument(newWord.length() <= 10, "one word's max length is 10");
Preconditions.checkArgument(oldWord.length() <= 10, "one word's max length is 10");
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("new_word", newWord);
jsonObject.addProperty("old_word", oldWord);
return _httpClient.sendPut(_baseUrl + sensitiveWordPath, jsonObject.toString());
} | java | public ResponseWrapper updateSensitiveWord(String newWord, String oldWord)
throws APIConnectionException, APIRequestException {
Preconditions.checkArgument(newWord.length() <= 10, "one word's max length is 10");
Preconditions.checkArgument(oldWord.length() <= 10, "one word's max length is 10");
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("new_word", newWord);
jsonObject.addProperty("old_word", oldWord);
return _httpClient.sendPut(_baseUrl + sensitiveWordPath, jsonObject.toString());
} | [
"public",
"ResponseWrapper",
"updateSensitiveWord",
"(",
"String",
"newWord",
",",
"String",
"oldWord",
")",
"throws",
"APIConnectionException",
",",
"APIRequestException",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"newWord",
".",
"length",
"(",
")",
"<=",
"10",
",",
"\"one word's max length is 10\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"oldWord",
".",
"length",
"(",
")",
"<=",
"10",
",",
"\"one word's max length is 10\"",
")",
";",
"JsonObject",
"jsonObject",
"=",
"new",
"JsonObject",
"(",
")",
";",
"jsonObject",
".",
"addProperty",
"(",
"\"new_word\"",
",",
"newWord",
")",
";",
"jsonObject",
".",
"addProperty",
"(",
"\"old_word\"",
",",
"oldWord",
")",
";",
"return",
"_httpClient",
".",
"sendPut",
"(",
"_baseUrl",
"+",
"sensitiveWordPath",
",",
"jsonObject",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Update sensitive word
@param newWord new word
@param oldWord old word
@return No content
@throws APIConnectionException connect exception
@throws APIRequestException request exception | [
"Update",
"sensitive",
"word"
] | train | https://github.com/jpush/jmessage-api-java-client/blob/767f5fb15e9fe5a546c00f6e68b64f6dd53c617c/src/main/java/cn/jmessage/api/sensitiveword/SensitiveWordClient.java#L77-L85 |
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.setDateLastModified | public void setDateLastModified(CmsDbContext dbc, CmsResource resource, long dateLastModified)
throws CmsDataAccessException {
"""
Changes the "last modified" timestamp of a resource.<p>
@param dbc the current database context
@param resource the resource to touch
@param dateLastModified the new last modified date of the resource
@throws CmsDataAccessException if something goes wrong
@see CmsObject#setDateLastModified(String, long, boolean)
@see I_CmsResourceType#setDateLastModified(CmsObject, CmsSecurityManager, CmsResource, long, boolean)
"""
// modify the last modification date
resource.setDateLastModified(dateLastModified);
if (resource.getState().isUnchanged()) {
resource.setState(CmsResource.STATE_CHANGED);
} else if (resource.getState().isNew() && (resource.getSiblingCount() > 1)) {
// in case of new resources with siblings make sure the state is correct
resource.setState(CmsResource.STATE_CHANGED);
}
resource.setUserLastModified(dbc.currentUser().getId());
getVfsDriver(dbc).writeResourceState(dbc, dbc.currentProject(), resource, UPDATE_RESOURCE, false);
log(
dbc,
new CmsLogEntry(
dbc,
resource.getStructureId(),
CmsLogEntryType.RESOURCE_TOUCHED,
new String[] {resource.getRootPath()}),
false);
// clear the cache
m_monitor.clearResourceCache();
// fire the event
Map<String, Object> data = new HashMap<String, Object>(2);
data.put(I_CmsEventListener.KEY_RESOURCE, resource);
data.put(I_CmsEventListener.KEY_CHANGE, new Integer(CHANGED_LASTMODIFIED));
OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_RESOURCE_MODIFIED, data));
} | java | public void setDateLastModified(CmsDbContext dbc, CmsResource resource, long dateLastModified)
throws CmsDataAccessException {
// modify the last modification date
resource.setDateLastModified(dateLastModified);
if (resource.getState().isUnchanged()) {
resource.setState(CmsResource.STATE_CHANGED);
} else if (resource.getState().isNew() && (resource.getSiblingCount() > 1)) {
// in case of new resources with siblings make sure the state is correct
resource.setState(CmsResource.STATE_CHANGED);
}
resource.setUserLastModified(dbc.currentUser().getId());
getVfsDriver(dbc).writeResourceState(dbc, dbc.currentProject(), resource, UPDATE_RESOURCE, false);
log(
dbc,
new CmsLogEntry(
dbc,
resource.getStructureId(),
CmsLogEntryType.RESOURCE_TOUCHED,
new String[] {resource.getRootPath()}),
false);
// clear the cache
m_monitor.clearResourceCache();
// fire the event
Map<String, Object> data = new HashMap<String, Object>(2);
data.put(I_CmsEventListener.KEY_RESOURCE, resource);
data.put(I_CmsEventListener.KEY_CHANGE, new Integer(CHANGED_LASTMODIFIED));
OpenCms.fireCmsEvent(new CmsEvent(I_CmsEventListener.EVENT_RESOURCE_MODIFIED, data));
} | [
"public",
"void",
"setDateLastModified",
"(",
"CmsDbContext",
"dbc",
",",
"CmsResource",
"resource",
",",
"long",
"dateLastModified",
")",
"throws",
"CmsDataAccessException",
"{",
"// modify the last modification date",
"resource",
".",
"setDateLastModified",
"(",
"dateLastModified",
")",
";",
"if",
"(",
"resource",
".",
"getState",
"(",
")",
".",
"isUnchanged",
"(",
")",
")",
"{",
"resource",
".",
"setState",
"(",
"CmsResource",
".",
"STATE_CHANGED",
")",
";",
"}",
"else",
"if",
"(",
"resource",
".",
"getState",
"(",
")",
".",
"isNew",
"(",
")",
"&&",
"(",
"resource",
".",
"getSiblingCount",
"(",
")",
">",
"1",
")",
")",
"{",
"// in case of new resources with siblings make sure the state is correct",
"resource",
".",
"setState",
"(",
"CmsResource",
".",
"STATE_CHANGED",
")",
";",
"}",
"resource",
".",
"setUserLastModified",
"(",
"dbc",
".",
"currentUser",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"getVfsDriver",
"(",
"dbc",
")",
".",
"writeResourceState",
"(",
"dbc",
",",
"dbc",
".",
"currentProject",
"(",
")",
",",
"resource",
",",
"UPDATE_RESOURCE",
",",
"false",
")",
";",
"log",
"(",
"dbc",
",",
"new",
"CmsLogEntry",
"(",
"dbc",
",",
"resource",
".",
"getStructureId",
"(",
")",
",",
"CmsLogEntryType",
".",
"RESOURCE_TOUCHED",
",",
"new",
"String",
"[",
"]",
"{",
"resource",
".",
"getRootPath",
"(",
")",
"}",
")",
",",
"false",
")",
";",
"// clear the cache",
"m_monitor",
".",
"clearResourceCache",
"(",
")",
";",
"// fire the event",
"Map",
"<",
"String",
",",
"Object",
">",
"data",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
"2",
")",
";",
"data",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_RESOURCE",
",",
"resource",
")",
";",
"data",
".",
"put",
"(",
"I_CmsEventListener",
".",
"KEY_CHANGE",
",",
"new",
"Integer",
"(",
"CHANGED_LASTMODIFIED",
")",
")",
";",
"OpenCms",
".",
"fireCmsEvent",
"(",
"new",
"CmsEvent",
"(",
"I_CmsEventListener",
".",
"EVENT_RESOURCE_MODIFIED",
",",
"data",
")",
")",
";",
"}"
] | Changes the "last modified" timestamp of a resource.<p>
@param dbc the current database context
@param resource the resource to touch
@param dateLastModified the new last modified date of the resource
@throws CmsDataAccessException if something goes wrong
@see CmsObject#setDateLastModified(String, long, boolean)
@see I_CmsResourceType#setDateLastModified(CmsObject, CmsSecurityManager, CmsResource, long, boolean) | [
"Changes",
"the",
"last",
"modified",
"timestamp",
"of",
"a",
"resource",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L8872-L8903 |
liferay/com-liferay-commerce | commerce-product-api/src/main/java/com/liferay/commerce/product/model/CPMeasurementUnitWrapper.java | CPMeasurementUnitWrapper.getName | @Override
public String getName(String languageId, boolean useDefault) {
"""
Returns the localized name of this cp measurement unit in the language, optionally using the default language if no localization exists for the requested language.
@param languageId the ID of the language
@param useDefault whether to use the default language if no localization exists for the requested language
@return the localized name of this cp measurement unit
"""
return _cpMeasurementUnit.getName(languageId, useDefault);
} | java | @Override
public String getName(String languageId, boolean useDefault) {
return _cpMeasurementUnit.getName(languageId, useDefault);
} | [
"@",
"Override",
"public",
"String",
"getName",
"(",
"String",
"languageId",
",",
"boolean",
"useDefault",
")",
"{",
"return",
"_cpMeasurementUnit",
".",
"getName",
"(",
"languageId",
",",
"useDefault",
")",
";",
"}"
] | Returns the localized name of this cp measurement unit in the language, optionally using the default language if no localization exists for the requested language.
@param languageId the ID of the language
@param useDefault whether to use the default language if no localization exists for the requested language
@return the localized name of this cp measurement unit | [
"Returns",
"the",
"localized",
"name",
"of",
"this",
"cp",
"measurement",
"unit",
"in",
"the",
"language",
"optionally",
"using",
"the",
"default",
"language",
"if",
"no",
"localization",
"exists",
"for",
"the",
"requested",
"language",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-product-api/src/main/java/com/liferay/commerce/product/model/CPMeasurementUnitWrapper.java#L321-L324 |
apache/groovy | src/main/groovy/groovy/lang/MetaClassImpl.java | MetaClassImpl.pickMethod | public MetaMethod pickMethod(String methodName, Class[] arguments) {
"""
Selects a method by name and argument classes. This method
does not search for an exact match, it searches for a compatible
method. For this the method selection mechanism is used as provided
by the implementation of this MetaClass. pickMethod may or may
not be used during the method selection process when invoking a method.
There is no warranty for that.
@return a matching MetaMethod or null
@throws GroovyRuntimeException if there is more than one matching method
@param methodName the name of the method to pick
@param arguments the method arguments
"""
return getMethodWithoutCaching(theClass, methodName, arguments, false);
} | java | public MetaMethod pickMethod(String methodName, Class[] arguments) {
return getMethodWithoutCaching(theClass, methodName, arguments, false);
} | [
"public",
"MetaMethod",
"pickMethod",
"(",
"String",
"methodName",
",",
"Class",
"[",
"]",
"arguments",
")",
"{",
"return",
"getMethodWithoutCaching",
"(",
"theClass",
",",
"methodName",
",",
"arguments",
",",
"false",
")",
";",
"}"
] | Selects a method by name and argument classes. This method
does not search for an exact match, it searches for a compatible
method. For this the method selection mechanism is used as provided
by the implementation of this MetaClass. pickMethod may or may
not be used during the method selection process when invoking a method.
There is no warranty for that.
@return a matching MetaMethod or null
@throws GroovyRuntimeException if there is more than one matching method
@param methodName the name of the method to pick
@param arguments the method arguments | [
"Selects",
"a",
"method",
"by",
"name",
"and",
"argument",
"classes",
".",
"This",
"method",
"does",
"not",
"search",
"for",
"an",
"exact",
"match",
"it",
"searches",
"for",
"a",
"compatible",
"method",
".",
"For",
"this",
"the",
"method",
"selection",
"mechanism",
"is",
"used",
"as",
"provided",
"by",
"the",
"implementation",
"of",
"this",
"MetaClass",
".",
"pickMethod",
"may",
"or",
"may",
"not",
"be",
"used",
"during",
"the",
"method",
"selection",
"process",
"when",
"invoking",
"a",
"method",
".",
"There",
"is",
"no",
"warranty",
"for",
"that",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/MetaClassImpl.java#L3909-L3911 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.