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
|
---|---|---|---|---|---|---|---|---|---|---|
apache/groovy | subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java | AstBuilder.visitBuiltInType | @Override
public VariableExpression visitBuiltInType(BuiltInTypeContext ctx) {
"""
/*
@Override
public VariableExpression visitIdentifier(IdentifierContext ctx) {
return this.configureAST(new VariableExpression(ctx.getText()), ctx);
}
"""
String text;
if (asBoolean(ctx.VOID())) {
text = ctx.VOID().getText();
} else if (asBoolean(ctx.BuiltInPrimitiveType())) {
text = ctx.BuiltInPrimitiveType().getText();
} else {
throw createParsingFailedException("Unsupported built-in type: " + ctx, ctx);
}
return configureAST(new VariableExpression(text), ctx);
} | java | @Override
public VariableExpression visitBuiltInType(BuiltInTypeContext ctx) {
String text;
if (asBoolean(ctx.VOID())) {
text = ctx.VOID().getText();
} else if (asBoolean(ctx.BuiltInPrimitiveType())) {
text = ctx.BuiltInPrimitiveType().getText();
} else {
throw createParsingFailedException("Unsupported built-in type: " + ctx, ctx);
}
return configureAST(new VariableExpression(text), ctx);
} | [
"@",
"Override",
"public",
"VariableExpression",
"visitBuiltInType",
"(",
"BuiltInTypeContext",
"ctx",
")",
"{",
"String",
"text",
";",
"if",
"(",
"asBoolean",
"(",
"ctx",
".",
"VOID",
"(",
")",
")",
")",
"{",
"text",
"=",
"ctx",
".",
"VOID",
"(",
")",
".",
"getText",
"(",
")",
";",
"}",
"else",
"if",
"(",
"asBoolean",
"(",
"ctx",
".",
"BuiltInPrimitiveType",
"(",
")",
")",
")",
"{",
"text",
"=",
"ctx",
".",
"BuiltInPrimitiveType",
"(",
")",
".",
"getText",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"createParsingFailedException",
"(",
"\"Unsupported built-in type: \"",
"+",
"ctx",
",",
"ctx",
")",
";",
"}",
"return",
"configureAST",
"(",
"new",
"VariableExpression",
"(",
"text",
")",
",",
"ctx",
")",
";",
"}"
] | /*
@Override
public VariableExpression visitIdentifier(IdentifierContext ctx) {
return this.configureAST(new VariableExpression(ctx.getText()), ctx);
} | [
"/",
"*"
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java#L3437-L3449 |
webmetrics/browsermob-proxy | src/main/java/cz/mallat/uasparser/UASparser.java | UASparser.processOsRegex | private void processOsRegex(String useragent, UserAgentInfo retObj) {
"""
Searches in the os regex table. if found a match copies the os data
@param useragent
@param retObj
"""
try {
lock.lock();
for (Map.Entry<Pattern, Long> entry : osRegMap.entrySet()) {
Matcher matcher = entry.getKey().matcher(useragent);
if (matcher.find()) {
// simply copy the OS data into the result object
Long idOs = entry.getValue();
OsEntry os = osMap.get(idOs);
if (os != null) {
os.copyTo(retObj);
}
break;
}
}
} finally {
lock.unlock();
}
} | java | private void processOsRegex(String useragent, UserAgentInfo retObj) {
try {
lock.lock();
for (Map.Entry<Pattern, Long> entry : osRegMap.entrySet()) {
Matcher matcher = entry.getKey().matcher(useragent);
if (matcher.find()) {
// simply copy the OS data into the result object
Long idOs = entry.getValue();
OsEntry os = osMap.get(idOs);
if (os != null) {
os.copyTo(retObj);
}
break;
}
}
} finally {
lock.unlock();
}
} | [
"private",
"void",
"processOsRegex",
"(",
"String",
"useragent",
",",
"UserAgentInfo",
"retObj",
")",
"{",
"try",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Pattern",
",",
"Long",
">",
"entry",
":",
"osRegMap",
".",
"entrySet",
"(",
")",
")",
"{",
"Matcher",
"matcher",
"=",
"entry",
".",
"getKey",
"(",
")",
".",
"matcher",
"(",
"useragent",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"// simply copy the OS data into the result object",
"Long",
"idOs",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"OsEntry",
"os",
"=",
"osMap",
".",
"get",
"(",
"idOs",
")",
";",
"if",
"(",
"os",
"!=",
"null",
")",
"{",
"os",
".",
"copyTo",
"(",
"retObj",
")",
";",
"}",
"break",
";",
"}",
"}",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Searches in the os regex table. if found a match copies the os data
@param useragent
@param retObj | [
"Searches",
"in",
"the",
"os",
"regex",
"table",
".",
"if",
"found",
"a",
"match",
"copies",
"the",
"os",
"data"
] | train | https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/cz/mallat/uasparser/UASparser.java#L107-L126 |
hawkular/hawkular-commons | hawkular-command-gateway/hawkular-command-gateway-war/src/main/java/org/hawkular/cmdgw/command/ws/server/WebSocketHelper.java | WebSocketHelper.sendBasicMessageAsync | public void sendBasicMessageAsync(Session session, BasicMessage msg) {
"""
Converts the given message to JSON and sends that JSON text to clients asynchronously.
@param session the client session where the JSON message will be sent
@param msg the message to be converted to JSON and sent
"""
String text = ApiDeserializer.toHawkularFormat(msg);
sendTextAsync(session, text);
} | java | public void sendBasicMessageAsync(Session session, BasicMessage msg) {
String text = ApiDeserializer.toHawkularFormat(msg);
sendTextAsync(session, text);
} | [
"public",
"void",
"sendBasicMessageAsync",
"(",
"Session",
"session",
",",
"BasicMessage",
"msg",
")",
"{",
"String",
"text",
"=",
"ApiDeserializer",
".",
"toHawkularFormat",
"(",
"msg",
")",
";",
"sendTextAsync",
"(",
"session",
",",
"text",
")",
";",
"}"
] | Converts the given message to JSON and sends that JSON text to clients asynchronously.
@param session the client session where the JSON message will be sent
@param msg the message to be converted to JSON and sent | [
"Converts",
"the",
"given",
"message",
"to",
"JSON",
"and",
"sends",
"that",
"JSON",
"text",
"to",
"clients",
"asynchronously",
"."
] | train | https://github.com/hawkular/hawkular-commons/blob/e4a832862b3446d7f4d629bb05790f2df578e035/hawkular-command-gateway/hawkular-command-gateway-war/src/main/java/org/hawkular/cmdgw/command/ws/server/WebSocketHelper.java#L80-L83 |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/domain/controller/plan/ServerTaskExecutor.java | ServerTaskExecutor.executeOperation | protected boolean executeOperation(final TransactionalProtocolClient.TransactionalOperationListener<ServerOperation> listener, TransactionalProtocolClient client, final ServerIdentity identity, final ModelNode operation, final OperationResultTransformer transformer) {
"""
Execute the operation.
@param listener the transactional operation listener
@param client the transactional protocol client
@param identity the server identity
@param operation the operation
@param transformer the operation result transformer
@return whether the operation was executed
"""
if(client == null) {
return false;
}
final OperationMessageHandler messageHandler = new DelegatingMessageHandler(context);
final OperationAttachments operationAttachments = new DelegatingOperationAttachments(context);
final ServerOperation serverOperation = new ServerOperation(identity, operation, messageHandler, operationAttachments, transformer);
try {
DomainControllerLogger.HOST_CONTROLLER_LOGGER.tracef("Sending %s to %s", operation, identity);
final Future<OperationResponse> result = client.execute(listener, serverOperation);
recordExecutedRequest(new ExecutedServerRequest(identity, result, transformer));
} catch (IOException e) {
final TransactionalProtocolClient.PreparedOperation<ServerOperation> result = BlockingQueueOperationListener.FailedOperation.create(serverOperation, e);
listener.operationPrepared(result);
recordExecutedRequest(new ExecutedServerRequest(identity, result.getFinalResult(), transformer));
}
return true;
} | java | protected boolean executeOperation(final TransactionalProtocolClient.TransactionalOperationListener<ServerOperation> listener, TransactionalProtocolClient client, final ServerIdentity identity, final ModelNode operation, final OperationResultTransformer transformer) {
if(client == null) {
return false;
}
final OperationMessageHandler messageHandler = new DelegatingMessageHandler(context);
final OperationAttachments operationAttachments = new DelegatingOperationAttachments(context);
final ServerOperation serverOperation = new ServerOperation(identity, operation, messageHandler, operationAttachments, transformer);
try {
DomainControllerLogger.HOST_CONTROLLER_LOGGER.tracef("Sending %s to %s", operation, identity);
final Future<OperationResponse> result = client.execute(listener, serverOperation);
recordExecutedRequest(new ExecutedServerRequest(identity, result, transformer));
} catch (IOException e) {
final TransactionalProtocolClient.PreparedOperation<ServerOperation> result = BlockingQueueOperationListener.FailedOperation.create(serverOperation, e);
listener.operationPrepared(result);
recordExecutedRequest(new ExecutedServerRequest(identity, result.getFinalResult(), transformer));
}
return true;
} | [
"protected",
"boolean",
"executeOperation",
"(",
"final",
"TransactionalProtocolClient",
".",
"TransactionalOperationListener",
"<",
"ServerOperation",
">",
"listener",
",",
"TransactionalProtocolClient",
"client",
",",
"final",
"ServerIdentity",
"identity",
",",
"final",
"ModelNode",
"operation",
",",
"final",
"OperationResultTransformer",
"transformer",
")",
"{",
"if",
"(",
"client",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"final",
"OperationMessageHandler",
"messageHandler",
"=",
"new",
"DelegatingMessageHandler",
"(",
"context",
")",
";",
"final",
"OperationAttachments",
"operationAttachments",
"=",
"new",
"DelegatingOperationAttachments",
"(",
"context",
")",
";",
"final",
"ServerOperation",
"serverOperation",
"=",
"new",
"ServerOperation",
"(",
"identity",
",",
"operation",
",",
"messageHandler",
",",
"operationAttachments",
",",
"transformer",
")",
";",
"try",
"{",
"DomainControllerLogger",
".",
"HOST_CONTROLLER_LOGGER",
".",
"tracef",
"(",
"\"Sending %s to %s\"",
",",
"operation",
",",
"identity",
")",
";",
"final",
"Future",
"<",
"OperationResponse",
">",
"result",
"=",
"client",
".",
"execute",
"(",
"listener",
",",
"serverOperation",
")",
";",
"recordExecutedRequest",
"(",
"new",
"ExecutedServerRequest",
"(",
"identity",
",",
"result",
",",
"transformer",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"final",
"TransactionalProtocolClient",
".",
"PreparedOperation",
"<",
"ServerOperation",
">",
"result",
"=",
"BlockingQueueOperationListener",
".",
"FailedOperation",
".",
"create",
"(",
"serverOperation",
",",
"e",
")",
";",
"listener",
".",
"operationPrepared",
"(",
"result",
")",
";",
"recordExecutedRequest",
"(",
"new",
"ExecutedServerRequest",
"(",
"identity",
",",
"result",
".",
"getFinalResult",
"(",
")",
",",
"transformer",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Execute the operation.
@param listener the transactional operation listener
@param client the transactional protocol client
@param identity the server identity
@param operation the operation
@param transformer the operation result transformer
@return whether the operation was executed | [
"Execute",
"the",
"operation",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/domain/controller/plan/ServerTaskExecutor.java#L113-L130 |
gallandarakhneorg/afc | core/text/src/main/java/org/arakhne/afc/text/TextUtil.java | TextUtil.cutString | @Pure
public static String cutString(String text, int column) {
"""
Format the text to be sure that each line is not
more longer than the specified quantity of characters.
@param text is the string to cut
@param column is the column number that corresponds to the splitting point.
@return the given {@code text} splitted in lines separated by <code>\n</code>.
"""
final StringBuilder buffer = new StringBuilder();
cutStringAlgo(text, new CutStringColumnCritera(column), new CutStringToString(buffer));
return buffer.toString();
} | java | @Pure
public static String cutString(String text, int column) {
final StringBuilder buffer = new StringBuilder();
cutStringAlgo(text, new CutStringColumnCritera(column), new CutStringToString(buffer));
return buffer.toString();
} | [
"@",
"Pure",
"public",
"static",
"String",
"cutString",
"(",
"String",
"text",
",",
"int",
"column",
")",
"{",
"final",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"cutStringAlgo",
"(",
"text",
",",
"new",
"CutStringColumnCritera",
"(",
"column",
")",
",",
"new",
"CutStringToString",
"(",
"buffer",
")",
")",
";",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | Format the text to be sure that each line is not
more longer than the specified quantity of characters.
@param text is the string to cut
@param column is the column number that corresponds to the splitting point.
@return the given {@code text} splitted in lines separated by <code>\n</code>. | [
"Format",
"the",
"text",
"to",
"be",
"sure",
"that",
"each",
"line",
"is",
"not",
"more",
"longer",
"than",
"the",
"specified",
"quantity",
"of",
"characters",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/text/src/main/java/org/arakhne/afc/text/TextUtil.java#L380-L385 |
jtmelton/appsensor | analysis-engines/appsensor-analysis-rules/src/main/java/org/owasp/appsensor/analysis/AggregateEventAnalysisEngine.java | AggregateEventAnalysisEngine.checkRule | protected boolean checkRule(Event triggerEvent, Rule rule) {
"""
Evaluates a {@link Rule}'s logic by compiling a list of all {@link Notification}s
and then evaluating each {@link Expression} within the {@link Rule}. All {@link Expression}s
must evaluate to true within the {@link Rule}'s window for the {@link Rule} to evaluate to
true. The process follows the "sliding window" pattern.
@param event the {@link Event} that triggered analysis
@param rule the {@link Rule} being evaluated
@return the boolean evaluation of the {@link Rule}
"""
Queue<Notification> notifications = getNotifications(triggerEvent, rule);
Queue<Notification> windowedNotifications = new PriorityQueue<Notification>(1, Notification.getStartTimeAscendingComparator());
Iterator<Expression> expressions = rule.getExpressions().iterator();
Expression currentExpression = expressions.next();
Notification tail = null;
while (!notifications.isEmpty()) {
tail = notifications.poll();
windowedNotifications.add(tail);
trim(windowedNotifications, tail.getEndTime().minus(currentExpression.getWindow().toMillis()));
if (checkExpression(currentExpression, windowedNotifications)) {
if (expressions.hasNext()) {
currentExpression = expressions.next();
windowedNotifications = new LinkedList<Notification>();
trim(notifications, tail.getEndTime());
}
else {
return true;
}
}
}
return false;
} | java | protected boolean checkRule(Event triggerEvent, Rule rule) {
Queue<Notification> notifications = getNotifications(triggerEvent, rule);
Queue<Notification> windowedNotifications = new PriorityQueue<Notification>(1, Notification.getStartTimeAscendingComparator());
Iterator<Expression> expressions = rule.getExpressions().iterator();
Expression currentExpression = expressions.next();
Notification tail = null;
while (!notifications.isEmpty()) {
tail = notifications.poll();
windowedNotifications.add(tail);
trim(windowedNotifications, tail.getEndTime().minus(currentExpression.getWindow().toMillis()));
if (checkExpression(currentExpression, windowedNotifications)) {
if (expressions.hasNext()) {
currentExpression = expressions.next();
windowedNotifications = new LinkedList<Notification>();
trim(notifications, tail.getEndTime());
}
else {
return true;
}
}
}
return false;
} | [
"protected",
"boolean",
"checkRule",
"(",
"Event",
"triggerEvent",
",",
"Rule",
"rule",
")",
"{",
"Queue",
"<",
"Notification",
">",
"notifications",
"=",
"getNotifications",
"(",
"triggerEvent",
",",
"rule",
")",
";",
"Queue",
"<",
"Notification",
">",
"windowedNotifications",
"=",
"new",
"PriorityQueue",
"<",
"Notification",
">",
"(",
"1",
",",
"Notification",
".",
"getStartTimeAscendingComparator",
"(",
")",
")",
";",
"Iterator",
"<",
"Expression",
">",
"expressions",
"=",
"rule",
".",
"getExpressions",
"(",
")",
".",
"iterator",
"(",
")",
";",
"Expression",
"currentExpression",
"=",
"expressions",
".",
"next",
"(",
")",
";",
"Notification",
"tail",
"=",
"null",
";",
"while",
"(",
"!",
"notifications",
".",
"isEmpty",
"(",
")",
")",
"{",
"tail",
"=",
"notifications",
".",
"poll",
"(",
")",
";",
"windowedNotifications",
".",
"add",
"(",
"tail",
")",
";",
"trim",
"(",
"windowedNotifications",
",",
"tail",
".",
"getEndTime",
"(",
")",
".",
"minus",
"(",
"currentExpression",
".",
"getWindow",
"(",
")",
".",
"toMillis",
"(",
")",
")",
")",
";",
"if",
"(",
"checkExpression",
"(",
"currentExpression",
",",
"windowedNotifications",
")",
")",
"{",
"if",
"(",
"expressions",
".",
"hasNext",
"(",
")",
")",
"{",
"currentExpression",
"=",
"expressions",
".",
"next",
"(",
")",
";",
"windowedNotifications",
"=",
"new",
"LinkedList",
"<",
"Notification",
">",
"(",
")",
";",
"trim",
"(",
"notifications",
",",
"tail",
".",
"getEndTime",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Evaluates a {@link Rule}'s logic by compiling a list of all {@link Notification}s
and then evaluating each {@link Expression} within the {@link Rule}. All {@link Expression}s
must evaluate to true within the {@link Rule}'s window for the {@link Rule} to evaluate to
true. The process follows the "sliding window" pattern.
@param event the {@link Event} that triggered analysis
@param rule the {@link Rule} being evaluated
@return the boolean evaluation of the {@link Rule} | [
"Evaluates",
"a",
"{",
"@link",
"Rule",
"}",
"s",
"logic",
"by",
"compiling",
"a",
"list",
"of",
"all",
"{",
"@link",
"Notification",
"}",
"s",
"and",
"then",
"evaluating",
"each",
"{",
"@link",
"Expression",
"}",
"within",
"the",
"{",
"@link",
"Rule",
"}",
".",
"All",
"{",
"@link",
"Expression",
"}",
"s",
"must",
"evaluate",
"to",
"true",
"within",
"the",
"{",
"@link",
"Rule",
"}",
"s",
"window",
"for",
"the",
"{",
"@link",
"Rule",
"}",
"to",
"evaluate",
"to",
"true",
".",
"The",
"process",
"follows",
"the",
"sliding",
"window",
"pattern",
"."
] | train | https://github.com/jtmelton/appsensor/blob/c3b4e9ada50fdee974e0d618ec4bdfabc2163798/analysis-engines/appsensor-analysis-rules/src/main/java/org/owasp/appsensor/analysis/AggregateEventAnalysisEngine.java#L82-L107 |
looly/hutool | hutool-bloomFilter/src/main/java/cn/hutool/bloomfilter/BitSetBloomFilter.java | BitSetBloomFilter.init | public void init(String path, String charset) throws IOException {
"""
通过文件初始化过滤器.
@param path 文件路径
@param charset 字符集
@throws IOException IO异常
"""
BufferedReader reader = FileUtil.getReader(path, charset);
try {
String line;
while(true) {
line = reader.readLine();
if(line == null) {
break;
}
this.add(line);
}
}finally {
IoUtil.close(reader);
}
} | java | public void init(String path, String charset) throws IOException {
BufferedReader reader = FileUtil.getReader(path, charset);
try {
String line;
while(true) {
line = reader.readLine();
if(line == null) {
break;
}
this.add(line);
}
}finally {
IoUtil.close(reader);
}
} | [
"public",
"void",
"init",
"(",
"String",
"path",
",",
"String",
"charset",
")",
"throws",
"IOException",
"{",
"BufferedReader",
"reader",
"=",
"FileUtil",
".",
"getReader",
"(",
"path",
",",
"charset",
")",
";",
"try",
"{",
"String",
"line",
";",
"while",
"(",
"true",
")",
"{",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"if",
"(",
"line",
"==",
"null",
")",
"{",
"break",
";",
"}",
"this",
".",
"add",
"(",
"line",
")",
";",
"}",
"}",
"finally",
"{",
"IoUtil",
".",
"close",
"(",
"reader",
")",
";",
"}",
"}"
] | 通过文件初始化过滤器.
@param path 文件路径
@param charset 字符集
@throws IOException IO异常 | [
"通过文件初始化过滤器",
"."
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-bloomFilter/src/main/java/cn/hutool/bloomfilter/BitSetBloomFilter.java#L44-L58 |
Swagger2Markup/swagger2markup | src/main/java/io/github/swagger2markup/Swagger2MarkupProperties.java | Swagger2MarkupProperties.getPathList | public List<Path> getPathList(String key) {
"""
Return a list of Path property values associated with the given key,
or {@code defaultValue} if the key cannot be resolved.
@param key the property name to resolve
@return The list of Path properties
@throws IllegalStateException if the value cannot be mapped to an array of strings
"""
List<Path> pathList = new ArrayList<>();
try {
String[] stringList = configuration.getStringArray(key);
for (String pathStr : stringList) {
pathList.add(Paths.get(pathStr));
}
} catch (ConversionException ce) {
throw new IllegalStateException(String.format("requested key [%s] is not convertable to an array", key));
}
return pathList;
} | java | public List<Path> getPathList(String key) {
List<Path> pathList = new ArrayList<>();
try {
String[] stringList = configuration.getStringArray(key);
for (String pathStr : stringList) {
pathList.add(Paths.get(pathStr));
}
} catch (ConversionException ce) {
throw new IllegalStateException(String.format("requested key [%s] is not convertable to an array", key));
}
return pathList;
} | [
"public",
"List",
"<",
"Path",
">",
"getPathList",
"(",
"String",
"key",
")",
"{",
"List",
"<",
"Path",
">",
"pathList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"{",
"String",
"[",
"]",
"stringList",
"=",
"configuration",
".",
"getStringArray",
"(",
"key",
")",
";",
"for",
"(",
"String",
"pathStr",
":",
"stringList",
")",
"{",
"pathList",
".",
"add",
"(",
"Paths",
".",
"get",
"(",
"pathStr",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ConversionException",
"ce",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"requested key [%s] is not convertable to an array\"",
",",
"key",
")",
")",
";",
"}",
"return",
"pathList",
";",
"}"
] | Return a list of Path property values associated with the given key,
or {@code defaultValue} if the key cannot be resolved.
@param key the property name to resolve
@return The list of Path properties
@throws IllegalStateException if the value cannot be mapped to an array of strings | [
"Return",
"a",
"list",
"of",
"Path",
"property",
"values",
"associated",
"with",
"the",
"given",
"key",
"or",
"{",
"@code",
"defaultValue",
"}",
"if",
"the",
"key",
"cannot",
"be",
"resolved",
"."
] | train | https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/Swagger2MarkupProperties.java#L235-L249 |
alkacon/opencms-core | src/org/opencms/db/CmsSecurityManager.java | CmsSecurityManager.readHistoryProject | public CmsHistoryProject readHistoryProject(CmsRequestContext context, CmsUUID projectId) throws CmsException {
"""
Returns the latest historical project entry with the given id.<p>
@param context the current request context
@param projectId the project id
@return the requested historical project entry
@throws CmsException if something goes wrong
"""
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
CmsHistoryProject result = null;
try {
result = m_driverManager.readHistoryProject(dbc, projectId);
} catch (Exception e) {
dbc.report(
null,
Messages.get().container(
Messages.ERR_READ_HISTORY_PROJECT_2,
projectId,
dbc.currentProject().getName()),
e);
} finally {
dbc.clear();
}
return result;
} | java | public CmsHistoryProject readHistoryProject(CmsRequestContext context, CmsUUID projectId) throws CmsException {
CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
CmsHistoryProject result = null;
try {
result = m_driverManager.readHistoryProject(dbc, projectId);
} catch (Exception e) {
dbc.report(
null,
Messages.get().container(
Messages.ERR_READ_HISTORY_PROJECT_2,
projectId,
dbc.currentProject().getName()),
e);
} finally {
dbc.clear();
}
return result;
} | [
"public",
"CmsHistoryProject",
"readHistoryProject",
"(",
"CmsRequestContext",
"context",
",",
"CmsUUID",
"projectId",
")",
"throws",
"CmsException",
"{",
"CmsDbContext",
"dbc",
"=",
"m_dbContextFactory",
".",
"getDbContext",
"(",
"context",
")",
";",
"CmsHistoryProject",
"result",
"=",
"null",
";",
"try",
"{",
"result",
"=",
"m_driverManager",
".",
"readHistoryProject",
"(",
"dbc",
",",
"projectId",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"dbc",
".",
"report",
"(",
"null",
",",
"Messages",
".",
"get",
"(",
")",
".",
"container",
"(",
"Messages",
".",
"ERR_READ_HISTORY_PROJECT_2",
",",
"projectId",
",",
"dbc",
".",
"currentProject",
"(",
")",
".",
"getName",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"finally",
"{",
"dbc",
".",
"clear",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Returns the latest historical project entry with the given id.<p>
@param context the current request context
@param projectId the project id
@return the requested historical project entry
@throws CmsException if something goes wrong | [
"Returns",
"the",
"latest",
"historical",
"project",
"entry",
"with",
"the",
"given",
"id",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsSecurityManager.java#L4427-L4445 |
Carbonado/Carbonado | src/main/java/com/amazon/carbonado/raw/KeyDecoder.java | KeyDecoder.decodeCharDesc | public static char decodeCharDesc(byte[] src, int srcOffset)
throws CorruptEncodingException {
"""
Decodes a char from exactly 2 bytes, as encoded for descending order.
@param src source of encoded bytes
@param srcOffset offset into source array
@return char value
"""
try {
return (char)~((src[srcOffset] << 8) | (src[srcOffset + 1] & 0xff));
} catch (IndexOutOfBoundsException e) {
throw new CorruptEncodingException(null, e);
}
} | java | public static char decodeCharDesc(byte[] src, int srcOffset)
throws CorruptEncodingException
{
try {
return (char)~((src[srcOffset] << 8) | (src[srcOffset + 1] & 0xff));
} catch (IndexOutOfBoundsException e) {
throw new CorruptEncodingException(null, e);
}
} | [
"public",
"static",
"char",
"decodeCharDesc",
"(",
"byte",
"[",
"]",
"src",
",",
"int",
"srcOffset",
")",
"throws",
"CorruptEncodingException",
"{",
"try",
"{",
"return",
"(",
"char",
")",
"~",
"(",
"(",
"src",
"[",
"srcOffset",
"]",
"<<",
"8",
")",
"|",
"(",
"src",
"[",
"srcOffset",
"+",
"1",
"]",
"&",
"0xff",
")",
")",
";",
"}",
"catch",
"(",
"IndexOutOfBoundsException",
"e",
")",
"{",
"throw",
"new",
"CorruptEncodingException",
"(",
"null",
",",
"e",
")",
";",
"}",
"}"
] | Decodes a char from exactly 2 bytes, as encoded for descending order.
@param src source of encoded bytes
@param srcOffset offset into source array
@return char value | [
"Decodes",
"a",
"char",
"from",
"exactly",
"2",
"bytes",
"as",
"encoded",
"for",
"descending",
"order",
"."
] | train | https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/KeyDecoder.java#L195-L203 |
Domo42/saga-lib | saga-lib-guice/src/main/java/com/codebullets/sagalib/guice/FirstSagaToHandle.java | FirstSagaToHandle.firstExecute | public NextSagaToHandle firstExecute(final Class<? extends Saga> first) {
"""
Define the first saga type to execute in case a message matches multiple ones.
"""
orderedTypes.add(0, first);
return new NextSagaToHandle(orderedTypes, builder);
} | java | public NextSagaToHandle firstExecute(final Class<? extends Saga> first) {
orderedTypes.add(0, first);
return new NextSagaToHandle(orderedTypes, builder);
} | [
"public",
"NextSagaToHandle",
"firstExecute",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Saga",
">",
"first",
")",
"{",
"orderedTypes",
".",
"add",
"(",
"0",
",",
"first",
")",
";",
"return",
"new",
"NextSagaToHandle",
"(",
"orderedTypes",
",",
"builder",
")",
";",
"}"
] | Define the first saga type to execute in case a message matches multiple ones. | [
"Define",
"the",
"first",
"saga",
"type",
"to",
"execute",
"in",
"case",
"a",
"message",
"matches",
"multiple",
"ones",
"."
] | train | https://github.com/Domo42/saga-lib/blob/c8f232e2a51fcb6a3fe0082cfbf105c1e6bf90ef/saga-lib-guice/src/main/java/com/codebullets/sagalib/guice/FirstSagaToHandle.java#L41-L44 |
alkacon/opencms-core | src-gwt/org/opencms/ade/sitemap/client/control/CmsSitemapController.java | CmsSitemapController.isValidEntryAndPath | private boolean isValidEntryAndPath(CmsClientSitemapEntry entry, String toPath) {
"""
Validates the entry and the given path.<p>
@param entry the entry
@param toPath the path
@return <code>true</code> if entry and path are valid
"""
return ((toPath != null)
&& (CmsResource.getParentFolder(toPath) != null)
&& (entry != null)
&& (getEntry(CmsResource.getParentFolder(toPath)) != null)
&& (getEntry(entry.getSitePath()) != null));
} | java | private boolean isValidEntryAndPath(CmsClientSitemapEntry entry, String toPath) {
return ((toPath != null)
&& (CmsResource.getParentFolder(toPath) != null)
&& (entry != null)
&& (getEntry(CmsResource.getParentFolder(toPath)) != null)
&& (getEntry(entry.getSitePath()) != null));
} | [
"private",
"boolean",
"isValidEntryAndPath",
"(",
"CmsClientSitemapEntry",
"entry",
",",
"String",
"toPath",
")",
"{",
"return",
"(",
"(",
"toPath",
"!=",
"null",
")",
"&&",
"(",
"CmsResource",
".",
"getParentFolder",
"(",
"toPath",
")",
"!=",
"null",
")",
"&&",
"(",
"entry",
"!=",
"null",
")",
"&&",
"(",
"getEntry",
"(",
"CmsResource",
".",
"getParentFolder",
"(",
"toPath",
")",
")",
"!=",
"null",
")",
"&&",
"(",
"getEntry",
"(",
"entry",
".",
"getSitePath",
"(",
")",
")",
"!=",
"null",
")",
")",
";",
"}"
] | Validates the entry and the given path.<p>
@param entry the entry
@param toPath the path
@return <code>true</code> if entry and path are valid | [
"Validates",
"the",
"entry",
"and",
"the",
"given",
"path",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/sitemap/client/control/CmsSitemapController.java#L2374-L2381 |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java | ClassUtils.collectInstanceFields | public static Field[] collectInstanceFields(Class<?> c, boolean excludePublic, boolean excludeProtected, boolean excludePrivate) {
"""
Produces an array with all the instance fields of the specified class which match the supplied rules
@param c The class specified
@param excludePublic Exclude public fields if true
@param excludeProtected Exclude protected fields if true
@param excludePrivate Exclude private fields if true
@return The array of matched Fields
"""
int inclusiveModifiers = 0;
int exclusiveModifiers = Modifier.STATIC;
if (excludePrivate) {
exclusiveModifiers += Modifier.PRIVATE;
}
if (excludePublic) {
exclusiveModifiers += Modifier.PUBLIC;
}
if (excludeProtected) {
exclusiveModifiers += Modifier.PROTECTED;
}
return collectFields(c, inclusiveModifiers, exclusiveModifiers);
} | java | public static Field[] collectInstanceFields(Class<?> c, boolean excludePublic, boolean excludeProtected, boolean excludePrivate) {
int inclusiveModifiers = 0;
int exclusiveModifiers = Modifier.STATIC;
if (excludePrivate) {
exclusiveModifiers += Modifier.PRIVATE;
}
if (excludePublic) {
exclusiveModifiers += Modifier.PUBLIC;
}
if (excludeProtected) {
exclusiveModifiers += Modifier.PROTECTED;
}
return collectFields(c, inclusiveModifiers, exclusiveModifiers);
} | [
"public",
"static",
"Field",
"[",
"]",
"collectInstanceFields",
"(",
"Class",
"<",
"?",
">",
"c",
",",
"boolean",
"excludePublic",
",",
"boolean",
"excludeProtected",
",",
"boolean",
"excludePrivate",
")",
"{",
"int",
"inclusiveModifiers",
"=",
"0",
";",
"int",
"exclusiveModifiers",
"=",
"Modifier",
".",
"STATIC",
";",
"if",
"(",
"excludePrivate",
")",
"{",
"exclusiveModifiers",
"+=",
"Modifier",
".",
"PRIVATE",
";",
"}",
"if",
"(",
"excludePublic",
")",
"{",
"exclusiveModifiers",
"+=",
"Modifier",
".",
"PUBLIC",
";",
"}",
"if",
"(",
"excludeProtected",
")",
"{",
"exclusiveModifiers",
"+=",
"Modifier",
".",
"PROTECTED",
";",
"}",
"return",
"collectFields",
"(",
"c",
",",
"inclusiveModifiers",
",",
"exclusiveModifiers",
")",
";",
"}"
] | Produces an array with all the instance fields of the specified class which match the supplied rules
@param c The class specified
@param excludePublic Exclude public fields if true
@param excludeProtected Exclude protected fields if true
@param excludePrivate Exclude private fields if true
@return The array of matched Fields | [
"Produces",
"an",
"array",
"with",
"all",
"the",
"instance",
"fields",
"of",
"the",
"specified",
"class",
"which",
"match",
"the",
"supplied",
"rules"
] | train | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java#L146-L162 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToUnknownStream.java | ToUnknownStream.elementDecl | public void elementDecl(String arg0, String arg1) throws SAXException {
"""
Pass the call on to the underlying handler
@see org.xml.sax.ext.DeclHandler#elementDecl(String, String)
"""
if (m_firstTagNotEmitted)
{
emitFirstTag();
}
m_handler.elementDecl(arg0, arg1);
} | java | public void elementDecl(String arg0, String arg1) throws SAXException
{
if (m_firstTagNotEmitted)
{
emitFirstTag();
}
m_handler.elementDecl(arg0, arg1);
} | [
"public",
"void",
"elementDecl",
"(",
"String",
"arg0",
",",
"String",
"arg1",
")",
"throws",
"SAXException",
"{",
"if",
"(",
"m_firstTagNotEmitted",
")",
"{",
"emitFirstTag",
"(",
")",
";",
"}",
"m_handler",
".",
"elementDecl",
"(",
"arg0",
",",
"arg1",
")",
";",
"}"
] | Pass the call on to the underlying handler
@see org.xml.sax.ext.DeclHandler#elementDecl(String, String) | [
"Pass",
"the",
"call",
"on",
"to",
"the",
"underlying",
"handler"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToUnknownStream.java#L733-L740 |
apiman/apiman | manager/api/war/src/main/java/io/apiman/manager/api/war/WarCdiFactory.java | WarCdiFactory.initEsStorage | private static EsStorage initEsStorage(WarApiManagerConfig config, EsStorage esStorage) {
"""
Initializes the ES storage (if required).
@param config
@param esStorage
"""
if (sESStorage == null) {
sESStorage = esStorage;
sESStorage.setIndexName(config.getStorageESIndexName());
if (config.isInitializeStorageES()) {
sESStorage.initialize();
}
}
return sESStorage;
} | java | private static EsStorage initEsStorage(WarApiManagerConfig config, EsStorage esStorage) {
if (sESStorage == null) {
sESStorage = esStorage;
sESStorage.setIndexName(config.getStorageESIndexName());
if (config.isInitializeStorageES()) {
sESStorage.initialize();
}
}
return sESStorage;
} | [
"private",
"static",
"EsStorage",
"initEsStorage",
"(",
"WarApiManagerConfig",
"config",
",",
"EsStorage",
"esStorage",
")",
"{",
"if",
"(",
"sESStorage",
"==",
"null",
")",
"{",
"sESStorage",
"=",
"esStorage",
";",
"sESStorage",
".",
"setIndexName",
"(",
"config",
".",
"getStorageESIndexName",
"(",
")",
")",
";",
"if",
"(",
"config",
".",
"isInitializeStorageES",
"(",
")",
")",
"{",
"sESStorage",
".",
"initialize",
"(",
")",
";",
"}",
"}",
"return",
"sESStorage",
";",
"}"
] | Initializes the ES storage (if required).
@param config
@param esStorage | [
"Initializes",
"the",
"ES",
"storage",
"(",
"if",
"required",
")",
"."
] | train | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/war/src/main/java/io/apiman/manager/api/war/WarCdiFactory.java#L284-L293 |
stapler/stapler | core/src/main/java/org/kohsuke/stapler/HttpResponses.java | HttpResponses.errorWithoutStack | public static HttpResponseException errorWithoutStack(final int code, final String errorMessage) {
"""
Sends an error without a stack trace.
@since 1.215
@see #error(int, String)
"""
return new HttpResponseException() {
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
rsp.sendError(code, errorMessage);
}
};
} | java | public static HttpResponseException errorWithoutStack(final int code, final String errorMessage) {
return new HttpResponseException() {
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
rsp.sendError(code, errorMessage);
}
};
} | [
"public",
"static",
"HttpResponseException",
"errorWithoutStack",
"(",
"final",
"int",
"code",
",",
"final",
"String",
"errorMessage",
")",
"{",
"return",
"new",
"HttpResponseException",
"(",
")",
"{",
"public",
"void",
"generateResponse",
"(",
"StaplerRequest",
"req",
",",
"StaplerResponse",
"rsp",
",",
"Object",
"node",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"rsp",
".",
"sendError",
"(",
"code",
",",
"errorMessage",
")",
";",
"}",
"}",
";",
"}"
] | Sends an error without a stack trace.
@since 1.215
@see #error(int, String) | [
"Sends",
"an",
"error",
"without",
"a",
"stack",
"trace",
"."
] | train | https://github.com/stapler/stapler/blob/11ad5af185e062fb46e01bf9fbed66f3ebf2a8f7/core/src/main/java/org/kohsuke/stapler/HttpResponses.java#L108-L114 |
joniles/mpxj | src/main/java/net/sf/mpxj/ResourceAssignment.java | ResourceAssignment.setEnterpriseDate | public void setEnterpriseDate(int index, Date value) {
"""
Set an enterprise date value.
@param index date index (1-30)
@param value date value
"""
set(selectField(AssignmentFieldLists.ENTERPRISE_DATE, index), value);
} | java | public void setEnterpriseDate(int index, Date value)
{
set(selectField(AssignmentFieldLists.ENTERPRISE_DATE, index), value);
} | [
"public",
"void",
"setEnterpriseDate",
"(",
"int",
"index",
",",
"Date",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"AssignmentFieldLists",
".",
"ENTERPRISE_DATE",
",",
"index",
")",
",",
"value",
")",
";",
"}"
] | Set an enterprise date value.
@param index date index (1-30)
@param value date value | [
"Set",
"an",
"enterprise",
"date",
"value",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ResourceAssignment.java#L1716-L1719 |
spockframework/spock | spock-core/src/main/java/org/spockframework/compiler/AstUtil.java | AstUtil.fixUpLocalVariables | public static void fixUpLocalVariables(List<? extends Variable> localVariables, VariableScope scope, boolean isClosureScope) {
"""
Fixes up scope references to variables that used to be free or class variables,
and have been changed to local variables.
"""
for (Variable localVar : localVariables) {
Variable scopeVar = scope.getReferencedClassVariable(localVar.getName());
if (scopeVar instanceof DynamicVariable) {
scope.removeReferencedClassVariable(localVar.getName());
scope.putReferencedLocalVariable(localVar);
if (isClosureScope)
localVar.setClosureSharedVariable(true);
}
}
} | java | public static void fixUpLocalVariables(List<? extends Variable> localVariables, VariableScope scope, boolean isClosureScope) {
for (Variable localVar : localVariables) {
Variable scopeVar = scope.getReferencedClassVariable(localVar.getName());
if (scopeVar instanceof DynamicVariable) {
scope.removeReferencedClassVariable(localVar.getName());
scope.putReferencedLocalVariable(localVar);
if (isClosureScope)
localVar.setClosureSharedVariable(true);
}
}
} | [
"public",
"static",
"void",
"fixUpLocalVariables",
"(",
"List",
"<",
"?",
"extends",
"Variable",
">",
"localVariables",
",",
"VariableScope",
"scope",
",",
"boolean",
"isClosureScope",
")",
"{",
"for",
"(",
"Variable",
"localVar",
":",
"localVariables",
")",
"{",
"Variable",
"scopeVar",
"=",
"scope",
".",
"getReferencedClassVariable",
"(",
"localVar",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"scopeVar",
"instanceof",
"DynamicVariable",
")",
"{",
"scope",
".",
"removeReferencedClassVariable",
"(",
"localVar",
".",
"getName",
"(",
")",
")",
";",
"scope",
".",
"putReferencedLocalVariable",
"(",
"localVar",
")",
";",
"if",
"(",
"isClosureScope",
")",
"localVar",
".",
"setClosureSharedVariable",
"(",
"true",
")",
";",
"}",
"}",
"}"
] | Fixes up scope references to variables that used to be free or class variables,
and have been changed to local variables. | [
"Fixes",
"up",
"scope",
"references",
"to",
"variables",
"that",
"used",
"to",
"be",
"free",
"or",
"class",
"variables",
"and",
"have",
"been",
"changed",
"to",
"local",
"variables",
"."
] | train | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/org/spockframework/compiler/AstUtil.java#L326-L336 |
Netflix/Nicobar | nicobar-core/src/main/java/com/netflix/nicobar/core/utils/ClassPathUtils.java | ClassPathUtils.findRootPathForClass | @Nullable
public static Path findRootPathForClass(Class<?> clazz) {
"""
Find the root path for the given class. If the class is found in a Jar file, then the
result will be an absolute path to the jar file. If the resource is found in a directory,
then the result will be the parent path of the given resource.
@param clazz class to search for
@return absolute path of the root of the resource.
"""
Objects.requireNonNull(clazz, "resourceName");
String resourceName = classToResourceName(clazz);
return findRootPathForResource(resourceName, clazz.getClassLoader());
} | java | @Nullable
public static Path findRootPathForClass(Class<?> clazz) {
Objects.requireNonNull(clazz, "resourceName");
String resourceName = classToResourceName(clazz);
return findRootPathForResource(resourceName, clazz.getClassLoader());
} | [
"@",
"Nullable",
"public",
"static",
"Path",
"findRootPathForClass",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"clazz",
",",
"\"resourceName\"",
")",
";",
"String",
"resourceName",
"=",
"classToResourceName",
"(",
"clazz",
")",
";",
"return",
"findRootPathForResource",
"(",
"resourceName",
",",
"clazz",
".",
"getClassLoader",
"(",
")",
")",
";",
"}"
] | Find the root path for the given class. If the class is found in a Jar file, then the
result will be an absolute path to the jar file. If the resource is found in a directory,
then the result will be the parent path of the given resource.
@param clazz class to search for
@return absolute path of the root of the resource. | [
"Find",
"the",
"root",
"path",
"for",
"the",
"given",
"class",
".",
"If",
"the",
"class",
"is",
"found",
"in",
"a",
"Jar",
"file",
"then",
"the",
"result",
"will",
"be",
"an",
"absolute",
"path",
"to",
"the",
"jar",
"file",
".",
"If",
"the",
"resource",
"is",
"found",
"in",
"a",
"directory",
"then",
"the",
"result",
"will",
"be",
"the",
"parent",
"path",
"of",
"the",
"given",
"resource",
"."
] | train | https://github.com/Netflix/Nicobar/blob/507173dcae4a86a955afc3df222a855862fab8d7/nicobar-core/src/main/java/com/netflix/nicobar/core/utils/ClassPathUtils.java#L107-L112 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/IssuesApi.java | IssuesApi.estimateTime | public TimeStats estimateTime(Object projectIdOrPath, Integer issueIid, Duration duration) throws GitLabApiException {
"""
Sets an estimated time of work in this issue
<pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/time_estimate</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param issueIid the internal ID of a project's issue
@param duration set the estimate of time to this duration
@return a TimeSTats instance
@throws GitLabApiException if any exception occurs
"""
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
String durationString = (duration != null ? DurationUtils.toString(duration.getSeconds(), false) : null);
GitLabApiForm formData = new GitLabApiForm().withParam("duration", durationString, true);
Response response = post(Response.Status.OK, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "time_estimate");
return (response.readEntity(TimeStats.class));
} | java | public TimeStats estimateTime(Object projectIdOrPath, Integer issueIid, Duration duration) throws GitLabApiException {
if (issueIid == null) {
throw new RuntimeException("issue IID cannot be null");
}
String durationString = (duration != null ? DurationUtils.toString(duration.getSeconds(), false) : null);
GitLabApiForm formData = new GitLabApiForm().withParam("duration", durationString, true);
Response response = post(Response.Status.OK, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "time_estimate");
return (response.readEntity(TimeStats.class));
} | [
"public",
"TimeStats",
"estimateTime",
"(",
"Object",
"projectIdOrPath",
",",
"Integer",
"issueIid",
",",
"Duration",
"duration",
")",
"throws",
"GitLabApiException",
"{",
"if",
"(",
"issueIid",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"issue IID cannot be null\"",
")",
";",
"}",
"String",
"durationString",
"=",
"(",
"duration",
"!=",
"null",
"?",
"DurationUtils",
".",
"toString",
"(",
"duration",
".",
"getSeconds",
"(",
")",
",",
"false",
")",
":",
"null",
")",
";",
"GitLabApiForm",
"formData",
"=",
"new",
"GitLabApiForm",
"(",
")",
".",
"withParam",
"(",
"\"duration\"",
",",
"durationString",
",",
"true",
")",
";",
"Response",
"response",
"=",
"post",
"(",
"Response",
".",
"Status",
".",
"OK",
",",
"formData",
".",
"asMap",
"(",
")",
",",
"\"projects\"",
",",
"getProjectIdOrPath",
"(",
"projectIdOrPath",
")",
",",
"\"issues\"",
",",
"issueIid",
",",
"\"time_estimate\"",
")",
";",
"return",
"(",
"response",
".",
"readEntity",
"(",
"TimeStats",
".",
"class",
")",
")",
";",
"}"
] | Sets an estimated time of work in this issue
<pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/time_estimate</code></pre>
@param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
@param issueIid the internal ID of a project's issue
@param duration set the estimate of time to this duration
@return a TimeSTats instance
@throws GitLabApiException if any exception occurs | [
"Sets",
"an",
"estimated",
"time",
"of",
"work",
"in",
"this",
"issue"
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/IssuesApi.java#L491-L503 |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/internal/provisioning/api/SamlSettingsApi.java | SamlSettingsApi.sendMetadata | public SendMetadataResponse sendMetadata(File metadataFile, String location) throws ApiException {
"""
Upload new metadata.
Adds or updates the specified metadata.
@param metadataFile The metadata as xml file. (optional)
@param location The region where send metadata. (optional)
@return SendMetadataResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<SendMetadataResponse> resp = sendMetadataWithHttpInfo(metadataFile, location);
return resp.getData();
} | java | public SendMetadataResponse sendMetadata(File metadataFile, String location) throws ApiException {
ApiResponse<SendMetadataResponse> resp = sendMetadataWithHttpInfo(metadataFile, location);
return resp.getData();
} | [
"public",
"SendMetadataResponse",
"sendMetadata",
"(",
"File",
"metadataFile",
",",
"String",
"location",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"SendMetadataResponse",
">",
"resp",
"=",
"sendMetadataWithHttpInfo",
"(",
"metadataFile",
",",
"location",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Upload new metadata.
Adds or updates the specified metadata.
@param metadataFile The metadata as xml file. (optional)
@param location The region where send metadata. (optional)
@return SendMetadataResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Upload",
"new",
"metadata",
".",
"Adds",
"or",
"updates",
"the",
"specified",
"metadata",
"."
] | train | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/internal/provisioning/api/SamlSettingsApi.java#L1118-L1121 |
alkacon/opencms-core | src-gwt/org/opencms/gwt/client/ui/input/colorpicker/CmsColor.java | CmsColor.RGBtoHSV | private void RGBtoHSV(float red, float green, float blue) {
"""
Converts the RGB into the HSV.<p>
@param red value
@param green value
@param blue value
"""
float min = 0;
float max = 0;
float delta = 0;
min = MIN(red, green, blue);
max = MAX(red, green, blue);
m_bri = max; // v
delta = max - min;
if (max != 0) {
m_sat = delta / max; // s
} else {
m_sat = 0;
m_hue = 0;
return;
}
if (delta == 0) {
m_hue = 0;
return;
}
if (red == max) {
m_hue = (green - blue) / delta;
} else if (green == max) {
m_hue = 2 + ((blue - red) / delta);
} else {
m_hue = 4 + ((red - green) / delta);
}
m_hue *= 60;
if (m_hue < 0) {
m_hue += 360;
}
} | java | private void RGBtoHSV(float red, float green, float blue) {
float min = 0;
float max = 0;
float delta = 0;
min = MIN(red, green, blue);
max = MAX(red, green, blue);
m_bri = max; // v
delta = max - min;
if (max != 0) {
m_sat = delta / max; // s
} else {
m_sat = 0;
m_hue = 0;
return;
}
if (delta == 0) {
m_hue = 0;
return;
}
if (red == max) {
m_hue = (green - blue) / delta;
} else if (green == max) {
m_hue = 2 + ((blue - red) / delta);
} else {
m_hue = 4 + ((red - green) / delta);
}
m_hue *= 60;
if (m_hue < 0) {
m_hue += 360;
}
} | [
"private",
"void",
"RGBtoHSV",
"(",
"float",
"red",
",",
"float",
"green",
",",
"float",
"blue",
")",
"{",
"float",
"min",
"=",
"0",
";",
"float",
"max",
"=",
"0",
";",
"float",
"delta",
"=",
"0",
";",
"min",
"=",
"MIN",
"(",
"red",
",",
"green",
",",
"blue",
")",
";",
"max",
"=",
"MAX",
"(",
"red",
",",
"green",
",",
"blue",
")",
";",
"m_bri",
"=",
"max",
";",
"// v\r",
"delta",
"=",
"max",
"-",
"min",
";",
"if",
"(",
"max",
"!=",
"0",
")",
"{",
"m_sat",
"=",
"delta",
"/",
"max",
";",
"// s\r",
"}",
"else",
"{",
"m_sat",
"=",
"0",
";",
"m_hue",
"=",
"0",
";",
"return",
";",
"}",
"if",
"(",
"delta",
"==",
"0",
")",
"{",
"m_hue",
"=",
"0",
";",
"return",
";",
"}",
"if",
"(",
"red",
"==",
"max",
")",
"{",
"m_hue",
"=",
"(",
"green",
"-",
"blue",
")",
"/",
"delta",
";",
"}",
"else",
"if",
"(",
"green",
"==",
"max",
")",
"{",
"m_hue",
"=",
"2",
"+",
"(",
"(",
"blue",
"-",
"red",
")",
"/",
"delta",
")",
";",
"}",
"else",
"{",
"m_hue",
"=",
"4",
"+",
"(",
"(",
"red",
"-",
"green",
")",
"/",
"delta",
")",
";",
"}",
"m_hue",
"*=",
"60",
";",
"if",
"(",
"m_hue",
"<",
"0",
")",
"{",
"m_hue",
"+=",
"360",
";",
"}",
"}"
] | Converts the RGB into the HSV.<p>
@param red value
@param green value
@param blue value | [
"Converts",
"the",
"RGB",
"into",
"the",
"HSV",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/colorpicker/CmsColor.java#L302-L341 |
twilio/twilio-java | src/main/java/com/twilio/base/Page.java | Page.getFirstPageUrl | public String getFirstPageUrl(String domain, String region) {
"""
Generate first page url for a list result.
@param domain domain to use
@param region region to use
@return the first page url
"""
if (firstPageUrl != null) {
return firstPageUrl;
}
return urlFromUri(domain, region, firstPageUri);
} | java | public String getFirstPageUrl(String domain, String region) {
if (firstPageUrl != null) {
return firstPageUrl;
}
return urlFromUri(domain, region, firstPageUri);
} | [
"public",
"String",
"getFirstPageUrl",
"(",
"String",
"domain",
",",
"String",
"region",
")",
"{",
"if",
"(",
"firstPageUrl",
"!=",
"null",
")",
"{",
"return",
"firstPageUrl",
";",
"}",
"return",
"urlFromUri",
"(",
"domain",
",",
"region",
",",
"firstPageUri",
")",
";",
"}"
] | Generate first page url for a list result.
@param domain domain to use
@param region region to use
@return the first page url | [
"Generate",
"first",
"page",
"url",
"for",
"a",
"list",
"result",
"."
] | train | https://github.com/twilio/twilio-java/blob/0318974c0a6a152994af167d430255684d5e9b9f/src/main/java/com/twilio/base/Page.java#L53-L59 |
lucee/Lucee | core/src/main/java/lucee/runtime/db/HSQLDBHandler.java | HSQLDBHandler.removeTable | private static void removeTable(Connection conn, String name) throws SQLException {
"""
remove a table from the memory database
@param conn
@param name
@throws DatabaseException
"""
name = name.replace('.', '_');
Statement stat = conn.createStatement();
stat.execute("DROP TABLE " + name);
DBUtil.commitEL(conn);
} | java | private static void removeTable(Connection conn, String name) throws SQLException {
name = name.replace('.', '_');
Statement stat = conn.createStatement();
stat.execute("DROP TABLE " + name);
DBUtil.commitEL(conn);
} | [
"private",
"static",
"void",
"removeTable",
"(",
"Connection",
"conn",
",",
"String",
"name",
")",
"throws",
"SQLException",
"{",
"name",
"=",
"name",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"Statement",
"stat",
"=",
"conn",
".",
"createStatement",
"(",
")",
";",
"stat",
".",
"execute",
"(",
"\"DROP TABLE \"",
"+",
"name",
")",
";",
"DBUtil",
".",
"commitEL",
"(",
"conn",
")",
";",
"}"
] | remove a table from the memory database
@param conn
@param name
@throws DatabaseException | [
"remove",
"a",
"table",
"from",
"the",
"memory",
"database"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/db/HSQLDBHandler.java#L200-L205 |
graknlabs/grakn | server/src/graql/gremlin/sets/EquivalentFragmentSets.java | EquivalentFragmentSets.isa | public static EquivalentFragmentSet isa(
VarProperty varProperty, Variable instance, Variable type, boolean mayHaveEdgeInstances) {
"""
An {@link EquivalentFragmentSet} that indicates a variable is a direct instance of a type.
"""
return new AutoValue_IsaFragmentSet(varProperty, instance, type, mayHaveEdgeInstances);
} | java | public static EquivalentFragmentSet isa(
VarProperty varProperty, Variable instance, Variable type, boolean mayHaveEdgeInstances) {
return new AutoValue_IsaFragmentSet(varProperty, instance, type, mayHaveEdgeInstances);
} | [
"public",
"static",
"EquivalentFragmentSet",
"isa",
"(",
"VarProperty",
"varProperty",
",",
"Variable",
"instance",
",",
"Variable",
"type",
",",
"boolean",
"mayHaveEdgeInstances",
")",
"{",
"return",
"new",
"AutoValue_IsaFragmentSet",
"(",
"varProperty",
",",
"instance",
",",
"type",
",",
"mayHaveEdgeInstances",
")",
";",
"}"
] | An {@link EquivalentFragmentSet} that indicates a variable is a direct instance of a type. | [
"An",
"{"
] | train | https://github.com/graknlabs/grakn/blob/6aaee75ea846202474d591f8809d62028262fac5/server/src/graql/gremlin/sets/EquivalentFragmentSets.java#L113-L116 |
jirutka/spring-rest-exception-handler | src/main/java/cz/jirutka/spring/exhandler/RestHandlerExceptionResolverBuilder.java | RestHandlerExceptionResolverBuilder.addHandler | public <E extends Exception>
RestHandlerExceptionResolverBuilder addHandler(AbstractRestExceptionHandler<E, ?> exceptionHandler) {
"""
Same as {@link #addHandler(Class, RestExceptionHandler)}, but the exception type is
determined from the handler.
"""
return addHandler(exceptionHandler.getExceptionClass(), exceptionHandler);
} | java | public <E extends Exception>
RestHandlerExceptionResolverBuilder addHandler(AbstractRestExceptionHandler<E, ?> exceptionHandler) {
return addHandler(exceptionHandler.getExceptionClass(), exceptionHandler);
} | [
"public",
"<",
"E",
"extends",
"Exception",
">",
"RestHandlerExceptionResolverBuilder",
"addHandler",
"(",
"AbstractRestExceptionHandler",
"<",
"E",
",",
"?",
">",
"exceptionHandler",
")",
"{",
"return",
"addHandler",
"(",
"exceptionHandler",
".",
"getExceptionClass",
"(",
")",
",",
"exceptionHandler",
")",
";",
"}"
] | Same as {@link #addHandler(Class, RestExceptionHandler)}, but the exception type is
determined from the handler. | [
"Same",
"as",
"{"
] | train | https://github.com/jirutka/spring-rest-exception-handler/blob/f171956e59fe866f1a853c7d38444f136acc7a3b/src/main/java/cz/jirutka/spring/exhandler/RestHandlerExceptionResolverBuilder.java#L198-L202 |
apache/groovy | src/main/groovy/groovy/util/FactoryBuilderSupport.java | FactoryBuilderSupport.withBuilder | public Object withBuilder(FactoryBuilderSupport builder, Closure closure) {
"""
Switches the builder's proxyBuilder during the execution of a closure.<br>
This is useful to temporary change the building context to another builder
without the need for a contrived setup. It will also take care of restoring
the previous proxyBuilder when the execution finishes, even if an exception
was thrown from inside the closure.
@param builder the temporary builder to switch to as proxyBuilder.
@param closure the closure to be executed under the temporary builder.
@return the execution result of the closure.
@throws RuntimeException - any exception the closure might have thrown during
execution.
"""
if (builder == null || closure == null) {
return null;
}
Object result = null;
Object previousContext = getProxyBuilder().getContext();
FactoryBuilderSupport previousProxyBuilder = localProxyBuilder.get();
try {
localProxyBuilder.set(builder);
closure.setDelegate(builder);
result = closure.call();
}
catch (RuntimeException e) {
// remove contexts created after we started
localProxyBuilder.set(previousProxyBuilder);
if (getProxyBuilder().getContexts().contains(previousContext)) {
Map<String, Object> context = getProxyBuilder().getContext();
while (context != null && context != previousContext) {
getProxyBuilder().popContext();
context = getProxyBuilder().getContext();
}
}
throw e;
}
finally {
localProxyBuilder.set(previousProxyBuilder);
}
return result;
} | java | public Object withBuilder(FactoryBuilderSupport builder, Closure closure) {
if (builder == null || closure == null) {
return null;
}
Object result = null;
Object previousContext = getProxyBuilder().getContext();
FactoryBuilderSupport previousProxyBuilder = localProxyBuilder.get();
try {
localProxyBuilder.set(builder);
closure.setDelegate(builder);
result = closure.call();
}
catch (RuntimeException e) {
// remove contexts created after we started
localProxyBuilder.set(previousProxyBuilder);
if (getProxyBuilder().getContexts().contains(previousContext)) {
Map<String, Object> context = getProxyBuilder().getContext();
while (context != null && context != previousContext) {
getProxyBuilder().popContext();
context = getProxyBuilder().getContext();
}
}
throw e;
}
finally {
localProxyBuilder.set(previousProxyBuilder);
}
return result;
} | [
"public",
"Object",
"withBuilder",
"(",
"FactoryBuilderSupport",
"builder",
",",
"Closure",
"closure",
")",
"{",
"if",
"(",
"builder",
"==",
"null",
"||",
"closure",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Object",
"result",
"=",
"null",
";",
"Object",
"previousContext",
"=",
"getProxyBuilder",
"(",
")",
".",
"getContext",
"(",
")",
";",
"FactoryBuilderSupport",
"previousProxyBuilder",
"=",
"localProxyBuilder",
".",
"get",
"(",
")",
";",
"try",
"{",
"localProxyBuilder",
".",
"set",
"(",
"builder",
")",
";",
"closure",
".",
"setDelegate",
"(",
"builder",
")",
";",
"result",
"=",
"closure",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"// remove contexts created after we started",
"localProxyBuilder",
".",
"set",
"(",
"previousProxyBuilder",
")",
";",
"if",
"(",
"getProxyBuilder",
"(",
")",
".",
"getContexts",
"(",
")",
".",
"contains",
"(",
"previousContext",
")",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"context",
"=",
"getProxyBuilder",
"(",
")",
".",
"getContext",
"(",
")",
";",
"while",
"(",
"context",
"!=",
"null",
"&&",
"context",
"!=",
"previousContext",
")",
"{",
"getProxyBuilder",
"(",
")",
".",
"popContext",
"(",
")",
";",
"context",
"=",
"getProxyBuilder",
"(",
")",
".",
"getContext",
"(",
")",
";",
"}",
"}",
"throw",
"e",
";",
"}",
"finally",
"{",
"localProxyBuilder",
".",
"set",
"(",
"previousProxyBuilder",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Switches the builder's proxyBuilder during the execution of a closure.<br>
This is useful to temporary change the building context to another builder
without the need for a contrived setup. It will also take care of restoring
the previous proxyBuilder when the execution finishes, even if an exception
was thrown from inside the closure.
@param builder the temporary builder to switch to as proxyBuilder.
@param closure the closure to be executed under the temporary builder.
@return the execution result of the closure.
@throws RuntimeException - any exception the closure might have thrown during
execution. | [
"Switches",
"the",
"builder",
"s",
"proxyBuilder",
"during",
"the",
"execution",
"of",
"a",
"closure",
".",
"<br",
">",
"This",
"is",
"useful",
"to",
"temporary",
"change",
"the",
"building",
"context",
"to",
"another",
"builder",
"without",
"the",
"need",
"for",
"a",
"contrived",
"setup",
".",
"It",
"will",
"also",
"take",
"care",
"of",
"restoring",
"the",
"previous",
"proxyBuilder",
"when",
"the",
"execution",
"finishes",
"even",
"if",
"an",
"exception",
"was",
"thrown",
"from",
"inside",
"the",
"closure",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/FactoryBuilderSupport.java#L1205-L1235 |
undertow-io/undertow | core/src/main/java/io/undertow/websockets/core/protocol/version07/Base64.java | Base64.encodeBytes | public static String encodeBytes(byte[] source, int off, int len, int options) throws java.io.IOException {
"""
Encodes a byte array into Base64 notation.
<p>
Example options:
<pre>
GZIP: gzip-compresses object before encoding it.
DO_BREAK_LINES: break lines at 76 characters
<i>Note: Technically, this makes your encoding non-compliant.</i>
</pre>
<p>
Example: <code>encodeBytes( myData, Base64.GZIP )</code> or
<p>
Example: <code>encodeBytes( myData, Base64.GZIP | Base64.DO_BREAK_LINES )</code>
<p>
As of v 2.3, if there is an error with the GZIP stream, the method will throw an java.io.IOException. <b>This is new to
v2.3!</b> In earlier versions, it just returned a null value, but in retrospect that's a pretty poor way to handle it.
</p>
@param source The data to convert
@param off Offset in array where conversion should begin
@param len Length of data to convert
@param options Specified options
@return The Base64-encoded data as a String
@see Base64#GZIP
@see Base64#DO_BREAK_LINES
@throws java.io.IOException if there is an error
@throws NullPointerException if source array is null
@throws IllegalArgumentException if source array, offset, or length are invalid
@since 2.0
"""
byte[] encoded = encodeBytesToBytes(source, off, len, options);
// Return value according to relevant encoding.
return new String(encoded, StandardCharsets.US_ASCII);
} | java | public static String encodeBytes(byte[] source, int off, int len, int options) throws java.io.IOException {
byte[] encoded = encodeBytesToBytes(source, off, len, options);
// Return value according to relevant encoding.
return new String(encoded, StandardCharsets.US_ASCII);
} | [
"public",
"static",
"String",
"encodeBytes",
"(",
"byte",
"[",
"]",
"source",
",",
"int",
"off",
",",
"int",
"len",
",",
"int",
"options",
")",
"throws",
"java",
".",
"io",
".",
"IOException",
"{",
"byte",
"[",
"]",
"encoded",
"=",
"encodeBytesToBytes",
"(",
"source",
",",
"off",
",",
"len",
",",
"options",
")",
";",
"// Return value according to relevant encoding.",
"return",
"new",
"String",
"(",
"encoded",
",",
"StandardCharsets",
".",
"US_ASCII",
")",
";",
"}"
] | Encodes a byte array into Base64 notation.
<p>
Example options:
<pre>
GZIP: gzip-compresses object before encoding it.
DO_BREAK_LINES: break lines at 76 characters
<i>Note: Technically, this makes your encoding non-compliant.</i>
</pre>
<p>
Example: <code>encodeBytes( myData, Base64.GZIP )</code> or
<p>
Example: <code>encodeBytes( myData, Base64.GZIP | Base64.DO_BREAK_LINES )</code>
<p>
As of v 2.3, if there is an error with the GZIP stream, the method will throw an java.io.IOException. <b>This is new to
v2.3!</b> In earlier versions, it just returned a null value, but in retrospect that's a pretty poor way to handle it.
</p>
@param source The data to convert
@param off Offset in array where conversion should begin
@param len Length of data to convert
@param options Specified options
@return The Base64-encoded data as a String
@see Base64#GZIP
@see Base64#DO_BREAK_LINES
@throws java.io.IOException if there is an error
@throws NullPointerException if source array is null
@throws IllegalArgumentException if source array, offset, or length are invalid
@since 2.0 | [
"Encodes",
"a",
"byte",
"array",
"into",
"Base64",
"notation",
".",
"<p",
">",
"Example",
"options",
":"
] | train | https://github.com/undertow-io/undertow/blob/87de0b856a7a4ba8faf5b659537b9af07b763263/core/src/main/java/io/undertow/websockets/core/protocol/version07/Base64.java#L760-L766 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/lss/LssClient.java | LssClient.queryAppStream | public GetAppStreamResponse queryAppStream(GetAppStreamRequest request) {
"""
get detail of your stream by app name and stream name
@param request The request object containing all parameters for query app stream.
@return the response
"""
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string.");
checkStringNotEmpty(request.getStream(), "The parameter stream should NOT be null or empty string.");
InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_APP,
request.getApp(), LIVE_SESSION, request.getStream());
return invokeHttpClient(internalRequest, GetAppStreamResponse.class);
} | java | public GetAppStreamResponse queryAppStream(GetAppStreamRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string.");
checkStringNotEmpty(request.getStream(), "The parameter stream should NOT be null or empty string.");
InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_APP,
request.getApp(), LIVE_SESSION, request.getStream());
return invokeHttpClient(internalRequest, GetAppStreamResponse.class);
} | [
"public",
"GetAppStreamResponse",
"queryAppStream",
"(",
"GetAppStreamRequest",
"request",
")",
"{",
"checkNotNull",
"(",
"request",
",",
"\"The parameter request should NOT be null.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getApp",
"(",
")",
",",
"\"The parameter app should NOT be null or empty string.\"",
")",
";",
"checkStringNotEmpty",
"(",
"request",
".",
"getStream",
"(",
")",
",",
"\"The parameter stream should NOT be null or empty string.\"",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"createRequest",
"(",
"HttpMethodName",
".",
"GET",
",",
"request",
",",
"LIVE_APP",
",",
"request",
".",
"getApp",
"(",
")",
",",
"LIVE_SESSION",
",",
"request",
".",
"getStream",
"(",
")",
")",
";",
"return",
"invokeHttpClient",
"(",
"internalRequest",
",",
"GetAppStreamResponse",
".",
"class",
")",
";",
"}"
] | get detail of your stream by app name and stream name
@param request The request object containing all parameters for query app stream.
@return the response | [
"get",
"detail",
"of",
"your",
"stream",
"by",
"app",
"name",
"and",
"stream",
"name"
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/lss/LssClient.java#L847-L854 |
apache/incubator-gobblin | gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleAnalyticsUnsampledExtractor.java | GoogleAnalyticsUnsampledExtractor.copyOf | private WorkUnitState copyOf(WorkUnitState src) {
"""
Copy WorkUnitState so that work unit also contains job state. FileBasedExtractor needs properties from job state (mostly source.* properties),
where it has been already removed when reached here.
@param src
@return
"""
WorkUnit copiedWorkUnit = WorkUnit.copyOf(src.getWorkunit());
copiedWorkUnit.addAllIfNotExist(src.getJobState());
WorkUnitState workUnitState = new WorkUnitState(copiedWorkUnit, src.getJobState());
workUnitState.addAll(src);
return workUnitState;
} | java | private WorkUnitState copyOf(WorkUnitState src) {
WorkUnit copiedWorkUnit = WorkUnit.copyOf(src.getWorkunit());
copiedWorkUnit.addAllIfNotExist(src.getJobState());
WorkUnitState workUnitState = new WorkUnitState(copiedWorkUnit, src.getJobState());
workUnitState.addAll(src);
return workUnitState;
} | [
"private",
"WorkUnitState",
"copyOf",
"(",
"WorkUnitState",
"src",
")",
"{",
"WorkUnit",
"copiedWorkUnit",
"=",
"WorkUnit",
".",
"copyOf",
"(",
"src",
".",
"getWorkunit",
"(",
")",
")",
";",
"copiedWorkUnit",
".",
"addAllIfNotExist",
"(",
"src",
".",
"getJobState",
"(",
")",
")",
";",
"WorkUnitState",
"workUnitState",
"=",
"new",
"WorkUnitState",
"(",
"copiedWorkUnit",
",",
"src",
".",
"getJobState",
"(",
")",
")",
";",
"workUnitState",
".",
"addAll",
"(",
"src",
")",
";",
"return",
"workUnitState",
";",
"}"
] | Copy WorkUnitState so that work unit also contains job state. FileBasedExtractor needs properties from job state (mostly source.* properties),
where it has been already removed when reached here.
@param src
@return | [
"Copy",
"WorkUnitState",
"so",
"that",
"work",
"unit",
"also",
"contains",
"job",
"state",
".",
"FileBasedExtractor",
"needs",
"properties",
"from",
"job",
"state",
"(",
"mostly",
"source",
".",
"*",
"properties",
")",
"where",
"it",
"has",
"been",
"already",
"removed",
"when",
"reached",
"here",
"."
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleAnalyticsUnsampledExtractor.java#L192-L199 |
loldevs/riotapi | rest/src/main/java/net/boreeas/riotapi/rest/ThrottledApiHandler.java | ThrottledApiHandler.getRuneList | public Future<RuneList> getRuneList(ItemData data, String version, String locale) {
"""
<p>
Get a list of all runes
</p>
This method does not count towards the rate limit and is not affected by the throttle
@param data Additional information to retrieve
@param version Data dragon version for returned data
@param locale Locale code for returned data
@return All runes
@see <a href=https://developer.riotgames.com/api/methods#!/649/2172>Official API documentation</a>
"""
return new DummyFuture<>(handler.getRuneList(data, version, locale));
} | java | public Future<RuneList> getRuneList(ItemData data, String version, String locale) {
return new DummyFuture<>(handler.getRuneList(data, version, locale));
} | [
"public",
"Future",
"<",
"RuneList",
">",
"getRuneList",
"(",
"ItemData",
"data",
",",
"String",
"version",
",",
"String",
"locale",
")",
"{",
"return",
"new",
"DummyFuture",
"<>",
"(",
"handler",
".",
"getRuneList",
"(",
"data",
",",
"version",
",",
"locale",
")",
")",
";",
"}"
] | <p>
Get a list of all runes
</p>
This method does not count towards the rate limit and is not affected by the throttle
@param data Additional information to retrieve
@param version Data dragon version for returned data
@param locale Locale code for returned data
@return All runes
@see <a href=https://developer.riotgames.com/api/methods#!/649/2172>Official API documentation</a> | [
"<p",
">",
"Get",
"a",
"list",
"of",
"all",
"runes",
"<",
"/",
"p",
">",
"This",
"method",
"does",
"not",
"count",
"towards",
"the",
"rate",
"limit",
"and",
"is",
"not",
"affected",
"by",
"the",
"throttle"
] | train | https://github.com/loldevs/riotapi/blob/0b8aac407aa5289845f249024f9732332855544f/rest/src/main/java/net/boreeas/riotapi/rest/ThrottledApiHandler.java#L657-L659 |
looly/hutool | hutool-db/src/main/java/cn/hutool/db/StatementUtil.java | StatementUtil.fillParams | public static PreparedStatement fillParams(PreparedStatement ps, Collection<Object> params) throws SQLException {
"""
填充SQL的参数。
@param ps PreparedStatement
@param params SQL参数
@return {@link PreparedStatement}
@throws SQLException SQL执行异常
"""
return fillParams(ps, params.toArray(new Object[params.size()]));
} | java | public static PreparedStatement fillParams(PreparedStatement ps, Collection<Object> params) throws SQLException {
return fillParams(ps, params.toArray(new Object[params.size()]));
} | [
"public",
"static",
"PreparedStatement",
"fillParams",
"(",
"PreparedStatement",
"ps",
",",
"Collection",
"<",
"Object",
">",
"params",
")",
"throws",
"SQLException",
"{",
"return",
"fillParams",
"(",
"ps",
",",
"params",
".",
"toArray",
"(",
"new",
"Object",
"[",
"params",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}"
] | 填充SQL的参数。
@param ps PreparedStatement
@param params SQL参数
@return {@link PreparedStatement}
@throws SQLException SQL执行异常 | [
"填充SQL的参数。"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-db/src/main/java/cn/hutool/db/StatementUtil.java#L40-L42 |
heroku/heroku.jar | heroku-api/src/main/java/com/heroku/api/HerokuAPI.java | HerokuAPI.addAddon | public AddonChange addAddon(String appName, String addonName) {
"""
Add an addon to the app.
@param appName App name. See {@link #listApps} for a list of apps that can be used.
@param addonName Addon name. See {@link #listAllAddons} to get a list of addons that can be used.
@return The request object
"""
return connection.execute(new AddonInstall(appName, addonName), apiKey);
} | java | public AddonChange addAddon(String appName, String addonName) {
return connection.execute(new AddonInstall(appName, addonName), apiKey);
} | [
"public",
"AddonChange",
"addAddon",
"(",
"String",
"appName",
",",
"String",
"addonName",
")",
"{",
"return",
"connection",
".",
"execute",
"(",
"new",
"AddonInstall",
"(",
"appName",
",",
"addonName",
")",
",",
"apiKey",
")",
";",
"}"
] | Add an addon to the app.
@param appName App name. See {@link #listApps} for a list of apps that can be used.
@param addonName Addon name. See {@link #listAllAddons} to get a list of addons that can be used.
@return The request object | [
"Add",
"an",
"addon",
"to",
"the",
"app",
"."
] | train | https://github.com/heroku/heroku.jar/blob/d9e52991293159498c10c498c6f91fcdd637378e/heroku-api/src/main/java/com/heroku/api/HerokuAPI.java#L214-L216 |
apache/groovy | src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java | ExpressionUtils.isNumberOrArrayOfNumber | public static boolean isNumberOrArrayOfNumber(ClassNode targetType, boolean recurse) {
"""
Determine if a type is derived from Number (or array thereof).
@param targetType the candidate type
@param recurse true if we can have multi-dimension arrays; should be false for annotation member types
@return true if the type equals the targetType or array thereof
"""
if (targetType == null) return false;
return targetType.isDerivedFrom(ClassHelper.Number_TYPE) ||
(targetType.isArray() && recurse
? isNumberOrArrayOfNumber(targetType.getComponentType(), recurse)
: targetType.isArray() && targetType.getComponentType().isDerivedFrom(ClassHelper.Number_TYPE));
} | java | public static boolean isNumberOrArrayOfNumber(ClassNode targetType, boolean recurse) {
if (targetType == null) return false;
return targetType.isDerivedFrom(ClassHelper.Number_TYPE) ||
(targetType.isArray() && recurse
? isNumberOrArrayOfNumber(targetType.getComponentType(), recurse)
: targetType.isArray() && targetType.getComponentType().isDerivedFrom(ClassHelper.Number_TYPE));
} | [
"public",
"static",
"boolean",
"isNumberOrArrayOfNumber",
"(",
"ClassNode",
"targetType",
",",
"boolean",
"recurse",
")",
"{",
"if",
"(",
"targetType",
"==",
"null",
")",
"return",
"false",
";",
"return",
"targetType",
".",
"isDerivedFrom",
"(",
"ClassHelper",
".",
"Number_TYPE",
")",
"||",
"(",
"targetType",
".",
"isArray",
"(",
")",
"&&",
"recurse",
"?",
"isNumberOrArrayOfNumber",
"(",
"targetType",
".",
"getComponentType",
"(",
")",
",",
"recurse",
")",
":",
"targetType",
".",
"isArray",
"(",
")",
"&&",
"targetType",
".",
"getComponentType",
"(",
")",
".",
"isDerivedFrom",
"(",
"ClassHelper",
".",
"Number_TYPE",
")",
")",
";",
"}"
] | Determine if a type is derived from Number (or array thereof).
@param targetType the candidate type
@param recurse true if we can have multi-dimension arrays; should be false for annotation member types
@return true if the type equals the targetType or array thereof | [
"Determine",
"if",
"a",
"type",
"is",
"derived",
"from",
"Number",
"(",
"or",
"array",
"thereof",
")",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java#L196-L202 |
xmlunit/xmlunit | xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/XMLAssert.java | XMLAssert.assertXMLEqual | public static void assertXMLEqual(String err, Reader control, Reader test)
throws SAXException, IOException {
"""
Assert that two XML documents are similar
@param err Message to be displayed on assertion failure
@param control XML to be compared against
@param test XML to be tested
@throws SAXException
@throws IOException
"""
Diff diff = new Diff(control, test);
assertXMLEqual(err, diff, true);
} | java | public static void assertXMLEqual(String err, Reader control, Reader test)
throws SAXException, IOException {
Diff diff = new Diff(control, test);
assertXMLEqual(err, diff, true);
} | [
"public",
"static",
"void",
"assertXMLEqual",
"(",
"String",
"err",
",",
"Reader",
"control",
",",
"Reader",
"test",
")",
"throws",
"SAXException",
",",
"IOException",
"{",
"Diff",
"diff",
"=",
"new",
"Diff",
"(",
"control",
",",
"test",
")",
";",
"assertXMLEqual",
"(",
"err",
",",
"diff",
",",
"true",
")",
";",
"}"
] | Assert that two XML documents are similar
@param err Message to be displayed on assertion failure
@param control XML to be compared against
@param test XML to be tested
@throws SAXException
@throws IOException | [
"Assert",
"that",
"two",
"XML",
"documents",
"are",
"similar"
] | train | https://github.com/xmlunit/xmlunit/blob/fe3d701d43f57ee83dcba336e4c1555619d3084b/xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/XMLAssert.java#L256-L260 |
codelibs/fess | src/main/java/org/codelibs/fess/mylasta/action/FessMessages.java | FessMessages.addErrorsPropertyTypeLong | public FessMessages addErrorsPropertyTypeLong(String property, String arg0) {
"""
Add the created action message for the key 'errors.property_type_long' with parameters.
<pre>
message: {0} should be numeric.
</pre>
@param property The property name for the message. (NotNull)
@param arg0 The parameter arg0 for message. (NotNull)
@return this. (NotNull)
"""
assertPropertyNotNull(property);
add(property, new UserMessage(ERRORS_property_type_long, arg0));
return this;
} | java | public FessMessages addErrorsPropertyTypeLong(String property, String arg0) {
assertPropertyNotNull(property);
add(property, new UserMessage(ERRORS_property_type_long, arg0));
return this;
} | [
"public",
"FessMessages",
"addErrorsPropertyTypeLong",
"(",
"String",
"property",
",",
"String",
"arg0",
")",
"{",
"assertPropertyNotNull",
"(",
"property",
")",
";",
"add",
"(",
"property",
",",
"new",
"UserMessage",
"(",
"ERRORS_property_type_long",
",",
"arg0",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add the created action message for the key 'errors.property_type_long' with parameters.
<pre>
message: {0} should be numeric.
</pre>
@param property The property name for the message. (NotNull)
@param arg0 The parameter arg0 for message. (NotNull)
@return this. (NotNull) | [
"Add",
"the",
"created",
"action",
"message",
"for",
"the",
"key",
"errors",
".",
"property_type_long",
"with",
"parameters",
".",
"<pre",
">",
"message",
":",
"{",
"0",
"}",
"should",
"be",
"numeric",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/codelibs/fess/blob/e5e4b722549d32a4958dfd94965b21937bfe64cf/src/main/java/org/codelibs/fess/mylasta/action/FessMessages.java#L2215-L2219 |
alibaba/transmittable-thread-local | src/main/java/com/alibaba/ttl/TtlTimerTask.java | TtlTimerTask.get | @Nullable
public static TtlTimerTask get(@Nullable TimerTask timerTask) {
"""
Factory method, wrap input {@link TimerTask} to {@link TtlTimerTask}.
<p>
This method is idempotent.
@param timerTask input {@link TimerTask}
@return Wrapped {@link TimerTask}
"""
return get(timerTask, false, false);
} | java | @Nullable
public static TtlTimerTask get(@Nullable TimerTask timerTask) {
return get(timerTask, false, false);
} | [
"@",
"Nullable",
"public",
"static",
"TtlTimerTask",
"get",
"(",
"@",
"Nullable",
"TimerTask",
"timerTask",
")",
"{",
"return",
"get",
"(",
"timerTask",
",",
"false",
",",
"false",
")",
";",
"}"
] | Factory method, wrap input {@link TimerTask} to {@link TtlTimerTask}.
<p>
This method is idempotent.
@param timerTask input {@link TimerTask}
@return Wrapped {@link TimerTask} | [
"Factory",
"method",
"wrap",
"input",
"{",
"@link",
"TimerTask",
"}",
"to",
"{",
"@link",
"TtlTimerTask",
"}",
".",
"<p",
">",
"This",
"method",
"is",
"idempotent",
"."
] | train | https://github.com/alibaba/transmittable-thread-local/blob/30b4d99cdb7064b4c1797d2e40bfa07adce8e7f9/src/main/java/com/alibaba/ttl/TtlTimerTask.java#L91-L94 |
google/closure-templates | java/src/com/google/template/soy/pysrc/internal/TranslateToPyExprVisitor.java | TranslateToPyExprVisitor.genCodeForLiteralKeyAccess | private static String genCodeForLiteralKeyAccess(String containerExpr, String key) {
"""
Generates the code for key access given a key literal, e.g. {@code .get('key')}.
@param key the String literal value to be used as a key
"""
return genCodeForLiteralKeyAccess(containerExpr, key, NotFoundBehavior.throwException());
} | java | private static String genCodeForLiteralKeyAccess(String containerExpr, String key) {
return genCodeForLiteralKeyAccess(containerExpr, key, NotFoundBehavior.throwException());
} | [
"private",
"static",
"String",
"genCodeForLiteralKeyAccess",
"(",
"String",
"containerExpr",
",",
"String",
"key",
")",
"{",
"return",
"genCodeForLiteralKeyAccess",
"(",
"containerExpr",
",",
"key",
",",
"NotFoundBehavior",
".",
"throwException",
"(",
")",
")",
";",
"}"
] | Generates the code for key access given a key literal, e.g. {@code .get('key')}.
@param key the String literal value to be used as a key | [
"Generates",
"the",
"code",
"for",
"key",
"access",
"given",
"a",
"key",
"literal",
"e",
".",
"g",
".",
"{",
"@code",
".",
"get",
"(",
"key",
")",
"}",
"."
] | train | https://github.com/google/closure-templates/blob/cc61e1dff70ae97f24f417a57410081bc498bd56/java/src/com/google/template/soy/pysrc/internal/TranslateToPyExprVisitor.java#L573-L575 |
datastax/java-driver | core/src/main/java/com/datastax/oss/driver/internal/core/util/Loggers.java | Loggers.warnWithException | public static void warnWithException(Logger logger, String format, Object... arguments) {
"""
Emits a warning log that includes an exception. If the current level is debug, the full stack
trace is included, otherwise only the exception's message.
"""
if (logger.isDebugEnabled()) {
logger.warn(format, arguments);
} else {
Object last = arguments[arguments.length - 1];
if (last instanceof Throwable) {
Throwable t = (Throwable) last;
arguments[arguments.length - 1] = t.getClass().getSimpleName() + ": " + t.getMessage();
logger.warn(format + " ({})", arguments);
} else {
// Should only be called with an exception as last argument, but handle gracefully anyway
logger.warn(format, arguments);
}
}
} | java | public static void warnWithException(Logger logger, String format, Object... arguments) {
if (logger.isDebugEnabled()) {
logger.warn(format, arguments);
} else {
Object last = arguments[arguments.length - 1];
if (last instanceof Throwable) {
Throwable t = (Throwable) last;
arguments[arguments.length - 1] = t.getClass().getSimpleName() + ": " + t.getMessage();
logger.warn(format + " ({})", arguments);
} else {
// Should only be called with an exception as last argument, but handle gracefully anyway
logger.warn(format, arguments);
}
}
} | [
"public",
"static",
"void",
"warnWithException",
"(",
"Logger",
"logger",
",",
"String",
"format",
",",
"Object",
"...",
"arguments",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"format",
",",
"arguments",
")",
";",
"}",
"else",
"{",
"Object",
"last",
"=",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"last",
"instanceof",
"Throwable",
")",
"{",
"Throwable",
"t",
"=",
"(",
"Throwable",
")",
"last",
";",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
"=",
"t",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\": \"",
"+",
"t",
".",
"getMessage",
"(",
")",
";",
"logger",
".",
"warn",
"(",
"format",
"+",
"\" ({})\"",
",",
"arguments",
")",
";",
"}",
"else",
"{",
"// Should only be called with an exception as last argument, but handle gracefully anyway",
"logger",
".",
"warn",
"(",
"format",
",",
"arguments",
")",
";",
"}",
"}",
"}"
] | Emits a warning log that includes an exception. If the current level is debug, the full stack
trace is included, otherwise only the exception's message. | [
"Emits",
"a",
"warning",
"log",
"that",
"includes",
"an",
"exception",
".",
"If",
"the",
"current",
"level",
"is",
"debug",
"the",
"full",
"stack",
"trace",
"is",
"included",
"otherwise",
"only",
"the",
"exception",
"s",
"message",
"."
] | train | https://github.com/datastax/java-driver/blob/612a63f2525618e2020e86c9ad75ab37adba6132/core/src/main/java/com/datastax/oss/driver/internal/core/util/Loggers.java#L26-L40 |
orbisgis/h2gis | h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/ST_MakeEllipse.java | ST_MakeEllipse.makeEllipse | public static Polygon makeEllipse(Point p, double width, double height) throws SQLException {
"""
Make an ellipse centered at the given point with the given width and
height.
@param p Point
@param width Width
@param height Height
@return An ellipse centered at the given point with the given width and height
@throws SQLException if the width or height is non-positive
"""
if(p == null){
return null;
}
if (height < 0 || width < 0) {
throw new SQLException("Both width and height must be positive.");
} else {
GSF.setCentre(new Coordinate(p.getX(), p.getY()));
GSF.setWidth(width);
GSF.setHeight(height);
return GSF.createEllipse();
}
} | java | public static Polygon makeEllipse(Point p, double width, double height) throws SQLException {
if(p == null){
return null;
}
if (height < 0 || width < 0) {
throw new SQLException("Both width and height must be positive.");
} else {
GSF.setCentre(new Coordinate(p.getX(), p.getY()));
GSF.setWidth(width);
GSF.setHeight(height);
return GSF.createEllipse();
}
} | [
"public",
"static",
"Polygon",
"makeEllipse",
"(",
"Point",
"p",
",",
"double",
"width",
",",
"double",
"height",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"p",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"height",
"<",
"0",
"||",
"width",
"<",
"0",
")",
"{",
"throw",
"new",
"SQLException",
"(",
"\"Both width and height must be positive.\"",
")",
";",
"}",
"else",
"{",
"GSF",
".",
"setCentre",
"(",
"new",
"Coordinate",
"(",
"p",
".",
"getX",
"(",
")",
",",
"p",
".",
"getY",
"(",
")",
")",
")",
";",
"GSF",
".",
"setWidth",
"(",
"width",
")",
";",
"GSF",
".",
"setHeight",
"(",
"height",
")",
";",
"return",
"GSF",
".",
"createEllipse",
"(",
")",
";",
"}",
"}"
] | Make an ellipse centered at the given point with the given width and
height.
@param p Point
@param width Width
@param height Height
@return An ellipse centered at the given point with the given width and height
@throws SQLException if the width or height is non-positive | [
"Make",
"an",
"ellipse",
"centered",
"at",
"the",
"given",
"point",
"with",
"the",
"given",
"width",
"and",
"height",
"."
] | train | https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/create/ST_MakeEllipse.java#L64-L76 |
actorapp/actor-platform | actor-sdk/sdk-core/core/core-shared/src/main/java/im/actor/core/Messenger.java | Messenger.sendMessage | @ObjectiveCName("sendMessageWithPeer:withText:withMentions:")
public void sendMessage(@NotNull Peer peer, @NotNull String text, @Nullable ArrayList<Integer> mentions) {
"""
Send Text Message with mentions
@param peer destination peer
@param text message text
@param mentions user's mentions
"""
sendMessage(peer, text, null, mentions, false);
} | java | @ObjectiveCName("sendMessageWithPeer:withText:withMentions:")
public void sendMessage(@NotNull Peer peer, @NotNull String text, @Nullable ArrayList<Integer> mentions) {
sendMessage(peer, text, null, mentions, false);
} | [
"@",
"ObjectiveCName",
"(",
"\"sendMessageWithPeer:withText:withMentions:\"",
")",
"public",
"void",
"sendMessage",
"(",
"@",
"NotNull",
"Peer",
"peer",
",",
"@",
"NotNull",
"String",
"text",
",",
"@",
"Nullable",
"ArrayList",
"<",
"Integer",
">",
"mentions",
")",
"{",
"sendMessage",
"(",
"peer",
",",
"text",
",",
"null",
",",
"mentions",
",",
"false",
")",
";",
"}"
] | Send Text Message with mentions
@param peer destination peer
@param text message text
@param mentions user's mentions | [
"Send",
"Text",
"Message",
"with",
"mentions"
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/core/core-shared/src/main/java/im/actor/core/Messenger.java#L806-L809 |
facebook/fresco | fbcore/src/main/java/com/facebook/common/file/FileTree.java | FileTree.walkFileTree | public static void walkFileTree(File directory, FileTreeVisitor visitor) {
"""
Iterates over the file tree of a directory. It receives a visitor and will call its methods
for each file in the directory.
preVisitDirectory (directory)
visitFile (file)
- recursively the same for every subdirectory
postVisitDirectory (directory)
@param directory the directory to iterate
@param visitor the visitor that will be invoked for each directory/file in the tree
"""
visitor.preVisitDirectory(directory);
File[] files = directory.listFiles();
if (files != null) {
for (File file: files) {
if (file.isDirectory()) {
walkFileTree(file, visitor);
} else {
visitor.visitFile(file);
}
}
}
visitor.postVisitDirectory(directory);
} | java | public static void walkFileTree(File directory, FileTreeVisitor visitor) {
visitor.preVisitDirectory(directory);
File[] files = directory.listFiles();
if (files != null) {
for (File file: files) {
if (file.isDirectory()) {
walkFileTree(file, visitor);
} else {
visitor.visitFile(file);
}
}
}
visitor.postVisitDirectory(directory);
} | [
"public",
"static",
"void",
"walkFileTree",
"(",
"File",
"directory",
",",
"FileTreeVisitor",
"visitor",
")",
"{",
"visitor",
".",
"preVisitDirectory",
"(",
"directory",
")",
";",
"File",
"[",
"]",
"files",
"=",
"directory",
".",
"listFiles",
"(",
")",
";",
"if",
"(",
"files",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"file",
":",
"files",
")",
"{",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"walkFileTree",
"(",
"file",
",",
"visitor",
")",
";",
"}",
"else",
"{",
"visitor",
".",
"visitFile",
"(",
"file",
")",
";",
"}",
"}",
"}",
"visitor",
".",
"postVisitDirectory",
"(",
"directory",
")",
";",
"}"
] | Iterates over the file tree of a directory. It receives a visitor and will call its methods
for each file in the directory.
preVisitDirectory (directory)
visitFile (file)
- recursively the same for every subdirectory
postVisitDirectory (directory)
@param directory the directory to iterate
@param visitor the visitor that will be invoked for each directory/file in the tree | [
"Iterates",
"over",
"the",
"file",
"tree",
"of",
"a",
"directory",
".",
"It",
"receives",
"a",
"visitor",
"and",
"will",
"call",
"its",
"methods",
"for",
"each",
"file",
"in",
"the",
"directory",
".",
"preVisitDirectory",
"(",
"directory",
")",
"visitFile",
"(",
"file",
")",
"-",
"recursively",
"the",
"same",
"for",
"every",
"subdirectory",
"postVisitDirectory",
"(",
"directory",
")"
] | train | https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/fbcore/src/main/java/com/facebook/common/file/FileTree.java#L30-L43 |
oboehm/jfachwert | src/main/java/de/jfachwert/bank/IBAN.java | IBAN.getLand | @SuppressWarnings( {
"""
Liefert das Land, zu dem die IBAN gehoert.
@return z.B. "de_DE" (als Locale)
@since 0.1.0
""""squid:SwitchLastCaseIsDefaultCheck", "squid:S1301"})
public Locale getLand() {
String country = this.getUnformatted().substring(0, 2);
String language = country.toLowerCase();
switch (country) {
case "AT":
case "CH":
language = "de";
break;
}
return new Locale(language, country);
} | java | @SuppressWarnings({"squid:SwitchLastCaseIsDefaultCheck", "squid:S1301"})
public Locale getLand() {
String country = this.getUnformatted().substring(0, 2);
String language = country.toLowerCase();
switch (country) {
case "AT":
case "CH":
language = "de";
break;
}
return new Locale(language, country);
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"squid:SwitchLastCaseIsDefaultCheck\"",
",",
"\"squid:S1301\"",
"}",
")",
"public",
"Locale",
"getLand",
"(",
")",
"{",
"String",
"country",
"=",
"this",
".",
"getUnformatted",
"(",
")",
".",
"substring",
"(",
"0",
",",
"2",
")",
";",
"String",
"language",
"=",
"country",
".",
"toLowerCase",
"(",
")",
";",
"switch",
"(",
"country",
")",
"{",
"case",
"\"AT\"",
":",
"case",
"\"CH\"",
":",
"language",
"=",
"\"de\"",
";",
"break",
";",
"}",
"return",
"new",
"Locale",
"(",
"language",
",",
"country",
")",
";",
"}"
] | Liefert das Land, zu dem die IBAN gehoert.
@return z.B. "de_DE" (als Locale)
@since 0.1.0 | [
"Liefert",
"das",
"Land",
"zu",
"dem",
"die",
"IBAN",
"gehoert",
"."
] | train | https://github.com/oboehm/jfachwert/blob/67b513d29e3114c7aee65cd1ea7a5b7e540b0d1b/src/main/java/de/jfachwert/bank/IBAN.java#L132-L143 |
GoogleCloudPlatform/appengine-plugins-core | src/main/java/com/google/cloud/tools/appengine/AppEngineDescriptor.java | AppEngineDescriptor.getEnvironment | public Map<String, String> getEnvironment() throws AppEngineException {
"""
Given the following structure:
<pre>{@code
<env-variables>
<env-var name="key" value="val" />
</env-variables>
}</pre>
<p>This will construct a map of the form {[key, value], ...}.
@return a map representing the environment variable settings in the appengine-web.xml
"""
Node environmentParentNode = getNode(document, "appengine-web-app", "env-variables");
if (environmentParentNode != null) {
return getAttributeMap(environmentParentNode, "env-var", "name", "value");
}
return new HashMap<>();
} | java | public Map<String, String> getEnvironment() throws AppEngineException {
Node environmentParentNode = getNode(document, "appengine-web-app", "env-variables");
if (environmentParentNode != null) {
return getAttributeMap(environmentParentNode, "env-var", "name", "value");
}
return new HashMap<>();
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getEnvironment",
"(",
")",
"throws",
"AppEngineException",
"{",
"Node",
"environmentParentNode",
"=",
"getNode",
"(",
"document",
",",
"\"appengine-web-app\"",
",",
"\"env-variables\"",
")",
";",
"if",
"(",
"environmentParentNode",
"!=",
"null",
")",
"{",
"return",
"getAttributeMap",
"(",
"environmentParentNode",
",",
"\"env-var\"",
",",
"\"name\"",
",",
"\"value\"",
")",
";",
"}",
"return",
"new",
"HashMap",
"<>",
"(",
")",
";",
"}"
] | Given the following structure:
<pre>{@code
<env-variables>
<env-var name="key" value="val" />
</env-variables>
}</pre>
<p>This will construct a map of the form {[key, value], ...}.
@return a map representing the environment variable settings in the appengine-web.xml | [
"Given",
"the",
"following",
"structure",
":"
] | train | https://github.com/GoogleCloudPlatform/appengine-plugins-core/blob/d22e9fa1103522409ab6fdfbf68c4a5a0bc5b97d/src/main/java/com/google/cloud/tools/appengine/AppEngineDescriptor.java#L134-L140 |
apptentive/apptentive-android | apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java | Util.alphaMixColors | public static int alphaMixColors(int backgroundColor, int foregroundColor) {
"""
/* Use alpha channel to compute percentage RGB share in blending.
* Background color may be visible only if foreground alpha is smaller than 100%
"""
final byte ALPHA_CHANNEL = 24;
final byte RED_CHANNEL = 16;
final byte GREEN_CHANNEL = 8;
final byte BLUE_CHANNEL = 0;
final double ap1 = (double) (backgroundColor >> ALPHA_CHANNEL & 0xff) / 255d;
final double ap2 = (double) (foregroundColor >> ALPHA_CHANNEL & 0xff) / 255d;
final double ap = ap2 + (ap1 * (1 - ap2));
final double amount1 = (ap1 * (1 - ap2)) / ap;
final double amount2 = amount1 / ap;
int a = ((int) (ap * 255d)) & 0xff;
int r = ((int) (((float) (backgroundColor >> RED_CHANNEL & 0xff) * amount1) +
((float) (foregroundColor >> RED_CHANNEL & 0xff) * amount2))) & 0xff;
int g = ((int) (((float) (backgroundColor >> GREEN_CHANNEL & 0xff) * amount1) +
((float) (foregroundColor >> GREEN_CHANNEL & 0xff) * amount2))) & 0xff;
int b = ((int) (((float) (backgroundColor & 0xff) * amount1) +
((float) (foregroundColor & 0xff) * amount2))) & 0xff;
return a << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b << BLUE_CHANNEL;
} | java | public static int alphaMixColors(int backgroundColor, int foregroundColor) {
final byte ALPHA_CHANNEL = 24;
final byte RED_CHANNEL = 16;
final byte GREEN_CHANNEL = 8;
final byte BLUE_CHANNEL = 0;
final double ap1 = (double) (backgroundColor >> ALPHA_CHANNEL & 0xff) / 255d;
final double ap2 = (double) (foregroundColor >> ALPHA_CHANNEL & 0xff) / 255d;
final double ap = ap2 + (ap1 * (1 - ap2));
final double amount1 = (ap1 * (1 - ap2)) / ap;
final double amount2 = amount1 / ap;
int a = ((int) (ap * 255d)) & 0xff;
int r = ((int) (((float) (backgroundColor >> RED_CHANNEL & 0xff) * amount1) +
((float) (foregroundColor >> RED_CHANNEL & 0xff) * amount2))) & 0xff;
int g = ((int) (((float) (backgroundColor >> GREEN_CHANNEL & 0xff) * amount1) +
((float) (foregroundColor >> GREEN_CHANNEL & 0xff) * amount2))) & 0xff;
int b = ((int) (((float) (backgroundColor & 0xff) * amount1) +
((float) (foregroundColor & 0xff) * amount2))) & 0xff;
return a << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b << BLUE_CHANNEL;
} | [
"public",
"static",
"int",
"alphaMixColors",
"(",
"int",
"backgroundColor",
",",
"int",
"foregroundColor",
")",
"{",
"final",
"byte",
"ALPHA_CHANNEL",
"=",
"24",
";",
"final",
"byte",
"RED_CHANNEL",
"=",
"16",
";",
"final",
"byte",
"GREEN_CHANNEL",
"=",
"8",
";",
"final",
"byte",
"BLUE_CHANNEL",
"=",
"0",
";",
"final",
"double",
"ap1",
"=",
"(",
"double",
")",
"(",
"backgroundColor",
">>",
"ALPHA_CHANNEL",
"&",
"0xff",
")",
"/",
"255d",
";",
"final",
"double",
"ap2",
"=",
"(",
"double",
")",
"(",
"foregroundColor",
">>",
"ALPHA_CHANNEL",
"&",
"0xff",
")",
"/",
"255d",
";",
"final",
"double",
"ap",
"=",
"ap2",
"+",
"(",
"ap1",
"*",
"(",
"1",
"-",
"ap2",
")",
")",
";",
"final",
"double",
"amount1",
"=",
"(",
"ap1",
"*",
"(",
"1",
"-",
"ap2",
")",
")",
"/",
"ap",
";",
"final",
"double",
"amount2",
"=",
"amount1",
"/",
"ap",
";",
"int",
"a",
"=",
"(",
"(",
"int",
")",
"(",
"ap",
"*",
"255d",
")",
")",
"&",
"0xff",
";",
"int",
"r",
"=",
"(",
"(",
"int",
")",
"(",
"(",
"(",
"float",
")",
"(",
"backgroundColor",
">>",
"RED_CHANNEL",
"&",
"0xff",
")",
"*",
"amount1",
")",
"+",
"(",
"(",
"float",
")",
"(",
"foregroundColor",
">>",
"RED_CHANNEL",
"&",
"0xff",
")",
"*",
"amount2",
")",
")",
")",
"&",
"0xff",
";",
"int",
"g",
"=",
"(",
"(",
"int",
")",
"(",
"(",
"(",
"float",
")",
"(",
"backgroundColor",
">>",
"GREEN_CHANNEL",
"&",
"0xff",
")",
"*",
"amount1",
")",
"+",
"(",
"(",
"float",
")",
"(",
"foregroundColor",
">>",
"GREEN_CHANNEL",
"&",
"0xff",
")",
"*",
"amount2",
")",
")",
")",
"&",
"0xff",
";",
"int",
"b",
"=",
"(",
"(",
"int",
")",
"(",
"(",
"(",
"float",
")",
"(",
"backgroundColor",
"&",
"0xff",
")",
"*",
"amount1",
")",
"+",
"(",
"(",
"float",
")",
"(",
"foregroundColor",
"&",
"0xff",
")",
"*",
"amount2",
")",
")",
")",
"&",
"0xff",
";",
"return",
"a",
"<<",
"ALPHA_CHANNEL",
"|",
"r",
"<<",
"RED_CHANNEL",
"|",
"g",
"<<",
"GREEN_CHANNEL",
"|",
"b",
"<<",
"BLUE_CHANNEL",
";",
"}"
] | /* Use alpha channel to compute percentage RGB share in blending.
* Background color may be visible only if foreground alpha is smaller than 100% | [
"/",
"*",
"Use",
"alpha",
"channel",
"to",
"compute",
"percentage",
"RGB",
"share",
"in",
"blending",
".",
"*",
"Background",
"color",
"may",
"be",
"visible",
"only",
"if",
"foreground",
"alpha",
"is",
"smaller",
"than",
"100%"
] | train | https://github.com/apptentive/apptentive-android/blob/887c08d7bd5ae6488a90366dfb58f58938861a93/apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java#L466-L489 |
looly/hutool | hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/SM2Engine.java | SM2Engine.xor | private void xor(byte[] data, byte[] kdfOut, int dOff, int dRemaining) {
"""
异或
@param data 数据
@param kdfOut kdf输出值
@param dOff d偏移
@param dRemaining d剩余
"""
for (int i = 0; i != dRemaining; i++) {
data[dOff + i] ^= kdfOut[i];
}
} | java | private void xor(byte[] data, byte[] kdfOut, int dOff, int dRemaining) {
for (int i = 0; i != dRemaining; i++) {
data[dOff + i] ^= kdfOut[i];
}
} | [
"private",
"void",
"xor",
"(",
"byte",
"[",
"]",
"data",
",",
"byte",
"[",
"]",
"kdfOut",
",",
"int",
"dOff",
",",
"int",
"dRemaining",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"!=",
"dRemaining",
";",
"i",
"++",
")",
"{",
"data",
"[",
"dOff",
"+",
"i",
"]",
"^=",
"kdfOut",
"[",
"i",
"]",
";",
"}",
"}"
] | 异或
@param data 数据
@param kdfOut kdf输出值
@param dOff d偏移
@param dRemaining d剩余 | [
"异或"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/SM2Engine.java#L326-L330 |
mapbox/mapbox-java | services-geojson/src/main/java/com/mapbox/geojson/GeometryCollection.java | GeometryCollection.fromGeometries | public static GeometryCollection fromGeometries(@NonNull List<Geometry> geometries) {
"""
Create a new instance of this class by giving the collection a list of {@link Geometry}.
@param geometries a non-null list of geometry which makes up this collection
@return a new instance of this class defined by the values passed inside this static factory
method
@since 1.0.0
"""
return new GeometryCollection(TYPE, null, geometries);
} | java | public static GeometryCollection fromGeometries(@NonNull List<Geometry> geometries) {
return new GeometryCollection(TYPE, null, geometries);
} | [
"public",
"static",
"GeometryCollection",
"fromGeometries",
"(",
"@",
"NonNull",
"List",
"<",
"Geometry",
">",
"geometries",
")",
"{",
"return",
"new",
"GeometryCollection",
"(",
"TYPE",
",",
"null",
",",
"geometries",
")",
";",
"}"
] | Create a new instance of this class by giving the collection a list of {@link Geometry}.
@param geometries a non-null list of geometry which makes up this collection
@return a new instance of this class defined by the values passed inside this static factory
method
@since 1.0.0 | [
"Create",
"a",
"new",
"instance",
"of",
"this",
"class",
"by",
"giving",
"the",
"collection",
"a",
"list",
"of",
"{",
"@link",
"Geometry",
"}",
"."
] | train | https://github.com/mapbox/mapbox-java/blob/c0be138f462f91441388584c668f3760ba0e18e2/services-geojson/src/main/java/com/mapbox/geojson/GeometryCollection.java#L100-L102 |
GenesysPureEngage/workspace-client-java | src/main/java/com/genesys/internal/workspace/api/MediaApi.java | MediaApi.assignContact | public ApiSuccessResponse assignContact(String mediatype, String id, String contactId, AssignContactData assignContactData) throws ApiException {
"""
Assign the contact to the open interaction
Assign the contact to the open interaction specified in the contactId path parameter
@param mediatype media-type of interaction (required)
@param id id of interaction (required)
@param contactId id of contact (required)
@param assignContactData Request parameters. (optional)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
"""
ApiResponse<ApiSuccessResponse> resp = assignContactWithHttpInfo(mediatype, id, contactId, assignContactData);
return resp.getData();
} | java | public ApiSuccessResponse assignContact(String mediatype, String id, String contactId, AssignContactData assignContactData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = assignContactWithHttpInfo(mediatype, id, contactId, assignContactData);
return resp.getData();
} | [
"public",
"ApiSuccessResponse",
"assignContact",
"(",
"String",
"mediatype",
",",
"String",
"id",
",",
"String",
"contactId",
",",
"AssignContactData",
"assignContactData",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ApiSuccessResponse",
">",
"resp",
"=",
"assignContactWithHttpInfo",
"(",
"mediatype",
",",
"id",
",",
"contactId",
",",
"assignContactData",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] | Assign the contact to the open interaction
Assign the contact to the open interaction specified in the contactId path parameter
@param mediatype media-type of interaction (required)
@param id id of interaction (required)
@param contactId id of contact (required)
@param assignContactData Request parameters. (optional)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Assign",
"the",
"contact",
"to",
"the",
"open",
"interaction",
"Assign",
"the",
"contact",
"to",
"the",
"open",
"interaction",
"specified",
"in",
"the",
"contactId",
"path",
"parameter"
] | train | https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/internal/workspace/api/MediaApi.java#L739-L742 |
adyliu/jafka | src/main/java/io/jafka/cluster/Broker.java | Broker.createBroker | public static Broker createBroker(int id, String brokerInfoString) {
"""
create a broker with given broker info
@param id broker id
@param brokerInfoString broker info format: <b>creatorId:host:port:autocreated</b>
@return broker instance with connection config
@see #getZKString()
"""
String[] brokerInfo = brokerInfoString.split(":");
String creator = brokerInfo[0].replace('#', ':');
String hostname = brokerInfo[1].replace('#', ':');
String port = brokerInfo[2];
boolean autocreated = Boolean.valueOf(brokerInfo.length > 3 ? brokerInfo[3] : "true");
return new Broker(id, creator, hostname, Integer.parseInt(port), autocreated);
} | java | public static Broker createBroker(int id, String brokerInfoString) {
String[] brokerInfo = brokerInfoString.split(":");
String creator = brokerInfo[0].replace('#', ':');
String hostname = brokerInfo[1].replace('#', ':');
String port = brokerInfo[2];
boolean autocreated = Boolean.valueOf(brokerInfo.length > 3 ? brokerInfo[3] : "true");
return new Broker(id, creator, hostname, Integer.parseInt(port), autocreated);
} | [
"public",
"static",
"Broker",
"createBroker",
"(",
"int",
"id",
",",
"String",
"brokerInfoString",
")",
"{",
"String",
"[",
"]",
"brokerInfo",
"=",
"brokerInfoString",
".",
"split",
"(",
"\":\"",
")",
";",
"String",
"creator",
"=",
"brokerInfo",
"[",
"0",
"]",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"String",
"hostname",
"=",
"brokerInfo",
"[",
"1",
"]",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"String",
"port",
"=",
"brokerInfo",
"[",
"2",
"]",
";",
"boolean",
"autocreated",
"=",
"Boolean",
".",
"valueOf",
"(",
"brokerInfo",
".",
"length",
">",
"3",
"?",
"brokerInfo",
"[",
"3",
"]",
":",
"\"true\"",
")",
";",
"return",
"new",
"Broker",
"(",
"id",
",",
"creator",
",",
"hostname",
",",
"Integer",
".",
"parseInt",
"(",
"port",
")",
",",
"autocreated",
")",
";",
"}"
] | create a broker with given broker info
@param id broker id
@param brokerInfoString broker info format: <b>creatorId:host:port:autocreated</b>
@return broker instance with connection config
@see #getZKString() | [
"create",
"a",
"broker",
"with",
"given",
"broker",
"info"
] | train | https://github.com/adyliu/jafka/blob/cc14d2ed60c039b12d7b106bb5269ef21d0add7e/src/main/java/io/jafka/cluster/Broker.java#L119-L126 |
Metatavu/edelphi | edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionNumericAnswerDAO.java | QueryQuestionNumericAnswerDAO.countByQueryFieldQueryRepliesInAndData | public Long countByQueryFieldQueryRepliesInAndData(QueryField queryField, Collection<QueryReply> queryReplies, Double data) {
"""
Counts query question numeric answers
@param queryField query field
@param queryReplies query reply set must be in this set
@param data data must equal this value
@return count of query question numeric answers
"""
if (queryReplies == null || queryReplies.isEmpty()) {
return 0l;
}
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> criteria = criteriaBuilder.createQuery(Long.class);
Root<QueryQuestionNumericAnswer> root = criteria.from(QueryQuestionNumericAnswer.class);
Join<QueryQuestionNumericAnswer, QueryReply> replyJoin = root.join(QueryQuestionNumericAnswer_.queryReply);
criteria.select(criteriaBuilder.count(root));
criteria.where(
criteriaBuilder.and(
criteriaBuilder.equal(root.get(QueryQuestionNumericAnswer_.queryField), queryField),
root.get(QueryQuestionNumericAnswer_.queryReply).in(queryReplies),
criteriaBuilder.equal(root.get(QueryQuestionNumericAnswer_.data), data),
criteriaBuilder.equal(replyJoin.get(QueryReply_.archived), Boolean.FALSE)
)
);
return entityManager.createQuery(criteria).getSingleResult();
} | java | public Long countByQueryFieldQueryRepliesInAndData(QueryField queryField, Collection<QueryReply> queryReplies, Double data) {
if (queryReplies == null || queryReplies.isEmpty()) {
return 0l;
}
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> criteria = criteriaBuilder.createQuery(Long.class);
Root<QueryQuestionNumericAnswer> root = criteria.from(QueryQuestionNumericAnswer.class);
Join<QueryQuestionNumericAnswer, QueryReply> replyJoin = root.join(QueryQuestionNumericAnswer_.queryReply);
criteria.select(criteriaBuilder.count(root));
criteria.where(
criteriaBuilder.and(
criteriaBuilder.equal(root.get(QueryQuestionNumericAnswer_.queryField), queryField),
root.get(QueryQuestionNumericAnswer_.queryReply).in(queryReplies),
criteriaBuilder.equal(root.get(QueryQuestionNumericAnswer_.data), data),
criteriaBuilder.equal(replyJoin.get(QueryReply_.archived), Boolean.FALSE)
)
);
return entityManager.createQuery(criteria).getSingleResult();
} | [
"public",
"Long",
"countByQueryFieldQueryRepliesInAndData",
"(",
"QueryField",
"queryField",
",",
"Collection",
"<",
"QueryReply",
">",
"queryReplies",
",",
"Double",
"data",
")",
"{",
"if",
"(",
"queryReplies",
"==",
"null",
"||",
"queryReplies",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"0l",
";",
"}",
"EntityManager",
"entityManager",
"=",
"getEntityManager",
"(",
")",
";",
"CriteriaBuilder",
"criteriaBuilder",
"=",
"entityManager",
".",
"getCriteriaBuilder",
"(",
")",
";",
"CriteriaQuery",
"<",
"Long",
">",
"criteria",
"=",
"criteriaBuilder",
".",
"createQuery",
"(",
"Long",
".",
"class",
")",
";",
"Root",
"<",
"QueryQuestionNumericAnswer",
">",
"root",
"=",
"criteria",
".",
"from",
"(",
"QueryQuestionNumericAnswer",
".",
"class",
")",
";",
"Join",
"<",
"QueryQuestionNumericAnswer",
",",
"QueryReply",
">",
"replyJoin",
"=",
"root",
".",
"join",
"(",
"QueryQuestionNumericAnswer_",
".",
"queryReply",
")",
";",
"criteria",
".",
"select",
"(",
"criteriaBuilder",
".",
"count",
"(",
"root",
")",
")",
";",
"criteria",
".",
"where",
"(",
"criteriaBuilder",
".",
"and",
"(",
"criteriaBuilder",
".",
"equal",
"(",
"root",
".",
"get",
"(",
"QueryQuestionNumericAnswer_",
".",
"queryField",
")",
",",
"queryField",
")",
",",
"root",
".",
"get",
"(",
"QueryQuestionNumericAnswer_",
".",
"queryReply",
")",
".",
"in",
"(",
"queryReplies",
")",
",",
"criteriaBuilder",
".",
"equal",
"(",
"root",
".",
"get",
"(",
"QueryQuestionNumericAnswer_",
".",
"data",
")",
",",
"data",
")",
",",
"criteriaBuilder",
".",
"equal",
"(",
"replyJoin",
".",
"get",
"(",
"QueryReply_",
".",
"archived",
")",
",",
"Boolean",
".",
"FALSE",
")",
")",
")",
";",
"return",
"entityManager",
".",
"createQuery",
"(",
"criteria",
")",
".",
"getSingleResult",
"(",
")",
";",
"}"
] | Counts query question numeric answers
@param queryField query field
@param queryReplies query reply set must be in this set
@param data data must equal this value
@return count of query question numeric answers | [
"Counts",
"query",
"question",
"numeric",
"answers"
] | train | https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi-persistence/src/main/java/fi/metatavu/edelphi/dao/querydata/QueryQuestionNumericAnswerDAO.java#L99-L122 |
JodaOrg/joda-time | src/main/java/org/joda/time/PeriodType.java | PeriodType.getIndexedField | int getIndexedField(ReadablePeriod period, int index) {
"""
Gets the indexed field part of the period.
@param period the period to query
@param index the index to use
@return the value of the field, zero if unsupported
"""
int realIndex = iIndices[index];
return (realIndex == -1 ? 0 : period.getValue(realIndex));
} | java | int getIndexedField(ReadablePeriod period, int index) {
int realIndex = iIndices[index];
return (realIndex == -1 ? 0 : period.getValue(realIndex));
} | [
"int",
"getIndexedField",
"(",
"ReadablePeriod",
"period",
",",
"int",
"index",
")",
"{",
"int",
"realIndex",
"=",
"iIndices",
"[",
"index",
"]",
";",
"return",
"(",
"realIndex",
"==",
"-",
"1",
"?",
"0",
":",
"period",
".",
"getValue",
"(",
"realIndex",
")",
")",
";",
"}"
] | Gets the indexed field part of the period.
@param period the period to query
@param index the index to use
@return the value of the field, zero if unsupported | [
"Gets",
"the",
"indexed",
"field",
"part",
"of",
"the",
"period",
"."
] | train | https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L673-L676 |
apache/reef | lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/process/ReefRunnableProcessObserver.java | ReefRunnableProcessObserver.onUncleanExit | private void onUncleanExit(final String processId, final int exitCode) {
"""
Inform REEF of an unclean process exit.
@param processId
@param exitCode
"""
this.onResourceStatus(
ResourceStatusEventImpl.newBuilder()
.setIdentifier(processId)
.setState(State.FAILED)
.setExitCode(exitCode)
.build()
);
} | java | private void onUncleanExit(final String processId, final int exitCode) {
this.onResourceStatus(
ResourceStatusEventImpl.newBuilder()
.setIdentifier(processId)
.setState(State.FAILED)
.setExitCode(exitCode)
.build()
);
} | [
"private",
"void",
"onUncleanExit",
"(",
"final",
"String",
"processId",
",",
"final",
"int",
"exitCode",
")",
"{",
"this",
".",
"onResourceStatus",
"(",
"ResourceStatusEventImpl",
".",
"newBuilder",
"(",
")",
".",
"setIdentifier",
"(",
"processId",
")",
".",
"setState",
"(",
"State",
".",
"FAILED",
")",
".",
"setExitCode",
"(",
"exitCode",
")",
".",
"build",
"(",
")",
")",
";",
"}"
] | Inform REEF of an unclean process exit.
@param processId
@param exitCode | [
"Inform",
"REEF",
"of",
"an",
"unclean",
"process",
"exit",
"."
] | train | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/process/ReefRunnableProcessObserver.java#L102-L110 |
netscaler/sdx_nitro | src/main/java/com/citrix/sdx/nitro/resource/config/mps/snmp_view.java | snmp_view.get_nitro_bulk_response | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception {
"""
<pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre>
"""
snmp_view_responses result = (snmp_view_responses) service.get_payload_formatter().string_to_resource(snmp_view_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.snmp_view_response_array);
}
snmp_view[] result_snmp_view = new snmp_view[result.snmp_view_response_array.length];
for(int i = 0; i < result.snmp_view_response_array.length; i++)
{
result_snmp_view[i] = result.snmp_view_response_array[i].snmp_view[0];
}
return result_snmp_view;
} | java | protected base_resource[] get_nitro_bulk_response(nitro_service service, String response) throws Exception
{
snmp_view_responses result = (snmp_view_responses) service.get_payload_formatter().string_to_resource(snmp_view_responses.class, response);
if(result.errorcode != 0)
{
if (result.errorcode == SESSION_NOT_EXISTS)
service.clear_session();
throw new nitro_exception(result.message, result.errorcode, (base_response [])result.snmp_view_response_array);
}
snmp_view[] result_snmp_view = new snmp_view[result.snmp_view_response_array.length];
for(int i = 0; i < result.snmp_view_response_array.length; i++)
{
result_snmp_view[i] = result.snmp_view_response_array[i].snmp_view[0];
}
return result_snmp_view;
} | [
"protected",
"base_resource",
"[",
"]",
"get_nitro_bulk_response",
"(",
"nitro_service",
"service",
",",
"String",
"response",
")",
"throws",
"Exception",
"{",
"snmp_view_responses",
"result",
"=",
"(",
"snmp_view_responses",
")",
"service",
".",
"get_payload_formatter",
"(",
")",
".",
"string_to_resource",
"(",
"snmp_view_responses",
".",
"class",
",",
"response",
")",
";",
"if",
"(",
"result",
".",
"errorcode",
"!=",
"0",
")",
"{",
"if",
"(",
"result",
".",
"errorcode",
"==",
"SESSION_NOT_EXISTS",
")",
"service",
".",
"clear_session",
"(",
")",
";",
"throw",
"new",
"nitro_exception",
"(",
"result",
".",
"message",
",",
"result",
".",
"errorcode",
",",
"(",
"base_response",
"[",
"]",
")",
"result",
".",
"snmp_view_response_array",
")",
";",
"}",
"snmp_view",
"[",
"]",
"result_snmp_view",
"=",
"new",
"snmp_view",
"[",
"result",
".",
"snmp_view_response_array",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"snmp_view_response_array",
".",
"length",
";",
"i",
"++",
")",
"{",
"result_snmp_view",
"[",
"i",
"]",
"=",
"result",
".",
"snmp_view_response_array",
"[",
"i",
"]",
".",
"snmp_view",
"[",
"0",
"]",
";",
"}",
"return",
"result_snmp_view",
";",
"}"
] | <pre>
Converts API response of bulk operation into object and returns the object array in case of get request.
</pre> | [
"<pre",
">",
"Converts",
"API",
"response",
"of",
"bulk",
"operation",
"into",
"object",
"and",
"returns",
"the",
"object",
"array",
"in",
"case",
"of",
"get",
"request",
".",
"<",
"/",
"pre",
">"
] | train | https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/snmp_view.java#L368-L385 |
kotcrab/vis-ui | ui/src/main/java/com/kotcrab/vis/ui/util/ColorUtils.java | ColorUtils.HSVtoRGB | public static Color HSVtoRGB (float h, float s, float v, Color targetColor) {
"""
Converts HSV color system to RGB
@param h hue 0-360
@param s saturation 0-100
@param v value 0-100
@param targetColor color that result will be stored in
@return targetColor
"""
if (h == 360) h = 359;
int r, g, b;
int i;
float f, p, q, t;
h = (float) Math.max(0.0, Math.min(360.0, h));
s = (float) Math.max(0.0, Math.min(100.0, s));
v = (float) Math.max(0.0, Math.min(100.0, v));
s /= 100;
v /= 100;
h /= 60;
i = MathUtils.floor(h);
f = h - i;
p = v * (1 - s);
q = v * (1 - s * f);
t = v * (1 - s * (1 - f));
switch (i) {
case 0:
r = MathUtils.round(255 * v);
g = MathUtils.round(255 * t);
b = MathUtils.round(255 * p);
break;
case 1:
r = MathUtils.round(255 * q);
g = MathUtils.round(255 * v);
b = MathUtils.round(255 * p);
break;
case 2:
r = MathUtils.round(255 * p);
g = MathUtils.round(255 * v);
b = MathUtils.round(255 * t);
break;
case 3:
r = MathUtils.round(255 * p);
g = MathUtils.round(255 * q);
b = MathUtils.round(255 * v);
break;
case 4:
r = MathUtils.round(255 * t);
g = MathUtils.round(255 * p);
b = MathUtils.round(255 * v);
break;
default:
r = MathUtils.round(255 * v);
g = MathUtils.round(255 * p);
b = MathUtils.round(255 * q);
}
targetColor.set(r / 255.0f, g / 255.0f, b / 255.0f, targetColor.a);
return targetColor;
} | java | public static Color HSVtoRGB (float h, float s, float v, Color targetColor) {
if (h == 360) h = 359;
int r, g, b;
int i;
float f, p, q, t;
h = (float) Math.max(0.0, Math.min(360.0, h));
s = (float) Math.max(0.0, Math.min(100.0, s));
v = (float) Math.max(0.0, Math.min(100.0, v));
s /= 100;
v /= 100;
h /= 60;
i = MathUtils.floor(h);
f = h - i;
p = v * (1 - s);
q = v * (1 - s * f);
t = v * (1 - s * (1 - f));
switch (i) {
case 0:
r = MathUtils.round(255 * v);
g = MathUtils.round(255 * t);
b = MathUtils.round(255 * p);
break;
case 1:
r = MathUtils.round(255 * q);
g = MathUtils.round(255 * v);
b = MathUtils.round(255 * p);
break;
case 2:
r = MathUtils.round(255 * p);
g = MathUtils.round(255 * v);
b = MathUtils.round(255 * t);
break;
case 3:
r = MathUtils.round(255 * p);
g = MathUtils.round(255 * q);
b = MathUtils.round(255 * v);
break;
case 4:
r = MathUtils.round(255 * t);
g = MathUtils.round(255 * p);
b = MathUtils.round(255 * v);
break;
default:
r = MathUtils.round(255 * v);
g = MathUtils.round(255 * p);
b = MathUtils.round(255 * q);
}
targetColor.set(r / 255.0f, g / 255.0f, b / 255.0f, targetColor.a);
return targetColor;
} | [
"public",
"static",
"Color",
"HSVtoRGB",
"(",
"float",
"h",
",",
"float",
"s",
",",
"float",
"v",
",",
"Color",
"targetColor",
")",
"{",
"if",
"(",
"h",
"==",
"360",
")",
"h",
"=",
"359",
";",
"int",
"r",
",",
"g",
",",
"b",
";",
"int",
"i",
";",
"float",
"f",
",",
"p",
",",
"q",
",",
"t",
";",
"h",
"=",
"(",
"float",
")",
"Math",
".",
"max",
"(",
"0.0",
",",
"Math",
".",
"min",
"(",
"360.0",
",",
"h",
")",
")",
";",
"s",
"=",
"(",
"float",
")",
"Math",
".",
"max",
"(",
"0.0",
",",
"Math",
".",
"min",
"(",
"100.0",
",",
"s",
")",
")",
";",
"v",
"=",
"(",
"float",
")",
"Math",
".",
"max",
"(",
"0.0",
",",
"Math",
".",
"min",
"(",
"100.0",
",",
"v",
")",
")",
";",
"s",
"/=",
"100",
";",
"v",
"/=",
"100",
";",
"h",
"/=",
"60",
";",
"i",
"=",
"MathUtils",
".",
"floor",
"(",
"h",
")",
";",
"f",
"=",
"h",
"-",
"i",
";",
"p",
"=",
"v",
"*",
"(",
"1",
"-",
"s",
")",
";",
"q",
"=",
"v",
"*",
"(",
"1",
"-",
"s",
"*",
"f",
")",
";",
"t",
"=",
"v",
"*",
"(",
"1",
"-",
"s",
"*",
"(",
"1",
"-",
"f",
")",
")",
";",
"switch",
"(",
"i",
")",
"{",
"case",
"0",
":",
"r",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"v",
")",
";",
"g",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"t",
")",
";",
"b",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"p",
")",
";",
"break",
";",
"case",
"1",
":",
"r",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"q",
")",
";",
"g",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"v",
")",
";",
"b",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"p",
")",
";",
"break",
";",
"case",
"2",
":",
"r",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"p",
")",
";",
"g",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"v",
")",
";",
"b",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"t",
")",
";",
"break",
";",
"case",
"3",
":",
"r",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"p",
")",
";",
"g",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"q",
")",
";",
"b",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"v",
")",
";",
"break",
";",
"case",
"4",
":",
"r",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"t",
")",
";",
"g",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"p",
")",
";",
"b",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"v",
")",
";",
"break",
";",
"default",
":",
"r",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"v",
")",
";",
"g",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"p",
")",
";",
"b",
"=",
"MathUtils",
".",
"round",
"(",
"255",
"*",
"q",
")",
";",
"}",
"targetColor",
".",
"set",
"(",
"r",
"/",
"255.0f",
",",
"g",
"/",
"255.0f",
",",
"b",
"/",
"255.0f",
",",
"targetColor",
".",
"a",
")",
";",
"return",
"targetColor",
";",
"}"
] | Converts HSV color system to RGB
@param h hue 0-360
@param s saturation 0-100
@param v value 0-100
@param targetColor color that result will be stored in
@return targetColor | [
"Converts",
"HSV",
"color",
"system",
"to",
"RGB"
] | train | https://github.com/kotcrab/vis-ui/blob/3b68f82d94ae32bffa2a3399c63f432e0f4908e0/ui/src/main/java/com/kotcrab/vis/ui/util/ColorUtils.java#L63-L113 |
haraldk/TwelveMonkeys | sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/DebugUtil.java | DebugUtil.printClassName | public static void printClassName(final Object pObject, final PrintStream pPrintStream) {
"""
Prints the top-wrapped class name of a {@code java.lang.Object} to a {@code java.io.PrintStream}.
<p>
@param pObject the {@code java.lang.Object} to be printed.
@param pPrintStream the {@code java.io.PrintStream} for flushing the results.
@see <a href="http://java.sun.com/products/jdk/1.3/docs/api/java/lang/Class.html">{@code java.lang.Class}</a>
"""
if (pPrintStream == null) {
System.err.println(PRINTSTREAM_IS_NULL_ERROR_MESSAGE);
return;
}
pPrintStream.println(getClassName(pObject));
} | java | public static void printClassName(final Object pObject, final PrintStream pPrintStream) {
if (pPrintStream == null) {
System.err.println(PRINTSTREAM_IS_NULL_ERROR_MESSAGE);
return;
}
pPrintStream.println(getClassName(pObject));
} | [
"public",
"static",
"void",
"printClassName",
"(",
"final",
"Object",
"pObject",
",",
"final",
"PrintStream",
"pPrintStream",
")",
"{",
"if",
"(",
"pPrintStream",
"==",
"null",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"PRINTSTREAM_IS_NULL_ERROR_MESSAGE",
")",
";",
"return",
";",
"}",
"pPrintStream",
".",
"println",
"(",
"getClassName",
"(",
"pObject",
")",
")",
";",
"}"
] | Prints the top-wrapped class name of a {@code java.lang.Object} to a {@code java.io.PrintStream}.
<p>
@param pObject the {@code java.lang.Object} to be printed.
@param pPrintStream the {@code java.io.PrintStream} for flushing the results.
@see <a href="http://java.sun.com/products/jdk/1.3/docs/api/java/lang/Class.html">{@code java.lang.Class}</a> | [
"Prints",
"the",
"top",
"-",
"wrapped",
"class",
"name",
"of",
"a",
"{"
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/sandbox/sandbox-common/src/main/java/com/twelvemonkeys/util/DebugUtil.java#L1268-L1275 |
ModeShape/modeshape | modeshape-schematic/src/main/java/org/modeshape/schematic/internal/document/BsonUtils.java | BsonUtils.writeObjectId | public static void writeObjectId(ObjectId id, byte[] b) {
"""
Write the 12-byte representation of the ObjectId per the BSON specification (or rather the <a
href="http://www.mongodb.org/display/DOCS/Object+IDs">MongoDB documentation</a>).
@param id
the ObjectId; may not be null
@param b
the bytes into which the object ID should be written
"""
int time = id.getTime();
int machine = id.getMachine();
int process = id.getProcess();
int inc = id.getInc();
b[0] = (byte) ((time >>> 24) & 0xFF);
b[1] = (byte) ((time >>> 16) & 0xFF);
b[2] = (byte) ((time >>> 8) & 0xFF);
b[3] = (byte) ((time >>> 0) & 0xFF);
b[4] = (byte) ((machine >>> 16) & 0xFF);
b[5] = (byte) ((machine >>> 8) & 0xFF);
b[6] = (byte) ((machine >>> 0) & 0xFF);
b[7] = (byte) ((process >>> 8) & 0xFF);
b[8] = (byte) ((process >>> 0) & 0xFF);
b[9] = (byte) ((inc >>> 16) & 0xFF);
b[10] = (byte) ((inc >>> 8) & 0xFF);
b[11] = (byte) ((inc >>> 0) & 0xFF);
} | java | public static void writeObjectId(ObjectId id, byte[] b) {
int time = id.getTime();
int machine = id.getMachine();
int process = id.getProcess();
int inc = id.getInc();
b[0] = (byte) ((time >>> 24) & 0xFF);
b[1] = (byte) ((time >>> 16) & 0xFF);
b[2] = (byte) ((time >>> 8) & 0xFF);
b[3] = (byte) ((time >>> 0) & 0xFF);
b[4] = (byte) ((machine >>> 16) & 0xFF);
b[5] = (byte) ((machine >>> 8) & 0xFF);
b[6] = (byte) ((machine >>> 0) & 0xFF);
b[7] = (byte) ((process >>> 8) & 0xFF);
b[8] = (byte) ((process >>> 0) & 0xFF);
b[9] = (byte) ((inc >>> 16) & 0xFF);
b[10] = (byte) ((inc >>> 8) & 0xFF);
b[11] = (byte) ((inc >>> 0) & 0xFF);
} | [
"public",
"static",
"void",
"writeObjectId",
"(",
"ObjectId",
"id",
",",
"byte",
"[",
"]",
"b",
")",
"{",
"int",
"time",
"=",
"id",
".",
"getTime",
"(",
")",
";",
"int",
"machine",
"=",
"id",
".",
"getMachine",
"(",
")",
";",
"int",
"process",
"=",
"id",
".",
"getProcess",
"(",
")",
";",
"int",
"inc",
"=",
"id",
".",
"getInc",
"(",
")",
";",
"b",
"[",
"0",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"time",
">>>",
"24",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"1",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"time",
">>>",
"16",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"2",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"time",
">>>",
"8",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"3",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"time",
">>>",
"0",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"4",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"machine",
">>>",
"16",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"5",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"machine",
">>>",
"8",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"6",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"machine",
">>>",
"0",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"7",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"process",
">>>",
"8",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"8",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"process",
">>>",
"0",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"9",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"inc",
">>>",
"16",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"10",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"inc",
">>>",
"8",
")",
"&",
"0xFF",
")",
";",
"b",
"[",
"11",
"]",
"=",
"(",
"byte",
")",
"(",
"(",
"inc",
">>>",
"0",
")",
"&",
"0xFF",
")",
";",
"}"
] | Write the 12-byte representation of the ObjectId per the BSON specification (or rather the <a
href="http://www.mongodb.org/display/DOCS/Object+IDs">MongoDB documentation</a>).
@param id
the ObjectId; may not be null
@param b
the bytes into which the object ID should be written | [
"Write",
"the",
"12",
"-",
"byte",
"representation",
"of",
"the",
"ObjectId",
"per",
"the",
"BSON",
"specification",
"(",
"or",
"rather",
"the",
"<a",
"href",
"=",
"http",
":",
"//",
"www",
".",
"mongodb",
".",
"org",
"/",
"display",
"/",
"DOCS",
"/",
"Object",
"+",
"IDs",
">",
"MongoDB",
"documentation<",
"/",
"a",
">",
")",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-schematic/src/main/java/org/modeshape/schematic/internal/document/BsonUtils.java#L145-L162 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/core/ECKey.java | ECKey.verifyMessage | public void verifyMessage(String message, String signatureBase64) throws SignatureException {
"""
Convenience wrapper around {@link ECKey#signedMessageToKey(String, String)}. If the key derived from the
signature is not the same as this one, throws a SignatureException.
"""
ECKey key = ECKey.signedMessageToKey(message, signatureBase64);
if (!key.pub.equals(pub))
throw new SignatureException("Signature did not match for message");
} | java | public void verifyMessage(String message, String signatureBase64) throws SignatureException {
ECKey key = ECKey.signedMessageToKey(message, signatureBase64);
if (!key.pub.equals(pub))
throw new SignatureException("Signature did not match for message");
} | [
"public",
"void",
"verifyMessage",
"(",
"String",
"message",
",",
"String",
"signatureBase64",
")",
"throws",
"SignatureException",
"{",
"ECKey",
"key",
"=",
"ECKey",
".",
"signedMessageToKey",
"(",
"message",
",",
"signatureBase64",
")",
";",
"if",
"(",
"!",
"key",
".",
"pub",
".",
"equals",
"(",
"pub",
")",
")",
"throw",
"new",
"SignatureException",
"(",
"\"Signature did not match for message\"",
")",
";",
"}"
] | Convenience wrapper around {@link ECKey#signedMessageToKey(String, String)}. If the key derived from the
signature is not the same as this one, throws a SignatureException. | [
"Convenience",
"wrapper",
"around",
"{"
] | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/ECKey.java#L935-L939 |
alkacon/opencms-core | src/org/opencms/ui/dialogs/permissions/CmsPermissionView.java | CmsPermissionView.isDenied | protected Boolean isDenied(CmsPermissionSet p, int value) {
"""
Checks if a certain permission of a permission set is denied.<p>
@param p the current CmsPermissionSet
@param value the int value of the permission to check
@return true if the permission is denied, otherwise false
"""
if ((p.getDeniedPermissions() & value) > 0) {
return Boolean.TRUE;
}
return Boolean.FALSE;
} | java | protected Boolean isDenied(CmsPermissionSet p, int value) {
if ((p.getDeniedPermissions() & value) > 0) {
return Boolean.TRUE;
}
return Boolean.FALSE;
} | [
"protected",
"Boolean",
"isDenied",
"(",
"CmsPermissionSet",
"p",
",",
"int",
"value",
")",
"{",
"if",
"(",
"(",
"p",
".",
"getDeniedPermissions",
"(",
")",
"&",
"value",
")",
">",
"0",
")",
"{",
"return",
"Boolean",
".",
"TRUE",
";",
"}",
"return",
"Boolean",
".",
"FALSE",
";",
"}"
] | Checks if a certain permission of a permission set is denied.<p>
@param p the current CmsPermissionSet
@param value the int value of the permission to check
@return true if the permission is denied, otherwise false | [
"Checks",
"if",
"a",
"certain",
"permission",
"of",
"a",
"permission",
"set",
"is",
"denied",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/dialogs/permissions/CmsPermissionView.java#L429-L435 |
kotcrab/vis-ui | ui/src/main/java/com/kotcrab/vis/ui/FocusManager.java | FocusManager.switchFocus | public static void switchFocus (Stage stage, Focusable widget) {
"""
Takes focus from current focused widget (if any), and sets focus to provided widget
@param stage if passed stage is not null then stage keyboard focus will be set to null
@param widget that will acquire focus
"""
if (focusedWidget == widget) return;
if (focusedWidget != null) focusedWidget.focusLost();
focusedWidget = widget;
if (stage != null) stage.setKeyboardFocus(null);
focusedWidget.focusGained();
} | java | public static void switchFocus (Stage stage, Focusable widget) {
if (focusedWidget == widget) return;
if (focusedWidget != null) focusedWidget.focusLost();
focusedWidget = widget;
if (stage != null) stage.setKeyboardFocus(null);
focusedWidget.focusGained();
} | [
"public",
"static",
"void",
"switchFocus",
"(",
"Stage",
"stage",
",",
"Focusable",
"widget",
")",
"{",
"if",
"(",
"focusedWidget",
"==",
"widget",
")",
"return",
";",
"if",
"(",
"focusedWidget",
"!=",
"null",
")",
"focusedWidget",
".",
"focusLost",
"(",
")",
";",
"focusedWidget",
"=",
"widget",
";",
"if",
"(",
"stage",
"!=",
"null",
")",
"stage",
".",
"setKeyboardFocus",
"(",
"null",
")",
";",
"focusedWidget",
".",
"focusGained",
"(",
")",
";",
"}"
] | Takes focus from current focused widget (if any), and sets focus to provided widget
@param stage if passed stage is not null then stage keyboard focus will be set to null
@param widget that will acquire focus | [
"Takes",
"focus",
"from",
"current",
"focused",
"widget",
"(",
"if",
"any",
")",
"and",
"sets",
"focus",
"to",
"provided",
"widget"
] | train | https://github.com/kotcrab/vis-ui/blob/3b68f82d94ae32bffa2a3399c63f432e0f4908e0/ui/src/main/java/com/kotcrab/vis/ui/FocusManager.java#L37-L43 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/FilesImpl.java | FilesImpl.listFromComputeNodeNextWithServiceResponseAsync | public Observable<ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders>> listFromComputeNodeNextWithServiceResponseAsync(final String nextPageLink, final FileListFromComputeNodeNextOptions fileListFromComputeNodeNextOptions) {
"""
Lists all of the files in task directories on the specified compute node.
@param nextPageLink The NextLink from the previous successful call to List operation.
@param fileListFromComputeNodeNextOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<NodeFile> object
"""
return listFromComputeNodeNextSinglePageAsync(nextPageLink, fileListFromComputeNodeNextOptions)
.concatMap(new Func1<ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders>, Observable<ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders>> call(ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listFromComputeNodeNextWithServiceResponseAsync(nextPageLink, fileListFromComputeNodeNextOptions));
}
});
} | java | public Observable<ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders>> listFromComputeNodeNextWithServiceResponseAsync(final String nextPageLink, final FileListFromComputeNodeNextOptions fileListFromComputeNodeNextOptions) {
return listFromComputeNodeNextSinglePageAsync(nextPageLink, fileListFromComputeNodeNextOptions)
.concatMap(new Func1<ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders>, Observable<ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders>>>() {
@Override
public Observable<ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders>> call(ServiceResponseWithHeaders<Page<NodeFile>, FileListFromComputeNodeHeaders> page) {
String nextPageLink = page.body().nextPageLink();
if (nextPageLink == null) {
return Observable.just(page);
}
return Observable.just(page).concatWith(listFromComputeNodeNextWithServiceResponseAsync(nextPageLink, fileListFromComputeNodeNextOptions));
}
});
} | [
"public",
"Observable",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"NodeFile",
">",
",",
"FileListFromComputeNodeHeaders",
">",
">",
"listFromComputeNodeNextWithServiceResponseAsync",
"(",
"final",
"String",
"nextPageLink",
",",
"final",
"FileListFromComputeNodeNextOptions",
"fileListFromComputeNodeNextOptions",
")",
"{",
"return",
"listFromComputeNodeNextSinglePageAsync",
"(",
"nextPageLink",
",",
"fileListFromComputeNodeNextOptions",
")",
".",
"concatMap",
"(",
"new",
"Func1",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"NodeFile",
">",
",",
"FileListFromComputeNodeHeaders",
">",
",",
"Observable",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"NodeFile",
">",
",",
"FileListFromComputeNodeHeaders",
">",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Observable",
"<",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"NodeFile",
">",
",",
"FileListFromComputeNodeHeaders",
">",
">",
"call",
"(",
"ServiceResponseWithHeaders",
"<",
"Page",
"<",
"NodeFile",
">",
",",
"FileListFromComputeNodeHeaders",
">",
"page",
")",
"{",
"String",
"nextPageLink",
"=",
"page",
".",
"body",
"(",
")",
".",
"nextPageLink",
"(",
")",
";",
"if",
"(",
"nextPageLink",
"==",
"null",
")",
"{",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
";",
"}",
"return",
"Observable",
".",
"just",
"(",
"page",
")",
".",
"concatWith",
"(",
"listFromComputeNodeNextWithServiceResponseAsync",
"(",
"nextPageLink",
",",
"fileListFromComputeNodeNextOptions",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Lists all of the files in task directories on the specified compute node.
@param nextPageLink The NextLink from the previous successful call to List operation.
@param fileListFromComputeNodeNextOptions Additional parameters for the operation
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PagedList<NodeFile> object | [
"Lists",
"all",
"of",
"the",
"files",
"in",
"task",
"directories",
"on",
"the",
"specified",
"compute",
"node",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/protocol/implementation/FilesImpl.java#L2646-L2658 |
Wadpam/guja | guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java | GeneratedDContactDaoImpl.queryByCreatedBy | public Iterable<DContact> queryByCreatedBy(Object parent, java.lang.String createdBy) {
"""
query-by method for field createdBy
@param createdBy the specified attribute
@return an Iterable of DContacts for the specified createdBy
"""
return queryByField(parent, DContactMapper.Field.CREATEDBY.getFieldName(), createdBy);
} | java | public Iterable<DContact> queryByCreatedBy(Object parent, java.lang.String createdBy) {
return queryByField(parent, DContactMapper.Field.CREATEDBY.getFieldName(), createdBy);
} | [
"public",
"Iterable",
"<",
"DContact",
">",
"queryByCreatedBy",
"(",
"Object",
"parent",
",",
"java",
".",
"lang",
".",
"String",
"createdBy",
")",
"{",
"return",
"queryByField",
"(",
"parent",
",",
"DContactMapper",
".",
"Field",
".",
"CREATEDBY",
".",
"getFieldName",
"(",
")",
",",
"createdBy",
")",
";",
"}"
] | query-by method for field createdBy
@param createdBy the specified attribute
@return an Iterable of DContacts for the specified createdBy | [
"query",
"-",
"by",
"method",
"for",
"field",
"createdBy"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java#L133-L135 |
HanSolo/tilesfx | src/main/java/eu/hansolo/tilesfx/tools/SunMoonCalculator.java | SunMoonCalculator.getDateAsString | public static String getDateAsString(final double JULIAN_DAY, final int TIMEZONE_OFFSET) throws Exception {
"""
Returns a date as a string.
@param JULIAN_DAY The Juliand day.
@return The String.
@throws Exception If the date does not exists.
"""
if (JULIAN_DAY == -1) return "NO RISE/SET/TRANSIT FOR THIS OBSERVER/DATE";
int date[] = SunMoonCalculator.getDate(JULIAN_DAY);
return date[0] + "/" + date[1] + "/" + date[2] + " " + ((date[3] + TIMEZONE_OFFSET) % 24) + ":" + date[4] + ":" + date[5] + " UT";
} | java | public static String getDateAsString(final double JULIAN_DAY, final int TIMEZONE_OFFSET) throws Exception {
if (JULIAN_DAY == -1) return "NO RISE/SET/TRANSIT FOR THIS OBSERVER/DATE";
int date[] = SunMoonCalculator.getDate(JULIAN_DAY);
return date[0] + "/" + date[1] + "/" + date[2] + " " + ((date[3] + TIMEZONE_OFFSET) % 24) + ":" + date[4] + ":" + date[5] + " UT";
} | [
"public",
"static",
"String",
"getDateAsString",
"(",
"final",
"double",
"JULIAN_DAY",
",",
"final",
"int",
"TIMEZONE_OFFSET",
")",
"throws",
"Exception",
"{",
"if",
"(",
"JULIAN_DAY",
"==",
"-",
"1",
")",
"return",
"\"NO RISE/SET/TRANSIT FOR THIS OBSERVER/DATE\"",
";",
"int",
"date",
"[",
"]",
"=",
"SunMoonCalculator",
".",
"getDate",
"(",
"JULIAN_DAY",
")",
";",
"return",
"date",
"[",
"0",
"]",
"+",
"\"/\"",
"+",
"date",
"[",
"1",
"]",
"+",
"\"/\"",
"+",
"date",
"[",
"2",
"]",
"+",
"\" \"",
"+",
"(",
"(",
"date",
"[",
"3",
"]",
"+",
"TIMEZONE_OFFSET",
")",
"%",
"24",
")",
"+",
"\":\"",
"+",
"date",
"[",
"4",
"]",
"+",
"\":\"",
"+",
"date",
"[",
"5",
"]",
"+",
"\" UT\"",
";",
"}"
] | Returns a date as a string.
@param JULIAN_DAY The Juliand day.
@return The String.
@throws Exception If the date does not exists. | [
"Returns",
"a",
"date",
"as",
"a",
"string",
"."
] | train | https://github.com/HanSolo/tilesfx/blob/36eb07b1119017beb851dad95256439224d1fcf4/src/main/java/eu/hansolo/tilesfx/tools/SunMoonCalculator.java#L215-L220 |
ltsopensource/light-task-scheduler | lts-core/src/main/java/com/github/ltsopensource/core/commons/utils/WebUtils.java | WebUtils.encode | public static String encode(String value, String charset) {
"""
使用指定的字符集编码请求参数值。
@param value 参数值
@param charset 字符集
@return 编码后的参数值
"""
String result = null;
if (!StringUtils.isEmpty(value)) {
try {
result = URLEncoder.encode(value, charset);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return result;
} | java | public static String encode(String value, String charset) {
String result = null;
if (!StringUtils.isEmpty(value)) {
try {
result = URLEncoder.encode(value, charset);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return result;
} | [
"public",
"static",
"String",
"encode",
"(",
"String",
"value",
",",
"String",
"charset",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"!",
"StringUtils",
".",
"isEmpty",
"(",
"value",
")",
")",
"{",
"try",
"{",
"result",
"=",
"URLEncoder",
".",
"encode",
"(",
"value",
",",
"charset",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | 使用指定的字符集编码请求参数值。
@param value 参数值
@param charset 字符集
@return 编码后的参数值 | [
"使用指定的字符集编码请求参数值。"
] | train | https://github.com/ltsopensource/light-task-scheduler/blob/64d3aa000ff5022be5e94f511b58f405e5f4c8eb/lts-core/src/main/java/com/github/ltsopensource/core/commons/utils/WebUtils.java#L332-L342 |
jeremybrooks/jinx | src/main/java/net/jeremybrooks/jinx/api/PhotosApi.java | PhotosApi.setTags | public Response setTags(String photoId, List<String> tags) throws JinxException {
"""
Set the tags for a photo.
<br>
This method requires authentication with 'write' permission.
<br>
Each tag in the list will be treated as a single tag. This method will automatically add quotation marks as
needed so that multi-word tags will be treated correctly by Flickr. This method can also be used to add
machine tags.
<br>
This list of tags will replace the tags that currently exist on the photo.
<br>
If the tag list is null or empty, all tags will be removed from the photo.
@param photoId id of the photo to set tags for.
@param tags all tags for the photo, one tag per list element. If this parameter is null or empty, all tags
will be removed from the photo.
@return response object with status of the requested operation.
@throws JinxException if photo id is null or empty, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.photos.setTags.html">flickr.photos.setTags</a>
"""
JinxUtils.validateParams(photoId);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.setTags");
params.put("photo_id", photoId);
if (tags == null || tags.size() == 0) {
params.put("tags", "");
} else {
StringBuilder sb = new StringBuilder();
for (String tag : tags) {
if (tag.contains(" ")) {
sb.append('"').append(tag).append('"');
} else {
sb.append(tag);
}
sb.append(' ');
}
sb.deleteCharAt(sb.length() - 1);
params.put("tags", sb.toString());
}
return this.jinx.flickrPost(params, Response.class);
} | java | public Response setTags(String photoId, List<String> tags) throws JinxException {
JinxUtils.validateParams(photoId);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.setTags");
params.put("photo_id", photoId);
if (tags == null || tags.size() == 0) {
params.put("tags", "");
} else {
StringBuilder sb = new StringBuilder();
for (String tag : tags) {
if (tag.contains(" ")) {
sb.append('"').append(tag).append('"');
} else {
sb.append(tag);
}
sb.append(' ');
}
sb.deleteCharAt(sb.length() - 1);
params.put("tags", sb.toString());
}
return this.jinx.flickrPost(params, Response.class);
} | [
"public",
"Response",
"setTags",
"(",
"String",
"photoId",
",",
"List",
"<",
"String",
">",
"tags",
")",
"throws",
"JinxException",
"{",
"JinxUtils",
".",
"validateParams",
"(",
"photoId",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"params",
".",
"put",
"(",
"\"method\"",
",",
"\"flickr.photos.setTags\"",
")",
";",
"params",
".",
"put",
"(",
"\"photo_id\"",
",",
"photoId",
")",
";",
"if",
"(",
"tags",
"==",
"null",
"||",
"tags",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"params",
".",
"put",
"(",
"\"tags\"",
",",
"\"\"",
")",
";",
"}",
"else",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"String",
"tag",
":",
"tags",
")",
"{",
"if",
"(",
"tag",
".",
"contains",
"(",
"\" \"",
")",
")",
"{",
"sb",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"tag",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"tag",
")",
";",
"}",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"sb",
".",
"deleteCharAt",
"(",
"sb",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"params",
".",
"put",
"(",
"\"tags\"",
",",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"this",
".",
"jinx",
".",
"flickrPost",
"(",
"params",
",",
"Response",
".",
"class",
")",
";",
"}"
] | Set the tags for a photo.
<br>
This method requires authentication with 'write' permission.
<br>
Each tag in the list will be treated as a single tag. This method will automatically add quotation marks as
needed so that multi-word tags will be treated correctly by Flickr. This method can also be used to add
machine tags.
<br>
This list of tags will replace the tags that currently exist on the photo.
<br>
If the tag list is null or empty, all tags will be removed from the photo.
@param photoId id of the photo to set tags for.
@param tags all tags for the photo, one tag per list element. If this parameter is null or empty, all tags
will be removed from the photo.
@return response object with status of the requested operation.
@throws JinxException if photo id is null or empty, or if there are any errors.
@see <a href="https://www.flickr.com/services/api/flickr.photos.setTags.html">flickr.photos.setTags</a> | [
"Set",
"the",
"tags",
"for",
"a",
"photo",
".",
"<br",
">",
"This",
"method",
"requires",
"authentication",
"with",
"write",
"permission",
".",
"<br",
">",
"Each",
"tag",
"in",
"the",
"list",
"will",
"be",
"treated",
"as",
"a",
"single",
"tag",
".",
"This",
"method",
"will",
"automatically",
"add",
"quotation",
"marks",
"as",
"needed",
"so",
"that",
"multi",
"-",
"word",
"tags",
"will",
"be",
"treated",
"correctly",
"by",
"Flickr",
".",
"This",
"method",
"can",
"also",
"be",
"used",
"to",
"add",
"machine",
"tags",
".",
"<br",
">",
"This",
"list",
"of",
"tags",
"will",
"replace",
"the",
"tags",
"that",
"currently",
"exist",
"on",
"the",
"photo",
".",
"<br",
">",
"If",
"the",
"tag",
"list",
"is",
"null",
"or",
"empty",
"all",
"tags",
"will",
"be",
"removed",
"from",
"the",
"photo",
"."
] | train | https://github.com/jeremybrooks/jinx/blob/ab7a4b7462d08bcbfd9b98bd3f5029771c20f6c6/src/main/java/net/jeremybrooks/jinx/api/PhotosApi.java#L1032-L1053 |
casmi/casmi | src/main/java/casmi/graphics/element/Quad.java | Quad.setConer | public void setConer(int index, Vector3D v) {
"""
Sets coordinates of a corner.
@param index The index of a corner.
@param v The coordinates of a corner.
"""
if (index <= 0) {
this.x1 = v.getX();
this.y1 = v.getY();
} else if (index == 1) {
this.x2 = v.getX();
this.y2 = v.getY();
} else if (index == 2) {
this.x3 = v.getX();
this.y3 = v.getY();
} else if (3 <= index) {
this.x4 = v.getX();
this.y4 = v.getY();
}
calcG();
} | java | public void setConer(int index, Vector3D v) {
if (index <= 0) {
this.x1 = v.getX();
this.y1 = v.getY();
} else if (index == 1) {
this.x2 = v.getX();
this.y2 = v.getY();
} else if (index == 2) {
this.x3 = v.getX();
this.y3 = v.getY();
} else if (3 <= index) {
this.x4 = v.getX();
this.y4 = v.getY();
}
calcG();
} | [
"public",
"void",
"setConer",
"(",
"int",
"index",
",",
"Vector3D",
"v",
")",
"{",
"if",
"(",
"index",
"<=",
"0",
")",
"{",
"this",
".",
"x1",
"=",
"v",
".",
"getX",
"(",
")",
";",
"this",
".",
"y1",
"=",
"v",
".",
"getY",
"(",
")",
";",
"}",
"else",
"if",
"(",
"index",
"==",
"1",
")",
"{",
"this",
".",
"x2",
"=",
"v",
".",
"getX",
"(",
")",
";",
"this",
".",
"y2",
"=",
"v",
".",
"getY",
"(",
")",
";",
"}",
"else",
"if",
"(",
"index",
"==",
"2",
")",
"{",
"this",
".",
"x3",
"=",
"v",
".",
"getX",
"(",
")",
";",
"this",
".",
"y3",
"=",
"v",
".",
"getY",
"(",
")",
";",
"}",
"else",
"if",
"(",
"3",
"<=",
"index",
")",
"{",
"this",
".",
"x4",
"=",
"v",
".",
"getX",
"(",
")",
";",
"this",
".",
"y4",
"=",
"v",
".",
"getY",
"(",
")",
";",
"}",
"calcG",
"(",
")",
";",
"}"
] | Sets coordinates of a corner.
@param index The index of a corner.
@param v The coordinates of a corner. | [
"Sets",
"coordinates",
"of",
"a",
"corner",
"."
] | train | https://github.com/casmi/casmi/blob/90f6514a9cbce0685186e7a92beb69e22a3b11c4/src/main/java/casmi/graphics/element/Quad.java#L199-L214 |
Sciss/abc4j | abc/src/main/java/abc/ui/swing/ScoreTemplate.java | ScoreTemplate.setVisible | public void setVisible(byte[] fields, boolean visible) {
"""
Sets the visibility of several fields
@param fields
array of {@link ScoreElements} constants
"""
for (byte field : fields) {
getFieldInfos(field).m_visible = visible;
}
notifyListeners();
} | java | public void setVisible(byte[] fields, boolean visible) {
for (byte field : fields) {
getFieldInfos(field).m_visible = visible;
}
notifyListeners();
} | [
"public",
"void",
"setVisible",
"(",
"byte",
"[",
"]",
"fields",
",",
"boolean",
"visible",
")",
"{",
"for",
"(",
"byte",
"field",
":",
"fields",
")",
"{",
"getFieldInfos",
"(",
"field",
")",
".",
"m_visible",
"=",
"visible",
";",
"}",
"notifyListeners",
"(",
")",
";",
"}"
] | Sets the visibility of several fields
@param fields
array of {@link ScoreElements} constants | [
"Sets",
"the",
"visibility",
"of",
"several",
"fields"
] | train | https://github.com/Sciss/abc4j/blob/117b405642c84a7bfca4e3e13668838258b90ca7/abc/src/main/java/abc/ui/swing/ScoreTemplate.java#L1037-L1042 |
gliga/ekstazi | ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/StaticSelectEkstaziMojo.java | StaticSelectEkstaziMojo.checkSurefirePlugin | protected void checkSurefirePlugin(Plugin plugin, String[] nonSupportedVersions, String minSupported) throws MojoExecutionException {
"""
Check if surefire plugin is available and if correct version is
used (we require 2.13 or higher, as previous versions do not
support excludesFile).
"""
// Check if plugin is available.
if (plugin == null) {
throw new MojoExecutionException("Surefire plugin not avaialble");
}
String version = plugin.getVersion();
for (String nonSupportedVersion : nonSupportedVersions) {
if (version.equals(nonSupportedVersion)) {
throw new MojoExecutionException("Not supported surefire version; version has to be " + minSupported + " or higher");
}
}
} | java | protected void checkSurefirePlugin(Plugin plugin, String[] nonSupportedVersions, String minSupported) throws MojoExecutionException {
// Check if plugin is available.
if (plugin == null) {
throw new MojoExecutionException("Surefire plugin not avaialble");
}
String version = plugin.getVersion();
for (String nonSupportedVersion : nonSupportedVersions) {
if (version.equals(nonSupportedVersion)) {
throw new MojoExecutionException("Not supported surefire version; version has to be " + minSupported + " or higher");
}
}
} | [
"protected",
"void",
"checkSurefirePlugin",
"(",
"Plugin",
"plugin",
",",
"String",
"[",
"]",
"nonSupportedVersions",
",",
"String",
"minSupported",
")",
"throws",
"MojoExecutionException",
"{",
"// Check if plugin is available.",
"if",
"(",
"plugin",
"==",
"null",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Surefire plugin not avaialble\"",
")",
";",
"}",
"String",
"version",
"=",
"plugin",
".",
"getVersion",
"(",
")",
";",
"for",
"(",
"String",
"nonSupportedVersion",
":",
"nonSupportedVersions",
")",
"{",
"if",
"(",
"version",
".",
"equals",
"(",
"nonSupportedVersion",
")",
")",
"{",
"throw",
"new",
"MojoExecutionException",
"(",
"\"Not supported surefire version; version has to be \"",
"+",
"minSupported",
"+",
"\" or higher\"",
")",
";",
"}",
"}",
"}"
] | Check if surefire plugin is available and if correct version is
used (we require 2.13 or higher, as previous versions do not
support excludesFile). | [
"Check",
"if",
"surefire",
"plugin",
"is",
"available",
"and",
"if",
"correct",
"version",
"is",
"used",
"(",
"we",
"require",
"2",
".",
"13",
"or",
"higher",
"as",
"previous",
"versions",
"do",
"not",
"support",
"excludesFile",
")",
"."
] | train | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/ekstazi-maven-plugin/src/main/java/org/ekstazi/maven/StaticSelectEkstaziMojo.java#L342-L353 |
citiususc/hipster | hipster-core/src/main/java/es/usc/citius/hipster/util/examples/maze/Maze2D.java | Maze2D.removeObstacleRectangle | public void removeObstacleRectangle(Point a, Point b) {
"""
Fill a rectangle defined by points a and b with empty tiles.
@param a point a of the rectangle.
@param b point b of the rectangle.
"""
updateRectangle(a, b, Symbol.EMPTY);
} | java | public void removeObstacleRectangle(Point a, Point b) {
updateRectangle(a, b, Symbol.EMPTY);
} | [
"public",
"void",
"removeObstacleRectangle",
"(",
"Point",
"a",
",",
"Point",
"b",
")",
"{",
"updateRectangle",
"(",
"a",
",",
"b",
",",
"Symbol",
".",
"EMPTY",
")",
";",
"}"
] | Fill a rectangle defined by points a and b with empty tiles.
@param a point a of the rectangle.
@param b point b of the rectangle. | [
"Fill",
"a",
"rectangle",
"defined",
"by",
"points",
"a",
"and",
"b",
"with",
"empty",
"tiles",
"."
] | train | https://github.com/citiususc/hipster/blob/9ab1236abb833a27641ae73ba9ca890d5c17598e/hipster-core/src/main/java/es/usc/citius/hipster/util/examples/maze/Maze2D.java#L305-L307 |
wildfly/wildfly-maven-plugin | core/src/main/java/org/wildfly/plugin/core/ServerHelper.java | ServerHelper.determineHostAddress | public static ModelNode determineHostAddress(final ModelControllerClient client) throws IOException, OperationExecutionException {
"""
Determines the address for the host being used.
@param client the client used to communicate with the server
@return the address of the host
@throws IOException if an error occurs communicating with the server
@throws OperationExecutionException if the operation used to determine the host name fails
"""
final ModelNode op = Operations.createReadAttributeOperation(EMPTY_ADDRESS, "local-host-name");
ModelNode response = client.execute(op);
if (Operations.isSuccessfulOutcome(response)) {
return DeploymentOperations.createAddress("host", Operations.readResult(response).asString());
}
throw new OperationExecutionException(op, response);
} | java | public static ModelNode determineHostAddress(final ModelControllerClient client) throws IOException, OperationExecutionException {
final ModelNode op = Operations.createReadAttributeOperation(EMPTY_ADDRESS, "local-host-name");
ModelNode response = client.execute(op);
if (Operations.isSuccessfulOutcome(response)) {
return DeploymentOperations.createAddress("host", Operations.readResult(response).asString());
}
throw new OperationExecutionException(op, response);
} | [
"public",
"static",
"ModelNode",
"determineHostAddress",
"(",
"final",
"ModelControllerClient",
"client",
")",
"throws",
"IOException",
",",
"OperationExecutionException",
"{",
"final",
"ModelNode",
"op",
"=",
"Operations",
".",
"createReadAttributeOperation",
"(",
"EMPTY_ADDRESS",
",",
"\"local-host-name\"",
")",
";",
"ModelNode",
"response",
"=",
"client",
".",
"execute",
"(",
"op",
")",
";",
"if",
"(",
"Operations",
".",
"isSuccessfulOutcome",
"(",
"response",
")",
")",
"{",
"return",
"DeploymentOperations",
".",
"createAddress",
"(",
"\"host\"",
",",
"Operations",
".",
"readResult",
"(",
"response",
")",
".",
"asString",
"(",
")",
")",
";",
"}",
"throw",
"new",
"OperationExecutionException",
"(",
"op",
",",
"response",
")",
";",
"}"
] | Determines the address for the host being used.
@param client the client used to communicate with the server
@return the address of the host
@throws IOException if an error occurs communicating with the server
@throws OperationExecutionException if the operation used to determine the host name fails | [
"Determines",
"the",
"address",
"for",
"the",
"host",
"being",
"used",
"."
] | train | https://github.com/wildfly/wildfly-maven-plugin/blob/c0e2d7ee28e511092561801959eae253b2b56def/core/src/main/java/org/wildfly/plugin/core/ServerHelper.java#L268-L275 |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.createEntity | public ApiResponse createEntity(Map<String, Object> properties) {
"""
Create a new entity on the server from a set of properties. Properties
must include a "type" property.
@param properties
@return an ApiResponse with the new entity in it.
"""
assertValidApplicationId();
if (isEmpty(properties.get("type"))) {
throw new IllegalArgumentException("Missing entity type");
}
ApiResponse response = apiRequest(HttpMethod.POST, null, properties,
organizationId, applicationId, properties.get("type").toString());
return response;
} | java | public ApiResponse createEntity(Map<String, Object> properties) {
assertValidApplicationId();
if (isEmpty(properties.get("type"))) {
throw new IllegalArgumentException("Missing entity type");
}
ApiResponse response = apiRequest(HttpMethod.POST, null, properties,
organizationId, applicationId, properties.get("type").toString());
return response;
} | [
"public",
"ApiResponse",
"createEntity",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"assertValidApplicationId",
"(",
")",
";",
"if",
"(",
"isEmpty",
"(",
"properties",
".",
"get",
"(",
"\"type\"",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Missing entity type\"",
")",
";",
"}",
"ApiResponse",
"response",
"=",
"apiRequest",
"(",
"HttpMethod",
".",
"POST",
",",
"null",
",",
"properties",
",",
"organizationId",
",",
"applicationId",
",",
"properties",
".",
"get",
"(",
"\"type\"",
")",
".",
"toString",
"(",
")",
")",
";",
"return",
"response",
";",
"}"
] | Create a new entity on the server from a set of properties. Properties
must include a "type" property.
@param properties
@return an ApiResponse with the new entity in it. | [
"Create",
"a",
"new",
"entity",
"on",
"the",
"server",
"from",
"a",
"set",
"of",
"properties",
".",
"Properties",
"must",
"include",
"a",
"type",
"property",
"."
] | train | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L596-L604 |
ironjacamar/ironjacamar | codegenerator/src/main/java/org/ironjacamar/codegenerator/BaseProfile.java | BaseProfile.writeIronjacamarXml | private void writeIronjacamarXml(Definition def, String outputDir) throws IOException {
"""
writeIronjacamarXml
@param def Definition
@param outputDir output directory
@throws IOException output exception
"""
FileWriter ijfw = Utils.createFile("ironjacamar.xml", outputDir + File.separatorChar + "META-INF");
IronjacamarXmlGen ijxGen = new IronjacamarXmlGen();
ijxGen.generate(def, ijfw);
ijfw.close();
} | java | private void writeIronjacamarXml(Definition def, String outputDir) throws IOException
{
FileWriter ijfw = Utils.createFile("ironjacamar.xml", outputDir + File.separatorChar + "META-INF");
IronjacamarXmlGen ijxGen = new IronjacamarXmlGen();
ijxGen.generate(def, ijfw);
ijfw.close();
} | [
"private",
"void",
"writeIronjacamarXml",
"(",
"Definition",
"def",
",",
"String",
"outputDir",
")",
"throws",
"IOException",
"{",
"FileWriter",
"ijfw",
"=",
"Utils",
".",
"createFile",
"(",
"\"ironjacamar.xml\"",
",",
"outputDir",
"+",
"File",
".",
"separatorChar",
"+",
"\"META-INF\"",
")",
";",
"IronjacamarXmlGen",
"ijxGen",
"=",
"new",
"IronjacamarXmlGen",
"(",
")",
";",
"ijxGen",
".",
"generate",
"(",
"def",
",",
"ijfw",
")",
";",
"ijfw",
".",
"close",
"(",
")",
";",
"}"
] | writeIronjacamarXml
@param def Definition
@param outputDir output directory
@throws IOException output exception | [
"writeIronjacamarXml"
] | train | https://github.com/ironjacamar/ironjacamar/blob/f0389ee7e62aa8b40ba09b251edad76d220ea796/codegenerator/src/main/java/org/ironjacamar/codegenerator/BaseProfile.java#L496-L502 |
davetcc/tcMenu | tcMenuJavaApi/src/main/java/com/thecoderscorner/menu/domain/state/MenuTree.java | MenuTree.moveItem | public void moveItem(SubMenuItem parent, MenuItem newItem, MoveType moveType) {
"""
Moves the item either up or down in the list for that submenu
@param parent the parent id
@param newItem the item to move
@param moveType the direction of the move.
"""
synchronized (subMenuItems) {
ArrayList<MenuItem> items = subMenuItems.get(parent);
int idx = items.indexOf(newItem);
if(idx < 0) return;
items.remove(idx);
idx = (moveType == MoveType.MOVE_UP)? --idx : ++idx;
if(idx<0) idx=0;
if(idx>=items.size()) {
items.add(newItem);
}
else {
items.add(idx, newItem);
}
}
} | java | public void moveItem(SubMenuItem parent, MenuItem newItem, MoveType moveType) {
synchronized (subMenuItems) {
ArrayList<MenuItem> items = subMenuItems.get(parent);
int idx = items.indexOf(newItem);
if(idx < 0) return;
items.remove(idx);
idx = (moveType == MoveType.MOVE_UP)? --idx : ++idx;
if(idx<0) idx=0;
if(idx>=items.size()) {
items.add(newItem);
}
else {
items.add(idx, newItem);
}
}
} | [
"public",
"void",
"moveItem",
"(",
"SubMenuItem",
"parent",
",",
"MenuItem",
"newItem",
",",
"MoveType",
"moveType",
")",
"{",
"synchronized",
"(",
"subMenuItems",
")",
"{",
"ArrayList",
"<",
"MenuItem",
">",
"items",
"=",
"subMenuItems",
".",
"get",
"(",
"parent",
")",
";",
"int",
"idx",
"=",
"items",
".",
"indexOf",
"(",
"newItem",
")",
";",
"if",
"(",
"idx",
"<",
"0",
")",
"return",
";",
"items",
".",
"remove",
"(",
"idx",
")",
";",
"idx",
"=",
"(",
"moveType",
"==",
"MoveType",
".",
"MOVE_UP",
")",
"?",
"--",
"idx",
":",
"++",
"idx",
";",
"if",
"(",
"idx",
"<",
"0",
")",
"idx",
"=",
"0",
";",
"if",
"(",
"idx",
">=",
"items",
".",
"size",
"(",
")",
")",
"{",
"items",
".",
"add",
"(",
"newItem",
")",
";",
"}",
"else",
"{",
"items",
".",
"add",
"(",
"idx",
",",
"newItem",
")",
";",
"}",
"}",
"}"
] | Moves the item either up or down in the list for that submenu
@param parent the parent id
@param newItem the item to move
@param moveType the direction of the move. | [
"Moves",
"the",
"item",
"either",
"up",
"or",
"down",
"in",
"the",
"list",
"for",
"that",
"submenu"
] | train | https://github.com/davetcc/tcMenu/blob/61546e4b982b25ceaff384073fe9ec1fff55e64a/tcMenuJavaApi/src/main/java/com/thecoderscorner/menu/domain/state/MenuTree.java#L156-L174 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/ApplicationSecurityGroupsInner.java | ApplicationSecurityGroupsInner.beginDelete | public void beginDelete(String resourceGroupName, String applicationSecurityGroupName) {
"""
Deletes the specified application security group.
@param resourceGroupName The name of the resource group.
@param applicationSecurityGroupName The name of the application security group.
@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
"""
beginDeleteWithServiceResponseAsync(resourceGroupName, applicationSecurityGroupName).toBlocking().single().body();
} | java | public void beginDelete(String resourceGroupName, String applicationSecurityGroupName) {
beginDeleteWithServiceResponseAsync(resourceGroupName, applicationSecurityGroupName).toBlocking().single().body();
} | [
"public",
"void",
"beginDelete",
"(",
"String",
"resourceGroupName",
",",
"String",
"applicationSecurityGroupName",
")",
"{",
"beginDeleteWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"applicationSecurityGroupName",
")",
".",
"toBlocking",
"(",
")",
".",
"single",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Deletes the specified application security group.
@param resourceGroupName The name of the resource group.
@param applicationSecurityGroupName The name of the application security group.
@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 | [
"Deletes",
"the",
"specified",
"application",
"security",
"group",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_06_01/src/main/java/com/microsoft/azure/management/network/v2018_06_01/implementation/ApplicationSecurityGroupsInner.java#L180-L182 |
Azure/azure-sdk-for-java | mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/ServersInner.java | ServersInner.getByResourceGroupAsync | public Observable<ServerInner> getByResourceGroupAsync(String resourceGroupName, String serverName) {
"""
Gets information about a server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServerInner object
"""
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<ServerInner>, ServerInner>() {
@Override
public ServerInner call(ServiceResponse<ServerInner> response) {
return response.body();
}
});
} | java | public Observable<ServerInner> getByResourceGroupAsync(String resourceGroupName, String serverName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<ServerInner>, ServerInner>() {
@Override
public ServerInner call(ServiceResponse<ServerInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ServerInner",
">",
"getByResourceGroupAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"ServerInner",
">",
",",
"ServerInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"ServerInner",
"call",
"(",
"ServiceResponse",
"<",
"ServerInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | Gets information about a server.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ServerInner object | [
"Gets",
"information",
"about",
"a",
"server",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/mysql/resource-manager/v2017_12_01/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01/implementation/ServersInner.java#L640-L647 |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchContext.java | IdentityPatchContext.getTargetFile | public File getTargetFile(final MiscContentItem item) {
"""
Get the target file for misc items.
@param item the misc item
@return the target location
"""
final State state = this.state;
if (state == State.NEW || state == State.ROLLBACK_ONLY) {
return getTargetFile(miscTargetRoot, item);
} else {
throw new IllegalStateException(); // internal wrong usage, no i18n
}
} | java | public File getTargetFile(final MiscContentItem item) {
final State state = this.state;
if (state == State.NEW || state == State.ROLLBACK_ONLY) {
return getTargetFile(miscTargetRoot, item);
} else {
throw new IllegalStateException(); // internal wrong usage, no i18n
}
} | [
"public",
"File",
"getTargetFile",
"(",
"final",
"MiscContentItem",
"item",
")",
"{",
"final",
"State",
"state",
"=",
"this",
".",
"state",
";",
"if",
"(",
"state",
"==",
"State",
".",
"NEW",
"||",
"state",
"==",
"State",
".",
"ROLLBACK_ONLY",
")",
"{",
"return",
"getTargetFile",
"(",
"miscTargetRoot",
",",
"item",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
")",
";",
"// internal wrong usage, no i18n",
"}",
"}"
] | Get the target file for misc items.
@param item the misc item
@return the target location | [
"Get",
"the",
"target",
"file",
"for",
"misc",
"items",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/runner/IdentityPatchContext.java#L566-L573 |
hypfvieh/java-utils | src/main/java/com/github/hypfvieh/util/StringUtil.java | StringUtil.containsAny | public static boolean containsAny(boolean _ignoreCase, String _str, String... _args) {
"""
Checks if any of the given strings in _args is contained in _str.
@param _ignoreCase true to ignore case, false to be case sensitive
@param _str string to check
@param _args patterns to find
@return true if any string in _args is found in _str, false if not or _str/_args is null
"""
if (_str == null || _args == null || _args.length == 0) {
return false;
}
String heystack = _str;
if (_ignoreCase) {
heystack = _str.toLowerCase();
}
for (String s : _args) {
String needle = _ignoreCase ? s.toLowerCase() : s;
if (heystack.contains(needle)) {
return true;
}
}
return false;
} | java | public static boolean containsAny(boolean _ignoreCase, String _str, String... _args) {
if (_str == null || _args == null || _args.length == 0) {
return false;
}
String heystack = _str;
if (_ignoreCase) {
heystack = _str.toLowerCase();
}
for (String s : _args) {
String needle = _ignoreCase ? s.toLowerCase() : s;
if (heystack.contains(needle)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"containsAny",
"(",
"boolean",
"_ignoreCase",
",",
"String",
"_str",
",",
"String",
"...",
"_args",
")",
"{",
"if",
"(",
"_str",
"==",
"null",
"||",
"_args",
"==",
"null",
"||",
"_args",
".",
"length",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"String",
"heystack",
"=",
"_str",
";",
"if",
"(",
"_ignoreCase",
")",
"{",
"heystack",
"=",
"_str",
".",
"toLowerCase",
"(",
")",
";",
"}",
"for",
"(",
"String",
"s",
":",
"_args",
")",
"{",
"String",
"needle",
"=",
"_ignoreCase",
"?",
"s",
".",
"toLowerCase",
"(",
")",
":",
"s",
";",
"if",
"(",
"heystack",
".",
"contains",
"(",
"needle",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if any of the given strings in _args is contained in _str.
@param _ignoreCase true to ignore case, false to be case sensitive
@param _str string to check
@param _args patterns to find
@return true if any string in _args is found in _str, false if not or _str/_args is null | [
"Checks",
"if",
"any",
"of",
"the",
"given",
"strings",
"in",
"_args",
"is",
"contained",
"in",
"_str",
"."
] | train | https://github.com/hypfvieh/java-utils/blob/407c32d6b485596d4d2b644f5f7fc7a02d0169c6/src/main/java/com/github/hypfvieh/util/StringUtil.java#L495-L512 |
spring-projects/spring-security-oauth | spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/OAuth2Request.java | OAuth2Request.createOAuth2Request | public OAuth2Request createOAuth2Request(Map<String, String> parameters) {
"""
Update the request parameters and return a new object with the same properties except the parameters.
@param parameters new parameters replacing the existing ones
@return a new OAuth2Request
"""
return new OAuth2Request(parameters, getClientId(), authorities, approved, getScope(), resourceIds,
redirectUri, responseTypes, extensions);
} | java | public OAuth2Request createOAuth2Request(Map<String, String> parameters) {
return new OAuth2Request(parameters, getClientId(), authorities, approved, getScope(), resourceIds,
redirectUri, responseTypes, extensions);
} | [
"public",
"OAuth2Request",
"createOAuth2Request",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
")",
"{",
"return",
"new",
"OAuth2Request",
"(",
"parameters",
",",
"getClientId",
"(",
")",
",",
"authorities",
",",
"approved",
",",
"getScope",
"(",
")",
",",
"resourceIds",
",",
"redirectUri",
",",
"responseTypes",
",",
"extensions",
")",
";",
"}"
] | Update the request parameters and return a new object with the same properties except the parameters.
@param parameters new parameters replacing the existing ones
@return a new OAuth2Request | [
"Update",
"the",
"request",
"parameters",
"and",
"return",
"a",
"new",
"object",
"with",
"the",
"same",
"properties",
"except",
"the",
"parameters",
"."
] | train | https://github.com/spring-projects/spring-security-oauth/blob/bbae0027eceb2c74a21ac26bbc86142dc732ffbe/spring-security-oauth2/src/main/java/org/springframework/security/oauth2/provider/OAuth2Request.java#L133-L136 |
pwall567/jsonutil | src/main/java/net/pwall/json/JSONObject.java | JSONObject.putValue | public JSONObject putValue(String key, CharSequence value) {
"""
Add a {@link JSONString} representing the supplied {@link CharSequence} ({@link String},
{@link StringBuilder} etc.) to the {@code JSONObject}.
@param key the key to use when storing the value
@param value the value (may not be {@code null})
@return {@code this} (for chaining)
@throws NullPointerException if key or value is {@code null}
"""
put(key, new JSONString(value));
return this;
} | java | public JSONObject putValue(String key, CharSequence value) {
put(key, new JSONString(value));
return this;
} | [
"public",
"JSONObject",
"putValue",
"(",
"String",
"key",
",",
"CharSequence",
"value",
")",
"{",
"put",
"(",
"key",
",",
"new",
"JSONString",
"(",
"value",
")",
")",
";",
"return",
"this",
";",
"}"
] | Add a {@link JSONString} representing the supplied {@link CharSequence} ({@link String},
{@link StringBuilder} etc.) to the {@code JSONObject}.
@param key the key to use when storing the value
@param value the value (may not be {@code null})
@return {@code this} (for chaining)
@throws NullPointerException if key or value is {@code null} | [
"Add",
"a",
"{",
"@link",
"JSONString",
"}",
"representing",
"the",
"supplied",
"{",
"@link",
"CharSequence",
"}",
"(",
"{",
"@link",
"String",
"}",
"{",
"@link",
"StringBuilder",
"}",
"etc",
".",
")",
"to",
"the",
"{",
"@code",
"JSONObject",
"}",
"."
] | train | https://github.com/pwall567/jsonutil/blob/dd5960b9b0bcc9acfe6c52b884fffd9ee5f422fe/src/main/java/net/pwall/json/JSONObject.java#L72-L75 |
SonarSource/sonarqube | server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java | NetworkUtilsImpl.getNextAvailablePort | @VisibleForTesting
static int getNextAvailablePort(InetAddress address, PortAllocator portAllocator) {
"""
Warning - the allocated ports are kept in memory and are never clean-up. Besides the memory consumption,
that means that ports already allocated are never freed. As a consequence
no more than ~64512 calls to this method are allowed.
"""
for (int i = 0; i < PORT_MAX_TRIES; i++) {
int port = portAllocator.getAvailable(address);
if (isValidPort(port)) {
PORTS_ALREADY_ALLOCATED.add(port);
return port;
}
}
throw new IllegalStateException("Fail to find an available port on " + address);
} | java | @VisibleForTesting
static int getNextAvailablePort(InetAddress address, PortAllocator portAllocator) {
for (int i = 0; i < PORT_MAX_TRIES; i++) {
int port = portAllocator.getAvailable(address);
if (isValidPort(port)) {
PORTS_ALREADY_ALLOCATED.add(port);
return port;
}
}
throw new IllegalStateException("Fail to find an available port on " + address);
} | [
"@",
"VisibleForTesting",
"static",
"int",
"getNextAvailablePort",
"(",
"InetAddress",
"address",
",",
"PortAllocator",
"portAllocator",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"PORT_MAX_TRIES",
";",
"i",
"++",
")",
"{",
"int",
"port",
"=",
"portAllocator",
".",
"getAvailable",
"(",
"address",
")",
";",
"if",
"(",
"isValidPort",
"(",
"port",
")",
")",
"{",
"PORTS_ALREADY_ALLOCATED",
".",
"add",
"(",
"port",
")",
";",
"return",
"port",
";",
"}",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"\"Fail to find an available port on \"",
"+",
"address",
")",
";",
"}"
] | Warning - the allocated ports are kept in memory and are never clean-up. Besides the memory consumption,
that means that ports already allocated are never freed. As a consequence
no more than ~64512 calls to this method are allowed. | [
"Warning",
"-",
"the",
"allocated",
"ports",
"are",
"kept",
"in",
"memory",
"and",
"are",
"never",
"clean",
"-",
"up",
".",
"Besides",
"the",
"memory",
"consumption",
"that",
"means",
"that",
"ports",
"already",
"allocated",
"are",
"never",
"freed",
".",
"As",
"a",
"consequence",
"no",
"more",
"than",
"~64512",
"calls",
"to",
"this",
"method",
"are",
"allowed",
"."
] | train | https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java#L56-L66 |
VoltDB/voltdb | third_party/java/src/org/apache/zookeeper_voltpatches/server/persistence/Util.java | Util.writeTxnBytes | public static void writeTxnBytes(OutputArchive oa, byte[] bytes)
throws IOException {
"""
Write the serialized transaction record to the output archive.
@param oa output archive
@param bytes serialized trasnaction record
@throws IOException
"""
oa.writeBuffer(bytes, "txnEntry");
oa.writeByte((byte) 0x42, "EOR"); // 'B'
} | java | public static void writeTxnBytes(OutputArchive oa, byte[] bytes)
throws IOException {
oa.writeBuffer(bytes, "txnEntry");
oa.writeByte((byte) 0x42, "EOR"); // 'B'
} | [
"public",
"static",
"void",
"writeTxnBytes",
"(",
"OutputArchive",
"oa",
",",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"oa",
".",
"writeBuffer",
"(",
"bytes",
",",
"\"txnEntry\"",
")",
";",
"oa",
".",
"writeByte",
"(",
"(",
"byte",
")",
"0x42",
",",
"\"EOR\"",
")",
";",
"// 'B'",
"}"
] | Write the serialized transaction record to the output archive.
@param oa output archive
@param bytes serialized trasnaction record
@throws IOException | [
"Write",
"the",
"serialized",
"transaction",
"record",
"to",
"the",
"output",
"archive",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/third_party/java/src/org/apache/zookeeper_voltpatches/server/persistence/Util.java#L275-L279 |
moparisthebest/beehive | beehive-jdbc-control/src/main/java/org/apache/beehive/controls/system/jdbc/DefaultRowSetResultSetMapper.java | DefaultRowSetResultSetMapper.mapToResultType | public RowSet mapToResultType(ControlBeanContext context, Method m, ResultSet resultSet, Calendar cal) {
"""
Map a ResultSet to a RowSet. Type of RowSet is defined by the SQL annotation for the method.
@param context A ControlBeanContext instance.
@param m Method assoicated with this call.
@param resultSet Result set to map.
@param cal A Calendar instance for resolving date/time values.
@return A RowSet object.
"""
final SQL methodSQL = (SQL) context.getMethodPropertySet(m, SQL.class);
final int maxrows = methodSQL.maxRows();
try {
CachedRowSetImpl rows = new CachedRowSetImpl();
if (maxrows > 0) {
rows.setMaxRows(maxrows);
}
rows.populate(resultSet);
return rows;
} catch (SQLException e) {
throw new ControlException(e.getMessage(), e);
}
} | java | public RowSet mapToResultType(ControlBeanContext context, Method m, ResultSet resultSet, Calendar cal) {
final SQL methodSQL = (SQL) context.getMethodPropertySet(m, SQL.class);
final int maxrows = methodSQL.maxRows();
try {
CachedRowSetImpl rows = new CachedRowSetImpl();
if (maxrows > 0) {
rows.setMaxRows(maxrows);
}
rows.populate(resultSet);
return rows;
} catch (SQLException e) {
throw new ControlException(e.getMessage(), e);
}
} | [
"public",
"RowSet",
"mapToResultType",
"(",
"ControlBeanContext",
"context",
",",
"Method",
"m",
",",
"ResultSet",
"resultSet",
",",
"Calendar",
"cal",
")",
"{",
"final",
"SQL",
"methodSQL",
"=",
"(",
"SQL",
")",
"context",
".",
"getMethodPropertySet",
"(",
"m",
",",
"SQL",
".",
"class",
")",
";",
"final",
"int",
"maxrows",
"=",
"methodSQL",
".",
"maxRows",
"(",
")",
";",
"try",
"{",
"CachedRowSetImpl",
"rows",
"=",
"new",
"CachedRowSetImpl",
"(",
")",
";",
"if",
"(",
"maxrows",
">",
"0",
")",
"{",
"rows",
".",
"setMaxRows",
"(",
"maxrows",
")",
";",
"}",
"rows",
".",
"populate",
"(",
"resultSet",
")",
";",
"return",
"rows",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"throw",
"new",
"ControlException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Map a ResultSet to a RowSet. Type of RowSet is defined by the SQL annotation for the method.
@param context A ControlBeanContext instance.
@param m Method assoicated with this call.
@param resultSet Result set to map.
@param cal A Calendar instance for resolving date/time values.
@return A RowSet object. | [
"Map",
"a",
"ResultSet",
"to",
"a",
"RowSet",
".",
"Type",
"of",
"RowSet",
"is",
"defined",
"by",
"the",
"SQL",
"annotation",
"for",
"the",
"method",
"."
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-jdbc-control/src/main/java/org/apache/beehive/controls/system/jdbc/DefaultRowSetResultSetMapper.java#L47-L63 |
williamwebb/alogger | BillingHelper/src/main/java/com/jug6ernaut/billing/IabHelper.java | IabHelper.consumeAsync | public void consumeAsync(Purchase purchase, OnConsumeFinishedListener listener) {
"""
Asynchronous wrapper to item consumption. Works like {@link #consume}, but
performs the consumption in the background and notifies completion through
the provided listener. This method is safe to call from a UI thread.
@param purchase The purchase to be consumed.
@param listener The listener to notify when the consumption operation finishes.
"""
checkNotDisposed();
checkSetupDone("consume");
List<Purchase> purchases = new ArrayList<Purchase>();
purchases.add(purchase);
consumeAsyncInternal(purchases, listener, null);
} | java | public void consumeAsync(Purchase purchase, OnConsumeFinishedListener listener) {
checkNotDisposed();
checkSetupDone("consume");
List<Purchase> purchases = new ArrayList<Purchase>();
purchases.add(purchase);
consumeAsyncInternal(purchases, listener, null);
} | [
"public",
"void",
"consumeAsync",
"(",
"Purchase",
"purchase",
",",
"OnConsumeFinishedListener",
"listener",
")",
"{",
"checkNotDisposed",
"(",
")",
";",
"checkSetupDone",
"(",
"\"consume\"",
")",
";",
"List",
"<",
"Purchase",
">",
"purchases",
"=",
"new",
"ArrayList",
"<",
"Purchase",
">",
"(",
")",
";",
"purchases",
".",
"add",
"(",
"purchase",
")",
";",
"consumeAsyncInternal",
"(",
"purchases",
",",
"listener",
",",
"null",
")",
";",
"}"
] | Asynchronous wrapper to item consumption. Works like {@link #consume}, but
performs the consumption in the background and notifies completion through
the provided listener. This method is safe to call from a UI thread.
@param purchase The purchase to be consumed.
@param listener The listener to notify when the consumption operation finishes. | [
"Asynchronous",
"wrapper",
"to",
"item",
"consumption",
".",
"Works",
"like",
"{",
"@link",
"#consume",
"}",
"but",
"performs",
"the",
"consumption",
"in",
"the",
"background",
"and",
"notifies",
"completion",
"through",
"the",
"provided",
"listener",
".",
"This",
"method",
"is",
"safe",
"to",
"call",
"from",
"a",
"UI",
"thread",
"."
] | train | https://github.com/williamwebb/alogger/blob/61fca49e0b8d9c3a76c40da8883ac354b240351e/BillingHelper/src/main/java/com/jug6ernaut/billing/IabHelper.java#L734-L740 |
brettwooldridge/SansOrm | src/main/java/com/zaxxer/sansorm/OrmElf.java | OrmElf.getColumnsCsv | public static <T> String getColumnsCsv(Class<T> clazz, String... tablePrefix) {
"""
Get a comma separated values list of column names for the given class, suitable
for inclusion into a SQL SELECT statement.
@param clazz the annotated class
@param tablePrefix an optional table prefix to append to each column
@param <T> the class template
@return a CSV of annotated column names
"""
return OrmReader.getColumnsCsv(clazz, tablePrefix);
} | java | public static <T> String getColumnsCsv(Class<T> clazz, String... tablePrefix)
{
return OrmReader.getColumnsCsv(clazz, tablePrefix);
} | [
"public",
"static",
"<",
"T",
">",
"String",
"getColumnsCsv",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"String",
"...",
"tablePrefix",
")",
"{",
"return",
"OrmReader",
".",
"getColumnsCsv",
"(",
"clazz",
",",
"tablePrefix",
")",
";",
"}"
] | Get a comma separated values list of column names for the given class, suitable
for inclusion into a SQL SELECT statement.
@param clazz the annotated class
@param tablePrefix an optional table prefix to append to each column
@param <T> the class template
@return a CSV of annotated column names | [
"Get",
"a",
"comma",
"separated",
"values",
"list",
"of",
"column",
"names",
"for",
"the",
"given",
"class",
"suitable",
"for",
"inclusion",
"into",
"a",
"SQL",
"SELECT",
"statement",
"."
] | train | https://github.com/brettwooldridge/SansOrm/blob/ab22721db79c5f20c0e8483f09eda2844d596557/src/main/java/com/zaxxer/sansorm/OrmElf.java#L319-L322 |
Addicticks/httpsupload | src/main/java/com/addicticks/net/httpsupload/HttpsFileUploaderConfig.java | HttpsFileUploaderConfig.setAdditionalHeaders | public void setAdditionalHeaders(Map<String,String> additionalHeaders) {
"""
Sets additional overall HTTP headers to add to the upload POST request. There's
rarely a need to use this method.
<p>The following header fields are automatically set:
<pre>
"Connection"
"Cache-Control"
"Content-Type"
"Content-Length"
"Authorization"
</pre> and you must <i>never</i> set these here. (if you do they will be
ignored)
<p>However you might want to use this method to
explicitly set e.g. {@code User-Agent} or non-standard header fields that
are required for your particular endpoint. For example by overriding
{@code User-Agent} you can make the upload operation look to the
endpoint as if it comes from a browser.
@param additionalHeaders Map of HTTP request headers. The key is the header field
name and the value is the header field value.
"""
Map<String, String> newMap = new HashMap<>();
for (Entry<String,String> e : additionalHeaders.entrySet()) {
boolean found = false;
for(String restrictedHeaderField : RESTRICTED_HTTP_HEADERS) {
if (e.getKey().equalsIgnoreCase(restrictedHeaderField)) {
found = true;
break;
}
}
if (!found) {
newMap.put(e.getKey(), e.getValue());
}
}
this.additionalHeaders = newMap;
} | java | public void setAdditionalHeaders(Map<String,String> additionalHeaders) {
Map<String, String> newMap = new HashMap<>();
for (Entry<String,String> e : additionalHeaders.entrySet()) {
boolean found = false;
for(String restrictedHeaderField : RESTRICTED_HTTP_HEADERS) {
if (e.getKey().equalsIgnoreCase(restrictedHeaderField)) {
found = true;
break;
}
}
if (!found) {
newMap.put(e.getKey(), e.getValue());
}
}
this.additionalHeaders = newMap;
} | [
"public",
"void",
"setAdditionalHeaders",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"additionalHeaders",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"newMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"e",
":",
"additionalHeaders",
".",
"entrySet",
"(",
")",
")",
"{",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"String",
"restrictedHeaderField",
":",
"RESTRICTED_HTTP_HEADERS",
")",
"{",
"if",
"(",
"e",
".",
"getKey",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"restrictedHeaderField",
")",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"newMap",
".",
"put",
"(",
"e",
".",
"getKey",
"(",
")",
",",
"e",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"this",
".",
"additionalHeaders",
"=",
"newMap",
";",
"}"
] | Sets additional overall HTTP headers to add to the upload POST request. There's
rarely a need to use this method.
<p>The following header fields are automatically set:
<pre>
"Connection"
"Cache-Control"
"Content-Type"
"Content-Length"
"Authorization"
</pre> and you must <i>never</i> set these here. (if you do they will be
ignored)
<p>However you might want to use this method to
explicitly set e.g. {@code User-Agent} or non-standard header fields that
are required for your particular endpoint. For example by overriding
{@code User-Agent} you can make the upload operation look to the
endpoint as if it comes from a browser.
@param additionalHeaders Map of HTTP request headers. The key is the header field
name and the value is the header field value. | [
"Sets",
"additional",
"overall",
"HTTP",
"headers",
"to",
"add",
"to",
"the",
"upload",
"POST",
"request",
".",
"There",
"s",
"rarely",
"a",
"need",
"to",
"use",
"this",
"method",
"."
] | train | https://github.com/Addicticks/httpsupload/blob/261a8e63ec923482a74ffe1352024c1900c55a55/src/main/java/com/addicticks/net/httpsupload/HttpsFileUploaderConfig.java#L327-L343 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/gfx/context/DomHelper.java | DomHelper.createOrUpdateSingleChild | public Element createOrUpdateSingleChild(Element parent, String type) {
"""
Create or update a one-of child element in the DOM. Needs no id as it will be created/deleted with the parent.
@param parent the parent element
@param type the type of the element (tag name, e.g. 'image')
@return the created or updated element or null if creation failed
"""
Element result = null;
if (parent.getElementsByTagName(type).getLength() == 0) {
switch (namespace) {
case HTML:
result = Dom.createElementNS(Dom.NS_HTML, type);
break;
case SVG:
result = Dom.createElementNS(Dom.NS_SVG, type);
break;
case VML:
result = Dom.createElementNS(Dom.NS_VML, type);
break;
}
parent.appendChild(result);
return result;
} else {
return (Element) (parent.getElementsByTagName(type).getItem(0));
}
} | java | public Element createOrUpdateSingleChild(Element parent, String type) {
Element result = null;
if (parent.getElementsByTagName(type).getLength() == 0) {
switch (namespace) {
case HTML:
result = Dom.createElementNS(Dom.NS_HTML, type);
break;
case SVG:
result = Dom.createElementNS(Dom.NS_SVG, type);
break;
case VML:
result = Dom.createElementNS(Dom.NS_VML, type);
break;
}
parent.appendChild(result);
return result;
} else {
return (Element) (parent.getElementsByTagName(type).getItem(0));
}
} | [
"public",
"Element",
"createOrUpdateSingleChild",
"(",
"Element",
"parent",
",",
"String",
"type",
")",
"{",
"Element",
"result",
"=",
"null",
";",
"if",
"(",
"parent",
".",
"getElementsByTagName",
"(",
"type",
")",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"switch",
"(",
"namespace",
")",
"{",
"case",
"HTML",
":",
"result",
"=",
"Dom",
".",
"createElementNS",
"(",
"Dom",
".",
"NS_HTML",
",",
"type",
")",
";",
"break",
";",
"case",
"SVG",
":",
"result",
"=",
"Dom",
".",
"createElementNS",
"(",
"Dom",
".",
"NS_SVG",
",",
"type",
")",
";",
"break",
";",
"case",
"VML",
":",
"result",
"=",
"Dom",
".",
"createElementNS",
"(",
"Dom",
".",
"NS_VML",
",",
"type",
")",
";",
"break",
";",
"}",
"parent",
".",
"appendChild",
"(",
"result",
")",
";",
"return",
"result",
";",
"}",
"else",
"{",
"return",
"(",
"Element",
")",
"(",
"parent",
".",
"getElementsByTagName",
"(",
"type",
")",
".",
"getItem",
"(",
"0",
")",
")",
";",
"}",
"}"
] | Create or update a one-of child element in the DOM. Needs no id as it will be created/deleted with the parent.
@param parent the parent element
@param type the type of the element (tag name, e.g. 'image')
@return the created or updated element or null if creation failed | [
"Create",
"or",
"update",
"a",
"one",
"-",
"of",
"child",
"element",
"in",
"the",
"DOM",
".",
"Needs",
"no",
"id",
"as",
"it",
"will",
"be",
"created",
"/",
"deleted",
"with",
"the",
"parent",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/gfx/context/DomHelper.java#L108-L127 |
lucee/Lucee | core/src/main/java/lucee/runtime/cache/CacheUtil.java | CacheUtil.getDefault | public static Cache getDefault(PageContext pc, int type) throws IOException {
"""
get the default cache for a certain type, also check definitions in application context
(application . cfc/cfapplication)
@param pc current PageContext
@param type default type -> Config.CACHE_DEFAULT_...
@return matching cache
@throws IOException
"""
// get default from application conetxt
String name = pc != null ? pc.getApplicationContext().getDefaultCacheName(type) : null;
if (!StringUtil.isEmpty(name)) {
Cache cc = getCache(pc, name, null);
if (cc != null) return cc;
}
// get default from config
Config config = ThreadLocalPageContext.getConfig(pc);
CacheConnection cc = ((ConfigImpl) config).getCacheDefaultConnection(type);
if (cc == null)
throw new CacheException("there is no default " + toStringType(type, "") + " cache defined, you need to define this default cache in the Lucee Administrator");
return cc.getInstance(config);
} | java | public static Cache getDefault(PageContext pc, int type) throws IOException {
// get default from application conetxt
String name = pc != null ? pc.getApplicationContext().getDefaultCacheName(type) : null;
if (!StringUtil.isEmpty(name)) {
Cache cc = getCache(pc, name, null);
if (cc != null) return cc;
}
// get default from config
Config config = ThreadLocalPageContext.getConfig(pc);
CacheConnection cc = ((ConfigImpl) config).getCacheDefaultConnection(type);
if (cc == null)
throw new CacheException("there is no default " + toStringType(type, "") + " cache defined, you need to define this default cache in the Lucee Administrator");
return cc.getInstance(config);
} | [
"public",
"static",
"Cache",
"getDefault",
"(",
"PageContext",
"pc",
",",
"int",
"type",
")",
"throws",
"IOException",
"{",
"// get default from application conetxt",
"String",
"name",
"=",
"pc",
"!=",
"null",
"?",
"pc",
".",
"getApplicationContext",
"(",
")",
".",
"getDefaultCacheName",
"(",
"type",
")",
":",
"null",
";",
"if",
"(",
"!",
"StringUtil",
".",
"isEmpty",
"(",
"name",
")",
")",
"{",
"Cache",
"cc",
"=",
"getCache",
"(",
"pc",
",",
"name",
",",
"null",
")",
";",
"if",
"(",
"cc",
"!=",
"null",
")",
"return",
"cc",
";",
"}",
"// get default from config",
"Config",
"config",
"=",
"ThreadLocalPageContext",
".",
"getConfig",
"(",
"pc",
")",
";",
"CacheConnection",
"cc",
"=",
"(",
"(",
"ConfigImpl",
")",
"config",
")",
".",
"getCacheDefaultConnection",
"(",
"type",
")",
";",
"if",
"(",
"cc",
"==",
"null",
")",
"throw",
"new",
"CacheException",
"(",
"\"there is no default \"",
"+",
"toStringType",
"(",
"type",
",",
"\"\"",
")",
"+",
"\" cache defined, you need to define this default cache in the Lucee Administrator\"",
")",
";",
"return",
"cc",
".",
"getInstance",
"(",
"config",
")",
";",
"}"
] | get the default cache for a certain type, also check definitions in application context
(application . cfc/cfapplication)
@param pc current PageContext
@param type default type -> Config.CACHE_DEFAULT_...
@return matching cache
@throws IOException | [
"get",
"the",
"default",
"cache",
"for",
"a",
"certain",
"type",
"also",
"check",
"definitions",
"in",
"application",
"context",
"(",
"application",
".",
"cfc",
"/",
"cfapplication",
")"
] | train | https://github.com/lucee/Lucee/blob/29b153fc4e126e5edb97da937f2ee2e231b87593/core/src/main/java/lucee/runtime/cache/CacheUtil.java#L94-L108 |
Azure/azure-sdk-for-java | sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/FailoverGroupsInner.java | FailoverGroupsInner.forceFailoverAllowDataLoss | public FailoverGroupInner forceFailoverAllowDataLoss(String resourceGroupName, String serverName, String failoverGroupName) {
"""
Fails over from the current primary server to this server. This operation might result in data loss.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server containing the failover group.
@param failoverGroupName The name of the failover group.
@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 FailoverGroupInner object if successful.
"""
return forceFailoverAllowDataLossWithServiceResponseAsync(resourceGroupName, serverName, failoverGroupName).toBlocking().last().body();
} | java | public FailoverGroupInner forceFailoverAllowDataLoss(String resourceGroupName, String serverName, String failoverGroupName) {
return forceFailoverAllowDataLossWithServiceResponseAsync(resourceGroupName, serverName, failoverGroupName).toBlocking().last().body();
} | [
"public",
"FailoverGroupInner",
"forceFailoverAllowDataLoss",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"failoverGroupName",
")",
"{",
"return",
"forceFailoverAllowDataLossWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"failoverGroupName",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] | Fails over from the current primary server to this server. This operation might result in data loss.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server containing the failover group.
@param failoverGroupName The name of the failover group.
@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 FailoverGroupInner object if successful. | [
"Fails",
"over",
"from",
"the",
"current",
"primary",
"server",
"to",
"this",
"server",
".",
"This",
"operation",
"might",
"result",
"in",
"data",
"loss",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/FailoverGroupsInner.java#L1060-L1062 |
javalite/activejdbc | activejdbc/src/main/java/org/javalite/activejdbc/dialects/PostgreSQLDialect.java | PostgreSQLDialect.formSelect | @Override
public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) {
"""
Generates adds limit, offset and order bys to a sub-query
@param tableName name of table. If table name is null, then the subQuery parameter is considered to be a full query, and all that needs to be done is to
add limit, offset and order bys
@param columns not used in this implementation
@param subQuery sub-query or a full query
@param orderBys
@param limit
@param offset
@return query with
"""
StringBuilder fullQuery = new StringBuilder();
appendSelect(fullQuery, tableName, columns, null, subQuery, orderBys);
if(limit != -1){
fullQuery.append(" LIMIT ").append(limit);
}
if(offset != -1){
fullQuery.append(" OFFSET ").append(offset);
}
return fullQuery.toString();
} | java | @Override
public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) {
StringBuilder fullQuery = new StringBuilder();
appendSelect(fullQuery, tableName, columns, null, subQuery, orderBys);
if(limit != -1){
fullQuery.append(" LIMIT ").append(limit);
}
if(offset != -1){
fullQuery.append(" OFFSET ").append(offset);
}
return fullQuery.toString();
} | [
"@",
"Override",
"public",
"String",
"formSelect",
"(",
"String",
"tableName",
",",
"String",
"[",
"]",
"columns",
",",
"String",
"subQuery",
",",
"List",
"<",
"String",
">",
"orderBys",
",",
"long",
"limit",
",",
"long",
"offset",
")",
"{",
"StringBuilder",
"fullQuery",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"appendSelect",
"(",
"fullQuery",
",",
"tableName",
",",
"columns",
",",
"null",
",",
"subQuery",
",",
"orderBys",
")",
";",
"if",
"(",
"limit",
"!=",
"-",
"1",
")",
"{",
"fullQuery",
".",
"append",
"(",
"\" LIMIT \"",
")",
".",
"append",
"(",
"limit",
")",
";",
"}",
"if",
"(",
"offset",
"!=",
"-",
"1",
")",
"{",
"fullQuery",
".",
"append",
"(",
"\" OFFSET \"",
")",
".",
"append",
"(",
"offset",
")",
";",
"}",
"return",
"fullQuery",
".",
"toString",
"(",
")",
";",
"}"
] | Generates adds limit, offset and order bys to a sub-query
@param tableName name of table. If table name is null, then the subQuery parameter is considered to be a full query, and all that needs to be done is to
add limit, offset and order bys
@param columns not used in this implementation
@param subQuery sub-query or a full query
@param orderBys
@param limit
@param offset
@return query with | [
"Generates",
"adds",
"limit",
"offset",
"and",
"order",
"bys",
"to",
"a",
"sub",
"-",
"query"
] | train | https://github.com/javalite/activejdbc/blob/ffcf5457cace19622a8f71e856cbbbe9e7dd5fcc/activejdbc/src/main/java/org/javalite/activejdbc/dialects/PostgreSQLDialect.java#L21-L36 |
lightblueseas/vintage-time | src/main/java/de/alpharogroup/date/CreateDateExtensions.java | CreateDateExtensions.newDate | public static Date newDate(final int year, final int month, final int day, final int hour,
final int min, final int sec) {
"""
Creates a new Date object from the given values.
@param year
The year.
@param month
The month.
@param day
The day.
@param hour
The hour.
@param min
The minute.
@param sec
The second.
@return Returns the created Date object.
"""
return newDate(year, month, day, hour, min, sec, 0);
} | java | public static Date newDate(final int year, final int month, final int day, final int hour,
final int min, final int sec)
{
return newDate(year, month, day, hour, min, sec, 0);
} | [
"public",
"static",
"Date",
"newDate",
"(",
"final",
"int",
"year",
",",
"final",
"int",
"month",
",",
"final",
"int",
"day",
",",
"final",
"int",
"hour",
",",
"final",
"int",
"min",
",",
"final",
"int",
"sec",
")",
"{",
"return",
"newDate",
"(",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"min",
",",
"sec",
",",
"0",
")",
";",
"}"
] | Creates a new Date object from the given values.
@param year
The year.
@param month
The month.
@param day
The day.
@param hour
The hour.
@param min
The minute.
@param sec
The second.
@return Returns the created Date object. | [
"Creates",
"a",
"new",
"Date",
"object",
"from",
"the",
"given",
"values",
"."
] | train | https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/CreateDateExtensions.java#L92-L96 |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeBinaryGridToPixel.java | QrCodeBinaryGridToPixel.setTransformFromLinesSquare | public void setTransformFromLinesSquare( QrCode qr ) {
"""
Used to estimate the image to grid coordinate system before the version is known. The top left square is
used to fix the coordinate system. Then 4 lines between corners going to other QR codes is used to
make it less suspectable to errors in the first 4 corners
"""
// clear old points
storagePairs2D.reset();
storagePairs3D.reset();
// use 3 of the corners to set the coordinate system
// set(0, 0, qr.ppCorner,0); <-- prone to damage. Significantly degrades results if used
set(0, 7, qr.ppCorner,1);
set(7, 7, qr.ppCorner,2);
set(7, 0, qr.ppCorner,3);
// Use 4 lines to make it more robust errors in these corners
// We just need to get the direction right for the lines. the exact grid to image doesn't matter
setLine(0,7,0,14,qr.ppCorner,1,qr.ppRight,0);
setLine(7,7,7,14,qr.ppCorner,2,qr.ppRight,3);
setLine(7,7,14,7,qr.ppCorner,2,qr.ppDown,1);
setLine(7,0,14,0,qr.ppCorner,3,qr.ppDown,0);
DMatrixRMaj HH = new DMatrixRMaj(3,3);
dlt.process(storagePairs2D.toList(),storagePairs3D.toList(),null,HH);
H.set(HH);
H.invert(Hinv);
ConvertFloatType.convert(Hinv, Hinv32);
ConvertFloatType.convert(H, H32);
} | java | public void setTransformFromLinesSquare( QrCode qr ) {
// clear old points
storagePairs2D.reset();
storagePairs3D.reset();
// use 3 of the corners to set the coordinate system
// set(0, 0, qr.ppCorner,0); <-- prone to damage. Significantly degrades results if used
set(0, 7, qr.ppCorner,1);
set(7, 7, qr.ppCorner,2);
set(7, 0, qr.ppCorner,3);
// Use 4 lines to make it more robust errors in these corners
// We just need to get the direction right for the lines. the exact grid to image doesn't matter
setLine(0,7,0,14,qr.ppCorner,1,qr.ppRight,0);
setLine(7,7,7,14,qr.ppCorner,2,qr.ppRight,3);
setLine(7,7,14,7,qr.ppCorner,2,qr.ppDown,1);
setLine(7,0,14,0,qr.ppCorner,3,qr.ppDown,0);
DMatrixRMaj HH = new DMatrixRMaj(3,3);
dlt.process(storagePairs2D.toList(),storagePairs3D.toList(),null,HH);
H.set(HH);
H.invert(Hinv);
ConvertFloatType.convert(Hinv, Hinv32);
ConvertFloatType.convert(H, H32);
} | [
"public",
"void",
"setTransformFromLinesSquare",
"(",
"QrCode",
"qr",
")",
"{",
"// clear old points",
"storagePairs2D",
".",
"reset",
"(",
")",
";",
"storagePairs3D",
".",
"reset",
"(",
")",
";",
"// use 3 of the corners to set the coordinate system",
"//\t\tset(0, 0, qr.ppCorner,0); <-- prone to damage. Significantly degrades results if used",
"set",
"(",
"0",
",",
"7",
",",
"qr",
".",
"ppCorner",
",",
"1",
")",
";",
"set",
"(",
"7",
",",
"7",
",",
"qr",
".",
"ppCorner",
",",
"2",
")",
";",
"set",
"(",
"7",
",",
"0",
",",
"qr",
".",
"ppCorner",
",",
"3",
")",
";",
"// Use 4 lines to make it more robust errors in these corners",
"// We just need to get the direction right for the lines. the exact grid to image doesn't matter",
"setLine",
"(",
"0",
",",
"7",
",",
"0",
",",
"14",
",",
"qr",
".",
"ppCorner",
",",
"1",
",",
"qr",
".",
"ppRight",
",",
"0",
")",
";",
"setLine",
"(",
"7",
",",
"7",
",",
"7",
",",
"14",
",",
"qr",
".",
"ppCorner",
",",
"2",
",",
"qr",
".",
"ppRight",
",",
"3",
")",
";",
"setLine",
"(",
"7",
",",
"7",
",",
"14",
",",
"7",
",",
"qr",
".",
"ppCorner",
",",
"2",
",",
"qr",
".",
"ppDown",
",",
"1",
")",
";",
"setLine",
"(",
"7",
",",
"0",
",",
"14",
",",
"0",
",",
"qr",
".",
"ppCorner",
",",
"3",
",",
"qr",
".",
"ppDown",
",",
"0",
")",
";",
"DMatrixRMaj",
"HH",
"=",
"new",
"DMatrixRMaj",
"(",
"3",
",",
"3",
")",
";",
"dlt",
".",
"process",
"(",
"storagePairs2D",
".",
"toList",
"(",
")",
",",
"storagePairs3D",
".",
"toList",
"(",
")",
",",
"null",
",",
"HH",
")",
";",
"H",
".",
"set",
"(",
"HH",
")",
";",
"H",
".",
"invert",
"(",
"Hinv",
")",
";",
"ConvertFloatType",
".",
"convert",
"(",
"Hinv",
",",
"Hinv32",
")",
";",
"ConvertFloatType",
".",
"convert",
"(",
"H",
",",
"H32",
")",
";",
"}"
] | Used to estimate the image to grid coordinate system before the version is known. The top left square is
used to fix the coordinate system. Then 4 lines between corners going to other QR codes is used to
make it less suspectable to errors in the first 4 corners | [
"Used",
"to",
"estimate",
"the",
"image",
"to",
"grid",
"coordinate",
"system",
"before",
"the",
"version",
"is",
"known",
".",
"The",
"top",
"left",
"square",
"is",
"used",
"to",
"fix",
"the",
"coordinate",
"system",
".",
"Then",
"4",
"lines",
"between",
"corners",
"going",
"to",
"other",
"QR",
"codes",
"is",
"used",
"to",
"make",
"it",
"less",
"suspectable",
"to",
"errors",
"in",
"the",
"first",
"4",
"corners"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeBinaryGridToPixel.java#L83-L107 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/io/MPIO.java | MPIO.getOrCreateNewMPConnection | public MPConnection getOrCreateNewMPConnection(SIBUuid8 remoteUuid,
MEConnection conn) {
"""
Get a MPConnection from the cache and if there isn't one, create a new one and
put it in the cache.
@param cellule The cellule to find a MPConnection for (optional)
@param conn The MEConnection to find a MPConnection for
@return the MPConnection
"""
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "getOrCreateNewMPConnection", new Object[] {remoteUuid, conn });
MPConnection mpConn;
synchronized(_mpConnectionsByMEConnection)
{
//look up the connection in the cache
mpConn = _mpConnectionsByMEConnection.get(conn);
//if it is not in the cache
if(mpConn == null)
{
//make sure we know the cellule
if(remoteUuid == null)
{
remoteUuid = new SIBUuid8(conn.getMessagingEngine().getUuid());
}
//create a new MPConnection for this MEConnection
mpConn = new MPConnection(this,conn,remoteUuid);
//put it in the cache
_mpConnectionsByMEConnection.put(conn, mpConn);
_mpConnectionsByMEUuid.put(remoteUuid, mpConn);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "getOrCreateNewMPConnection", mpConn);
//return the MPConnection
return mpConn;
} | java | public MPConnection getOrCreateNewMPConnection(SIBUuid8 remoteUuid,
MEConnection conn)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "getOrCreateNewMPConnection", new Object[] {remoteUuid, conn });
MPConnection mpConn;
synchronized(_mpConnectionsByMEConnection)
{
//look up the connection in the cache
mpConn = _mpConnectionsByMEConnection.get(conn);
//if it is not in the cache
if(mpConn == null)
{
//make sure we know the cellule
if(remoteUuid == null)
{
remoteUuid = new SIBUuid8(conn.getMessagingEngine().getUuid());
}
//create a new MPConnection for this MEConnection
mpConn = new MPConnection(this,conn,remoteUuid);
//put it in the cache
_mpConnectionsByMEConnection.put(conn, mpConn);
_mpConnectionsByMEUuid.put(remoteUuid, mpConn);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "getOrCreateNewMPConnection", mpConn);
//return the MPConnection
return mpConn;
} | [
"public",
"MPConnection",
"getOrCreateNewMPConnection",
"(",
"SIBUuid8",
"remoteUuid",
",",
"MEConnection",
"conn",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"getOrCreateNewMPConnection\"",
",",
"new",
"Object",
"[",
"]",
"{",
"remoteUuid",
",",
"conn",
"}",
")",
";",
"MPConnection",
"mpConn",
";",
"synchronized",
"(",
"_mpConnectionsByMEConnection",
")",
"{",
"//look up the connection in the cache",
"mpConn",
"=",
"_mpConnectionsByMEConnection",
".",
"get",
"(",
"conn",
")",
";",
"//if it is not in the cache",
"if",
"(",
"mpConn",
"==",
"null",
")",
"{",
"//make sure we know the cellule",
"if",
"(",
"remoteUuid",
"==",
"null",
")",
"{",
"remoteUuid",
"=",
"new",
"SIBUuid8",
"(",
"conn",
".",
"getMessagingEngine",
"(",
")",
".",
"getUuid",
"(",
")",
")",
";",
"}",
"//create a new MPConnection for this MEConnection",
"mpConn",
"=",
"new",
"MPConnection",
"(",
"this",
",",
"conn",
",",
"remoteUuid",
")",
";",
"//put it in the cache",
"_mpConnectionsByMEConnection",
".",
"put",
"(",
"conn",
",",
"mpConn",
")",
";",
"_mpConnectionsByMEUuid",
".",
"put",
"(",
"remoteUuid",
",",
"mpConn",
")",
";",
"}",
"}",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"getOrCreateNewMPConnection\"",
",",
"mpConn",
")",
";",
"//return the MPConnection",
"return",
"mpConn",
";",
"}"
] | Get a MPConnection from the cache and if there isn't one, create a new one and
put it in the cache.
@param cellule The cellule to find a MPConnection for (optional)
@param conn The MEConnection to find a MPConnection for
@return the MPConnection | [
"Get",
"a",
"MPConnection",
"from",
"the",
"cache",
"and",
"if",
"there",
"isn",
"t",
"one",
"create",
"a",
"new",
"one",
"and",
"put",
"it",
"in",
"the",
"cache",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/processor/io/MPIO.java#L231-L264 |
Samsung/GearVRf | GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPose.java | GVRPose.setPosition | public boolean setPosition(float x, float y, float z) {
"""
Sets the world position of a root bone and propagates to all children.
<p>
This has the effect of moving the overall skeleton to a new position
without affecting the orientation of it's bones.
@param x,y,z new world position of root bone.
@return true if world position set, false if bone is not a root bone.
@see #setWorldPositions
@see #getWorldPosition
"""
Bone bone = mBones[0];
float dx = x - bone.WorldMatrix.m30();
float dy = y - bone.WorldMatrix.m31();
float dz = z - bone.WorldMatrix.m32();
sync();
bone.LocalMatrix.setTranslation(x, y, z);
for (int i = 0; i < mBones.length; ++i)
{
bone = mBones[i];
bone.WorldMatrix.m30(bone.WorldMatrix.m30() + dx);
bone.WorldMatrix.m31(bone.WorldMatrix.m31() + dy);
bone.WorldMatrix.m32(bone.WorldMatrix.m32() + dz);
}
if (sDebug)
{
Log.d("BONE", "setWorldPosition: %s ", mSkeleton.getBoneName(0), bone.toString());
}
return true;
} | java | public boolean setPosition(float x, float y, float z)
{
Bone bone = mBones[0];
float dx = x - bone.WorldMatrix.m30();
float dy = y - bone.WorldMatrix.m31();
float dz = z - bone.WorldMatrix.m32();
sync();
bone.LocalMatrix.setTranslation(x, y, z);
for (int i = 0; i < mBones.length; ++i)
{
bone = mBones[i];
bone.WorldMatrix.m30(bone.WorldMatrix.m30() + dx);
bone.WorldMatrix.m31(bone.WorldMatrix.m31() + dy);
bone.WorldMatrix.m32(bone.WorldMatrix.m32() + dz);
}
if (sDebug)
{
Log.d("BONE", "setWorldPosition: %s ", mSkeleton.getBoneName(0), bone.toString());
}
return true;
} | [
"public",
"boolean",
"setPosition",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"z",
")",
"{",
"Bone",
"bone",
"=",
"mBones",
"[",
"0",
"]",
";",
"float",
"dx",
"=",
"x",
"-",
"bone",
".",
"WorldMatrix",
".",
"m30",
"(",
")",
";",
"float",
"dy",
"=",
"y",
"-",
"bone",
".",
"WorldMatrix",
".",
"m31",
"(",
")",
";",
"float",
"dz",
"=",
"z",
"-",
"bone",
".",
"WorldMatrix",
".",
"m32",
"(",
")",
";",
"sync",
"(",
")",
";",
"bone",
".",
"LocalMatrix",
".",
"setTranslation",
"(",
"x",
",",
"y",
",",
"z",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mBones",
".",
"length",
";",
"++",
"i",
")",
"{",
"bone",
"=",
"mBones",
"[",
"i",
"]",
";",
"bone",
".",
"WorldMatrix",
".",
"m30",
"(",
"bone",
".",
"WorldMatrix",
".",
"m30",
"(",
")",
"+",
"dx",
")",
";",
"bone",
".",
"WorldMatrix",
".",
"m31",
"(",
"bone",
".",
"WorldMatrix",
".",
"m31",
"(",
")",
"+",
"dy",
")",
";",
"bone",
".",
"WorldMatrix",
".",
"m32",
"(",
"bone",
".",
"WorldMatrix",
".",
"m32",
"(",
")",
"+",
"dz",
")",
";",
"}",
"if",
"(",
"sDebug",
")",
"{",
"Log",
".",
"d",
"(",
"\"BONE\"",
",",
"\"setWorldPosition: %s \"",
",",
"mSkeleton",
".",
"getBoneName",
"(",
"0",
")",
",",
"bone",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Sets the world position of a root bone and propagates to all children.
<p>
This has the effect of moving the overall skeleton to a new position
without affecting the orientation of it's bones.
@param x,y,z new world position of root bone.
@return true if world position set, false if bone is not a root bone.
@see #setWorldPositions
@see #getWorldPosition | [
"Sets",
"the",
"world",
"position",
"of",
"a",
"root",
"bone",
"and",
"propagates",
"to",
"all",
"children",
".",
"<p",
">",
"This",
"has",
"the",
"effect",
"of",
"moving",
"the",
"overall",
"skeleton",
"to",
"a",
"new",
"position",
"without",
"affecting",
"the",
"orientation",
"of",
"it",
"s",
"bones",
".",
"@param",
"x",
"y",
"z",
"new",
"world",
"position",
"of",
"root",
"bone",
".",
"@return",
"true",
"if",
"world",
"position",
"set",
"false",
"if",
"bone",
"is",
"not",
"a",
"root",
"bone",
"."
] | train | https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/animation/GVRPose.java#L841-L862 |
RestComm/sip-servlets | sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java | FacebookRestClient.postFileRequest | protected InputStream postFileRequest(String methodName, Map<String, CharSequence> params)
throws IOException {
"""
Helper function for posting a request that includes raw file data, eg {@link #photos_upload(File)}.
@param methodName the name of the method
@param params request parameters (not including the file)
@return an InputStream with the request response
@see #photos_upload(File)
"""
assert (null != _uploadFile);
try {
BufferedInputStream bufin = new BufferedInputStream(new FileInputStream(_uploadFile));
String boundary = Long.toString(System.currentTimeMillis(), 16);
URLConnection con = SERVER_URL.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", "multipart/form-data; charset=UTF-8; boundary=" + boundary);
con.setRequestProperty("MIME-version", "1.0");
DataOutputStream out = new DataOutputStream(con.getOutputStream());
for (Map.Entry<String, CharSequence> entry : params.entrySet()) {
out.writeBytes(PREF + boundary + CRLF);
out.writeBytes("Content-disposition: form-data; name=\"" + entry.getKey() + "\"");
out.writeBytes(CRLF + CRLF);
byte[] bytes = entry.getValue().toString().getBytes("UTF-8");
out.write(bytes);
out.writeBytes(CRLF);
}
out.writeBytes(PREF + boundary + CRLF);
out.writeBytes("Content-disposition: form-data; filename=\"" + _uploadFile.getName() + "\"" +
CRLF);
out.writeBytes("Content-Type: image/jpeg" + CRLF);
// out.writeBytes("Content-Transfer-Encoding: binary" + CRLF); // not necessary
// Write the file
out.writeBytes(CRLF);
byte b[] = new byte[UPLOAD_BUFFER_SIZE];
int byteCounter = 0;
int i;
while (-1 != (i = bufin.read(b))) {
byteCounter += i;
out.write(b, 0, i);
}
out.writeBytes(CRLF + PREF + boundary + PREF + CRLF);
out.flush();
out.close();
InputStream is = con.getInputStream();
return is;
} catch (Exception e) {
logException(e);
return null;
}
} | java | protected InputStream postFileRequest(String methodName, Map<String, CharSequence> params)
throws IOException {
assert (null != _uploadFile);
try {
BufferedInputStream bufin = new BufferedInputStream(new FileInputStream(_uploadFile));
String boundary = Long.toString(System.currentTimeMillis(), 16);
URLConnection con = SERVER_URL.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", "multipart/form-data; charset=UTF-8; boundary=" + boundary);
con.setRequestProperty("MIME-version", "1.0");
DataOutputStream out = new DataOutputStream(con.getOutputStream());
for (Map.Entry<String, CharSequence> entry : params.entrySet()) {
out.writeBytes(PREF + boundary + CRLF);
out.writeBytes("Content-disposition: form-data; name=\"" + entry.getKey() + "\"");
out.writeBytes(CRLF + CRLF);
byte[] bytes = entry.getValue().toString().getBytes("UTF-8");
out.write(bytes);
out.writeBytes(CRLF);
}
out.writeBytes(PREF + boundary + CRLF);
out.writeBytes("Content-disposition: form-data; filename=\"" + _uploadFile.getName() + "\"" +
CRLF);
out.writeBytes("Content-Type: image/jpeg" + CRLF);
// out.writeBytes("Content-Transfer-Encoding: binary" + CRLF); // not necessary
// Write the file
out.writeBytes(CRLF);
byte b[] = new byte[UPLOAD_BUFFER_SIZE];
int byteCounter = 0;
int i;
while (-1 != (i = bufin.read(b))) {
byteCounter += i;
out.write(b, 0, i);
}
out.writeBytes(CRLF + PREF + boundary + PREF + CRLF);
out.flush();
out.close();
InputStream is = con.getInputStream();
return is;
} catch (Exception e) {
logException(e);
return null;
}
} | [
"protected",
"InputStream",
"postFileRequest",
"(",
"String",
"methodName",
",",
"Map",
"<",
"String",
",",
"CharSequence",
">",
"params",
")",
"throws",
"IOException",
"{",
"assert",
"(",
"null",
"!=",
"_uploadFile",
")",
";",
"try",
"{",
"BufferedInputStream",
"bufin",
"=",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"_uploadFile",
")",
")",
";",
"String",
"boundary",
"=",
"Long",
".",
"toString",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
",",
"16",
")",
";",
"URLConnection",
"con",
"=",
"SERVER_URL",
".",
"openConnection",
"(",
")",
";",
"con",
".",
"setDoInput",
"(",
"true",
")",
";",
"con",
".",
"setDoOutput",
"(",
"true",
")",
";",
"con",
".",
"setUseCaches",
"(",
"false",
")",
";",
"con",
".",
"setRequestProperty",
"(",
"\"Content-Type\"",
",",
"\"multipart/form-data; charset=UTF-8; boundary=\"",
"+",
"boundary",
")",
";",
"con",
".",
"setRequestProperty",
"(",
"\"MIME-version\"",
",",
"\"1.0\"",
")",
";",
"DataOutputStream",
"out",
"=",
"new",
"DataOutputStream",
"(",
"con",
".",
"getOutputStream",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"CharSequence",
">",
"entry",
":",
"params",
".",
"entrySet",
"(",
")",
")",
"{",
"out",
".",
"writeBytes",
"(",
"PREF",
"+",
"boundary",
"+",
"CRLF",
")",
";",
"out",
".",
"writeBytes",
"(",
"\"Content-disposition: form-data; name=\\\"\"",
"+",
"entry",
".",
"getKey",
"(",
")",
"+",
"\"\\\"\"",
")",
";",
"out",
".",
"writeBytes",
"(",
"CRLF",
"+",
"CRLF",
")",
";",
"byte",
"[",
"]",
"bytes",
"=",
"entry",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"\"UTF-8\"",
")",
";",
"out",
".",
"write",
"(",
"bytes",
")",
";",
"out",
".",
"writeBytes",
"(",
"CRLF",
")",
";",
"}",
"out",
".",
"writeBytes",
"(",
"PREF",
"+",
"boundary",
"+",
"CRLF",
")",
";",
"out",
".",
"writeBytes",
"(",
"\"Content-disposition: form-data; filename=\\\"\"",
"+",
"_uploadFile",
".",
"getName",
"(",
")",
"+",
"\"\\\"\"",
"+",
"CRLF",
")",
";",
"out",
".",
"writeBytes",
"(",
"\"Content-Type: image/jpeg\"",
"+",
"CRLF",
")",
";",
"// out.writeBytes(\"Content-Transfer-Encoding: binary\" + CRLF); // not necessary",
"// Write the file",
"out",
".",
"writeBytes",
"(",
"CRLF",
")",
";",
"byte",
"b",
"[",
"]",
"=",
"new",
"byte",
"[",
"UPLOAD_BUFFER_SIZE",
"]",
";",
"int",
"byteCounter",
"=",
"0",
";",
"int",
"i",
";",
"while",
"(",
"-",
"1",
"!=",
"(",
"i",
"=",
"bufin",
".",
"read",
"(",
"b",
")",
")",
")",
"{",
"byteCounter",
"+=",
"i",
";",
"out",
".",
"write",
"(",
"b",
",",
"0",
",",
"i",
")",
";",
"}",
"out",
".",
"writeBytes",
"(",
"CRLF",
"+",
"PREF",
"+",
"boundary",
"+",
"PREF",
"+",
"CRLF",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"InputStream",
"is",
"=",
"con",
".",
"getInputStream",
"(",
")",
";",
"return",
"is",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logException",
"(",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Helper function for posting a request that includes raw file data, eg {@link #photos_upload(File)}.
@param methodName the name of the method
@param params request parameters (not including the file)
@return an InputStream with the request response
@see #photos_upload(File) | [
"Helper",
"function",
"for",
"posting",
"a",
"request",
"that",
"includes",
"raw",
"file",
"data",
"eg",
"{"
] | train | https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/sip-servlets-examples/facebook-c2c/src/main/java/com/facebook/api/FacebookRestClient.java#L1056-L1107 |
ModeShape/modeshape | web/modeshape-web-explorer/src/main/java/org/modeshape/web/BackupUploadServlet.java | BackupUploadServlet.processRequest | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
"""
Processes requests for both HTTP
<code>GET</code> and
<code>POST</code> methods.
@param request servlet request
@param response servlet response
@throws ServletException if a servlet-specific error occurs
@throws IOException if an I/O error occurs
"""
List<FileItem> items;
// Parse the request
try {
items = upload.parseRequest(request);
} catch (FileUploadException e) {
throw new ServletException(e);
}
String repository = getParameter(items, REPOSITORY_NAME_PARAMETER);
String incBinaries = getParameter(items, INCLUDE_BINARY_PARAMETER);
String reindexOnFinish = getParameter(items, REINDEX_ON_FINISH_PARAMETER);
RestoreParams params = new RestoreParams();
params.setIncludeBinaries(Boolean.valueOf(incBinaries));
params.setReindexOnFinish(Boolean.valueOf(reindexOnFinish));
InputStream in = getStream(items);
File dir = new File(tempDir.getAbsolutePath() + File.pathSeparator +
Long.toString(System.currentTimeMillis()));
FileUtil.unzip(in, dir.getAbsolutePath());
Connector connector = (Connector) request.getSession().getAttribute(REPOSITORY_CONNECTOR);
try {
connector.find(repository).restore(dir.getAbsolutePath(), params);
} catch (Exception e) {
throw new ServletException(e);
}
String uri = request.getContextPath()
+ String.format(DESTINATION_URL, repository);
response.sendRedirect(uri);
} | java | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List<FileItem> items;
// Parse the request
try {
items = upload.parseRequest(request);
} catch (FileUploadException e) {
throw new ServletException(e);
}
String repository = getParameter(items, REPOSITORY_NAME_PARAMETER);
String incBinaries = getParameter(items, INCLUDE_BINARY_PARAMETER);
String reindexOnFinish = getParameter(items, REINDEX_ON_FINISH_PARAMETER);
RestoreParams params = new RestoreParams();
params.setIncludeBinaries(Boolean.valueOf(incBinaries));
params.setReindexOnFinish(Boolean.valueOf(reindexOnFinish));
InputStream in = getStream(items);
File dir = new File(tempDir.getAbsolutePath() + File.pathSeparator +
Long.toString(System.currentTimeMillis()));
FileUtil.unzip(in, dir.getAbsolutePath());
Connector connector = (Connector) request.getSession().getAttribute(REPOSITORY_CONNECTOR);
try {
connector.find(repository).restore(dir.getAbsolutePath(), params);
} catch (Exception e) {
throw new ServletException(e);
}
String uri = request.getContextPath()
+ String.format(DESTINATION_URL, repository);
response.sendRedirect(uri);
} | [
"protected",
"void",
"processRequest",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"List",
"<",
"FileItem",
">",
"items",
";",
"// Parse the request",
"try",
"{",
"items",
"=",
"upload",
".",
"parseRequest",
"(",
"request",
")",
";",
"}",
"catch",
"(",
"FileUploadException",
"e",
")",
"{",
"throw",
"new",
"ServletException",
"(",
"e",
")",
";",
"}",
"String",
"repository",
"=",
"getParameter",
"(",
"items",
",",
"REPOSITORY_NAME_PARAMETER",
")",
";",
"String",
"incBinaries",
"=",
"getParameter",
"(",
"items",
",",
"INCLUDE_BINARY_PARAMETER",
")",
";",
"String",
"reindexOnFinish",
"=",
"getParameter",
"(",
"items",
",",
"REINDEX_ON_FINISH_PARAMETER",
")",
";",
"RestoreParams",
"params",
"=",
"new",
"RestoreParams",
"(",
")",
";",
"params",
".",
"setIncludeBinaries",
"(",
"Boolean",
".",
"valueOf",
"(",
"incBinaries",
")",
")",
";",
"params",
".",
"setReindexOnFinish",
"(",
"Boolean",
".",
"valueOf",
"(",
"reindexOnFinish",
")",
")",
";",
"InputStream",
"in",
"=",
"getStream",
"(",
"items",
")",
";",
"File",
"dir",
"=",
"new",
"File",
"(",
"tempDir",
".",
"getAbsolutePath",
"(",
")",
"+",
"File",
".",
"pathSeparator",
"+",
"Long",
".",
"toString",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
")",
";",
"FileUtil",
".",
"unzip",
"(",
"in",
",",
"dir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"Connector",
"connector",
"=",
"(",
"Connector",
")",
"request",
".",
"getSession",
"(",
")",
".",
"getAttribute",
"(",
"REPOSITORY_CONNECTOR",
")",
";",
"try",
"{",
"connector",
".",
"find",
"(",
"repository",
")",
".",
"restore",
"(",
"dir",
".",
"getAbsolutePath",
"(",
")",
",",
"params",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ServletException",
"(",
"e",
")",
";",
"}",
"String",
"uri",
"=",
"request",
".",
"getContextPath",
"(",
")",
"+",
"String",
".",
"format",
"(",
"DESTINATION_URL",
",",
"repository",
")",
";",
"response",
".",
"sendRedirect",
"(",
"uri",
")",
";",
"}"
] | Processes requests for both HTTP
<code>GET</code> and
<code>POST</code> methods.
@param request servlet request
@param response servlet response
@throws ServletException if a servlet-specific error occurs
@throws IOException if an I/O error occurs | [
"Processes",
"requests",
"for",
"both",
"HTTP",
"<code",
">",
"GET<",
"/",
"code",
">",
"and",
"<code",
">",
"POST<",
"/",
"code",
">",
"methods",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/web/modeshape-web-explorer/src/main/java/org/modeshape/web/BackupUploadServlet.java#L61-L96 |
hawkular/hawkular-apm | api/src/main/java/org/hawkular/apm/api/services/AbstractAnalyticsService.java | AbstractAnalyticsService.obtainEndpoints | protected void obtainEndpoints(List<Node> nodes, List<EndpointInfo> endpoints) {
"""
This method collects the information regarding endpoints.
@param nodes The nodes
@param endpoints The list of endpoints
"""
for (int i = 0; i < nodes.size(); i++) {
Node node = nodes.get(i);
if (node.getUri() != null) {
EndpointInfo ei=new EndpointInfo();
ei.setEndpoint(EndpointUtil.encodeEndpoint(node.getUri(), node.getOperation()));
if (!endpoints.contains(ei)) {
initEndpointInfo(ei);
endpoints.add(ei);
}
}
if (node instanceof ContainerNode) {
obtainEndpoints(((ContainerNode) node).getNodes(), endpoints);
}
}
} | java | protected void obtainEndpoints(List<Node> nodes, List<EndpointInfo> endpoints) {
for (int i = 0; i < nodes.size(); i++) {
Node node = nodes.get(i);
if (node.getUri() != null) {
EndpointInfo ei=new EndpointInfo();
ei.setEndpoint(EndpointUtil.encodeEndpoint(node.getUri(), node.getOperation()));
if (!endpoints.contains(ei)) {
initEndpointInfo(ei);
endpoints.add(ei);
}
}
if (node instanceof ContainerNode) {
obtainEndpoints(((ContainerNode) node).getNodes(), endpoints);
}
}
} | [
"protected",
"void",
"obtainEndpoints",
"(",
"List",
"<",
"Node",
">",
"nodes",
",",
"List",
"<",
"EndpointInfo",
">",
"endpoints",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"nodes",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"node",
"=",
"nodes",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"node",
".",
"getUri",
"(",
")",
"!=",
"null",
")",
"{",
"EndpointInfo",
"ei",
"=",
"new",
"EndpointInfo",
"(",
")",
";",
"ei",
".",
"setEndpoint",
"(",
"EndpointUtil",
".",
"encodeEndpoint",
"(",
"node",
".",
"getUri",
"(",
")",
",",
"node",
".",
"getOperation",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"endpoints",
".",
"contains",
"(",
"ei",
")",
")",
"{",
"initEndpointInfo",
"(",
"ei",
")",
";",
"endpoints",
".",
"add",
"(",
"ei",
")",
";",
"}",
"}",
"if",
"(",
"node",
"instanceof",
"ContainerNode",
")",
"{",
"obtainEndpoints",
"(",
"(",
"(",
"ContainerNode",
")",
"node",
")",
".",
"getNodes",
"(",
")",
",",
"endpoints",
")",
";",
"}",
"}",
"}"
] | This method collects the information regarding endpoints.
@param nodes The nodes
@param endpoints The list of endpoints | [
"This",
"method",
"collects",
"the",
"information",
"regarding",
"endpoints",
"."
] | train | https://github.com/hawkular/hawkular-apm/blob/57a4df0611b359597626563ea5f9ac64d4bb2533/api/src/main/java/org/hawkular/apm/api/services/AbstractAnalyticsService.java#L447-L465 |
Trilarion/java-vorbis-support | src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java | VorbisAudioFileReader.getAudioInputStream | @Override
public AudioInputStream getAudioInputStream(InputStream inputStream) throws UnsupportedAudioFileException, IOException {
"""
Return the AudioInputStream from the given InputStream.
@return
@throws javax.sound.sampled.UnsupportedAudioFileException
@throws java.io.IOException
"""
LOG.log(Level.FINE, "getAudioInputStream(InputStream inputStream)");
return getAudioInputStream(inputStream, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED);
} | java | @Override
public AudioInputStream getAudioInputStream(InputStream inputStream) throws UnsupportedAudioFileException, IOException {
LOG.log(Level.FINE, "getAudioInputStream(InputStream inputStream)");
return getAudioInputStream(inputStream, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED);
} | [
"@",
"Override",
"public",
"AudioInputStream",
"getAudioInputStream",
"(",
"InputStream",
"inputStream",
")",
"throws",
"UnsupportedAudioFileException",
",",
"IOException",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"getAudioInputStream(InputStream inputStream)\"",
")",
";",
"return",
"getAudioInputStream",
"(",
"inputStream",
",",
"AudioSystem",
".",
"NOT_SPECIFIED",
",",
"AudioSystem",
".",
"NOT_SPECIFIED",
")",
";",
"}"
] | Return the AudioInputStream from the given InputStream.
@return
@throws javax.sound.sampled.UnsupportedAudioFileException
@throws java.io.IOException | [
"Return",
"the",
"AudioInputStream",
"from",
"the",
"given",
"InputStream",
"."
] | train | https://github.com/Trilarion/java-vorbis-support/blob/f72aba7d97167fe0ff20b1b719fdb5bb662ff736/src/main/java/com/github/trilarion/sound/vorbis/sampled/spi/VorbisAudioFileReader.java#L274-L278 |
eclipse/hawkbit | hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java | JpaControllerManagement.handleRegisterRetrieved | private Action handleRegisterRetrieved(final Long actionId, final String message) {
"""
Registers retrieved status for given {@link Target} and {@link Action} if
it does not exist yet.
@param actionId
to the handle status for
@param message
for the status
@return the updated action in case the status has been changed to
{@link Status#RETRIEVED}
"""
final JpaAction action = getActionAndThrowExceptionIfNotFound(actionId);
// do a manual query with CriteriaBuilder to avoid unnecessary field
// queries and an extra
// count query made by spring-data when using pageable requests, we
// don't need an extra count
// query, we just want to check if the last action status is a retrieved
// or not.
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<Object[]> queryActionStatus = cb.createQuery(Object[].class);
final Root<JpaActionStatus> actionStatusRoot = queryActionStatus.from(JpaActionStatus.class);
final CriteriaQuery<Object[]> query = queryActionStatus
.multiselect(actionStatusRoot.get(JpaActionStatus_.id), actionStatusRoot.get(JpaActionStatus_.status))
.where(cb.equal(actionStatusRoot.get(JpaActionStatus_.action).get(JpaAction_.id), actionId))
.orderBy(cb.desc(actionStatusRoot.get(JpaActionStatus_.id)));
final List<Object[]> resultList = entityManager.createQuery(query).setFirstResult(0).setMaxResults(1)
.getResultList();
// if the latest status is not in retrieve state then we add a retrieved
// state again, we want
// to document a deployment retrieved status and a cancel retrieved
// status, but multiple
// retrieves after the other we don't want to store to protect to
// overflood action status in
// case controller retrieves a action multiple times.
if (resultList.isEmpty() || !Status.RETRIEVED.equals(resultList.get(0)[1])) {
// document that the status has been retrieved
actionStatusRepository
.save(new JpaActionStatus(action, Status.RETRIEVED, System.currentTimeMillis(), message));
// don't change the action status itself in case the action is in
// canceling state otherwise
// we modify the action status and the controller won't get the
// cancel job anymore.
if (!action.isCancelingOrCanceled()) {
action.setStatus(Status.RETRIEVED);
return actionRepository.save(action);
}
}
return action;
} | java | private Action handleRegisterRetrieved(final Long actionId, final String message) {
final JpaAction action = getActionAndThrowExceptionIfNotFound(actionId);
// do a manual query with CriteriaBuilder to avoid unnecessary field
// queries and an extra
// count query made by spring-data when using pageable requests, we
// don't need an extra count
// query, we just want to check if the last action status is a retrieved
// or not.
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<Object[]> queryActionStatus = cb.createQuery(Object[].class);
final Root<JpaActionStatus> actionStatusRoot = queryActionStatus.from(JpaActionStatus.class);
final CriteriaQuery<Object[]> query = queryActionStatus
.multiselect(actionStatusRoot.get(JpaActionStatus_.id), actionStatusRoot.get(JpaActionStatus_.status))
.where(cb.equal(actionStatusRoot.get(JpaActionStatus_.action).get(JpaAction_.id), actionId))
.orderBy(cb.desc(actionStatusRoot.get(JpaActionStatus_.id)));
final List<Object[]> resultList = entityManager.createQuery(query).setFirstResult(0).setMaxResults(1)
.getResultList();
// if the latest status is not in retrieve state then we add a retrieved
// state again, we want
// to document a deployment retrieved status and a cancel retrieved
// status, but multiple
// retrieves after the other we don't want to store to protect to
// overflood action status in
// case controller retrieves a action multiple times.
if (resultList.isEmpty() || !Status.RETRIEVED.equals(resultList.get(0)[1])) {
// document that the status has been retrieved
actionStatusRepository
.save(new JpaActionStatus(action, Status.RETRIEVED, System.currentTimeMillis(), message));
// don't change the action status itself in case the action is in
// canceling state otherwise
// we modify the action status and the controller won't get the
// cancel job anymore.
if (!action.isCancelingOrCanceled()) {
action.setStatus(Status.RETRIEVED);
return actionRepository.save(action);
}
}
return action;
} | [
"private",
"Action",
"handleRegisterRetrieved",
"(",
"final",
"Long",
"actionId",
",",
"final",
"String",
"message",
")",
"{",
"final",
"JpaAction",
"action",
"=",
"getActionAndThrowExceptionIfNotFound",
"(",
"actionId",
")",
";",
"// do a manual query with CriteriaBuilder to avoid unnecessary field",
"// queries and an extra",
"// count query made by spring-data when using pageable requests, we",
"// don't need an extra count",
"// query, we just want to check if the last action status is a retrieved",
"// or not.",
"final",
"CriteriaBuilder",
"cb",
"=",
"entityManager",
".",
"getCriteriaBuilder",
"(",
")",
";",
"final",
"CriteriaQuery",
"<",
"Object",
"[",
"]",
">",
"queryActionStatus",
"=",
"cb",
".",
"createQuery",
"(",
"Object",
"[",
"]",
".",
"class",
")",
";",
"final",
"Root",
"<",
"JpaActionStatus",
">",
"actionStatusRoot",
"=",
"queryActionStatus",
".",
"from",
"(",
"JpaActionStatus",
".",
"class",
")",
";",
"final",
"CriteriaQuery",
"<",
"Object",
"[",
"]",
">",
"query",
"=",
"queryActionStatus",
".",
"multiselect",
"(",
"actionStatusRoot",
".",
"get",
"(",
"JpaActionStatus_",
".",
"id",
")",
",",
"actionStatusRoot",
".",
"get",
"(",
"JpaActionStatus_",
".",
"status",
")",
")",
".",
"where",
"(",
"cb",
".",
"equal",
"(",
"actionStatusRoot",
".",
"get",
"(",
"JpaActionStatus_",
".",
"action",
")",
".",
"get",
"(",
"JpaAction_",
".",
"id",
")",
",",
"actionId",
")",
")",
".",
"orderBy",
"(",
"cb",
".",
"desc",
"(",
"actionStatusRoot",
".",
"get",
"(",
"JpaActionStatus_",
".",
"id",
")",
")",
")",
";",
"final",
"List",
"<",
"Object",
"[",
"]",
">",
"resultList",
"=",
"entityManager",
".",
"createQuery",
"(",
"query",
")",
".",
"setFirstResult",
"(",
"0",
")",
".",
"setMaxResults",
"(",
"1",
")",
".",
"getResultList",
"(",
")",
";",
"// if the latest status is not in retrieve state then we add a retrieved",
"// state again, we want",
"// to document a deployment retrieved status and a cancel retrieved",
"// status, but multiple",
"// retrieves after the other we don't want to store to protect to",
"// overflood action status in",
"// case controller retrieves a action multiple times.",
"if",
"(",
"resultList",
".",
"isEmpty",
"(",
")",
"||",
"!",
"Status",
".",
"RETRIEVED",
".",
"equals",
"(",
"resultList",
".",
"get",
"(",
"0",
")",
"[",
"1",
"]",
")",
")",
"{",
"// document that the status has been retrieved",
"actionStatusRepository",
".",
"save",
"(",
"new",
"JpaActionStatus",
"(",
"action",
",",
"Status",
".",
"RETRIEVED",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
",",
"message",
")",
")",
";",
"// don't change the action status itself in case the action is in",
"// canceling state otherwise",
"// we modify the action status and the controller won't get the",
"// cancel job anymore.",
"if",
"(",
"!",
"action",
".",
"isCancelingOrCanceled",
"(",
")",
")",
"{",
"action",
".",
"setStatus",
"(",
"Status",
".",
"RETRIEVED",
")",
";",
"return",
"actionRepository",
".",
"save",
"(",
"action",
")",
";",
"}",
"}",
"return",
"action",
";",
"}"
] | Registers retrieved status for given {@link Target} and {@link Action} if
it does not exist yet.
@param actionId
to the handle status for
@param message
for the status
@return the updated action in case the status has been changed to
{@link Status#RETRIEVED} | [
"Registers",
"retrieved",
"status",
"for",
"given",
"{",
"@link",
"Target",
"}",
"and",
"{",
"@link",
"Action",
"}",
"if",
"it",
"does",
"not",
"exist",
"yet",
"."
] | train | https://github.com/eclipse/hawkbit/blob/9884452ad42f3b4827461606d8a9215c8625a7fe/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java#L808-L848 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/registry/GlobalTransformerRegistry.java | GlobalTransformerRegistry.mergeSubtree | public void mergeSubtree(final OperationTransformerRegistry targetRegistry, final Map<PathAddress, ModelVersion> subTree) {
"""
Merge a subtree.
@param targetRegistry the target registry
@param subTree the subtree
"""
for(Map.Entry<PathAddress, ModelVersion> entry: subTree.entrySet()) {
mergeSubtree(targetRegistry, entry.getKey(), entry.getValue());
}
} | java | public void mergeSubtree(final OperationTransformerRegistry targetRegistry, final Map<PathAddress, ModelVersion> subTree) {
for(Map.Entry<PathAddress, ModelVersion> entry: subTree.entrySet()) {
mergeSubtree(targetRegistry, entry.getKey(), entry.getValue());
}
} | [
"public",
"void",
"mergeSubtree",
"(",
"final",
"OperationTransformerRegistry",
"targetRegistry",
",",
"final",
"Map",
"<",
"PathAddress",
",",
"ModelVersion",
">",
"subTree",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"PathAddress",
",",
"ModelVersion",
">",
"entry",
":",
"subTree",
".",
"entrySet",
"(",
")",
")",
"{",
"mergeSubtree",
"(",
"targetRegistry",
",",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] | Merge a subtree.
@param targetRegistry the target registry
@param subTree the subtree | [
"Merge",
"a",
"subtree",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/registry/GlobalTransformerRegistry.java#L152-L156 |
CrawlScript/WebCollector | src/main/java/cn/edu/hfut/dmic/webcollector/example/DemoRedirectCrawler.java | DemoRedirectCrawler.createBingUrl | public static String createBingUrl(String keyword, int pageIndex) throws Exception {
"""
construct the Bing Search url by the search keyword and the pageIndex
@param keyword
@param pageIndex
@return the constructed url
@throws Exception
"""
int first = pageIndex * 10 - 9;
keyword = URLEncoder.encode(keyword, "utf-8");
return String.format("http://cn.bing.com/search?q=%s&first=%s", keyword, first);
} | java | public static String createBingUrl(String keyword, int pageIndex) throws Exception {
int first = pageIndex * 10 - 9;
keyword = URLEncoder.encode(keyword, "utf-8");
return String.format("http://cn.bing.com/search?q=%s&first=%s", keyword, first);
} | [
"public",
"static",
"String",
"createBingUrl",
"(",
"String",
"keyword",
",",
"int",
"pageIndex",
")",
"throws",
"Exception",
"{",
"int",
"first",
"=",
"pageIndex",
"*",
"10",
"-",
"9",
";",
"keyword",
"=",
"URLEncoder",
".",
"encode",
"(",
"keyword",
",",
"\"utf-8\"",
")",
";",
"return",
"String",
".",
"format",
"(",
"\"http://cn.bing.com/search?q=%s&first=%s\"",
",",
"keyword",
",",
"first",
")",
";",
"}"
] | construct the Bing Search url by the search keyword and the pageIndex
@param keyword
@param pageIndex
@return the constructed url
@throws Exception | [
"construct",
"the",
"Bing",
"Search",
"url",
"by",
"the",
"search",
"keyword",
"and",
"the",
"pageIndex"
] | train | https://github.com/CrawlScript/WebCollector/blob/4ca71ec0e69d354feaf64319d76e64663159902d/src/main/java/cn/edu/hfut/dmic/webcollector/example/DemoRedirectCrawler.java#L79-L83 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/util/StringUtils.java | StringUtils.containsIgnoreCase | public static boolean containsIgnoreCase(Collection<String> c, String s) {
"""
Convenience method: a case-insensitive variant of Collection.contains
@param c Collection<String>
@param s String
@return true if s case-insensitively matches a string in c
"""
for (String squote: c) {
if (squote.equalsIgnoreCase(s))
return true;
}
return false;
} | java | public static boolean containsIgnoreCase(Collection<String> c, String s) {
for (String squote: c) {
if (squote.equalsIgnoreCase(s))
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"containsIgnoreCase",
"(",
"Collection",
"<",
"String",
">",
"c",
",",
"String",
"s",
")",
"{",
"for",
"(",
"String",
"squote",
":",
"c",
")",
"{",
"if",
"(",
"squote",
".",
"equalsIgnoreCase",
"(",
"s",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Convenience method: a case-insensitive variant of Collection.contains
@param c Collection<String>
@param s String
@return true if s case-insensitively matches a string in c | [
"Convenience",
"method",
":",
"a",
"case",
"-",
"insensitive",
"variant",
"of",
"Collection",
".",
"contains"
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/util/StringUtils.java#L63-L69 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.