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
listlengths 20
832
| func_documentation_string
stringlengths 61
2k
| func_documentation_tokens
listlengths 1
647
| split_name
stringclasses 1
value | func_code_url
stringlengths 102
339
|
---|---|---|---|---|---|---|---|---|---|---|
elki-project/elki
|
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java
|
BitsUtil.previousClearBit
|
public static int previousClearBit(long v, int start) {
"""
Find the previous clear bit.
@param v Values to process
@param start Start position (inclusive)
@return Position of previous clear bit, or -1.
"""
if(start < 0) {
return -1;
}
start = start < Long.SIZE ? start : Long.SIZE - 1;
long cur = ~v & (LONG_ALL_BITS >>> -(start + 1));
return cur == 0 ? -1 : 63 - Long.numberOfLeadingZeros(cur);
}
|
java
|
public static int previousClearBit(long v, int start) {
if(start < 0) {
return -1;
}
start = start < Long.SIZE ? start : Long.SIZE - 1;
long cur = ~v & (LONG_ALL_BITS >>> -(start + 1));
return cur == 0 ? -1 : 63 - Long.numberOfLeadingZeros(cur);
}
|
[
"public",
"static",
"int",
"previousClearBit",
"(",
"long",
"v",
",",
"int",
"start",
")",
"{",
"if",
"(",
"start",
"<",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"start",
"=",
"start",
"<",
"Long",
".",
"SIZE",
"?",
"start",
":",
"Long",
".",
"SIZE",
"-",
"1",
";",
"long",
"cur",
"=",
"~",
"v",
"&",
"(",
"LONG_ALL_BITS",
">>>",
"-",
"(",
"start",
"+",
"1",
")",
")",
";",
"return",
"cur",
"==",
"0",
"?",
"-",
"1",
":",
"63",
"-",
"Long",
".",
"numberOfLeadingZeros",
"(",
"cur",
")",
";",
"}"
] |
Find the previous clear bit.
@param v Values to process
@param start Start position (inclusive)
@return Position of previous clear bit, or -1.
|
[
"Find",
"the",
"previous",
"clear",
"bit",
"."
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1262-L1269
|
box/box-android-sdk
|
box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiFile.java
|
BoxApiFile.getCreateUploadVersionSessionRequest
|
public BoxRequestsFile.CreateNewVersionUploadSession getCreateUploadVersionSessionRequest(File file, String fileId)
throws FileNotFoundException {
"""
Gets a request that creates an upload session for uploading a new file version
@param file The file to be uploaded
@param fileId The fileId
@return request to create an upload session for uploading a new file version
"""
return new BoxRequestsFile.CreateNewVersionUploadSession(file, getUploadSessionForNewFileVersionUrl(fileId), mSession);
}
|
java
|
public BoxRequestsFile.CreateNewVersionUploadSession getCreateUploadVersionSessionRequest(File file, String fileId)
throws FileNotFoundException {
return new BoxRequestsFile.CreateNewVersionUploadSession(file, getUploadSessionForNewFileVersionUrl(fileId), mSession);
}
|
[
"public",
"BoxRequestsFile",
".",
"CreateNewVersionUploadSession",
"getCreateUploadVersionSessionRequest",
"(",
"File",
"file",
",",
"String",
"fileId",
")",
"throws",
"FileNotFoundException",
"{",
"return",
"new",
"BoxRequestsFile",
".",
"CreateNewVersionUploadSession",
"(",
"file",
",",
"getUploadSessionForNewFileVersionUrl",
"(",
"fileId",
")",
",",
"mSession",
")",
";",
"}"
] |
Gets a request that creates an upload session for uploading a new file version
@param file The file to be uploaded
@param fileId The fileId
@return request to create an upload session for uploading a new file version
|
[
"Gets",
"a",
"request",
"that",
"creates",
"an",
"upload",
"session",
"for",
"uploading",
"a",
"new",
"file",
"version"
] |
train
|
https://github.com/box/box-android-sdk/blob/a621ad5ddebf23067fec27529130d72718fc0e88/box-content-sdk/src/main/java/com/box/androidsdk/content/BoxApiFile.java#L603-L606
|
xwiki/xwiki-rendering
|
xwiki-rendering-syntaxes/xwiki-rendering-syntax-plain/src/main/java/org/xwiki/rendering/internal/parser/plain/PlainTextStreamParser.java
|
PlainTextStreamParser.readChar
|
private int readChar(Reader source) throws ParseException {
"""
Read a single char from an Reader source.
@param source the input to read from
@return the char read
@throws ParseException in case of reading error
"""
int c;
try {
c = source.read();
} catch (IOException e) {
throw new ParseException("Failed to read input source", e);
}
return c;
}
|
java
|
private int readChar(Reader source) throws ParseException
{
int c;
try {
c = source.read();
} catch (IOException e) {
throw new ParseException("Failed to read input source", e);
}
return c;
}
|
[
"private",
"int",
"readChar",
"(",
"Reader",
"source",
")",
"throws",
"ParseException",
"{",
"int",
"c",
";",
"try",
"{",
"c",
"=",
"source",
".",
"read",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"\"Failed to read input source\"",
",",
"e",
")",
";",
"}",
"return",
"c",
";",
"}"
] |
Read a single char from an Reader source.
@param source the input to read from
@return the char read
@throws ParseException in case of reading error
|
[
"Read",
"a",
"single",
"char",
"from",
"an",
"Reader",
"source",
"."
] |
train
|
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-plain/src/main/java/org/xwiki/rendering/internal/parser/plain/PlainTextStreamParser.java#L67-L78
|
legsem/legstar.avro
|
legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslatorMain.java
|
Xsd2AvroTranslatorMain.collectOptions
|
private boolean collectOptions(final Options options, final String[] args)
throws Exception {
"""
Take arguments received on the command line and setup corresponding
options.
<p/>
No arguments is valid. It means use the defaults.
@param options the expected options
@param args the actual arguments received on the command line
@return true if arguments were valid
@throws Exception if something goes wrong while parsing arguments
"""
if (args != null && args.length > 0) {
CommandLineParser parser = new PosixParser();
CommandLine line = parser.parse(options, args);
return processLine(line, options);
}
return true;
}
|
java
|
private boolean collectOptions(final Options options, final String[] args)
throws Exception {
if (args != null && args.length > 0) {
CommandLineParser parser = new PosixParser();
CommandLine line = parser.parse(options, args);
return processLine(line, options);
}
return true;
}
|
[
"private",
"boolean",
"collectOptions",
"(",
"final",
"Options",
"options",
",",
"final",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"if",
"(",
"args",
"!=",
"null",
"&&",
"args",
".",
"length",
">",
"0",
")",
"{",
"CommandLineParser",
"parser",
"=",
"new",
"PosixParser",
"(",
")",
";",
"CommandLine",
"line",
"=",
"parser",
".",
"parse",
"(",
"options",
",",
"args",
")",
";",
"return",
"processLine",
"(",
"line",
",",
"options",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Take arguments received on the command line and setup corresponding
options.
<p/>
No arguments is valid. It means use the defaults.
@param options the expected options
@param args the actual arguments received on the command line
@return true if arguments were valid
@throws Exception if something goes wrong while parsing arguments
|
[
"Take",
"arguments",
"received",
"on",
"the",
"command",
"line",
"and",
"setup",
"corresponding",
"options",
".",
"<p",
"/",
">",
"No",
"arguments",
"is",
"valid",
".",
"It",
"means",
"use",
"the",
"defaults",
"."
] |
train
|
https://github.com/legsem/legstar.avro/blob/bad5e0bf41700951eee1ad6a5d6d0c47b3da8f0b/legstar.avro.translator/src/main/java/com/legstar/avro/translator/Xsd2AvroTranslatorMain.java#L153-L161
|
alkacon/opencms-core
|
src/org/opencms/file/CmsObject.java
|
CmsObject.setDateExpired
|
public void setDateExpired(String resourcename, long dateExpired, boolean recursive) throws CmsException {
"""
Changes the "expire" date of a resource.<p>
@param resourcename the name of the resource to change (full current site relative path)
@param dateExpired the new expire date of the changed resource
@param recursive if this operation is to be applied recursively to all resources in a folder
@throws CmsException if something goes wrong
"""
CmsResource resource = readResource(resourcename, CmsResourceFilter.IGNORE_EXPIRATION);
setDateExpired(resource, dateExpired, recursive);
}
|
java
|
public void setDateExpired(String resourcename, long dateExpired, boolean recursive) throws CmsException {
CmsResource resource = readResource(resourcename, CmsResourceFilter.IGNORE_EXPIRATION);
setDateExpired(resource, dateExpired, recursive);
}
|
[
"public",
"void",
"setDateExpired",
"(",
"String",
"resourcename",
",",
"long",
"dateExpired",
",",
"boolean",
"recursive",
")",
"throws",
"CmsException",
"{",
"CmsResource",
"resource",
"=",
"readResource",
"(",
"resourcename",
",",
"CmsResourceFilter",
".",
"IGNORE_EXPIRATION",
")",
";",
"setDateExpired",
"(",
"resource",
",",
"dateExpired",
",",
"recursive",
")",
";",
"}"
] |
Changes the "expire" date of a resource.<p>
@param resourcename the name of the resource to change (full current site relative path)
@param dateExpired the new expire date of the changed resource
@param recursive if this operation is to be applied recursively to all resources in a folder
@throws CmsException if something goes wrong
|
[
"Changes",
"the",
"expire",
"date",
"of",
"a",
"resource",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/CmsObject.java#L3767-L3771
|
RestComm/sip-servlets
|
containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipNamingContextListener.java
|
SipNamingContextListener.removeTimerService
|
public static void removeTimerService(Context envCtx, String appName, TimerService timerService) {
"""
Removes the Timer Service binding from the jndi mapping
@param appName the application name subcontext
@param timerService the Timer Service to remove
"""
if(envCtx != null) {
try {
javax.naming.Context sipContext = (javax.naming.Context)envCtx.lookup(SIP_SUBCONTEXT + "/" + appName);
sipContext.unbind(TIMER_SERVICE_JNDI_NAME);
} catch (NamingException e) {
logger.error(sm.getString("naming.unbindFailed", e));
}
}
}
|
java
|
public static void removeTimerService(Context envCtx, String appName, TimerService timerService) {
if(envCtx != null) {
try {
javax.naming.Context sipContext = (javax.naming.Context)envCtx.lookup(SIP_SUBCONTEXT + "/" + appName);
sipContext.unbind(TIMER_SERVICE_JNDI_NAME);
} catch (NamingException e) {
logger.error(sm.getString("naming.unbindFailed", e));
}
}
}
|
[
"public",
"static",
"void",
"removeTimerService",
"(",
"Context",
"envCtx",
",",
"String",
"appName",
",",
"TimerService",
"timerService",
")",
"{",
"if",
"(",
"envCtx",
"!=",
"null",
")",
"{",
"try",
"{",
"javax",
".",
"naming",
".",
"Context",
"sipContext",
"=",
"(",
"javax",
".",
"naming",
".",
"Context",
")",
"envCtx",
".",
"lookup",
"(",
"SIP_SUBCONTEXT",
"+",
"\"/\"",
"+",
"appName",
")",
";",
"sipContext",
".",
"unbind",
"(",
"TIMER_SERVICE_JNDI_NAME",
")",
";",
"}",
"catch",
"(",
"NamingException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"sm",
".",
"getString",
"(",
"\"naming.unbindFailed\"",
",",
"e",
")",
")",
";",
"}",
"}",
"}"
] |
Removes the Timer Service binding from the jndi mapping
@param appName the application name subcontext
@param timerService the Timer Service to remove
|
[
"Removes",
"the",
"Timer",
"Service",
"binding",
"from",
"the",
"jndi",
"mapping"
] |
train
|
https://github.com/RestComm/sip-servlets/blob/fd7011d2803ab1d205b140768a760c8c69e0c997/containers/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipNamingContextListener.java#L262-L271
|
sniffy/sniffy
|
sniffy-core/src/main/java/io/sniffy/LegacySpy.java
|
LegacySpy.verifyBetween
|
@Deprecated
public C verifyBetween(int minAllowedStatements, int maxAllowedStatements, Threads threadMatcher) throws WrongNumberOfQueriesError {
"""
Verifies that at least {@code minAllowedStatements} and at most
{@code maxAllowedStatements} were called between the creation of the current instance
and a call to {@link #verify()} method
@throws WrongNumberOfQueriesError if wrong number of queries was executed
@since 2.0
"""
return verify(SqlQueries.queriesBetween(minAllowedStatements, maxAllowedStatements).threads(threadMatcher));
}
|
java
|
@Deprecated
public C verifyBetween(int minAllowedStatements, int maxAllowedStatements, Threads threadMatcher) throws WrongNumberOfQueriesError {
return verify(SqlQueries.queriesBetween(minAllowedStatements, maxAllowedStatements).threads(threadMatcher));
}
|
[
"@",
"Deprecated",
"public",
"C",
"verifyBetween",
"(",
"int",
"minAllowedStatements",
",",
"int",
"maxAllowedStatements",
",",
"Threads",
"threadMatcher",
")",
"throws",
"WrongNumberOfQueriesError",
"{",
"return",
"verify",
"(",
"SqlQueries",
".",
"queriesBetween",
"(",
"minAllowedStatements",
",",
"maxAllowedStatements",
")",
".",
"threads",
"(",
"threadMatcher",
")",
")",
";",
"}"
] |
Verifies that at least {@code minAllowedStatements} and at most
{@code maxAllowedStatements} were called between the creation of the current instance
and a call to {@link #verify()} method
@throws WrongNumberOfQueriesError if wrong number of queries was executed
@since 2.0
|
[
"Verifies",
"that",
"at",
"least",
"{"
] |
train
|
https://github.com/sniffy/sniffy/blob/7bdddb9593e6b6e9fe5c7c87519f864acbc3a5c0/sniffy-core/src/main/java/io/sniffy/LegacySpy.java#L651-L654
|
VoltDB/voltdb
|
src/frontend/org/voltdb/utils/CatalogUtil.java
|
CatalogUtil.getDeployment
|
public static String getDeployment(DeploymentType deployment, boolean indent) throws IOException {
"""
Given the deployment object generate the XML
@param deployment
@param indent
@return XML of deployment object.
@throws IOException
"""
try {
if (m_jc == null || m_schema == null) {
throw new RuntimeException("Error schema validation.");
}
Marshaller marshaller = m_jc.createMarshaller();
marshaller.setSchema(m_schema);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.valueOf(indent));
StringWriter sw = new StringWriter();
marshaller.marshal(new JAXBElement<>(new QName("","deployment"), DeploymentType.class, deployment), sw);
return sw.toString();
} catch (JAXBException e) {
// Convert some linked exceptions to more friendly errors.
if (e.getLinkedException() instanceof java.io.FileNotFoundException) {
hostLog.error(e.getLinkedException().getMessage());
return null;
} else if (e.getLinkedException() instanceof org.xml.sax.SAXParseException) {
hostLog.error("Error schema validating deployment.xml file. " + e.getLinkedException().getMessage());
return null;
} else {
throw new RuntimeException(e);
}
}
}
|
java
|
public static String getDeployment(DeploymentType deployment, boolean indent) throws IOException {
try {
if (m_jc == null || m_schema == null) {
throw new RuntimeException("Error schema validation.");
}
Marshaller marshaller = m_jc.createMarshaller();
marshaller.setSchema(m_schema);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.valueOf(indent));
StringWriter sw = new StringWriter();
marshaller.marshal(new JAXBElement<>(new QName("","deployment"), DeploymentType.class, deployment), sw);
return sw.toString();
} catch (JAXBException e) {
// Convert some linked exceptions to more friendly errors.
if (e.getLinkedException() instanceof java.io.FileNotFoundException) {
hostLog.error(e.getLinkedException().getMessage());
return null;
} else if (e.getLinkedException() instanceof org.xml.sax.SAXParseException) {
hostLog.error("Error schema validating deployment.xml file. " + e.getLinkedException().getMessage());
return null;
} else {
throw new RuntimeException(e);
}
}
}
|
[
"public",
"static",
"String",
"getDeployment",
"(",
"DeploymentType",
"deployment",
",",
"boolean",
"indent",
")",
"throws",
"IOException",
"{",
"try",
"{",
"if",
"(",
"m_jc",
"==",
"null",
"||",
"m_schema",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error schema validation.\"",
")",
";",
"}",
"Marshaller",
"marshaller",
"=",
"m_jc",
".",
"createMarshaller",
"(",
")",
";",
"marshaller",
".",
"setSchema",
"(",
"m_schema",
")",
";",
"marshaller",
".",
"setProperty",
"(",
"Marshaller",
".",
"JAXB_FORMATTED_OUTPUT",
",",
"Boolean",
".",
"valueOf",
"(",
"indent",
")",
")",
";",
"StringWriter",
"sw",
"=",
"new",
"StringWriter",
"(",
")",
";",
"marshaller",
".",
"marshal",
"(",
"new",
"JAXBElement",
"<>",
"(",
"new",
"QName",
"(",
"\"\"",
",",
"\"deployment\"",
")",
",",
"DeploymentType",
".",
"class",
",",
"deployment",
")",
",",
"sw",
")",
";",
"return",
"sw",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"// Convert some linked exceptions to more friendly errors.",
"if",
"(",
"e",
".",
"getLinkedException",
"(",
")",
"instanceof",
"java",
".",
"io",
".",
"FileNotFoundException",
")",
"{",
"hostLog",
".",
"error",
"(",
"e",
".",
"getLinkedException",
"(",
")",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"e",
".",
"getLinkedException",
"(",
")",
"instanceof",
"org",
".",
"xml",
".",
"sax",
".",
"SAXParseException",
")",
"{",
"hostLog",
".",
"error",
"(",
"\"Error schema validating deployment.xml file. \"",
"+",
"e",
".",
"getLinkedException",
"(",
")",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] |
Given the deployment object generate the XML
@param deployment
@param indent
@return XML of deployment object.
@throws IOException
|
[
"Given",
"the",
"deployment",
"object",
"generate",
"the",
"XML"
] |
train
|
https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/utils/CatalogUtil.java#L1213-L1236
|
wildfly/wildfly-core
|
controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java
|
AttributeDefinition.resolveModelAttribute
|
public ModelNode resolveModelAttribute(final ExpressionResolver resolver, final ModelNode model) throws OperationFailedException {
"""
Finds a value in the given {@code model} whose key matches this attribute's {@link #getName() name},
uses the given {@code resolver} to {@link ExpressionResolver#resolveExpressions(org.jboss.dmr.ModelNode)} resolve}
it and validates it using this attribute's {@link #getValidator() validator}. If the value is
undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
@param resolver the expression resolver
@param model model node of type {@link ModelType#OBJECT}, typically representing a model resource
@return the resolved value, possibly the default value if the model does not have a defined value matching
this attribute's name
@throws OperationFailedException if the value is not valid
"""
final ModelNode node = new ModelNode();
if(model.has(name)) {
node.set(model.get(name));
}
return resolveValue(resolver, node);
}
|
java
|
public ModelNode resolveModelAttribute(final ExpressionResolver resolver, final ModelNode model) throws OperationFailedException {
final ModelNode node = new ModelNode();
if(model.has(name)) {
node.set(model.get(name));
}
return resolveValue(resolver, node);
}
|
[
"public",
"ModelNode",
"resolveModelAttribute",
"(",
"final",
"ExpressionResolver",
"resolver",
",",
"final",
"ModelNode",
"model",
")",
"throws",
"OperationFailedException",
"{",
"final",
"ModelNode",
"node",
"=",
"new",
"ModelNode",
"(",
")",
";",
"if",
"(",
"model",
".",
"has",
"(",
"name",
")",
")",
"{",
"node",
".",
"set",
"(",
"model",
".",
"get",
"(",
"name",
")",
")",
";",
"}",
"return",
"resolveValue",
"(",
"resolver",
",",
"node",
")",
";",
"}"
] |
Finds a value in the given {@code model} whose key matches this attribute's {@link #getName() name},
uses the given {@code resolver} to {@link ExpressionResolver#resolveExpressions(org.jboss.dmr.ModelNode)} resolve}
it and validates it using this attribute's {@link #getValidator() validator}. If the value is
undefined and a {@link #getDefaultValue() default value} is available, the default value is used.
@param resolver the expression resolver
@param model model node of type {@link ModelType#OBJECT}, typically representing a model resource
@return the resolved value, possibly the default value if the model does not have a defined value matching
this attribute's name
@throws OperationFailedException if the value is not valid
|
[
"Finds",
"a",
"value",
"in",
"the",
"given",
"{",
"@code",
"model",
"}",
"whose",
"key",
"matches",
"this",
"attribute",
"s",
"{",
"@link",
"#getName",
"()",
"name",
"}",
"uses",
"the",
"given",
"{",
"@code",
"resolver",
"}",
"to",
"{",
"@link",
"ExpressionResolver#resolveExpressions",
"(",
"org",
".",
"jboss",
".",
"dmr",
".",
"ModelNode",
")",
"}",
"resolve",
"}",
"it",
"and",
"validates",
"it",
"using",
"this",
"attribute",
"s",
"{",
"@link",
"#getValidator",
"()",
"validator",
"}",
".",
"If",
"the",
"value",
"is",
"undefined",
"and",
"a",
"{",
"@link",
"#getDefaultValue",
"()",
"default",
"value",
"}",
"is",
"available",
"the",
"default",
"value",
"is",
"used",
"."
] |
train
|
https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java#L621-L627
|
Impetus/Kundera
|
src/jpa-engine/core/src/main/java/com/impetus/kundera/graph/GraphGenerator.java
|
GraphGenerator.assignNodeLinkProperty
|
private void assignNodeLinkProperty(Node node, Relation relation, Node childNode) {
"""
On assigning node link properties
@param node
node
@param relation
relation
@param childNode
child node
"""
// Construct Node Link for this relationship
NodeLink nodeLink = new NodeLink(node.getNodeId(), childNode.getNodeId());
setLink(node, relation, childNode, nodeLink);
}
|
java
|
private void assignNodeLinkProperty(Node node, Relation relation, Node childNode)
{
// Construct Node Link for this relationship
NodeLink nodeLink = new NodeLink(node.getNodeId(), childNode.getNodeId());
setLink(node, relation, childNode, nodeLink);
}
|
[
"private",
"void",
"assignNodeLinkProperty",
"(",
"Node",
"node",
",",
"Relation",
"relation",
",",
"Node",
"childNode",
")",
"{",
"// Construct Node Link for this relationship",
"NodeLink",
"nodeLink",
"=",
"new",
"NodeLink",
"(",
"node",
".",
"getNodeId",
"(",
")",
",",
"childNode",
".",
"getNodeId",
"(",
")",
")",
";",
"setLink",
"(",
"node",
",",
"relation",
",",
"childNode",
",",
"nodeLink",
")",
";",
"}"
] |
On assigning node link properties
@param node
node
@param relation
relation
@param childNode
child node
|
[
"On",
"assigning",
"node",
"link",
"properties"
] |
train
|
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/graph/GraphGenerator.java#L278-L283
|
google/j2objc
|
jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java
|
Cipher.matchAttribute
|
static boolean matchAttribute(Provider.Service service, String attr, String value) {
"""
If the attribute listed exists, check that it matches the regular
expression.
"""
if (value == null) {
return true;
}
final String pattern = service.getAttribute(attr);
if (pattern == null) {
return true;
}
final String valueUc = value.toUpperCase(Locale.US);
return valueUc.matches(pattern.toUpperCase(Locale.US));
}
|
java
|
static boolean matchAttribute(Provider.Service service, String attr, String value) {
if (value == null) {
return true;
}
final String pattern = service.getAttribute(attr);
if (pattern == null) {
return true;
}
final String valueUc = value.toUpperCase(Locale.US);
return valueUc.matches(pattern.toUpperCase(Locale.US));
}
|
[
"static",
"boolean",
"matchAttribute",
"(",
"Provider",
".",
"Service",
"service",
",",
"String",
"attr",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"final",
"String",
"pattern",
"=",
"service",
".",
"getAttribute",
"(",
"attr",
")",
";",
"if",
"(",
"pattern",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"final",
"String",
"valueUc",
"=",
"value",
".",
"toUpperCase",
"(",
"Locale",
".",
"US",
")",
";",
"return",
"valueUc",
".",
"matches",
"(",
"pattern",
".",
"toUpperCase",
"(",
"Locale",
".",
"US",
")",
")",
";",
"}"
] |
If the attribute listed exists, check that it matches the regular
expression.
|
[
"If",
"the",
"attribute",
"listed",
"exists",
"check",
"that",
"it",
"matches",
"the",
"regular",
"expression",
"."
] |
train
|
https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/javax/crypto/Cipher.java#L2685-L2695
|
op4j/op4j-jodatime
|
src/main/java/org/op4j/jodatime/functions/FnPeriod.java
|
FnPeriod.timestampFieldArrayToPeriod
|
public static final Function<Timestamp[], Period> timestampFieldArrayToPeriod(final PeriodType periodType, final Chronology chronology) {
"""
<p>
The function receives an Array of two {@link Timestamp} elements used as the start and end of the
{@link Period} it creates. The {@link Period} will be created using the specified
specified {@link PeriodType} and {@link Chronology}
</p>
@param periodType the {@link PeriodType} to be created. It specifies which duration fields are to be used
@param chronology {@link Chronology} to be used
@return the {@link Period} created from the input and arguments
"""
return new TimestampFieldArrayToPeriod(periodType, chronology);
}
|
java
|
public static final Function<Timestamp[], Period> timestampFieldArrayToPeriod(final PeriodType periodType, final Chronology chronology) {
return new TimestampFieldArrayToPeriod(periodType, chronology);
}
|
[
"public",
"static",
"final",
"Function",
"<",
"Timestamp",
"[",
"]",
",",
"Period",
">",
"timestampFieldArrayToPeriod",
"(",
"final",
"PeriodType",
"periodType",
",",
"final",
"Chronology",
"chronology",
")",
"{",
"return",
"new",
"TimestampFieldArrayToPeriod",
"(",
"periodType",
",",
"chronology",
")",
";",
"}"
] |
<p>
The function receives an Array of two {@link Timestamp} elements used as the start and end of the
{@link Period} it creates. The {@link Period} will be created using the specified
specified {@link PeriodType} and {@link Chronology}
</p>
@param periodType the {@link PeriodType} to be created. It specifies which duration fields are to be used
@param chronology {@link Chronology} to be used
@return the {@link Period} created from the input and arguments
|
[
"<p",
">",
"The",
"function",
"receives",
"an",
"Array",
"of",
"two",
"{",
"@link",
"Timestamp",
"}",
"elements",
"used",
"as",
"the",
"start",
"and",
"end",
"of",
"the",
"{",
"@link",
"Period",
"}",
"it",
"creates",
".",
"The",
"{",
"@link",
"Period",
"}",
"will",
"be",
"created",
"using",
"the",
"specified",
"specified",
"{",
"@link",
"PeriodType",
"}",
"and",
"{",
"@link",
"Chronology",
"}",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/op4j/op4j-jodatime/blob/26e5b8cda8553fb3b5a4a64b3109dbbf5df21194/src/main/java/org/op4j/jodatime/functions/FnPeriod.java#L300-L302
|
lessthanoptimal/BoofCV
|
main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/SurfDescribeOps.java
|
SurfDescribeOps.rotatedWidth
|
public static double rotatedWidth( double width , double c , double s ) {
"""
Computes the width of a square containment region that contains a rotated rectangle.
@param width Size of the original rectangle.
@param c Cosine(theta)
@param s Sine(theta)
@return Side length of the containment square.
"""
return Math.abs(c)*width + Math.abs(s)*width;
}
|
java
|
public static double rotatedWidth( double width , double c , double s )
{
return Math.abs(c)*width + Math.abs(s)*width;
}
|
[
"public",
"static",
"double",
"rotatedWidth",
"(",
"double",
"width",
",",
"double",
"c",
",",
"double",
"s",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"c",
")",
"*",
"width",
"+",
"Math",
".",
"abs",
"(",
"s",
")",
"*",
"width",
";",
"}"
] |
Computes the width of a square containment region that contains a rotated rectangle.
@param width Size of the original rectangle.
@param c Cosine(theta)
@param s Sine(theta)
@return Side length of the containment square.
|
[
"Computes",
"the",
"width",
"of",
"a",
"square",
"containment",
"region",
"that",
"contains",
"a",
"rotated",
"rectangle",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/SurfDescribeOps.java#L214-L217
|
lievendoclo/Valkyrie-RCP
|
valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java
|
Constraints.gte
|
public PropertyConstraint gte(String propertyName, Comparable propertyValue) {
"""
Apply a "greater than equal to" constraint to a bean property.
@param propertyName The first property
@param propertyValue The constraint value
@return The constraint
"""
return new ParameterizedPropertyConstraint(propertyName, gte(propertyValue));
}
|
java
|
public PropertyConstraint gte(String propertyName, Comparable propertyValue) {
return new ParameterizedPropertyConstraint(propertyName, gte(propertyValue));
}
|
[
"public",
"PropertyConstraint",
"gte",
"(",
"String",
"propertyName",
",",
"Comparable",
"propertyValue",
")",
"{",
"return",
"new",
"ParameterizedPropertyConstraint",
"(",
"propertyName",
",",
"gte",
"(",
"propertyValue",
")",
")",
";",
"}"
] |
Apply a "greater than equal to" constraint to a bean property.
@param propertyName The first property
@param propertyValue The constraint value
@return The constraint
|
[
"Apply",
"a",
"greater",
"than",
"equal",
"to",
"constraint",
"to",
"a",
"bean",
"property",
"."
] |
train
|
https://github.com/lievendoclo/Valkyrie-RCP/blob/6aad6e640b348cda8f3b0841f6e42025233f1eb8/valkyrie-rcp-core/src/main/java/org/valkyriercp/rules/constraint/Constraints.java#L702-L704
|
googleapis/google-cloud-java
|
google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java
|
CloudStorageFileSystemProvider.listBuckets
|
Page<Bucket> listBuckets(Storage.BucketListOption... options) {
"""
Lists the project's buckets. But use the one in CloudStorageFileSystem.
<p>Example of listing buckets, specifying the page size and a name prefix.
<pre>{@code
String prefix = "bucket_";
Page<Bucket> buckets = provider.listBuckets(BucketListOption.prefix(prefix));
Iterator<Bucket> bucketIterator = buckets.iterateAll();
while (bucketIterator.hasNext()) {
Bucket bucket = bucketIterator.next();
// do something with the bucket
}
}</pre>
@throws StorageException upon failure
"""
initStorage();
return storage.list(options);
}
|
java
|
Page<Bucket> listBuckets(Storage.BucketListOption... options) {
initStorage();
return storage.list(options);
}
|
[
"Page",
"<",
"Bucket",
">",
"listBuckets",
"(",
"Storage",
".",
"BucketListOption",
"...",
"options",
")",
"{",
"initStorage",
"(",
")",
";",
"return",
"storage",
".",
"list",
"(",
"options",
")",
";",
"}"
] |
Lists the project's buckets. But use the one in CloudStorageFileSystem.
<p>Example of listing buckets, specifying the page size and a name prefix.
<pre>{@code
String prefix = "bucket_";
Page<Bucket> buckets = provider.listBuckets(BucketListOption.prefix(prefix));
Iterator<Bucket> bucketIterator = buckets.iterateAll();
while (bucketIterator.hasNext()) {
Bucket bucket = bucketIterator.next();
// do something with the bucket
}
}</pre>
@throws StorageException upon failure
|
[
"Lists",
"the",
"project",
"s",
"buckets",
".",
"But",
"use",
"the",
"one",
"in",
"CloudStorageFileSystem",
"."
] |
train
|
https://github.com/googleapis/google-cloud-java/blob/d2f0bc64a53049040fe9c9d338b12fab3dd1ad6a/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java#L1006-L1009
|
google/error-prone-javac
|
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
|
HtmlDocletWriter.getPackageLink
|
public Content getPackageLink(PackageElement packageElement, Content label) {
"""
Return the link to the given package.
@param packageElement the package to link to.
@param label the label for the link.
@return a content tree for the package link.
"""
boolean included = packageElement != null && utils.isIncluded(packageElement);
if (!included) {
for (PackageElement p : configuration.packages) {
if (p.equals(packageElement)) {
included = true;
break;
}
}
}
if (included || packageElement == null) {
return getHyperLink(pathString(packageElement, DocPaths.PACKAGE_SUMMARY),
label);
} else {
DocLink crossPkgLink = getCrossPackageLink(utils.getPackageName(packageElement));
if (crossPkgLink != null) {
return getHyperLink(crossPkgLink, label);
} else {
return label;
}
}
}
|
java
|
public Content getPackageLink(PackageElement packageElement, Content label) {
boolean included = packageElement != null && utils.isIncluded(packageElement);
if (!included) {
for (PackageElement p : configuration.packages) {
if (p.equals(packageElement)) {
included = true;
break;
}
}
}
if (included || packageElement == null) {
return getHyperLink(pathString(packageElement, DocPaths.PACKAGE_SUMMARY),
label);
} else {
DocLink crossPkgLink = getCrossPackageLink(utils.getPackageName(packageElement));
if (crossPkgLink != null) {
return getHyperLink(crossPkgLink, label);
} else {
return label;
}
}
}
|
[
"public",
"Content",
"getPackageLink",
"(",
"PackageElement",
"packageElement",
",",
"Content",
"label",
")",
"{",
"boolean",
"included",
"=",
"packageElement",
"!=",
"null",
"&&",
"utils",
".",
"isIncluded",
"(",
"packageElement",
")",
";",
"if",
"(",
"!",
"included",
")",
"{",
"for",
"(",
"PackageElement",
"p",
":",
"configuration",
".",
"packages",
")",
"{",
"if",
"(",
"p",
".",
"equals",
"(",
"packageElement",
")",
")",
"{",
"included",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"included",
"||",
"packageElement",
"==",
"null",
")",
"{",
"return",
"getHyperLink",
"(",
"pathString",
"(",
"packageElement",
",",
"DocPaths",
".",
"PACKAGE_SUMMARY",
")",
",",
"label",
")",
";",
"}",
"else",
"{",
"DocLink",
"crossPkgLink",
"=",
"getCrossPackageLink",
"(",
"utils",
".",
"getPackageName",
"(",
"packageElement",
")",
")",
";",
"if",
"(",
"crossPkgLink",
"!=",
"null",
")",
"{",
"return",
"getHyperLink",
"(",
"crossPkgLink",
",",
"label",
")",
";",
"}",
"else",
"{",
"return",
"label",
";",
"}",
"}",
"}"
] |
Return the link to the given package.
@param packageElement the package to link to.
@param label the label for the link.
@return a content tree for the package link.
|
[
"Return",
"the",
"link",
"to",
"the",
"given",
"package",
"."
] |
train
|
https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java#L1114-L1135
|
igniterealtime/REST-API-Client
|
src/main/java/org/igniterealtime/restclient/RestApiClient.java
|
RestApiClient.addRosterEntry
|
public Response addRosterEntry(String username, RosterItemEntity rosterItemEntity) {
"""
Adds the roster entry.
@param username
the username
@param rosterItemEntity
the roster item entity
@return the response
"""
return restClient.post("users/" + username + "/roster", rosterItemEntity, new HashMap<String, String>());
}
|
java
|
public Response addRosterEntry(String username, RosterItemEntity rosterItemEntity) {
return restClient.post("users/" + username + "/roster", rosterItemEntity, new HashMap<String, String>());
}
|
[
"public",
"Response",
"addRosterEntry",
"(",
"String",
"username",
",",
"RosterItemEntity",
"rosterItemEntity",
")",
"{",
"return",
"restClient",
".",
"post",
"(",
"\"users/\"",
"+",
"username",
"+",
"\"/roster\"",
",",
"rosterItemEntity",
",",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
")",
";",
"}"
] |
Adds the roster entry.
@param username
the username
@param rosterItemEntity
the roster item entity
@return the response
|
[
"Adds",
"the",
"roster",
"entry",
"."
] |
train
|
https://github.com/igniterealtime/REST-API-Client/blob/fd544dd770ec2ababa47fef51579522ddce09f05/src/main/java/org/igniterealtime/restclient/RestApiClient.java#L691-L693
|
aws/aws-sdk-java
|
aws-java-sdk-clouddirectory/src/main/java/com/amazonaws/services/clouddirectory/model/BatchListObjectChildrenResponse.java
|
BatchListObjectChildrenResponse.withChildren
|
public BatchListObjectChildrenResponse withChildren(java.util.Map<String, String> children) {
"""
<p>
The children structure, which is a map with the key as the <code>LinkName</code> and
<code>ObjectIdentifier</code> as the value.
</p>
@param children
The children structure, which is a map with the key as the <code>LinkName</code> and
<code>ObjectIdentifier</code> as the value.
@return Returns a reference to this object so that method calls can be chained together.
"""
setChildren(children);
return this;
}
|
java
|
public BatchListObjectChildrenResponse withChildren(java.util.Map<String, String> children) {
setChildren(children);
return this;
}
|
[
"public",
"BatchListObjectChildrenResponse",
"withChildren",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"children",
")",
"{",
"setChildren",
"(",
"children",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
The children structure, which is a map with the key as the <code>LinkName</code> and
<code>ObjectIdentifier</code> as the value.
</p>
@param children
The children structure, which is a map with the key as the <code>LinkName</code> and
<code>ObjectIdentifier</code> as the value.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"The",
"children",
"structure",
"which",
"is",
"a",
"map",
"with",
"the",
"key",
"as",
"the",
"<code",
">",
"LinkName<",
"/",
"code",
">",
"and",
"<code",
">",
"ObjectIdentifier<",
"/",
"code",
">",
"as",
"the",
"value",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-clouddirectory/src/main/java/com/amazonaws/services/clouddirectory/model/BatchListObjectChildrenResponse.java#L86-L89
|
OpenLiberty/open-liberty
|
dev/com.ibm.websphere.javaee.jsf.2.2/src/javax/faces/component/_SharedRendererUtils.java
|
_SharedRendererUtils.getValueTypeConverter
|
static Converter getValueTypeConverter(FacesContext facesContext, UISelectMany component) {
"""
Uses the valueType attribute of the given UISelectMany component to
get a by-type converter.
@param facesContext
@param component
@return
"""
Converter converter = null;
Object valueTypeAttr = component.getAttributes().get(VALUE_TYPE_KEY);
if (valueTypeAttr != null)
{
// treat the valueType attribute exactly like the collectionType attribute
Class<?> valueType = getClassFromAttribute(facesContext, valueTypeAttr);
if (valueType == null)
{
throw new FacesException(
"The attribute "
+ VALUE_TYPE_KEY
+ " of component "
+ component.getClientId(facesContext)
+ " does not evaluate to a "
+ "String, a Class object or a ValueExpression pointing "
+ "to a String or a Class object.");
}
// now we have a valid valueType
// --> try to get a registered-by-class converter
converter = facesContext.getApplication().createConverter(valueType);
if (converter == null)
{
facesContext.getExternalContext().log("Found attribute valueType on component " +
_ComponentUtils.getPathToComponent(component) +
", but could not get a by-type converter for type " +
valueType.getName());
}
}
return converter;
}
|
java
|
static Converter getValueTypeConverter(FacesContext facesContext, UISelectMany component)
{
Converter converter = null;
Object valueTypeAttr = component.getAttributes().get(VALUE_TYPE_KEY);
if (valueTypeAttr != null)
{
// treat the valueType attribute exactly like the collectionType attribute
Class<?> valueType = getClassFromAttribute(facesContext, valueTypeAttr);
if (valueType == null)
{
throw new FacesException(
"The attribute "
+ VALUE_TYPE_KEY
+ " of component "
+ component.getClientId(facesContext)
+ " does not evaluate to a "
+ "String, a Class object or a ValueExpression pointing "
+ "to a String or a Class object.");
}
// now we have a valid valueType
// --> try to get a registered-by-class converter
converter = facesContext.getApplication().createConverter(valueType);
if (converter == null)
{
facesContext.getExternalContext().log("Found attribute valueType on component " +
_ComponentUtils.getPathToComponent(component) +
", but could not get a by-type converter for type " +
valueType.getName());
}
}
return converter;
}
|
[
"static",
"Converter",
"getValueTypeConverter",
"(",
"FacesContext",
"facesContext",
",",
"UISelectMany",
"component",
")",
"{",
"Converter",
"converter",
"=",
"null",
";",
"Object",
"valueTypeAttr",
"=",
"component",
".",
"getAttributes",
"(",
")",
".",
"get",
"(",
"VALUE_TYPE_KEY",
")",
";",
"if",
"(",
"valueTypeAttr",
"!=",
"null",
")",
"{",
"// treat the valueType attribute exactly like the collectionType attribute",
"Class",
"<",
"?",
">",
"valueType",
"=",
"getClassFromAttribute",
"(",
"facesContext",
",",
"valueTypeAttr",
")",
";",
"if",
"(",
"valueType",
"==",
"null",
")",
"{",
"throw",
"new",
"FacesException",
"(",
"\"The attribute \"",
"+",
"VALUE_TYPE_KEY",
"+",
"\" of component \"",
"+",
"component",
".",
"getClientId",
"(",
"facesContext",
")",
"+",
"\" does not evaluate to a \"",
"+",
"\"String, a Class object or a ValueExpression pointing \"",
"+",
"\"to a String or a Class object.\"",
")",
";",
"}",
"// now we have a valid valueType",
"// --> try to get a registered-by-class converter",
"converter",
"=",
"facesContext",
".",
"getApplication",
"(",
")",
".",
"createConverter",
"(",
"valueType",
")",
";",
"if",
"(",
"converter",
"==",
"null",
")",
"{",
"facesContext",
".",
"getExternalContext",
"(",
")",
".",
"log",
"(",
"\"Found attribute valueType on component \"",
"+",
"_ComponentUtils",
".",
"getPathToComponent",
"(",
"component",
")",
"+",
"\", but could not get a by-type converter for type \"",
"+",
"valueType",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"return",
"converter",
";",
"}"
] |
Uses the valueType attribute of the given UISelectMany component to
get a by-type converter.
@param facesContext
@param component
@return
|
[
"Uses",
"the",
"valueType",
"attribute",
"of",
"the",
"given",
"UISelectMany",
"component",
"to",
"get",
"a",
"by",
"-",
"type",
"converter",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.websphere.javaee.jsf.2.2/src/javax/faces/component/_SharedRendererUtils.java#L404-L438
|
Samsung/GearVRf
|
GVRf/Framework/framework/src/main/java/org/gearvrf/GVRShaderData.java
|
GVRShaderData.setTexCoord
|
public void setTexCoord(String texName, String texCoordAttr, String shaderVarName) {
"""
Designate the vertex attribute and shader variable for the texture coordinates
associated with the named texture.
@param texName name of texture
@param texCoordAttr name of vertex attribute with texture coordinates.
@param shaderVarName name of shader variable to get texture coordinates.
"""
synchronized (textures)
{
GVRTexture tex = textures.get(texName);
if (tex != null)
{
tex.setTexCoord(texCoordAttr, shaderVarName);
}
else
{
throw new UnsupportedOperationException("Texture must be set before updating texture coordinate information");
}
}
}
|
java
|
public void setTexCoord(String texName, String texCoordAttr, String shaderVarName)
{
synchronized (textures)
{
GVRTexture tex = textures.get(texName);
if (tex != null)
{
tex.setTexCoord(texCoordAttr, shaderVarName);
}
else
{
throw new UnsupportedOperationException("Texture must be set before updating texture coordinate information");
}
}
}
|
[
"public",
"void",
"setTexCoord",
"(",
"String",
"texName",
",",
"String",
"texCoordAttr",
",",
"String",
"shaderVarName",
")",
"{",
"synchronized",
"(",
"textures",
")",
"{",
"GVRTexture",
"tex",
"=",
"textures",
".",
"get",
"(",
"texName",
")",
";",
"if",
"(",
"tex",
"!=",
"null",
")",
"{",
"tex",
".",
"setTexCoord",
"(",
"texCoordAttr",
",",
"shaderVarName",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Texture must be set before updating texture coordinate information\"",
")",
";",
"}",
"}",
"}"
] |
Designate the vertex attribute and shader variable for the texture coordinates
associated with the named texture.
@param texName name of texture
@param texCoordAttr name of vertex attribute with texture coordinates.
@param shaderVarName name of shader variable to get texture coordinates.
|
[
"Designate",
"the",
"vertex",
"attribute",
"and",
"shader",
"variable",
"for",
"the",
"texture",
"coordinates",
"associated",
"with",
"the",
"named",
"texture",
"."
] |
train
|
https://github.com/Samsung/GearVRf/blob/05034d465a7b0a494fabb9e9f2971ac19392f32d/GVRf/Framework/framework/src/main/java/org/gearvrf/GVRShaderData.java#L465-L480
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/ChannelUtilsBase.java
|
ChannelUtilsBase.traceChannels
|
protected final void traceChannels(Object logTool, ChannelFramework cfw, String message, String prefix) {
"""
Print channel configuration - for debug
@param logTool
Caller's LogTool (should be Logger OR TraceComponent)
@param cfw
Reference to channel framework service
@param message
Description to accompany trace, e.g. "CFW Channel
Configuration"
@param prefix
Component-type prefix used to associate traces together, e.g.
"XMEM", "ZIOP", "TCP", "SOAP"
"""
if (cfw == null) {
debugTrace(logTool, prefix + " - No cfw to trace channels");
return;
}
List<?> lchannel;
Iterator<?> ichannel;
ChannelData channel;
ChannelData[] channelList;
// Create new String builder for list of configured channels
StringBuilder traceMessage = new StringBuilder(300);
// Prepend message passed as argument to our output
traceMessage.append(prefix + ": Configured Channels - ");
if (message != null)
traceMessage.append(message);
traceMessage.append(EOLN);
// Get a list of all existing channels (should include XMem)
channelList = cfw.getAllChannels();
// Trace all configured channels
lchannel = Arrays.asList(channelList);
for (ichannel = lchannel.iterator(); ichannel.hasNext();) {
channel = (ChannelData) ichannel.next();
traceMessage.append(prefix + ": ");
traceMessage.append(channel.getName());
traceMessage.append(" - ");
traceMessage.append(channel.getFactoryType());
traceMessage.append(EOLN);
}
debugTrace(logTool, traceMessage.toString());
}
|
java
|
protected final void traceChannels(Object logTool, ChannelFramework cfw, String message, String prefix) {
if (cfw == null) {
debugTrace(logTool, prefix + " - No cfw to trace channels");
return;
}
List<?> lchannel;
Iterator<?> ichannel;
ChannelData channel;
ChannelData[] channelList;
// Create new String builder for list of configured channels
StringBuilder traceMessage = new StringBuilder(300);
// Prepend message passed as argument to our output
traceMessage.append(prefix + ": Configured Channels - ");
if (message != null)
traceMessage.append(message);
traceMessage.append(EOLN);
// Get a list of all existing channels (should include XMem)
channelList = cfw.getAllChannels();
// Trace all configured channels
lchannel = Arrays.asList(channelList);
for (ichannel = lchannel.iterator(); ichannel.hasNext();) {
channel = (ChannelData) ichannel.next();
traceMessage.append(prefix + ": ");
traceMessage.append(channel.getName());
traceMessage.append(" - ");
traceMessage.append(channel.getFactoryType());
traceMessage.append(EOLN);
}
debugTrace(logTool, traceMessage.toString());
}
|
[
"protected",
"final",
"void",
"traceChannels",
"(",
"Object",
"logTool",
",",
"ChannelFramework",
"cfw",
",",
"String",
"message",
",",
"String",
"prefix",
")",
"{",
"if",
"(",
"cfw",
"==",
"null",
")",
"{",
"debugTrace",
"(",
"logTool",
",",
"prefix",
"+",
"\" - No cfw to trace channels\"",
")",
";",
"return",
";",
"}",
"List",
"<",
"?",
">",
"lchannel",
";",
"Iterator",
"<",
"?",
">",
"ichannel",
";",
"ChannelData",
"channel",
";",
"ChannelData",
"[",
"]",
"channelList",
";",
"// Create new String builder for list of configured channels",
"StringBuilder",
"traceMessage",
"=",
"new",
"StringBuilder",
"(",
"300",
")",
";",
"// Prepend message passed as argument to our output",
"traceMessage",
".",
"append",
"(",
"prefix",
"+",
"\": Configured Channels - \"",
")",
";",
"if",
"(",
"message",
"!=",
"null",
")",
"traceMessage",
".",
"append",
"(",
"message",
")",
";",
"traceMessage",
".",
"append",
"(",
"EOLN",
")",
";",
"// Get a list of all existing channels (should include XMem)",
"channelList",
"=",
"cfw",
".",
"getAllChannels",
"(",
")",
";",
"// Trace all configured channels",
"lchannel",
"=",
"Arrays",
".",
"asList",
"(",
"channelList",
")",
";",
"for",
"(",
"ichannel",
"=",
"lchannel",
".",
"iterator",
"(",
")",
";",
"ichannel",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"channel",
"=",
"(",
"ChannelData",
")",
"ichannel",
".",
"next",
"(",
")",
";",
"traceMessage",
".",
"append",
"(",
"prefix",
"+",
"\": \"",
")",
";",
"traceMessage",
".",
"append",
"(",
"channel",
".",
"getName",
"(",
")",
")",
";",
"traceMessage",
".",
"append",
"(",
"\" - \"",
")",
";",
"traceMessage",
".",
"append",
"(",
"channel",
".",
"getFactoryType",
"(",
")",
")",
";",
"traceMessage",
".",
"append",
"(",
"EOLN",
")",
";",
"}",
"debugTrace",
"(",
"logTool",
",",
"traceMessage",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Print channel configuration - for debug
@param logTool
Caller's LogTool (should be Logger OR TraceComponent)
@param cfw
Reference to channel framework service
@param message
Description to accompany trace, e.g. "CFW Channel
Configuration"
@param prefix
Component-type prefix used to associate traces together, e.g.
"XMEM", "ZIOP", "TCP", "SOAP"
|
[
"Print",
"channel",
"configuration",
"-",
"for",
"debug"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.channelfw/src/com/ibm/ws/channelfw/internal/ChannelUtilsBase.java#L205-L243
|
spotify/apollo
|
apollo-extra/src/main/java/com/spotify/apollo/route/HtmlSerializerMiddlewares.java
|
HtmlSerializerMiddlewares.serialize
|
public static <T> ByteString serialize(final String templateName, T object) {
"""
Call the template engine and return the result.
@param templateName The template name, respective to the "resources" folder
@param object The parameter to pass to the template
@param <T> The Type of the parameters
@return The HTML
"""
StringWriter templateResults = new StringWriter();
try {
final Template template = configuration.getTemplate(templateName);
template.process(object, templateResults);
} catch (Exception e) {
throw Throwables.propagate(e);
}
return ByteString.encodeUtf8(templateResults.toString());
}
|
java
|
public static <T> ByteString serialize(final String templateName, T object) {
StringWriter templateResults = new StringWriter();
try {
final Template template = configuration.getTemplate(templateName);
template.process(object, templateResults);
} catch (Exception e) {
throw Throwables.propagate(e);
}
return ByteString.encodeUtf8(templateResults.toString());
}
|
[
"public",
"static",
"<",
"T",
">",
"ByteString",
"serialize",
"(",
"final",
"String",
"templateName",
",",
"T",
"object",
")",
"{",
"StringWriter",
"templateResults",
"=",
"new",
"StringWriter",
"(",
")",
";",
"try",
"{",
"final",
"Template",
"template",
"=",
"configuration",
".",
"getTemplate",
"(",
"templateName",
")",
";",
"template",
".",
"process",
"(",
"object",
",",
"templateResults",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"Throwables",
".",
"propagate",
"(",
"e",
")",
";",
"}",
"return",
"ByteString",
".",
"encodeUtf8",
"(",
"templateResults",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Call the template engine and return the result.
@param templateName The template name, respective to the "resources" folder
@param object The parameter to pass to the template
@param <T> The Type of the parameters
@return The HTML
|
[
"Call",
"the",
"template",
"engine",
"and",
"return",
"the",
"result",
"."
] |
train
|
https://github.com/spotify/apollo/blob/3aba09840538a2aff9cdac5be42cc114dd276c70/apollo-extra/src/main/java/com/spotify/apollo/route/HtmlSerializerMiddlewares.java#L65-L74
|
sawano/java-commons
|
src/main/java/se/sawano/java/commons/lang/validate/Validate.java
|
Validate.noNullElements
|
public static <T extends Iterable<?>> T noNullElements(final T iterable, final String message, final Object... values) {
"""
<p>Validate that the specified argument iterable is neither {@code null} nor contains any elements that are {@code null}; otherwise throwing an exception with the specified message.
<pre>Validate.noNullElements(myCollection, "The collection contains null at position %d");</pre>
<p>If the iterable is {@code null}, then the message in the exception is "The validated object is null".</p><p>If the iterable has a {@code null} element, then the iteration index of
the invalid element is appended to the {@code values} argument.</p>
@param <T>
the iterable type
@param iterable
the iterable to check, validated not null by this method
@param message
the {@link String#format(String, Object...)} exception message if invalid, not null
@param values
the optional values for the formatted exception message, null array not recommended
@return the validated iterable (never {@code null} method for chaining)
@throws NullPointerValidationException
if the array is {@code null}
@throws IllegalArgumentException
if an element is {@code null}
@see #noNullElements(Iterable)
"""
return INSTANCE.noNullElements(iterable, message, values);
}
|
java
|
public static <T extends Iterable<?>> T noNullElements(final T iterable, final String message, final Object... values) {
return INSTANCE.noNullElements(iterable, message, values);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"Iterable",
"<",
"?",
">",
">",
"T",
"noNullElements",
"(",
"final",
"T",
"iterable",
",",
"final",
"String",
"message",
",",
"final",
"Object",
"...",
"values",
")",
"{",
"return",
"INSTANCE",
".",
"noNullElements",
"(",
"iterable",
",",
"message",
",",
"values",
")",
";",
"}"
] |
<p>Validate that the specified argument iterable is neither {@code null} nor contains any elements that are {@code null}; otherwise throwing an exception with the specified message.
<pre>Validate.noNullElements(myCollection, "The collection contains null at position %d");</pre>
<p>If the iterable is {@code null}, then the message in the exception is "The validated object is null".</p><p>If the iterable has a {@code null} element, then the iteration index of
the invalid element is appended to the {@code values} argument.</p>
@param <T>
the iterable type
@param iterable
the iterable to check, validated not null by this method
@param message
the {@link String#format(String, Object...)} exception message if invalid, not null
@param values
the optional values for the formatted exception message, null array not recommended
@return the validated iterable (never {@code null} method for chaining)
@throws NullPointerValidationException
if the array is {@code null}
@throws IllegalArgumentException
if an element is {@code null}
@see #noNullElements(Iterable)
|
[
"<p",
">",
"Validate",
"that",
"the",
"specified",
"argument",
"iterable",
"is",
"neither",
"{",
"@code",
"null",
"}",
"nor",
"contains",
"any",
"elements",
"that",
"are",
"{",
"@code",
"null",
"}",
";",
"otherwise",
"throwing",
"an",
"exception",
"with",
"the",
"specified",
"message",
".",
"<pre",
">",
"Validate",
".",
"noNullElements",
"(",
"myCollection",
"The",
"collection",
"contains",
"null",
"at",
"position",
"%d",
")",
";",
"<",
"/",
"pre",
">",
"<p",
">",
"If",
"the",
"iterable",
"is",
"{",
"@code",
"null",
"}",
"then",
"the",
"message",
"in",
"the",
"exception",
"is",
""",
";",
"The",
"validated",
"object",
"is",
"null"",
";",
".",
"<",
"/",
"p",
">",
"<p",
">",
"If",
"the",
"iterable",
"has",
"a",
"{",
"@code",
"null",
"}",
"element",
"then",
"the",
"iteration",
"index",
"of",
"the",
"invalid",
"element",
"is",
"appended",
"to",
"the",
"{",
"@code",
"values",
"}",
"argument",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/sawano/java-commons/blob/6f219c9e8dec4401dbe528d17ae6ec1ef9c0d284/src/main/java/se/sawano/java/commons/lang/validate/Validate.java#L1122-L1124
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.kernel.service.location/src/com/ibm/ws/kernel/service/location/internal/FileLocator.java
|
FileLocator.findFileInNamedPath
|
public static File findFileInNamedPath(String name, Collection<String> pathNameList) {
"""
Look for given file in any of the specified directories, return the first
one found.
@param name
The name of the file to find
@param pathNameList
The list of directories to check
@return The File object if the file is found; null if name is null,
pathNameList is null or empty, or file is not found.
@throws SecurityException
If a security manager exists and its <code>{@link java.lang.SecurityManager#checkRead(java.lang.String)}</code> method denies read access to the file.
"""
if (name == null || pathNameList == null || pathNameList.size() == 0)
return null;
for (String path : pathNameList) {
if (path == null || path.length() == 0)
continue;
File result = getFile(new File(path), name);
if (result != null)
return result;
}
return null;
}
|
java
|
public static File findFileInNamedPath(String name, Collection<String> pathNameList) {
if (name == null || pathNameList == null || pathNameList.size() == 0)
return null;
for (String path : pathNameList) {
if (path == null || path.length() == 0)
continue;
File result = getFile(new File(path), name);
if (result != null)
return result;
}
return null;
}
|
[
"public",
"static",
"File",
"findFileInNamedPath",
"(",
"String",
"name",
",",
"Collection",
"<",
"String",
">",
"pathNameList",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"pathNameList",
"==",
"null",
"||",
"pathNameList",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
"null",
";",
"for",
"(",
"String",
"path",
":",
"pathNameList",
")",
"{",
"if",
"(",
"path",
"==",
"null",
"||",
"path",
".",
"length",
"(",
")",
"==",
"0",
")",
"continue",
";",
"File",
"result",
"=",
"getFile",
"(",
"new",
"File",
"(",
"path",
")",
",",
"name",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"return",
"result",
";",
"}",
"return",
"null",
";",
"}"
] |
Look for given file in any of the specified directories, return the first
one found.
@param name
The name of the file to find
@param pathNameList
The list of directories to check
@return The File object if the file is found; null if name is null,
pathNameList is null or empty, or file is not found.
@throws SecurityException
If a security manager exists and its <code>{@link java.lang.SecurityManager#checkRead(java.lang.String)}</code> method denies read access to the file.
|
[
"Look",
"for",
"given",
"file",
"in",
"any",
"of",
"the",
"specified",
"directories",
"return",
"the",
"first",
"one",
"found",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.kernel.service.location/src/com/ibm/ws/kernel/service/location/internal/FileLocator.java#L44-L57
|
MTDdk/jawn
|
jawn-core-new/src/main/java/net/javapla/jawn/core/util/ConvertUtil.java
|
ConvertUtil.toDouble
|
public static Double toDouble(Object value) throws ConversionException {
"""
Converts any value to <code>Double</code>.
@param value value to convert.
@return converted double.
@throws ConversionException if the conversion failed
"""
if (value == null) {
return null;
} else if (value instanceof Number) {
return ((Number) value).doubleValue();
} else {
NumberFormat nf = new DecimalFormat();
try {
return nf.parse(value.toString()).doubleValue();
} catch (ParseException e) {
throw new ConversionException("failed to convert: '" + value + "' to Double", e);
}
}
}
|
java
|
public static Double toDouble(Object value) throws ConversionException {
if (value == null) {
return null;
} else if (value instanceof Number) {
return ((Number) value).doubleValue();
} else {
NumberFormat nf = new DecimalFormat();
try {
return nf.parse(value.toString()).doubleValue();
} catch (ParseException e) {
throw new ConversionException("failed to convert: '" + value + "' to Double", e);
}
}
}
|
[
"public",
"static",
"Double",
"toDouble",
"(",
"Object",
"value",
")",
"throws",
"ConversionException",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"value",
"instanceof",
"Number",
")",
"{",
"return",
"(",
"(",
"Number",
")",
"value",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"else",
"{",
"NumberFormat",
"nf",
"=",
"new",
"DecimalFormat",
"(",
")",
";",
"try",
"{",
"return",
"nf",
".",
"parse",
"(",
"value",
".",
"toString",
"(",
")",
")",
".",
"doubleValue",
"(",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"throw",
"new",
"ConversionException",
"(",
"\"failed to convert: '\"",
"+",
"value",
"+",
"\"' to Double\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Converts any value to <code>Double</code>.
@param value value to convert.
@return converted double.
@throws ConversionException if the conversion failed
|
[
"Converts",
"any",
"value",
"to",
"<code",
">",
"Double<",
"/",
"code",
">",
".",
"@param",
"value",
"value",
"to",
"convert",
"."
] |
train
|
https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-core-new/src/main/java/net/javapla/jawn/core/util/ConvertUtil.java#L98-L111
|
Impetus/Kundera
|
src/jpa-engine/core/src/main/java/com/impetus/kundera/classreading/ClasspathReader.java
|
ClasspathReader.findResourcesByClasspath
|
@SuppressWarnings("deprecation")
@Override
public final URL[] findResourcesByClasspath() {
"""
Uses the java.class.path system property to obtain a list of URLs that
represent the CLASSPATH
@return the URl[]
"""
List<URL> list = new ArrayList<URL>();
String classpath = System.getProperty("java.class.path");
StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);
while (tokenizer.hasMoreTokens())
{
String path = tokenizer.nextToken();
File fp = new File(path);
if (!fp.exists())
throw new ResourceReadingException("File in java.class.path does not exist: " + fp);
try
{
list.add(fp.toURL());
}
catch (MalformedURLException e)
{
throw new ResourceReadingException(e);
}
}
return list.toArray(new URL[list.size()]);
}
|
java
|
@SuppressWarnings("deprecation")
@Override
public final URL[] findResourcesByClasspath()
{
List<URL> list = new ArrayList<URL>();
String classpath = System.getProperty("java.class.path");
StringTokenizer tokenizer = new StringTokenizer(classpath, File.pathSeparator);
while (tokenizer.hasMoreTokens())
{
String path = tokenizer.nextToken();
File fp = new File(path);
if (!fp.exists())
throw new ResourceReadingException("File in java.class.path does not exist: " + fp);
try
{
list.add(fp.toURL());
}
catch (MalformedURLException e)
{
throw new ResourceReadingException(e);
}
}
return list.toArray(new URL[list.size()]);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"@",
"Override",
"public",
"final",
"URL",
"[",
"]",
"findResourcesByClasspath",
"(",
")",
"{",
"List",
"<",
"URL",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"URL",
">",
"(",
")",
";",
"String",
"classpath",
"=",
"System",
".",
"getProperty",
"(",
"\"java.class.path\"",
")",
";",
"StringTokenizer",
"tokenizer",
"=",
"new",
"StringTokenizer",
"(",
"classpath",
",",
"File",
".",
"pathSeparator",
")",
";",
"while",
"(",
"tokenizer",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"String",
"path",
"=",
"tokenizer",
".",
"nextToken",
"(",
")",
";",
"File",
"fp",
"=",
"new",
"File",
"(",
"path",
")",
";",
"if",
"(",
"!",
"fp",
".",
"exists",
"(",
")",
")",
"throw",
"new",
"ResourceReadingException",
"(",
"\"File in java.class.path does not exist: \"",
"+",
"fp",
")",
";",
"try",
"{",
"list",
".",
"add",
"(",
"fp",
".",
"toURL",
"(",
")",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"throw",
"new",
"ResourceReadingException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"list",
".",
"toArray",
"(",
"new",
"URL",
"[",
"list",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Uses the java.class.path system property to obtain a list of URLs that
represent the CLASSPATH
@return the URl[]
|
[
"Uses",
"the",
"java",
".",
"class",
".",
"path",
"system",
"property",
"to",
"obtain",
"a",
"list",
"of",
"URLs",
"that",
"represent",
"the",
"CLASSPATH"
] |
train
|
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/classreading/ClasspathReader.java#L108-L133
|
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/ServerKeysInner.java
|
ServerKeysInner.listByServerAsync
|
public Observable<Page<ServerKeyInner>> listByServerAsync(final String resourceGroupName, final String serverName) {
"""
Gets a list of server keys.
@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 PagedList<ServerKeyInner> object
"""
return listByServerWithServiceResponseAsync(resourceGroupName, serverName)
.map(new Func1<ServiceResponse<Page<ServerKeyInner>>, Page<ServerKeyInner>>() {
@Override
public Page<ServerKeyInner> call(ServiceResponse<Page<ServerKeyInner>> response) {
return response.body();
}
});
}
|
java
|
public Observable<Page<ServerKeyInner>> listByServerAsync(final String resourceGroupName, final String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName)
.map(new Func1<ServiceResponse<Page<ServerKeyInner>>, Page<ServerKeyInner>>() {
@Override
public Page<ServerKeyInner> call(ServiceResponse<Page<ServerKeyInner>> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"Page",
"<",
"ServerKeyInner",
">",
">",
"listByServerAsync",
"(",
"final",
"String",
"resourceGroupName",
",",
"final",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"Page",
"<",
"ServerKeyInner",
">",
">",
",",
"Page",
"<",
"ServerKeyInner",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Page",
"<",
"ServerKeyInner",
">",
"call",
"(",
"ServiceResponse",
"<",
"Page",
"<",
"ServerKeyInner",
">",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Gets a list of server keys.
@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 PagedList<ServerKeyInner> object
|
[
"Gets",
"a",
"list",
"of",
"server",
"keys",
"."
] |
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/ServerKeysInner.java#L143-L151
|
xmlet/XsdAsmFaster
|
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmElements.java
|
XsdAsmElements.generateMethodsForElement
|
static void generateMethodsForElement(ClassWriter classWriter, String childName, String classType, String apiName, String[] annotationsDesc) {
"""
Generates the methods in a given class for a given child that the class is allowed to have.
@param classWriter The {@link ClassWriter} where the method will be written.
@param childName The child name that represents a method.
@param classType The type of the class which contains the children elements.
@param apiName The name of the generated fluent interface.
@param annotationsDesc An array with annotation names to apply to the generated method.
"""
childName = firstToLower(getCleanName(childName));
String childCamelName = firstToUpper(childName);
String childType = getFullClassTypeName(childCamelName, apiName);
String childTypeDesc = getFullClassTypeNameDesc(childCamelName, apiName);
MethodVisitor mVisitor = classWriter.visitMethod(ACC_PUBLIC, childName, "()" + childTypeDesc, "()L" + childType + "<TT;>;", null);
for (String annotationDesc: annotationsDesc) {
mVisitor.visitAnnotation(annotationDesc, true);
}
mVisitor.visitCode();
mVisitor.visitTypeInsn(NEW, childType);
mVisitor.visitInsn(DUP);
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, classType, "self", "()" + elementTypeDesc, true);
mVisitor.visitMethodInsn(INVOKESPECIAL, childType, CONSTRUCTOR, "(" + elementTypeDesc + ")V", false);
mVisitor.visitInsn(ARETURN);
mVisitor.visitMaxs(3, 1);
mVisitor.visitEnd();
}
|
java
|
static void generateMethodsForElement(ClassWriter classWriter, String childName, String classType, String apiName, String[] annotationsDesc) {
childName = firstToLower(getCleanName(childName));
String childCamelName = firstToUpper(childName);
String childType = getFullClassTypeName(childCamelName, apiName);
String childTypeDesc = getFullClassTypeNameDesc(childCamelName, apiName);
MethodVisitor mVisitor = classWriter.visitMethod(ACC_PUBLIC, childName, "()" + childTypeDesc, "()L" + childType + "<TT;>;", null);
for (String annotationDesc: annotationsDesc) {
mVisitor.visitAnnotation(annotationDesc, true);
}
mVisitor.visitCode();
mVisitor.visitTypeInsn(NEW, childType);
mVisitor.visitInsn(DUP);
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKEINTERFACE, classType, "self", "()" + elementTypeDesc, true);
mVisitor.visitMethodInsn(INVOKESPECIAL, childType, CONSTRUCTOR, "(" + elementTypeDesc + ")V", false);
mVisitor.visitInsn(ARETURN);
mVisitor.visitMaxs(3, 1);
mVisitor.visitEnd();
}
|
[
"static",
"void",
"generateMethodsForElement",
"(",
"ClassWriter",
"classWriter",
",",
"String",
"childName",
",",
"String",
"classType",
",",
"String",
"apiName",
",",
"String",
"[",
"]",
"annotationsDesc",
")",
"{",
"childName",
"=",
"firstToLower",
"(",
"getCleanName",
"(",
"childName",
")",
")",
";",
"String",
"childCamelName",
"=",
"firstToUpper",
"(",
"childName",
")",
";",
"String",
"childType",
"=",
"getFullClassTypeName",
"(",
"childCamelName",
",",
"apiName",
")",
";",
"String",
"childTypeDesc",
"=",
"getFullClassTypeNameDesc",
"(",
"childCamelName",
",",
"apiName",
")",
";",
"MethodVisitor",
"mVisitor",
"=",
"classWriter",
".",
"visitMethod",
"(",
"ACC_PUBLIC",
",",
"childName",
",",
"\"()\"",
"+",
"childTypeDesc",
",",
"\"()L\"",
"+",
"childType",
"+",
"\"<TT;>;\"",
",",
"null",
")",
";",
"for",
"(",
"String",
"annotationDesc",
":",
"annotationsDesc",
")",
"{",
"mVisitor",
".",
"visitAnnotation",
"(",
"annotationDesc",
",",
"true",
")",
";",
"}",
"mVisitor",
".",
"visitCode",
"(",
")",
";",
"mVisitor",
".",
"visitTypeInsn",
"(",
"NEW",
",",
"childType",
")",
";",
"mVisitor",
".",
"visitInsn",
"(",
"DUP",
")",
";",
"mVisitor",
".",
"visitVarInsn",
"(",
"ALOAD",
",",
"0",
")",
";",
"mVisitor",
".",
"visitMethodInsn",
"(",
"INVOKEINTERFACE",
",",
"classType",
",",
"\"self\"",
",",
"\"()\"",
"+",
"elementTypeDesc",
",",
"true",
")",
";",
"mVisitor",
".",
"visitMethodInsn",
"(",
"INVOKESPECIAL",
",",
"childType",
",",
"CONSTRUCTOR",
",",
"\"(\"",
"+",
"elementTypeDesc",
"+",
"\")V\"",
",",
"false",
")",
";",
"mVisitor",
".",
"visitInsn",
"(",
"ARETURN",
")",
";",
"mVisitor",
".",
"visitMaxs",
"(",
"3",
",",
"1",
")",
";",
"mVisitor",
".",
"visitEnd",
"(",
")",
";",
"}"
] |
Generates the methods in a given class for a given child that the class is allowed to have.
@param classWriter The {@link ClassWriter} where the method will be written.
@param childName The child name that represents a method.
@param classType The type of the class which contains the children elements.
@param apiName The name of the generated fluent interface.
@param annotationsDesc An array with annotation names to apply to the generated method.
|
[
"Generates",
"the",
"methods",
"in",
"a",
"given",
"class",
"for",
"a",
"given",
"child",
"that",
"the",
"class",
"is",
"allowed",
"to",
"have",
"."
] |
train
|
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmElements.java#L275-L296
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/nio/file/attribute/UserAttrs.java
|
UserAttrs.setStringAttribute
|
public static final void setStringAttribute(Path path, String attribute, String value, LinkOption... options) throws IOException {
"""
Set user-defined-attribute
@param path
@param attribute user:attribute name. user: can be omitted.
@param value
@param options
@throws IOException
"""
attribute = attribute.startsWith("user:") ? attribute : "user:"+attribute;
if (value != null)
{
Files.setAttribute(path, attribute, value.getBytes(UTF_8), options);
}
else
{
Files.setAttribute(path, attribute, null, options);
}
}
|
java
|
public static final void setStringAttribute(Path path, String attribute, String value, LinkOption... options) throws IOException
{
attribute = attribute.startsWith("user:") ? attribute : "user:"+attribute;
if (value != null)
{
Files.setAttribute(path, attribute, value.getBytes(UTF_8), options);
}
else
{
Files.setAttribute(path, attribute, null, options);
}
}
|
[
"public",
"static",
"final",
"void",
"setStringAttribute",
"(",
"Path",
"path",
",",
"String",
"attribute",
",",
"String",
"value",
",",
"LinkOption",
"...",
"options",
")",
"throws",
"IOException",
"{",
"attribute",
"=",
"attribute",
".",
"startsWith",
"(",
"\"user:\"",
")",
"?",
"attribute",
":",
"\"user:\"",
"+",
"attribute",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"Files",
".",
"setAttribute",
"(",
"path",
",",
"attribute",
",",
"value",
".",
"getBytes",
"(",
"UTF_8",
")",
",",
"options",
")",
";",
"}",
"else",
"{",
"Files",
".",
"setAttribute",
"(",
"path",
",",
"attribute",
",",
"null",
",",
"options",
")",
";",
"}",
"}"
] |
Set user-defined-attribute
@param path
@param attribute user:attribute name. user: can be omitted.
@param value
@param options
@throws IOException
|
[
"Set",
"user",
"-",
"defined",
"-",
"attribute"
] |
train
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/file/attribute/UserAttrs.java#L105-L116
|
aws/aws-sdk-java
|
aws-java-sdk-cloudwatchmetrics/src/main/java/com/amazonaws/metrics/internal/cloudwatch/MachineMetricFactory.java
|
MachineMetricFactory.metricValues
|
private MetricValues metricValues(Set<MachineMetric> customSet,
List<MachineMetric> defaults, List<Long> values) {
"""
Returns a subset of the given list of metrics in "defaults" and the
corresponding value of each returned metric in the subset. Note if the
custom set is empty, the full set of default machine metrics and values
will be returned. (In particular, as in set theory, a set is a subset of
itself.)
@param customSet
custom machine metrics specified in the SDK metrics registry
@param defaults
the given default list of metrics
@param values
corresponding values of each metric in "defaults"
"""
List<MachineMetric> actualMetrics = defaults;
List<Long> actualValues = values;
if (customSet.size() > 0) {
// custom set of machine metrics specified
actualMetrics = new ArrayList<MachineMetric>();
actualValues = new ArrayList<Long>();
for (int i=0; i < defaults.size(); i++) {
MachineMetric mm = defaults.get(i);
if (customSet.contains(mm)) {
actualMetrics.add(mm);
actualValues.add(values.get(i));
}
}
}
return new MetricValues(actualMetrics, actualValues);
}
|
java
|
private MetricValues metricValues(Set<MachineMetric> customSet,
List<MachineMetric> defaults, List<Long> values) {
List<MachineMetric> actualMetrics = defaults;
List<Long> actualValues = values;
if (customSet.size() > 0) {
// custom set of machine metrics specified
actualMetrics = new ArrayList<MachineMetric>();
actualValues = new ArrayList<Long>();
for (int i=0; i < defaults.size(); i++) {
MachineMetric mm = defaults.get(i);
if (customSet.contains(mm)) {
actualMetrics.add(mm);
actualValues.add(values.get(i));
}
}
}
return new MetricValues(actualMetrics, actualValues);
}
|
[
"private",
"MetricValues",
"metricValues",
"(",
"Set",
"<",
"MachineMetric",
">",
"customSet",
",",
"List",
"<",
"MachineMetric",
">",
"defaults",
",",
"List",
"<",
"Long",
">",
"values",
")",
"{",
"List",
"<",
"MachineMetric",
">",
"actualMetrics",
"=",
"defaults",
";",
"List",
"<",
"Long",
">",
"actualValues",
"=",
"values",
";",
"if",
"(",
"customSet",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"// custom set of machine metrics specified",
"actualMetrics",
"=",
"new",
"ArrayList",
"<",
"MachineMetric",
">",
"(",
")",
";",
"actualValues",
"=",
"new",
"ArrayList",
"<",
"Long",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"defaults",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"MachineMetric",
"mm",
"=",
"defaults",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"customSet",
".",
"contains",
"(",
"mm",
")",
")",
"{",
"actualMetrics",
".",
"add",
"(",
"mm",
")",
";",
"actualValues",
".",
"add",
"(",
"values",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"}",
"}",
"return",
"new",
"MetricValues",
"(",
"actualMetrics",
",",
"actualValues",
")",
";",
"}"
] |
Returns a subset of the given list of metrics in "defaults" and the
corresponding value of each returned metric in the subset. Note if the
custom set is empty, the full set of default machine metrics and values
will be returned. (In particular, as in set theory, a set is a subset of
itself.)
@param customSet
custom machine metrics specified in the SDK metrics registry
@param defaults
the given default list of metrics
@param values
corresponding values of each metric in "defaults"
|
[
"Returns",
"a",
"subset",
"of",
"the",
"given",
"list",
"of",
"metrics",
"in",
"defaults",
"and",
"the",
"corresponding",
"value",
"of",
"each",
"returned",
"metric",
"in",
"the",
"subset",
".",
"Note",
"if",
"the",
"custom",
"set",
"is",
"empty",
"the",
"full",
"set",
"of",
"default",
"machine",
"metrics",
"and",
"values",
"will",
"be",
"returned",
".",
"(",
"In",
"particular",
"as",
"in",
"set",
"theory",
"a",
"set",
"is",
"a",
"subset",
"of",
"itself",
".",
")"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cloudwatchmetrics/src/main/java/com/amazonaws/metrics/internal/cloudwatch/MachineMetricFactory.java#L120-L137
|
apache/incubator-gobblin
|
gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java
|
Utils.toDateTime
|
public static DateTime toDateTime(long input, String format, String timezone) {
"""
Convert timestamp in a long format to joda time
@param input timestamp
@param format timestamp format
@param timezone time zone of timestamp
@return joda time
"""
return toDateTime(Long.toString(input), format, timezone);
}
|
java
|
public static DateTime toDateTime(long input, String format, String timezone) {
return toDateTime(Long.toString(input), format, timezone);
}
|
[
"public",
"static",
"DateTime",
"toDateTime",
"(",
"long",
"input",
",",
"String",
"format",
",",
"String",
"timezone",
")",
"{",
"return",
"toDateTime",
"(",
"Long",
".",
"toString",
"(",
"input",
")",
",",
"format",
",",
"timezone",
")",
";",
"}"
] |
Convert timestamp in a long format to joda time
@param input timestamp
@param format timestamp format
@param timezone time zone of timestamp
@return joda time
|
[
"Convert",
"timestamp",
"in",
"a",
"long",
"format",
"to",
"joda",
"time"
] |
train
|
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L349-L351
|
xwiki/xwiki-commons
|
xwiki-commons-core/xwiki-commons-xml/src/main/java/org/xwiki/xml/stax/StAXUtils.java
|
StAXUtils.getXMLStreamReader
|
public static XMLStreamReader getXMLStreamReader(XMLInputFactory factory, Source source) throws XMLStreamException {
"""
Extract or create an instance of {@link XMLStreamReader} from the provided {@link Source}.
@param factory the {@link XMLStreamReader} to use (if needed)
@param source the source
@return the {@link XMLStreamReader}
@throws XMLStreamException when failing to extract xml stream reader
@since 9.5
@since 9.6RC1
"""
XMLStreamReader xmlStreamReader;
if (source instanceof StAXSource) {
// StAXSource is not supported by standard XMLInputFactory
StAXSource staxSource = (StAXSource) source;
if (staxSource.getXMLStreamReader() != null) {
xmlStreamReader = staxSource.getXMLStreamReader();
} else {
// TODO: add support for XMLStreamReader -> XMLEventReader
throw new XMLStreamException("XMLEventReader is not supported as source");
}
} else {
xmlStreamReader = factory.createXMLStreamReader(source);
}
return xmlStreamReader;
}
|
java
|
public static XMLStreamReader getXMLStreamReader(XMLInputFactory factory, Source source) throws XMLStreamException
{
XMLStreamReader xmlStreamReader;
if (source instanceof StAXSource) {
// StAXSource is not supported by standard XMLInputFactory
StAXSource staxSource = (StAXSource) source;
if (staxSource.getXMLStreamReader() != null) {
xmlStreamReader = staxSource.getXMLStreamReader();
} else {
// TODO: add support for XMLStreamReader -> XMLEventReader
throw new XMLStreamException("XMLEventReader is not supported as source");
}
} else {
xmlStreamReader = factory.createXMLStreamReader(source);
}
return xmlStreamReader;
}
|
[
"public",
"static",
"XMLStreamReader",
"getXMLStreamReader",
"(",
"XMLInputFactory",
"factory",
",",
"Source",
"source",
")",
"throws",
"XMLStreamException",
"{",
"XMLStreamReader",
"xmlStreamReader",
";",
"if",
"(",
"source",
"instanceof",
"StAXSource",
")",
"{",
"// StAXSource is not supported by standard XMLInputFactory",
"StAXSource",
"staxSource",
"=",
"(",
"StAXSource",
")",
"source",
";",
"if",
"(",
"staxSource",
".",
"getXMLStreamReader",
"(",
")",
"!=",
"null",
")",
"{",
"xmlStreamReader",
"=",
"staxSource",
".",
"getXMLStreamReader",
"(",
")",
";",
"}",
"else",
"{",
"// TODO: add support for XMLStreamReader -> XMLEventReader",
"throw",
"new",
"XMLStreamException",
"(",
"\"XMLEventReader is not supported as source\"",
")",
";",
"}",
"}",
"else",
"{",
"xmlStreamReader",
"=",
"factory",
".",
"createXMLStreamReader",
"(",
"source",
")",
";",
"}",
"return",
"xmlStreamReader",
";",
"}"
] |
Extract or create an instance of {@link XMLStreamReader} from the provided {@link Source}.
@param factory the {@link XMLStreamReader} to use (if needed)
@param source the source
@return the {@link XMLStreamReader}
@throws XMLStreamException when failing to extract xml stream reader
@since 9.5
@since 9.6RC1
|
[
"Extract",
"or",
"create",
"an",
"instance",
"of",
"{",
"@link",
"XMLStreamReader",
"}",
"from",
"the",
"provided",
"{",
"@link",
"Source",
"}",
"."
] |
train
|
https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-xml/src/main/java/org/xwiki/xml/stax/StAXUtils.java#L91-L109
|
jbundle/jbundle
|
base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/opt/HBlinkImageView.java
|
HBlinkImageView.printInputControl
|
public void printInputControl(PrintWriter out, String strFieldDesc, String strFieldName, String strSize, String strMaxSize, String strValue, String strControlType, int iHtmlAttributes) {
"""
display this field in html input format.
@param out The html out stream.
@param strFieldDesc The field description.
@param strFieldName The field name.
@param strSize The control size.
@param strMaxSize The string max size.
@param strValue The default value.
@param strControlType The control type.
@param iHtmlAttribures The attributes.
"""
String strImage = "";
out.println("<td>" + strImage + "</td>");
}
|
java
|
public void printInputControl(PrintWriter out, String strFieldDesc, String strFieldName, String strSize, String strMaxSize, String strValue, String strControlType, int iHtmlAttributes)
{
String strImage = "";
out.println("<td>" + strImage + "</td>");
}
|
[
"public",
"void",
"printInputControl",
"(",
"PrintWriter",
"out",
",",
"String",
"strFieldDesc",
",",
"String",
"strFieldName",
",",
"String",
"strSize",
",",
"String",
"strMaxSize",
",",
"String",
"strValue",
",",
"String",
"strControlType",
",",
"int",
"iHtmlAttributes",
")",
"{",
"String",
"strImage",
"=",
"\"\"",
";",
"out",
".",
"println",
"(",
"\"<td>\"",
"+",
"strImage",
"+",
"\"</td>\"",
")",
";",
"}"
] |
display this field in html input format.
@param out The html out stream.
@param strFieldDesc The field description.
@param strFieldName The field name.
@param strSize The control size.
@param strMaxSize The string max size.
@param strValue The default value.
@param strControlType The control type.
@param iHtmlAttribures The attributes.
|
[
"display",
"this",
"field",
"in",
"html",
"input",
"format",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/opt/HBlinkImageView.java#L69-L73
|
thinkaurelius/faunus
|
src/main/java/com/thinkaurelius/faunus/FaunusPipeline.java
|
FaunusPipeline.hasNot
|
public FaunusPipeline hasNot(final String key, final Compare compare, final Object... values) {
"""
Emit the current element if it does not have a property value comparable to the provided values.
@param key the property key of the element
@param compare the comparator (will be not'd)
@param values the values to compare against where only one needs to succeed (or'd)
@return the extended FaunusPipeline
"""
return this.has(key, compare.opposite(), values);
}
|
java
|
public FaunusPipeline hasNot(final String key, final Compare compare, final Object... values) {
return this.has(key, compare.opposite(), values);
}
|
[
"public",
"FaunusPipeline",
"hasNot",
"(",
"final",
"String",
"key",
",",
"final",
"Compare",
"compare",
",",
"final",
"Object",
"...",
"values",
")",
"{",
"return",
"this",
".",
"has",
"(",
"key",
",",
"compare",
".",
"opposite",
"(",
")",
",",
"values",
")",
";",
"}"
] |
Emit the current element if it does not have a property value comparable to the provided values.
@param key the property key of the element
@param compare the comparator (will be not'd)
@param values the values to compare against where only one needs to succeed (or'd)
@return the extended FaunusPipeline
|
[
"Emit",
"the",
"current",
"element",
"if",
"it",
"does",
"not",
"have",
"a",
"property",
"value",
"comparable",
"to",
"the",
"provided",
"values",
"."
] |
train
|
https://github.com/thinkaurelius/faunus/blob/1eb8494eeb3fe3b84a98d810d304ba01d55b0d6e/src/main/java/com/thinkaurelius/faunus/FaunusPipeline.java#L671-L673
|
future-architect/uroborosql
|
src/main/java/jp/co/future/uroborosql/config/DefaultSqlConfig.java
|
DefaultSqlConfig.getConfig
|
public static SqlConfig getConfig(final String url, final String user, final String password) {
"""
DB接続情報を指定してSqlConfigを取得する
@param url JDBC接続URL
@param user JDBC接続ユーザ
@param password JDBC接続パスワード
@return SqlConfigオブジェクト
"""
return getConfig(url, user, password, null, false, false, null);
}
|
java
|
public static SqlConfig getConfig(final String url, final String user, final String password) {
return getConfig(url, user, password, null, false, false, null);
}
|
[
"public",
"static",
"SqlConfig",
"getConfig",
"(",
"final",
"String",
"url",
",",
"final",
"String",
"user",
",",
"final",
"String",
"password",
")",
"{",
"return",
"getConfig",
"(",
"url",
",",
"user",
",",
"password",
",",
"null",
",",
"false",
",",
"false",
",",
"null",
")",
";",
"}"
] |
DB接続情報を指定してSqlConfigを取得する
@param url JDBC接続URL
@param user JDBC接続ユーザ
@param password JDBC接続パスワード
@return SqlConfigオブジェクト
|
[
"DB接続情報を指定してSqlConfigを取得する"
] |
train
|
https://github.com/future-architect/uroborosql/blob/4c26db51defdac3c6ed16866e33ab45e190e2e0c/src/main/java/jp/co/future/uroborosql/config/DefaultSqlConfig.java#L109-L111
|
spring-projects/spring-social
|
spring-social-config/src/main/java/org/springframework/social/config/support/ProviderConfigurationSupport.java
|
ProviderConfigurationSupport.getApiHelperBeanDefinitionBuilder
|
protected BeanDefinitionBuilder getApiHelperBeanDefinitionBuilder(Map<String, Object> allAttributes) {
"""
Subclassing hook to allow api helper bean to be configured with attributes from annotation
@param allAttributes additional attributes that may be used when creating the API helper bean.
@return a {@link BeanDefinitionBuilder} for the API Helper
"""
return BeanDefinitionBuilder.genericBeanDefinition(apiHelperClass)
.addConstructorArgReference("usersConnectionRepository")
.addConstructorArgReference("userIdSource");
}
|
java
|
protected BeanDefinitionBuilder getApiHelperBeanDefinitionBuilder(Map<String, Object> allAttributes)
{
return BeanDefinitionBuilder.genericBeanDefinition(apiHelperClass)
.addConstructorArgReference("usersConnectionRepository")
.addConstructorArgReference("userIdSource");
}
|
[
"protected",
"BeanDefinitionBuilder",
"getApiHelperBeanDefinitionBuilder",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"allAttributes",
")",
"{",
"return",
"BeanDefinitionBuilder",
".",
"genericBeanDefinition",
"(",
"apiHelperClass",
")",
".",
"addConstructorArgReference",
"(",
"\"usersConnectionRepository\"",
")",
".",
"addConstructorArgReference",
"(",
"\"userIdSource\"",
")",
";",
"}"
] |
Subclassing hook to allow api helper bean to be configured with attributes from annotation
@param allAttributes additional attributes that may be used when creating the API helper bean.
@return a {@link BeanDefinitionBuilder} for the API Helper
|
[
"Subclassing",
"hook",
"to",
"allow",
"api",
"helper",
"bean",
"to",
"be",
"configured",
"with",
"attributes",
"from",
"annotation"
] |
train
|
https://github.com/spring-projects/spring-social/blob/e41cfecb288022b83c79413b58f52511c3c9d4fc/spring-social-config/src/main/java/org/springframework/social/config/support/ProviderConfigurationSupport.java#L177-L182
|
apache/flink
|
flink-runtime/src/main/java/org/apache/flink/runtime/jobgraph/JobVertex.java
|
JobVertex.setStrictlyCoLocatedWith
|
public void setStrictlyCoLocatedWith(JobVertex strictlyCoLocatedWith) {
"""
Tells this vertex to strictly co locate its subtasks with the subtasks of the given vertex.
Strict co-location implies that the n'th subtask of this vertex will run on the same parallel computing
instance (TaskManager) as the n'th subtask of the given vertex.
NOTE: Co-location is only possible between vertices in a slot sharing group.
NOTE: This vertex must (transitively) depend on the vertex to be co-located with. That means that the
respective vertex must be a (transitive) input of this vertex.
@param strictlyCoLocatedWith The vertex whose subtasks to co-locate this vertex's subtasks with.
@throws IllegalArgumentException Thrown, if this vertex and the vertex to co-locate with are not in a common
slot sharing group.
@see #setSlotSharingGroup(SlotSharingGroup)
"""
if (this.slotSharingGroup == null || this.slotSharingGroup != strictlyCoLocatedWith.slotSharingGroup) {
throw new IllegalArgumentException("Strict co-location requires that both vertices are in the same slot sharing group.");
}
CoLocationGroup thisGroup = this.coLocationGroup;
CoLocationGroup otherGroup = strictlyCoLocatedWith.coLocationGroup;
if (otherGroup == null) {
if (thisGroup == null) {
CoLocationGroup group = new CoLocationGroup(this, strictlyCoLocatedWith);
this.coLocationGroup = group;
strictlyCoLocatedWith.coLocationGroup = group;
}
else {
thisGroup.addVertex(strictlyCoLocatedWith);
strictlyCoLocatedWith.coLocationGroup = thisGroup;
}
}
else {
if (thisGroup == null) {
otherGroup.addVertex(this);
this.coLocationGroup = otherGroup;
}
else {
// both had yet distinct groups, we need to merge them
thisGroup.mergeInto(otherGroup);
}
}
}
|
java
|
public void setStrictlyCoLocatedWith(JobVertex strictlyCoLocatedWith) {
if (this.slotSharingGroup == null || this.slotSharingGroup != strictlyCoLocatedWith.slotSharingGroup) {
throw new IllegalArgumentException("Strict co-location requires that both vertices are in the same slot sharing group.");
}
CoLocationGroup thisGroup = this.coLocationGroup;
CoLocationGroup otherGroup = strictlyCoLocatedWith.coLocationGroup;
if (otherGroup == null) {
if (thisGroup == null) {
CoLocationGroup group = new CoLocationGroup(this, strictlyCoLocatedWith);
this.coLocationGroup = group;
strictlyCoLocatedWith.coLocationGroup = group;
}
else {
thisGroup.addVertex(strictlyCoLocatedWith);
strictlyCoLocatedWith.coLocationGroup = thisGroup;
}
}
else {
if (thisGroup == null) {
otherGroup.addVertex(this);
this.coLocationGroup = otherGroup;
}
else {
// both had yet distinct groups, we need to merge them
thisGroup.mergeInto(otherGroup);
}
}
}
|
[
"public",
"void",
"setStrictlyCoLocatedWith",
"(",
"JobVertex",
"strictlyCoLocatedWith",
")",
"{",
"if",
"(",
"this",
".",
"slotSharingGroup",
"==",
"null",
"||",
"this",
".",
"slotSharingGroup",
"!=",
"strictlyCoLocatedWith",
".",
"slotSharingGroup",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Strict co-location requires that both vertices are in the same slot sharing group.\"",
")",
";",
"}",
"CoLocationGroup",
"thisGroup",
"=",
"this",
".",
"coLocationGroup",
";",
"CoLocationGroup",
"otherGroup",
"=",
"strictlyCoLocatedWith",
".",
"coLocationGroup",
";",
"if",
"(",
"otherGroup",
"==",
"null",
")",
"{",
"if",
"(",
"thisGroup",
"==",
"null",
")",
"{",
"CoLocationGroup",
"group",
"=",
"new",
"CoLocationGroup",
"(",
"this",
",",
"strictlyCoLocatedWith",
")",
";",
"this",
".",
"coLocationGroup",
"=",
"group",
";",
"strictlyCoLocatedWith",
".",
"coLocationGroup",
"=",
"group",
";",
"}",
"else",
"{",
"thisGroup",
".",
"addVertex",
"(",
"strictlyCoLocatedWith",
")",
";",
"strictlyCoLocatedWith",
".",
"coLocationGroup",
"=",
"thisGroup",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"thisGroup",
"==",
"null",
")",
"{",
"otherGroup",
".",
"addVertex",
"(",
"this",
")",
";",
"this",
".",
"coLocationGroup",
"=",
"otherGroup",
";",
"}",
"else",
"{",
"// both had yet distinct groups, we need to merge them",
"thisGroup",
".",
"mergeInto",
"(",
"otherGroup",
")",
";",
"}",
"}",
"}"
] |
Tells this vertex to strictly co locate its subtasks with the subtasks of the given vertex.
Strict co-location implies that the n'th subtask of this vertex will run on the same parallel computing
instance (TaskManager) as the n'th subtask of the given vertex.
NOTE: Co-location is only possible between vertices in a slot sharing group.
NOTE: This vertex must (transitively) depend on the vertex to be co-located with. That means that the
respective vertex must be a (transitive) input of this vertex.
@param strictlyCoLocatedWith The vertex whose subtasks to co-locate this vertex's subtasks with.
@throws IllegalArgumentException Thrown, if this vertex and the vertex to co-locate with are not in a common
slot sharing group.
@see #setSlotSharingGroup(SlotSharingGroup)
|
[
"Tells",
"this",
"vertex",
"to",
"strictly",
"co",
"locate",
"its",
"subtasks",
"with",
"the",
"subtasks",
"of",
"the",
"given",
"vertex",
".",
"Strict",
"co",
"-",
"location",
"implies",
"that",
"the",
"n",
"th",
"subtask",
"of",
"this",
"vertex",
"will",
"run",
"on",
"the",
"same",
"parallel",
"computing",
"instance",
"(",
"TaskManager",
")",
"as",
"the",
"n",
"th",
"subtask",
"of",
"the",
"given",
"vertex",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/jobgraph/JobVertex.java#L405-L434
|
wmdietl/jsr308-langtools
|
src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
|
JavacProcessingEnvironment.needClassLoader
|
private boolean needClassLoader(String procNames, Iterable<? extends File> workingpath) {
"""
/*
Called retroactively to determine if a class loader was required,
after we have failed to create one.
"""
if (procNames != null)
return true;
URL[] urls = new URL[1];
for(File pathElement : workingpath) {
try {
urls[0] = pathElement.toURI().toURL();
if (ServiceProxy.hasService(Processor.class, urls))
return true;
} catch (MalformedURLException ex) {
throw new AssertionError(ex);
}
catch (ServiceProxy.ServiceConfigurationError e) {
log.error("proc.bad.config.file", e.getLocalizedMessage());
return true;
}
}
return false;
}
|
java
|
private boolean needClassLoader(String procNames, Iterable<? extends File> workingpath) {
if (procNames != null)
return true;
URL[] urls = new URL[1];
for(File pathElement : workingpath) {
try {
urls[0] = pathElement.toURI().toURL();
if (ServiceProxy.hasService(Processor.class, urls))
return true;
} catch (MalformedURLException ex) {
throw new AssertionError(ex);
}
catch (ServiceProxy.ServiceConfigurationError e) {
log.error("proc.bad.config.file", e.getLocalizedMessage());
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"needClassLoader",
"(",
"String",
"procNames",
",",
"Iterable",
"<",
"?",
"extends",
"File",
">",
"workingpath",
")",
"{",
"if",
"(",
"procNames",
"!=",
"null",
")",
"return",
"true",
";",
"URL",
"[",
"]",
"urls",
"=",
"new",
"URL",
"[",
"1",
"]",
";",
"for",
"(",
"File",
"pathElement",
":",
"workingpath",
")",
"{",
"try",
"{",
"urls",
"[",
"0",
"]",
"=",
"pathElement",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
";",
"if",
"(",
"ServiceProxy",
".",
"hasService",
"(",
"Processor",
".",
"class",
",",
"urls",
")",
")",
"return",
"true",
";",
"}",
"catch",
"(",
"MalformedURLException",
"ex",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"ex",
")",
";",
"}",
"catch",
"(",
"ServiceProxy",
".",
"ServiceConfigurationError",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"proc.bad.config.file\"",
",",
"e",
".",
"getLocalizedMessage",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
/*
Called retroactively to determine if a class loader was required,
after we have failed to create one.
|
[
"/",
"*",
"Called",
"retroactively",
"to",
"determine",
"if",
"a",
"class",
"loader",
"was",
"required",
"after",
"we",
"have",
"failed",
"to",
"create",
"one",
"."
] |
train
|
https://github.com/wmdietl/jsr308-langtools/blob/8812d28c20f4de070a0dd6de1b45602431379834/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java#L1324-L1344
|
flow/caustic
|
api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java
|
CausticUtil.fromIntRGBA
|
public static Vector4f fromIntRGBA(int r, int g, int b, int a) {
"""
Converts 4 byte color components to a normalized float color.
@param r The red component
@param b The blue component
@param g The green component
@param a The alpha component
@return The color as a 4 float vector
"""
return new Vector4f((r & 0xff) / 255f, (g & 0xff) / 255f, (b & 0xff) / 255f, (a & 0xff) / 255f);
}
|
java
|
public static Vector4f fromIntRGBA(int r, int g, int b, int a) {
return new Vector4f((r & 0xff) / 255f, (g & 0xff) / 255f, (b & 0xff) / 255f, (a & 0xff) / 255f);
}
|
[
"public",
"static",
"Vector4f",
"fromIntRGBA",
"(",
"int",
"r",
",",
"int",
"g",
",",
"int",
"b",
",",
"int",
"a",
")",
"{",
"return",
"new",
"Vector4f",
"(",
"(",
"r",
"&",
"0xff",
")",
"/",
"255f",
",",
"(",
"g",
"&",
"0xff",
")",
"/",
"255f",
",",
"(",
"b",
"&",
"0xff",
")",
"/",
"255f",
",",
"(",
"a",
"&",
"0xff",
")",
"/",
"255f",
")",
";",
"}"
] |
Converts 4 byte color components to a normalized float color.
@param r The red component
@param b The blue component
@param g The green component
@param a The alpha component
@return The color as a 4 float vector
|
[
"Converts",
"4",
"byte",
"color",
"components",
"to",
"a",
"normalized",
"float",
"color",
"."
] |
train
|
https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java#L280-L282
|
apache/groovy
|
src/main/groovy/groovy/lang/MetaClassImpl.java
|
MetaClassImpl.invokeMissingMethod
|
public Object invokeMissingMethod(Object instance, String methodName, Object[] arguments) {
"""
Invoke a missing method on the given object with the given arguments.
@param instance The object the method should be invoked on.
@param methodName The name of the method to invoke.
@param arguments The arguments to the invoked method.
@return The result of the method invocation.
"""
return invokeMissingMethod(instance, methodName, arguments, null, false);
}
|
java
|
public Object invokeMissingMethod(Object instance, String methodName, Object[] arguments) {
return invokeMissingMethod(instance, methodName, arguments, null, false);
}
|
[
"public",
"Object",
"invokeMissingMethod",
"(",
"Object",
"instance",
",",
"String",
"methodName",
",",
"Object",
"[",
"]",
"arguments",
")",
"{",
"return",
"invokeMissingMethod",
"(",
"instance",
",",
"methodName",
",",
"arguments",
",",
"null",
",",
"false",
")",
";",
"}"
] |
Invoke a missing method on the given object with the given arguments.
@param instance The object the method should be invoked on.
@param methodName The name of the method to invoke.
@param arguments The arguments to the invoked method.
@return The result of the method invocation.
|
[
"Invoke",
"a",
"missing",
"method",
"on",
"the",
"given",
"object",
"with",
"the",
"given",
"arguments",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/MetaClassImpl.java#L839-L841
|
square/picasso
|
picasso/src/main/java/com/squareup/picasso3/BitmapUtils.java
|
BitmapUtils.decodeStream
|
static Bitmap decodeStream(Source source, Request request) throws IOException {
"""
Decode a byte stream into a Bitmap. This method will take into account additional information
about the supplied request in order to do the decoding efficiently (such as through leveraging
{@code inSampleSize}).
"""
ExceptionCatchingSource exceptionCatchingSource = new ExceptionCatchingSource(source);
BufferedSource bufferedSource = Okio.buffer(exceptionCatchingSource);
Bitmap bitmap = SDK_INT >= 28
? decodeStreamP(request, bufferedSource)
: decodeStreamPreP(request, bufferedSource);
exceptionCatchingSource.throwIfCaught();
return bitmap;
}
|
java
|
static Bitmap decodeStream(Source source, Request request) throws IOException {
ExceptionCatchingSource exceptionCatchingSource = new ExceptionCatchingSource(source);
BufferedSource bufferedSource = Okio.buffer(exceptionCatchingSource);
Bitmap bitmap = SDK_INT >= 28
? decodeStreamP(request, bufferedSource)
: decodeStreamPreP(request, bufferedSource);
exceptionCatchingSource.throwIfCaught();
return bitmap;
}
|
[
"static",
"Bitmap",
"decodeStream",
"(",
"Source",
"source",
",",
"Request",
"request",
")",
"throws",
"IOException",
"{",
"ExceptionCatchingSource",
"exceptionCatchingSource",
"=",
"new",
"ExceptionCatchingSource",
"(",
"source",
")",
";",
"BufferedSource",
"bufferedSource",
"=",
"Okio",
".",
"buffer",
"(",
"exceptionCatchingSource",
")",
";",
"Bitmap",
"bitmap",
"=",
"SDK_INT",
">=",
"28",
"?",
"decodeStreamP",
"(",
"request",
",",
"bufferedSource",
")",
":",
"decodeStreamPreP",
"(",
"request",
",",
"bufferedSource",
")",
";",
"exceptionCatchingSource",
".",
"throwIfCaught",
"(",
")",
";",
"return",
"bitmap",
";",
"}"
] |
Decode a byte stream into a Bitmap. This method will take into account additional information
about the supplied request in order to do the decoding efficiently (such as through leveraging
{@code inSampleSize}).
|
[
"Decode",
"a",
"byte",
"stream",
"into",
"a",
"Bitmap",
".",
"This",
"method",
"will",
"take",
"into",
"account",
"additional",
"information",
"about",
"the",
"supplied",
"request",
"in",
"order",
"to",
"do",
"the",
"decoding",
"efficiently",
"(",
"such",
"as",
"through",
"leveraging",
"{"
] |
train
|
https://github.com/square/picasso/blob/89f55b76e3be2b65e5997b7698f782f16f8547e3/picasso/src/main/java/com/squareup/picasso3/BitmapUtils.java#L105-L113
|
jayantk/jklol
|
src/com/jayantkrish/jklol/models/TableFactor.java
|
TableFactor.mapKeyValuesToOutcomes
|
private Iterator<Outcome> mapKeyValuesToOutcomes(Iterator<KeyValue> iterator) {
"""
Maps an iterator over a tensor's {@code KeyValue}s into {@code Outcome}s.
"""
final Outcome outcome = new Outcome(null, 0.0);
final VariableNumMap vars = getVars();
return Iterators.transform(iterator, new Function<KeyValue, Outcome>() {
@Override
public Outcome apply(KeyValue keyValue) {
outcome.setAssignment(vars.intArrayToAssignment(keyValue.getKey()));
outcome.setProbability(keyValue.getValue());
return outcome;
}
});
}
|
java
|
private Iterator<Outcome> mapKeyValuesToOutcomes(Iterator<KeyValue> iterator) {
final Outcome outcome = new Outcome(null, 0.0);
final VariableNumMap vars = getVars();
return Iterators.transform(iterator, new Function<KeyValue, Outcome>() {
@Override
public Outcome apply(KeyValue keyValue) {
outcome.setAssignment(vars.intArrayToAssignment(keyValue.getKey()));
outcome.setProbability(keyValue.getValue());
return outcome;
}
});
}
|
[
"private",
"Iterator",
"<",
"Outcome",
">",
"mapKeyValuesToOutcomes",
"(",
"Iterator",
"<",
"KeyValue",
">",
"iterator",
")",
"{",
"final",
"Outcome",
"outcome",
"=",
"new",
"Outcome",
"(",
"null",
",",
"0.0",
")",
";",
"final",
"VariableNumMap",
"vars",
"=",
"getVars",
"(",
")",
";",
"return",
"Iterators",
".",
"transform",
"(",
"iterator",
",",
"new",
"Function",
"<",
"KeyValue",
",",
"Outcome",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Outcome",
"apply",
"(",
"KeyValue",
"keyValue",
")",
"{",
"outcome",
".",
"setAssignment",
"(",
"vars",
".",
"intArrayToAssignment",
"(",
"keyValue",
".",
"getKey",
"(",
")",
")",
")",
";",
"outcome",
".",
"setProbability",
"(",
"keyValue",
".",
"getValue",
"(",
")",
")",
";",
"return",
"outcome",
";",
"}",
"}",
")",
";",
"}"
] |
Maps an iterator over a tensor's {@code KeyValue}s into {@code Outcome}s.
|
[
"Maps",
"an",
"iterator",
"over",
"a",
"tensor",
"s",
"{"
] |
train
|
https://github.com/jayantk/jklol/blob/d27532ca83e212d51066cf28f52621acc3fd44cc/src/com/jayantkrish/jklol/models/TableFactor.java#L256-L268
|
mfornos/humanize
|
humanize-slim/src/main/java/humanize/Humanize.java
|
Humanize.naturalTime
|
public static String naturalTime(final Date reference, final Date duration, final TimeMillis precision,
final Locale locale) {
"""
Same as {@link #naturalTime(Date, Date, long, Locale)}.
@param reference
The reference
@param duration
The duration
@param precision
The precesion to retain in milliseconds
@param locale
The locale
@return String representing the relative date
"""
return naturalTime(reference, duration, precision.millis(), locale);
}
|
java
|
public static String naturalTime(final Date reference, final Date duration, final TimeMillis precision,
final Locale locale)
{
return naturalTime(reference, duration, precision.millis(), locale);
}
|
[
"public",
"static",
"String",
"naturalTime",
"(",
"final",
"Date",
"reference",
",",
"final",
"Date",
"duration",
",",
"final",
"TimeMillis",
"precision",
",",
"final",
"Locale",
"locale",
")",
"{",
"return",
"naturalTime",
"(",
"reference",
",",
"duration",
",",
"precision",
".",
"millis",
"(",
")",
",",
"locale",
")",
";",
"}"
] |
Same as {@link #naturalTime(Date, Date, long, Locale)}.
@param reference
The reference
@param duration
The duration
@param precision
The precesion to retain in milliseconds
@param locale
The locale
@return String representing the relative date
|
[
"Same",
"as",
"{",
"@link",
"#naturalTime",
"(",
"Date",
"Date",
"long",
"Locale",
")",
"}",
"."
] |
train
|
https://github.com/mfornos/humanize/blob/59fc103045de9d217c9e77dbcb7621f992f46c63/humanize-slim/src/main/java/humanize/Humanize.java#L1651-L1655
|
windup/windup
|
rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ModuleAnalysisHelper.java
|
ModuleAnalysisHelper.deriveGroupIdFromPackages
|
String deriveGroupIdFromPackages(ProjectModel projectModel) {
"""
Counts the packages prefixes appearing in this project and if some of them make more than half of the total of existing packages, this prefix
is returned. Otherwise, returns null.
This is just a helper, it isn't something really hard-setting the package. It's something to use if the user didn't specify using
--mavenize.groupId, and the archive or project name is something insane, like few sencences paragraph (a description) or a number or such.
"""
Map<Object, Long> pkgsMap = new HashMap<>();
Set<String> pkgs = new HashSet<>(1000);
GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(graphContext.getGraph()).V(projectModel);
pkgsMap = pipeline.out(ProjectModel.PROJECT_MODEL_TO_FILE)
.has(WindupVertexFrame.TYPE_PROP, new P(new BiPredicate<String, String>() {
@Override
public boolean test(String o, String o2) {
return o.contains(o2);
}
},
GraphTypeManager.getTypeValue(JavaClassFileModel.class)))
.hasKey(JavaClassFileModel.PROPERTY_PACKAGE_NAME)
.groupCount()
.by(v -> upToThirdDot(graphContext, (Vertex)v)).toList().get(0);
Map.Entry<Object, Long> biggest = null;
for (Map.Entry<Object, Long> entry : pkgsMap.entrySet())
{
if (biggest == null || biggest.getValue() < entry.getValue())
biggest = entry;
}
// More than a half is of this package.
if (biggest != null && biggest.getValue() > pkgsMap.size() / 2)
return biggest.getKey().toString();
return null;
}
|
java
|
String deriveGroupIdFromPackages(ProjectModel projectModel)
{
Map<Object, Long> pkgsMap = new HashMap<>();
Set<String> pkgs = new HashSet<>(1000);
GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(graphContext.getGraph()).V(projectModel);
pkgsMap = pipeline.out(ProjectModel.PROJECT_MODEL_TO_FILE)
.has(WindupVertexFrame.TYPE_PROP, new P(new BiPredicate<String, String>() {
@Override
public boolean test(String o, String o2) {
return o.contains(o2);
}
},
GraphTypeManager.getTypeValue(JavaClassFileModel.class)))
.hasKey(JavaClassFileModel.PROPERTY_PACKAGE_NAME)
.groupCount()
.by(v -> upToThirdDot(graphContext, (Vertex)v)).toList().get(0);
Map.Entry<Object, Long> biggest = null;
for (Map.Entry<Object, Long> entry : pkgsMap.entrySet())
{
if (biggest == null || biggest.getValue() < entry.getValue())
biggest = entry;
}
// More than a half is of this package.
if (biggest != null && biggest.getValue() > pkgsMap.size() / 2)
return biggest.getKey().toString();
return null;
}
|
[
"String",
"deriveGroupIdFromPackages",
"(",
"ProjectModel",
"projectModel",
")",
"{",
"Map",
"<",
"Object",
",",
"Long",
">",
"pkgsMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Set",
"<",
"String",
">",
"pkgs",
"=",
"new",
"HashSet",
"<>",
"(",
"1000",
")",
";",
"GraphTraversal",
"<",
"Vertex",
",",
"Vertex",
">",
"pipeline",
"=",
"new",
"GraphTraversalSource",
"(",
"graphContext",
".",
"getGraph",
"(",
")",
")",
".",
"V",
"(",
"projectModel",
")",
";",
"pkgsMap",
"=",
"pipeline",
".",
"out",
"(",
"ProjectModel",
".",
"PROJECT_MODEL_TO_FILE",
")",
".",
"has",
"(",
"WindupVertexFrame",
".",
"TYPE_PROP",
",",
"new",
"P",
"(",
"new",
"BiPredicate",
"<",
"String",
",",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"String",
"o",
",",
"String",
"o2",
")",
"{",
"return",
"o",
".",
"contains",
"(",
"o2",
")",
";",
"}",
"}",
",",
"GraphTypeManager",
".",
"getTypeValue",
"(",
"JavaClassFileModel",
".",
"class",
")",
")",
")",
".",
"hasKey",
"(",
"JavaClassFileModel",
".",
"PROPERTY_PACKAGE_NAME",
")",
".",
"groupCount",
"(",
")",
".",
"by",
"(",
"v",
"->",
"upToThirdDot",
"(",
"graphContext",
",",
"(",
"Vertex",
")",
"v",
")",
")",
".",
"toList",
"(",
")",
".",
"get",
"(",
"0",
")",
";",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Long",
">",
"biggest",
"=",
"null",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Long",
">",
"entry",
":",
"pkgsMap",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"biggest",
"==",
"null",
"||",
"biggest",
".",
"getValue",
"(",
")",
"<",
"entry",
".",
"getValue",
"(",
")",
")",
"biggest",
"=",
"entry",
";",
"}",
"// More than a half is of this package.",
"if",
"(",
"biggest",
"!=",
"null",
"&&",
"biggest",
".",
"getValue",
"(",
")",
">",
"pkgsMap",
".",
"size",
"(",
")",
"/",
"2",
")",
"return",
"biggest",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
";",
"return",
"null",
";",
"}"
] |
Counts the packages prefixes appearing in this project and if some of them make more than half of the total of existing packages, this prefix
is returned. Otherwise, returns null.
This is just a helper, it isn't something really hard-setting the package. It's something to use if the user didn't specify using
--mavenize.groupId, and the archive or project name is something insane, like few sencences paragraph (a description) or a number or such.
|
[
"Counts",
"the",
"packages",
"prefixes",
"appearing",
"in",
"this",
"project",
"and",
"if",
"some",
"of",
"them",
"make",
"more",
"than",
"half",
"of",
"the",
"total",
"of",
"existing",
"packages",
"this",
"prefix",
"is",
"returned",
".",
"Otherwise",
"returns",
"null",
"."
] |
train
|
https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java/api/src/main/java/org/jboss/windup/rules/apps/mavenize/ModuleAnalysisHelper.java#L87-L117
|
phax/ph-commons
|
ph-commons/src/main/java/com/helger/commons/text/codepoint/CodepointHelper.java
|
CodepointHelper.inverseSetContains
|
public static boolean inverseSetContains (@Nonnull final int [] aCodepointSet, final int value) {
"""
Treats the specified int array as an Inversion Set and returns
<code>true</code> if the value is located within the set. This will only
work correctly if the values in the int array are monotonically increasing
@param aCodepointSet
Source set
@param value
Value to check
@return <code>true</code> if the value is located within the set
"""
int nStart = 0;
int nEnd = aCodepointSet.length;
while (nEnd - nStart > 8)
{
final int i = (nEnd + nStart) >>> 1;
nStart = aCodepointSet[i] <= value ? i : nStart;
nEnd = aCodepointSet[i] > value ? i : nEnd;
}
while (nStart < nEnd)
{
if (value < aCodepointSet[nStart])
break;
nStart++;
}
return ((nStart - 1) & 1) == 0;
}
|
java
|
public static boolean inverseSetContains (@Nonnull final int [] aCodepointSet, final int value)
{
int nStart = 0;
int nEnd = aCodepointSet.length;
while (nEnd - nStart > 8)
{
final int i = (nEnd + nStart) >>> 1;
nStart = aCodepointSet[i] <= value ? i : nStart;
nEnd = aCodepointSet[i] > value ? i : nEnd;
}
while (nStart < nEnd)
{
if (value < aCodepointSet[nStart])
break;
nStart++;
}
return ((nStart - 1) & 1) == 0;
}
|
[
"public",
"static",
"boolean",
"inverseSetContains",
"(",
"@",
"Nonnull",
"final",
"int",
"[",
"]",
"aCodepointSet",
",",
"final",
"int",
"value",
")",
"{",
"int",
"nStart",
"=",
"0",
";",
"int",
"nEnd",
"=",
"aCodepointSet",
".",
"length",
";",
"while",
"(",
"nEnd",
"-",
"nStart",
">",
"8",
")",
"{",
"final",
"int",
"i",
"=",
"(",
"nEnd",
"+",
"nStart",
")",
">>>",
"1",
";",
"nStart",
"=",
"aCodepointSet",
"[",
"i",
"]",
"<=",
"value",
"?",
"i",
":",
"nStart",
";",
"nEnd",
"=",
"aCodepointSet",
"[",
"i",
"]",
">",
"value",
"?",
"i",
":",
"nEnd",
";",
"}",
"while",
"(",
"nStart",
"<",
"nEnd",
")",
"{",
"if",
"(",
"value",
"<",
"aCodepointSet",
"[",
"nStart",
"]",
")",
"break",
";",
"nStart",
"++",
";",
"}",
"return",
"(",
"(",
"nStart",
"-",
"1",
")",
"&",
"1",
")",
"==",
"0",
";",
"}"
] |
Treats the specified int array as an Inversion Set and returns
<code>true</code> if the value is located within the set. This will only
work correctly if the values in the int array are monotonically increasing
@param aCodepointSet
Source set
@param value
Value to check
@return <code>true</code> if the value is located within the set
|
[
"Treats",
"the",
"specified",
"int",
"array",
"as",
"an",
"Inversion",
"Set",
"and",
"returns",
"<code",
">",
"true<",
"/",
"code",
">",
"if",
"the",
"value",
"is",
"located",
"within",
"the",
"set",
".",
"This",
"will",
"only",
"work",
"correctly",
"if",
"the",
"values",
"in",
"the",
"int",
"array",
"are",
"monotonically",
"increasing"
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/text/codepoint/CodepointHelper.java#L464-L481
|
BranchMetrics/android-branch-deep-linking
|
Branch-SDK/src/io/branch/indexing/BranchUniversalObject.java
|
BranchUniversalObject.generateShortUrl
|
public void generateShortUrl(@NonNull Context context, @NonNull LinkProperties linkProperties, @Nullable Branch.BranchLinkCreateListener callback) {
"""
Creates a short url for the BUO asynchronously
@param context {@link Context} instance
@param linkProperties An object of {@link LinkProperties} specifying the properties of this link
@param callback An instance of {@link io.branch.referral.Branch.BranchLinkCreateListener} to receive the results
"""
getLinkBuilder(context, linkProperties).generateShortUrl(callback);
}
|
java
|
public void generateShortUrl(@NonNull Context context, @NonNull LinkProperties linkProperties, @Nullable Branch.BranchLinkCreateListener callback) {
getLinkBuilder(context, linkProperties).generateShortUrl(callback);
}
|
[
"public",
"void",
"generateShortUrl",
"(",
"@",
"NonNull",
"Context",
"context",
",",
"@",
"NonNull",
"LinkProperties",
"linkProperties",
",",
"@",
"Nullable",
"Branch",
".",
"BranchLinkCreateListener",
"callback",
")",
"{",
"getLinkBuilder",
"(",
"context",
",",
"linkProperties",
")",
".",
"generateShortUrl",
"(",
"callback",
")",
";",
"}"
] |
Creates a short url for the BUO asynchronously
@param context {@link Context} instance
@param linkProperties An object of {@link LinkProperties} specifying the properties of this link
@param callback An instance of {@link io.branch.referral.Branch.BranchLinkCreateListener} to receive the results
|
[
"Creates",
"a",
"short",
"url",
"for",
"the",
"BUO",
"asynchronously"
] |
train
|
https://github.com/BranchMetrics/android-branch-deep-linking/blob/e3bee2ccfcbf6d4bf1a5815b5b86666e4ff8f848/Branch-SDK/src/io/branch/indexing/BranchUniversalObject.java#L621-L623
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.security.fat.common/src/com/ibm/ws/security/fat/common/utils/FatStringUtils.java
|
FatStringUtils.extractRegexGroup
|
public static String extractRegexGroup(String fromContent, String regex, int groupNumber) throws Exception {
"""
Extracts the specified matching group in the provided content. An exception is thrown if the group number is invalid
(negative or greater than the number of groups found in the content), or if a matching group cannot be found in the
content.
"""
if (regex == null) {
throw new Exception("Cannot extract regex group because the provided regular expression is null.");
}
Pattern expectedPattern = Pattern.compile(regex);
return extractRegexGroup(fromContent, expectedPattern, groupNumber);
}
|
java
|
public static String extractRegexGroup(String fromContent, String regex, int groupNumber) throws Exception {
if (regex == null) {
throw new Exception("Cannot extract regex group because the provided regular expression is null.");
}
Pattern expectedPattern = Pattern.compile(regex);
return extractRegexGroup(fromContent, expectedPattern, groupNumber);
}
|
[
"public",
"static",
"String",
"extractRegexGroup",
"(",
"String",
"fromContent",
",",
"String",
"regex",
",",
"int",
"groupNumber",
")",
"throws",
"Exception",
"{",
"if",
"(",
"regex",
"==",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Cannot extract regex group because the provided regular expression is null.\"",
")",
";",
"}",
"Pattern",
"expectedPattern",
"=",
"Pattern",
".",
"compile",
"(",
"regex",
")",
";",
"return",
"extractRegexGroup",
"(",
"fromContent",
",",
"expectedPattern",
",",
"groupNumber",
")",
";",
"}"
] |
Extracts the specified matching group in the provided content. An exception is thrown if the group number is invalid
(negative or greater than the number of groups found in the content), or if a matching group cannot be found in the
content.
|
[
"Extracts",
"the",
"specified",
"matching",
"group",
"in",
"the",
"provided",
"content",
".",
"An",
"exception",
"is",
"thrown",
"if",
"the",
"group",
"number",
"is",
"invalid",
"(",
"negative",
"or",
"greater",
"than",
"the",
"number",
"of",
"groups",
"found",
"in",
"the",
"content",
")",
"or",
"if",
"a",
"matching",
"group",
"cannot",
"be",
"found",
"in",
"the",
"content",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.fat.common/src/com/ibm/ws/security/fat/common/utils/FatStringUtils.java#L39-L45
|
neoremind/fluent-validator
|
fluent-validator/src/main/java/com/baidu/unbiz/fluentvalidator/util/ReflectionUtil.java
|
ReflectionUtil.getAnnotation
|
public static <A extends Annotation> A getAnnotation(Field field, Class<A> annotationType) {
"""
获取<code>Field</code>上的注解
@param field 属性
@param annotationType 注解类型
@return 注解对象
"""
if (field == null || annotationType == null) {
return null;
}
return field.getAnnotation(annotationType);
}
|
java
|
public static <A extends Annotation> A getAnnotation(Field field, Class<A> annotationType) {
if (field == null || annotationType == null) {
return null;
}
return field.getAnnotation(annotationType);
}
|
[
"public",
"static",
"<",
"A",
"extends",
"Annotation",
">",
"A",
"getAnnotation",
"(",
"Field",
"field",
",",
"Class",
"<",
"A",
">",
"annotationType",
")",
"{",
"if",
"(",
"field",
"==",
"null",
"||",
"annotationType",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"field",
".",
"getAnnotation",
"(",
"annotationType",
")",
";",
"}"
] |
获取<code>Field</code>上的注解
@param field 属性
@param annotationType 注解类型
@return 注解对象
|
[
"获取<code",
">",
"Field<",
"/",
"code",
">",
"上的注解"
] |
train
|
https://github.com/neoremind/fluent-validator/blob/b516970591aa9468b44ba63938b98ec341fd6ead/fluent-validator/src/main/java/com/baidu/unbiz/fluentvalidator/util/ReflectionUtil.java#L74-L80
|
alkacon/opencms-core
|
src-gwt/org/opencms/gwt/client/ui/input/colorpicker/CmsColorSelector.java
|
CmsColorSelector.setRGB
|
public void setRGB(int red, int green, int blue) throws Exception {
"""
Sets the Red, Green, and Blue color variables. This will automatically populate the Hue, Saturation and Brightness and Hexadecimal fields, too.
The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue.
@param red strength - valid range is 0-255
@param green strength - valid range is 0-255
@param blue strength - valid range is 0-255
@throws java.lang.Exception Exception if the Red, Green or Blue variables are out of range.
"""
CmsColor color = new CmsColor();
color.setRGB(red, green, blue);
m_red = red;
m_green = green;
m_blue = blue;
m_hue = color.getHue();
m_saturation = color.getSaturation();
m_brightness = color.getValue();
m_tbRed.setText(Integer.toString(m_red));
m_tbGreen.setText(Integer.toString(m_green));
m_tbBlue.setText(Integer.toString(m_blue));
m_tbHue.setText(Integer.toString(m_hue));
m_tbSaturation.setText(Integer.toString(m_saturation));
m_tbBrightness.setText(Integer.toString(m_brightness));
m_tbHexColor.setText(color.getHex());
setPreview(color.getHex());
updateSliders();
}
|
java
|
public void setRGB(int red, int green, int blue) throws Exception {
CmsColor color = new CmsColor();
color.setRGB(red, green, blue);
m_red = red;
m_green = green;
m_blue = blue;
m_hue = color.getHue();
m_saturation = color.getSaturation();
m_brightness = color.getValue();
m_tbRed.setText(Integer.toString(m_red));
m_tbGreen.setText(Integer.toString(m_green));
m_tbBlue.setText(Integer.toString(m_blue));
m_tbHue.setText(Integer.toString(m_hue));
m_tbSaturation.setText(Integer.toString(m_saturation));
m_tbBrightness.setText(Integer.toString(m_brightness));
m_tbHexColor.setText(color.getHex());
setPreview(color.getHex());
updateSliders();
}
|
[
"public",
"void",
"setRGB",
"(",
"int",
"red",
",",
"int",
"green",
",",
"int",
"blue",
")",
"throws",
"Exception",
"{",
"CmsColor",
"color",
"=",
"new",
"CmsColor",
"(",
")",
";",
"color",
".",
"setRGB",
"(",
"red",
",",
"green",
",",
"blue",
")",
";",
"m_red",
"=",
"red",
";",
"m_green",
"=",
"green",
";",
"m_blue",
"=",
"blue",
";",
"m_hue",
"=",
"color",
".",
"getHue",
"(",
")",
";",
"m_saturation",
"=",
"color",
".",
"getSaturation",
"(",
")",
";",
"m_brightness",
"=",
"color",
".",
"getValue",
"(",
")",
";",
"m_tbRed",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_red",
")",
")",
";",
"m_tbGreen",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_green",
")",
")",
";",
"m_tbBlue",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_blue",
")",
")",
";",
"m_tbHue",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_hue",
")",
")",
";",
"m_tbSaturation",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_saturation",
")",
")",
";",
"m_tbBrightness",
".",
"setText",
"(",
"Integer",
".",
"toString",
"(",
"m_brightness",
")",
")",
";",
"m_tbHexColor",
".",
"setText",
"(",
"color",
".",
"getHex",
"(",
")",
")",
";",
"setPreview",
"(",
"color",
".",
"getHex",
"(",
")",
")",
";",
"updateSliders",
"(",
")",
";",
"}"
] |
Sets the Red, Green, and Blue color variables. This will automatically populate the Hue, Saturation and Brightness and Hexadecimal fields, too.
The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue.
@param red strength - valid range is 0-255
@param green strength - valid range is 0-255
@param blue strength - valid range is 0-255
@throws java.lang.Exception Exception if the Red, Green or Blue variables are out of range.
|
[
"Sets",
"the",
"Red",
"Green",
"and",
"Blue",
"color",
"variables",
".",
"This",
"will",
"automatically",
"populate",
"the",
"Hue",
"Saturation",
"and",
"Brightness",
"and",
"Hexadecimal",
"fields",
"too",
"."
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/gwt/client/ui/input/colorpicker/CmsColorSelector.java#L787-L809
|
sirthias/parboiled
|
parboiled-core/src/main/java/org/parboiled/support/Characters.java
|
Characters.of
|
public static Characters of(char... chars) {
"""
Creates a new Characters instance containing only the given chars.
@param chars the chars
@return a new Characters object
"""
return chars.length == 0 ? Characters.NONE : new Characters(false, chars.clone());
}
|
java
|
public static Characters of(char... chars) {
return chars.length == 0 ? Characters.NONE : new Characters(false, chars.clone());
}
|
[
"public",
"static",
"Characters",
"of",
"(",
"char",
"...",
"chars",
")",
"{",
"return",
"chars",
".",
"length",
"==",
"0",
"?",
"Characters",
".",
"NONE",
":",
"new",
"Characters",
"(",
"false",
",",
"chars",
".",
"clone",
"(",
")",
")",
";",
"}"
] |
Creates a new Characters instance containing only the given chars.
@param chars the chars
@return a new Characters object
|
[
"Creates",
"a",
"new",
"Characters",
"instance",
"containing",
"only",
"the",
"given",
"chars",
"."
] |
train
|
https://github.com/sirthias/parboiled/blob/84f3ed43e3e171b4c6ab5e6ca6297d264a9d686a/parboiled-core/src/main/java/org/parboiled/support/Characters.java#L247-L249
|
quattor/pan
|
panc/src/main/java/org/quattor/pan/ttemplate/LocalVariableMap.java
|
LocalVariableMap.put
|
public Element put(String name, Element value) {
"""
Assign the value to the given variable name. If the value is null, then
the variable is undefined. If an old value existed, then this method will
check that the new value is a valid replacement for the old one. If not,
an exception will be thrown.
@param name
variable name to assign value to
@param value
Element to assign to the given variable name; variable is
removed if the value is null
@return old value of the named variable or null if it wasn't defined
"""
assert (name != null);
Element oldValue = null;
if (value != null) {
// Set the value and ensure that the replacement can be done.
oldValue = map.put(name, value);
if (oldValue != null) {
oldValue.checkValidReplacement(value);
}
} else {
// Remove the referenced variable.
oldValue = map.remove(name);
}
return oldValue;
}
|
java
|
public Element put(String name, Element value) {
assert (name != null);
Element oldValue = null;
if (value != null) {
// Set the value and ensure that the replacement can be done.
oldValue = map.put(name, value);
if (oldValue != null) {
oldValue.checkValidReplacement(value);
}
} else {
// Remove the referenced variable.
oldValue = map.remove(name);
}
return oldValue;
}
|
[
"public",
"Element",
"put",
"(",
"String",
"name",
",",
"Element",
"value",
")",
"{",
"assert",
"(",
"name",
"!=",
"null",
")",
";",
"Element",
"oldValue",
"=",
"null",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"// Set the value and ensure that the replacement can be done.",
"oldValue",
"=",
"map",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"if",
"(",
"oldValue",
"!=",
"null",
")",
"{",
"oldValue",
".",
"checkValidReplacement",
"(",
"value",
")",
";",
"}",
"}",
"else",
"{",
"// Remove the referenced variable.",
"oldValue",
"=",
"map",
".",
"remove",
"(",
"name",
")",
";",
"}",
"return",
"oldValue",
";",
"}"
] |
Assign the value to the given variable name. If the value is null, then
the variable is undefined. If an old value existed, then this method will
check that the new value is a valid replacement for the old one. If not,
an exception will be thrown.
@param name
variable name to assign value to
@param value
Element to assign to the given variable name; variable is
removed if the value is null
@return old value of the named variable or null if it wasn't defined
|
[
"Assign",
"the",
"value",
"to",
"the",
"given",
"variable",
"name",
".",
"If",
"the",
"value",
"is",
"null",
"then",
"the",
"variable",
"is",
"undefined",
".",
"If",
"an",
"old",
"value",
"existed",
"then",
"this",
"method",
"will",
"check",
"that",
"the",
"new",
"value",
"is",
"a",
"valid",
"replacement",
"for",
"the",
"old",
"one",
".",
"If",
"not",
"an",
"exception",
"will",
"be",
"thrown",
"."
] |
train
|
https://github.com/quattor/pan/blob/009934a603dd0c08d3fa4bb7d9389c380a916f54/panc/src/main/java/org/quattor/pan/ttemplate/LocalVariableMap.java#L74-L95
|
beanshell/beanshell
|
src/main/java/bsh/org/objectweb/asm/SymbolTable.java
|
SymbolTable.addConstantInteger
|
private void addConstantInteger(final int index, final int tag, final int value) {
"""
Adds a new CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol
table.
@param index the constant pool index of the new Symbol.
@param tag one of {@link Symbol#CONSTANT_INTEGER_TAG} or {@link Symbol#CONSTANT_FLOAT_TAG}.
@param value an int or float.
"""
add(new Entry(index, tag, value, hash(tag, value)));
}
|
java
|
private void addConstantInteger(final int index, final int tag, final int value) {
add(new Entry(index, tag, value, hash(tag, value)));
}
|
[
"private",
"void",
"addConstantInteger",
"(",
"final",
"int",
"index",
",",
"final",
"int",
"tag",
",",
"final",
"int",
"value",
")",
"{",
"add",
"(",
"new",
"Entry",
"(",
"index",
",",
"tag",
",",
"value",
",",
"hash",
"(",
"tag",
",",
"value",
")",
")",
")",
";",
"}"
] |
Adds a new CONSTANT_Integer_info or CONSTANT_Float_info to the constant pool of this symbol
table.
@param index the constant pool index of the new Symbol.
@param tag one of {@link Symbol#CONSTANT_INTEGER_TAG} or {@link Symbol#CONSTANT_FLOAT_TAG}.
@param value an int or float.
|
[
"Adds",
"a",
"new",
"CONSTANT_Integer_info",
"or",
"CONSTANT_Float_info",
"to",
"the",
"constant",
"pool",
"of",
"this",
"symbol",
"table",
"."
] |
train
|
https://github.com/beanshell/beanshell/blob/fdddee3de948c9e6babb2d1337028f6fd0a2ba5c/src/main/java/bsh/org/objectweb/asm/SymbolTable.java#L516-L518
|
csc19601128/Phynixx
|
phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java
|
WatchdogRegistry.registerWatchdog
|
private synchronized void registerWatchdog(Long key, Watchdog wd) {
"""
Fuegt einen Thread hinzu
@param key String Schluessel unter dem der Thread gespeichert wird
@param wd Watchdog
@throws IllegalStateException falls Thread NICHT zur aktuellen ThreadGroup( ==this) geh�rt;
"""
if (wd == null) {
throw new NullPointerException("Thread");
}
if (wd.getThread() == null) {
wd.restart();
}
registeredWachdogs.put(key, wd);
}
|
java
|
private synchronized void registerWatchdog(Long key, Watchdog wd) {
if (wd == null) {
throw new NullPointerException("Thread");
}
if (wd.getThread() == null) {
wd.restart();
}
registeredWachdogs.put(key, wd);
}
|
[
"private",
"synchronized",
"void",
"registerWatchdog",
"(",
"Long",
"key",
",",
"Watchdog",
"wd",
")",
"{",
"if",
"(",
"wd",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"Thread\"",
")",
";",
"}",
"if",
"(",
"wd",
".",
"getThread",
"(",
")",
"==",
"null",
")",
"{",
"wd",
".",
"restart",
"(",
")",
";",
"}",
"registeredWachdogs",
".",
"put",
"(",
"key",
",",
"wd",
")",
";",
"}"
] |
Fuegt einen Thread hinzu
@param key String Schluessel unter dem der Thread gespeichert wird
@param wd Watchdog
@throws IllegalStateException falls Thread NICHT zur aktuellen ThreadGroup( ==this) geh�rt;
|
[
"Fuegt",
"einen",
"Thread",
"hinzu"
] |
train
|
https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-watchdog/src/main/java/org/csc/phynixx/watchdog/WatchdogRegistry.java#L230-L238
|
grails/grails-core
|
grails-core/src/main/groovy/grails/util/GrailsClassUtils.java
|
GrailsClassUtils.getBooleanFromMap
|
public static boolean getBooleanFromMap(String key, Map<?, ?> map) {
"""
Retrieves a boolean value from a Map for the given key
@param key The key that references the boolean value
@param map The map to look in
@return A boolean value which will be false if the map is null, the map doesn't contain the key or the value is false
"""
boolean defaultValue = false;
return getBooleanFromMap(key, map, defaultValue);
}
|
java
|
public static boolean getBooleanFromMap(String key, Map<?, ?> map) {
boolean defaultValue = false;
return getBooleanFromMap(key, map, defaultValue);
}
|
[
"public",
"static",
"boolean",
"getBooleanFromMap",
"(",
"String",
"key",
",",
"Map",
"<",
"?",
",",
"?",
">",
"map",
")",
"{",
"boolean",
"defaultValue",
"=",
"false",
";",
"return",
"getBooleanFromMap",
"(",
"key",
",",
"map",
",",
"defaultValue",
")",
";",
"}"
] |
Retrieves a boolean value from a Map for the given key
@param key The key that references the boolean value
@param map The map to look in
@return A boolean value which will be false if the map is null, the map doesn't contain the key or the value is false
|
[
"Retrieves",
"a",
"boolean",
"value",
"from",
"a",
"Map",
"for",
"the",
"given",
"key"
] |
train
|
https://github.com/grails/grails-core/blob/c0b08aa995b0297143b75d05642abba8cb7b4122/grails-core/src/main/groovy/grails/util/GrailsClassUtils.java#L812-L815
|
vkostyukov/la4j
|
src/main/java/org/la4j/Matrices.java
|
Matrices.mkEuclideanNormAccumulator
|
public static MatrixAccumulator mkEuclideanNormAccumulator() {
"""
Makes an Euclidean norm accumulator that allows to use
{@link org.la4j.Matrix#fold(org.la4j.matrix.functor.MatrixAccumulator)}
method for norm calculation.
@return an Euclidean norm accumulator
"""
return new MatrixAccumulator() {
private BigDecimal result = BigDecimal.valueOf(0.0);
@Override
public void update(int i, int j, double value) {
result = result.add(BigDecimal.valueOf(value * value));
}
@Override
public double accumulate() {
double value = result.setScale(Matrices.ROUND_FACTOR, RoundingMode.CEILING).doubleValue();
result = BigDecimal.valueOf(0.0);
return Math.sqrt(value);
}
};
}
|
java
|
public static MatrixAccumulator mkEuclideanNormAccumulator() {
return new MatrixAccumulator() {
private BigDecimal result = BigDecimal.valueOf(0.0);
@Override
public void update(int i, int j, double value) {
result = result.add(BigDecimal.valueOf(value * value));
}
@Override
public double accumulate() {
double value = result.setScale(Matrices.ROUND_FACTOR, RoundingMode.CEILING).doubleValue();
result = BigDecimal.valueOf(0.0);
return Math.sqrt(value);
}
};
}
|
[
"public",
"static",
"MatrixAccumulator",
"mkEuclideanNormAccumulator",
"(",
")",
"{",
"return",
"new",
"MatrixAccumulator",
"(",
")",
"{",
"private",
"BigDecimal",
"result",
"=",
"BigDecimal",
".",
"valueOf",
"(",
"0.0",
")",
";",
"@",
"Override",
"public",
"void",
"update",
"(",
"int",
"i",
",",
"int",
"j",
",",
"double",
"value",
")",
"{",
"result",
"=",
"result",
".",
"add",
"(",
"BigDecimal",
".",
"valueOf",
"(",
"value",
"*",
"value",
")",
")",
";",
"}",
"@",
"Override",
"public",
"double",
"accumulate",
"(",
")",
"{",
"double",
"value",
"=",
"result",
".",
"setScale",
"(",
"Matrices",
".",
"ROUND_FACTOR",
",",
"RoundingMode",
".",
"CEILING",
")",
".",
"doubleValue",
"(",
")",
";",
"result",
"=",
"BigDecimal",
".",
"valueOf",
"(",
"0.0",
")",
";",
"return",
"Math",
".",
"sqrt",
"(",
"value",
")",
";",
"}",
"}",
";",
"}"
] |
Makes an Euclidean norm accumulator that allows to use
{@link org.la4j.Matrix#fold(org.la4j.matrix.functor.MatrixAccumulator)}
method for norm calculation.
@return an Euclidean norm accumulator
|
[
"Makes",
"an",
"Euclidean",
"norm",
"accumulator",
"that",
"allows",
"to",
"use",
"{",
"@link",
"org",
".",
"la4j",
".",
"Matrix#fold",
"(",
"org",
".",
"la4j",
".",
"matrix",
".",
"functor",
".",
"MatrixAccumulator",
")",
"}",
"method",
"for",
"norm",
"calculation",
"."
] |
train
|
https://github.com/vkostyukov/la4j/blob/dd1b917caf9606399a49afa6b0d738934cd3a7b3/src/main/java/org/la4j/Matrices.java#L565-L581
|
seedstack/i18n-addon
|
rest/src/it/java/org/seedstack/i18n/shared/AbstractI18nRestIT.java
|
AbstractI18nRestIT.httpPut
|
protected Response httpPut(String path, String body, int status) {
"""
Puts the body to the given path and expect a 200 status code.
@param path the resource URI
@param body the resource representation
@return the http response
"""
return httpRequest(status, null).body(body).put(baseURL + PATH_PREFIX + path);
}
|
java
|
protected Response httpPut(String path, String body, int status) {
return httpRequest(status, null).body(body).put(baseURL + PATH_PREFIX + path);
}
|
[
"protected",
"Response",
"httpPut",
"(",
"String",
"path",
",",
"String",
"body",
",",
"int",
"status",
")",
"{",
"return",
"httpRequest",
"(",
"status",
",",
"null",
")",
".",
"body",
"(",
"body",
")",
".",
"put",
"(",
"baseURL",
"+",
"PATH_PREFIX",
"+",
"path",
")",
";",
"}"
] |
Puts the body to the given path and expect a 200 status code.
@param path the resource URI
@param body the resource representation
@return the http response
|
[
"Puts",
"the",
"body",
"to",
"the",
"given",
"path",
"and",
"expect",
"a",
"200",
"status",
"code",
"."
] |
train
|
https://github.com/seedstack/i18n-addon/blob/1e65101d8554623f09bda2497b0151fd10a16615/rest/src/it/java/org/seedstack/i18n/shared/AbstractI18nRestIT.java#L109-L111
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java
|
ApiOvhDomain.zone_zoneName_serviceInfos_PUT
|
public void zone_zoneName_serviceInfos_PUT(String zoneName, OvhService body) throws IOException {
"""
Alter this object properties
REST: PUT /domain/zone/{zoneName}/serviceInfos
@param body [required] New object properties
@param zoneName [required] The internal name of your zone
"""
String qPath = "/domain/zone/{zoneName}/serviceInfos";
StringBuilder sb = path(qPath, zoneName);
exec(qPath, "PUT", sb.toString(), body);
}
|
java
|
public void zone_zoneName_serviceInfos_PUT(String zoneName, OvhService body) throws IOException {
String qPath = "/domain/zone/{zoneName}/serviceInfos";
StringBuilder sb = path(qPath, zoneName);
exec(qPath, "PUT", sb.toString(), body);
}
|
[
"public",
"void",
"zone_zoneName_serviceInfos_PUT",
"(",
"String",
"zoneName",
",",
"OvhService",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/domain/zone/{zoneName}/serviceInfos\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"zoneName",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] |
Alter this object properties
REST: PUT /domain/zone/{zoneName}/serviceInfos
@param body [required] New object properties
@param zoneName [required] The internal name of your zone
|
[
"Alter",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-domain/src/main/java/net/minidev/ovh/api/ApiOvhDomain.java#L706-L710
|
lessthanoptimal/ejml
|
main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF5.java
|
CommonOps_DDF5.fill
|
public static void fill( DMatrix5 a , double v ) {
"""
<p>
Sets every element in the vector to the specified value.<br>
<br>
a<sub>i</sub> = value
<p>
@param a A vector whose elements are about to be set. Modified.
@param v The value each element will have.
"""
a.a1 = v;
a.a2 = v;
a.a3 = v;
a.a4 = v;
a.a5 = v;
}
|
java
|
public static void fill( DMatrix5 a , double v ) {
a.a1 = v;
a.a2 = v;
a.a3 = v;
a.a4 = v;
a.a5 = v;
}
|
[
"public",
"static",
"void",
"fill",
"(",
"DMatrix5",
"a",
",",
"double",
"v",
")",
"{",
"a",
".",
"a1",
"=",
"v",
";",
"a",
".",
"a2",
"=",
"v",
";",
"a",
".",
"a3",
"=",
"v",
";",
"a",
".",
"a4",
"=",
"v",
";",
"a",
".",
"a5",
"=",
"v",
";",
"}"
] |
<p>
Sets every element in the vector to the specified value.<br>
<br>
a<sub>i</sub> = value
<p>
@param a A vector whose elements are about to be set. Modified.
@param v The value each element will have.
|
[
"<p",
">",
"Sets",
"every",
"element",
"in",
"the",
"vector",
"to",
"the",
"specified",
"value",
".",
"<br",
">",
"<br",
">",
"a<sub",
">",
"i<",
"/",
"sub",
">",
"=",
"value",
"<p",
">"
] |
train
|
https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF5.java#L1938-L1944
|
google/closure-compiler
|
src/com/google/javascript/jscomp/PureFunctionIdentifier.java
|
AmbiguatedFunctionSummary.createInGraph
|
static AmbiguatedFunctionSummary createInGraph(
DiGraph<AmbiguatedFunctionSummary, SideEffectPropagation> graph, String name) {
"""
Adds a new summary node to {@code graph}, storing the node and returning the summary.
"""
return new AmbiguatedFunctionSummary(graph, name);
}
|
java
|
static AmbiguatedFunctionSummary createInGraph(
DiGraph<AmbiguatedFunctionSummary, SideEffectPropagation> graph, String name) {
return new AmbiguatedFunctionSummary(graph, name);
}
|
[
"static",
"AmbiguatedFunctionSummary",
"createInGraph",
"(",
"DiGraph",
"<",
"AmbiguatedFunctionSummary",
",",
"SideEffectPropagation",
">",
"graph",
",",
"String",
"name",
")",
"{",
"return",
"new",
"AmbiguatedFunctionSummary",
"(",
"graph",
",",
"name",
")",
";",
"}"
] |
Adds a new summary node to {@code graph}, storing the node and returning the summary.
|
[
"Adds",
"a",
"new",
"summary",
"node",
"to",
"{"
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/PureFunctionIdentifier.java#L1175-L1178
|
exoplatform/jcr
|
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
|
SearchIndex.retrieveAggregateRoot
|
protected void retrieveAggregateRoot(NodeData state, Map<String, NodeData> map) {
"""
Retrieves the root of the indexing aggregate for <code>state</code> and
puts it into <code>map</code>.
@param state
the node state for which we want to retrieve the aggregate
root.
@param map
aggregate roots are collected in this map. Key=UUID,
value=NodeState.
"""
if (indexingConfig != null)
{
AggregateRule[] aggregateRules = indexingConfig.getAggregateRules();
if (aggregateRules == null)
{
return;
}
try
{
for (int i = 0; i < aggregateRules.length; i++)
{
NodeData root = aggregateRules[i].getAggregateRoot(state);
if (root != null)
{
map.put(root.getIdentifier(), root);
}
}
}
catch (Exception e)
{
log.warn("Unable to get aggregate root for " + state.getIdentifier(), e);
}
}
}
|
java
|
protected void retrieveAggregateRoot(NodeData state, Map<String, NodeData> map)
{
if (indexingConfig != null)
{
AggregateRule[] aggregateRules = indexingConfig.getAggregateRules();
if (aggregateRules == null)
{
return;
}
try
{
for (int i = 0; i < aggregateRules.length; i++)
{
NodeData root = aggregateRules[i].getAggregateRoot(state);
if (root != null)
{
map.put(root.getIdentifier(), root);
}
}
}
catch (Exception e)
{
log.warn("Unable to get aggregate root for " + state.getIdentifier(), e);
}
}
}
|
[
"protected",
"void",
"retrieveAggregateRoot",
"(",
"NodeData",
"state",
",",
"Map",
"<",
"String",
",",
"NodeData",
">",
"map",
")",
"{",
"if",
"(",
"indexingConfig",
"!=",
"null",
")",
"{",
"AggregateRule",
"[",
"]",
"aggregateRules",
"=",
"indexingConfig",
".",
"getAggregateRules",
"(",
")",
";",
"if",
"(",
"aggregateRules",
"==",
"null",
")",
"{",
"return",
";",
"}",
"try",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"aggregateRules",
".",
"length",
";",
"i",
"++",
")",
"{",
"NodeData",
"root",
"=",
"aggregateRules",
"[",
"i",
"]",
".",
"getAggregateRoot",
"(",
"state",
")",
";",
"if",
"(",
"root",
"!=",
"null",
")",
"{",
"map",
".",
"put",
"(",
"root",
".",
"getIdentifier",
"(",
")",
",",
"root",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Unable to get aggregate root for \"",
"+",
"state",
".",
"getIdentifier",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Retrieves the root of the indexing aggregate for <code>state</code> and
puts it into <code>map</code>.
@param state
the node state for which we want to retrieve the aggregate
root.
@param map
aggregate roots are collected in this map. Key=UUID,
value=NodeState.
|
[
"Retrieves",
"the",
"root",
"of",
"the",
"indexing",
"aggregate",
"for",
"<code",
">",
"state<",
"/",
"code",
">",
"and",
"puts",
"it",
"into",
"<code",
">",
"map<",
"/",
"code",
">",
"."
] |
train
|
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java#L2327-L2352
|
alkacon/opencms-core
|
src-gwt/org/opencms/ade/upload/client/ui/CmsUploadHookDialog.java
|
CmsUploadHookDialog.openDialog
|
public static void openDialog(
String title,
String hookUri,
List<String> uploadedFiles,
final CloseHandler<PopupPanel> closeHandler) {
"""
Opens a new upload property dialog.<p>
@param title the title for the dialog popup
@param hookUri the URI of the upload hook page
@param uploadedFiles the uploaded files
@param closeHandler the dialog close handler
"""
if (hookUri.startsWith("#")) {
List<CmsUUID> resourceIds = new ArrayList<CmsUUID>();
if (uploadedFiles != null) {
for (String id : uploadedFiles) {
resourceIds.add(new CmsUUID(id));
}
}
CmsEmbeddedDialogHandler handler = new CmsEmbeddedDialogHandler(new I_CmsActionHandler() {
public void leavePage(String targetUri) {
// TODO Auto-generated method stub
}
public void onSiteOrProjectChange(String sitePath, String serverLink) {
// TODO Auto-generated method stub
}
public void refreshResource(CmsUUID structureId) {
closeHandler.onClose(null);
}
});
String dialogId = hookUri.substring(1);
handler.openDialog(dialogId, CmsGwtConstants.CONTEXT_TYPE_FILE_TABLE, resourceIds);
} else {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(I_CmsUploadConstants.PARAM_RESOURCES, Joiner.on(",").join(uploadedFiles));
CmsPopup popup = CmsFrameDialog.showFrameDialog(
title,
CmsCoreProvider.get().link(hookUri),
parameters,
closeHandler);
popup.setHeight(DIALOG_HEIGHT);
popup.setWidth(CmsPopup.DEFAULT_WIDTH);
popup.center();
}
}
|
java
|
public static void openDialog(
String title,
String hookUri,
List<String> uploadedFiles,
final CloseHandler<PopupPanel> closeHandler) {
if (hookUri.startsWith("#")) {
List<CmsUUID> resourceIds = new ArrayList<CmsUUID>();
if (uploadedFiles != null) {
for (String id : uploadedFiles) {
resourceIds.add(new CmsUUID(id));
}
}
CmsEmbeddedDialogHandler handler = new CmsEmbeddedDialogHandler(new I_CmsActionHandler() {
public void leavePage(String targetUri) {
// TODO Auto-generated method stub
}
public void onSiteOrProjectChange(String sitePath, String serverLink) {
// TODO Auto-generated method stub
}
public void refreshResource(CmsUUID structureId) {
closeHandler.onClose(null);
}
});
String dialogId = hookUri.substring(1);
handler.openDialog(dialogId, CmsGwtConstants.CONTEXT_TYPE_FILE_TABLE, resourceIds);
} else {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(I_CmsUploadConstants.PARAM_RESOURCES, Joiner.on(",").join(uploadedFiles));
CmsPopup popup = CmsFrameDialog.showFrameDialog(
title,
CmsCoreProvider.get().link(hookUri),
parameters,
closeHandler);
popup.setHeight(DIALOG_HEIGHT);
popup.setWidth(CmsPopup.DEFAULT_WIDTH);
popup.center();
}
}
|
[
"public",
"static",
"void",
"openDialog",
"(",
"String",
"title",
",",
"String",
"hookUri",
",",
"List",
"<",
"String",
">",
"uploadedFiles",
",",
"final",
"CloseHandler",
"<",
"PopupPanel",
">",
"closeHandler",
")",
"{",
"if",
"(",
"hookUri",
".",
"startsWith",
"(",
"\"#\"",
")",
")",
"{",
"List",
"<",
"CmsUUID",
">",
"resourceIds",
"=",
"new",
"ArrayList",
"<",
"CmsUUID",
">",
"(",
")",
";",
"if",
"(",
"uploadedFiles",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"id",
":",
"uploadedFiles",
")",
"{",
"resourceIds",
".",
"add",
"(",
"new",
"CmsUUID",
"(",
"id",
")",
")",
";",
"}",
"}",
"CmsEmbeddedDialogHandler",
"handler",
"=",
"new",
"CmsEmbeddedDialogHandler",
"(",
"new",
"I_CmsActionHandler",
"(",
")",
"{",
"public",
"void",
"leavePage",
"(",
"String",
"targetUri",
")",
"{",
"// TODO Auto-generated method stub\r",
"}",
"public",
"void",
"onSiteOrProjectChange",
"(",
"String",
"sitePath",
",",
"String",
"serverLink",
")",
"{",
"// TODO Auto-generated method stub\r",
"}",
"public",
"void",
"refreshResource",
"(",
"CmsUUID",
"structureId",
")",
"{",
"closeHandler",
".",
"onClose",
"(",
"null",
")",
";",
"}",
"}",
")",
";",
"String",
"dialogId",
"=",
"hookUri",
".",
"substring",
"(",
"1",
")",
";",
"handler",
".",
"openDialog",
"(",
"dialogId",
",",
"CmsGwtConstants",
".",
"CONTEXT_TYPE_FILE_TABLE",
",",
"resourceIds",
")",
";",
"}",
"else",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"parameters",
".",
"put",
"(",
"I_CmsUploadConstants",
".",
"PARAM_RESOURCES",
",",
"Joiner",
".",
"on",
"(",
"\",\"",
")",
".",
"join",
"(",
"uploadedFiles",
")",
")",
";",
"CmsPopup",
"popup",
"=",
"CmsFrameDialog",
".",
"showFrameDialog",
"(",
"title",
",",
"CmsCoreProvider",
".",
"get",
"(",
")",
".",
"link",
"(",
"hookUri",
")",
",",
"parameters",
",",
"closeHandler",
")",
";",
"popup",
".",
"setHeight",
"(",
"DIALOG_HEIGHT",
")",
";",
"popup",
".",
"setWidth",
"(",
"CmsPopup",
".",
"DEFAULT_WIDTH",
")",
";",
"popup",
".",
"center",
"(",
")",
";",
"}",
"}"
] |
Opens a new upload property dialog.<p>
@param title the title for the dialog popup
@param hookUri the URI of the upload hook page
@param uploadedFiles the uploaded files
@param closeHandler the dialog close handler
|
[
"Opens",
"a",
"new",
"upload",
"property",
"dialog",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src-gwt/org/opencms/ade/upload/client/ui/CmsUploadHookDialog.java#L72-L120
|
real-logic/agrona
|
agrona/src/main/java/org/agrona/BitUtil.java
|
BitUtil.isAligned
|
public static boolean isAligned(final long address, final int alignment) {
"""
Is an address aligned on a boundary.
@param address to be tested.
@param alignment boundary the address is tested against.
@return true if the address is on the aligned boundary otherwise false.
@throws IllegalArgumentException if the alignment is not a power of 2.
"""
if (!BitUtil.isPowerOfTwo(alignment))
{
throw new IllegalArgumentException("alignment must be a power of 2: alignment=" + alignment);
}
return (address & (alignment - 1)) == 0;
}
|
java
|
public static boolean isAligned(final long address, final int alignment)
{
if (!BitUtil.isPowerOfTwo(alignment))
{
throw new IllegalArgumentException("alignment must be a power of 2: alignment=" + alignment);
}
return (address & (alignment - 1)) == 0;
}
|
[
"public",
"static",
"boolean",
"isAligned",
"(",
"final",
"long",
"address",
",",
"final",
"int",
"alignment",
")",
"{",
"if",
"(",
"!",
"BitUtil",
".",
"isPowerOfTwo",
"(",
"alignment",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"alignment must be a power of 2: alignment=\"",
"+",
"alignment",
")",
";",
"}",
"return",
"(",
"address",
"&",
"(",
"alignment",
"-",
"1",
")",
")",
"==",
"0",
";",
"}"
] |
Is an address aligned on a boundary.
@param address to be tested.
@param alignment boundary the address is tested against.
@return true if the address is on the aligned boundary otherwise false.
@throws IllegalArgumentException if the alignment is not a power of 2.
|
[
"Is",
"an",
"address",
"aligned",
"on",
"a",
"boundary",
"."
] |
train
|
https://github.com/real-logic/agrona/blob/d1ea76e6e3598cd6a0d34879687652ef123f639b/agrona/src/main/java/org/agrona/BitUtil.java#L325-L333
|
bbossgroups/bboss-elasticsearch
|
bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/client/ConfigRestClientUtil.java
|
ConfigRestClientUtil.createIndiceMapping
|
public String createIndiceMapping(String indexName, String templateName, Object parameter) throws ElasticSearchException {
"""
创建索引定义
curl -XPUT 'localhost:9200/test?pretty' -H 'Content-Type: application/json' -d'
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"properties" : {
"field1" : { "type" : "text" }
}
}
}
}
@return
@throws ElasticSearchException
"""
return super.createIndiceMapping(indexName, ESTemplateHelper.evalTemplate(esUtil,templateName, parameter));
}
|
java
|
public String createIndiceMapping(String indexName, String templateName, Object parameter) throws ElasticSearchException {
return super.createIndiceMapping(indexName, ESTemplateHelper.evalTemplate(esUtil,templateName, parameter));
}
|
[
"public",
"String",
"createIndiceMapping",
"(",
"String",
"indexName",
",",
"String",
"templateName",
",",
"Object",
"parameter",
")",
"throws",
"ElasticSearchException",
"{",
"return",
"super",
".",
"createIndiceMapping",
"(",
"indexName",
",",
"ESTemplateHelper",
".",
"evalTemplate",
"(",
"esUtil",
",",
"templateName",
",",
"parameter",
")",
")",
";",
"}"
] |
创建索引定义
curl -XPUT 'localhost:9200/test?pretty' -H 'Content-Type: application/json' -d'
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"properties" : {
"field1" : { "type" : "text" }
}
}
}
}
@return
@throws ElasticSearchException
|
[
"创建索引定义",
"curl",
"-",
"XPUT",
"localhost",
":",
"9200",
"/",
"test?pretty",
"-",
"H",
"Content",
"-",
"Type",
":",
"application",
"/",
"json",
"-",
"d",
"{",
"settings",
":",
"{",
"number_of_shards",
":",
"1",
"}",
"mappings",
":",
"{",
"type1",
":",
"{",
"properties",
":",
"{",
"field1",
":",
"{",
"type",
":",
"text",
"}",
"}",
"}",
"}",
"}"
] |
train
|
https://github.com/bbossgroups/bboss-elasticsearch/blob/31717c8aa2c4c880987be53aeeb8a0cf5183c3a7/bboss-elasticsearch-rest/src/main/java/org/frameworkset/elasticsearch/client/ConfigRestClientUtil.java#L696-L698
|
osmdroid/osmdroid
|
osmdroid-geopackage/src/main/java/org/osmdroid/gpkg/overlay/features/SphericalUtil.java
|
SphericalUtil.computeHeading
|
public static double computeHeading(IGeoPoint from, IGeoPoint to) {
"""
Returns the heading from one LatLng to another LatLng. Headings are
expressed in degrees clockwise from North within the range [-180,180).
@return The heading in degrees clockwise from north.
"""
// http://williams.best.vwh.net/avform.htm#Crs
double fromLat = toRadians(from.getLatitude());
double fromLng = toRadians(from.getLongitude());
double toLat = toRadians(to.getLatitude());
double toLng = toRadians(to.getLongitude());
double dLng = toLng - fromLng;
double heading = atan2(
sin(dLng) * cos(toLat),
cos(fromLat) * sin(toLat) - sin(fromLat) * cos(toLat) * cos(dLng));
return wrap(toDegrees(heading), -180, 180);
}
|
java
|
public static double computeHeading(IGeoPoint from, IGeoPoint to) {
// http://williams.best.vwh.net/avform.htm#Crs
double fromLat = toRadians(from.getLatitude());
double fromLng = toRadians(from.getLongitude());
double toLat = toRadians(to.getLatitude());
double toLng = toRadians(to.getLongitude());
double dLng = toLng - fromLng;
double heading = atan2(
sin(dLng) * cos(toLat),
cos(fromLat) * sin(toLat) - sin(fromLat) * cos(toLat) * cos(dLng));
return wrap(toDegrees(heading), -180, 180);
}
|
[
"public",
"static",
"double",
"computeHeading",
"(",
"IGeoPoint",
"from",
",",
"IGeoPoint",
"to",
")",
"{",
"// http://williams.best.vwh.net/avform.htm#Crs",
"double",
"fromLat",
"=",
"toRadians",
"(",
"from",
".",
"getLatitude",
"(",
")",
")",
";",
"double",
"fromLng",
"=",
"toRadians",
"(",
"from",
".",
"getLongitude",
"(",
")",
")",
";",
"double",
"toLat",
"=",
"toRadians",
"(",
"to",
".",
"getLatitude",
"(",
")",
")",
";",
"double",
"toLng",
"=",
"toRadians",
"(",
"to",
".",
"getLongitude",
"(",
")",
")",
";",
"double",
"dLng",
"=",
"toLng",
"-",
"fromLng",
";",
"double",
"heading",
"=",
"atan2",
"(",
"sin",
"(",
"dLng",
")",
"*",
"cos",
"(",
"toLat",
")",
",",
"cos",
"(",
"fromLat",
")",
"*",
"sin",
"(",
"toLat",
")",
"-",
"sin",
"(",
"fromLat",
")",
"*",
"cos",
"(",
"toLat",
")",
"*",
"cos",
"(",
"dLng",
")",
")",
";",
"return",
"wrap",
"(",
"toDegrees",
"(",
"heading",
")",
",",
"-",
"180",
",",
"180",
")",
";",
"}"
] |
Returns the heading from one LatLng to another LatLng. Headings are
expressed in degrees clockwise from North within the range [-180,180).
@return The heading in degrees clockwise from north.
|
[
"Returns",
"the",
"heading",
"from",
"one",
"LatLng",
"to",
"another",
"LatLng",
".",
"Headings",
"are",
"expressed",
"in",
"degrees",
"clockwise",
"from",
"North",
"within",
"the",
"range",
"[",
"-",
"180",
"180",
")",
"."
] |
train
|
https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-geopackage/src/main/java/org/osmdroid/gpkg/overlay/features/SphericalUtil.java#L136-L147
|
nmorel/gwt-jackson
|
extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/google/appengine/api/datastore/AppIdNamespace.java
|
AppIdNamespace.parseEncodedAppIdNamespace
|
public static AppIdNamespace parseEncodedAppIdNamespace( String encodedAppIdNamespace ) {
"""
Converts an encoded appId/namespace to {@link AppIdNamespace}.
<p>
<p>Only one form of an appId/namespace pair will be allowed. i.e. "app!"
is an illegal form and must be encoded as "app".
<p>
<p>An appId/namespace pair may contain at most one "!" character.
@param encodedAppIdNamespace The encoded application Id/namespace string.
"""
if ( encodedAppIdNamespace == null ) {
throw new IllegalArgumentException( "appIdNamespaceString may not be null" );
}
int index = encodedAppIdNamespace.indexOf( NamespaceResources.NAMESPACE_SEPARATOR );
if ( index == -1 ) {
return new AppIdNamespace( encodedAppIdNamespace, "" );
}
String appId = encodedAppIdNamespace.substring( 0, index );
String namespace = encodedAppIdNamespace.substring( index + 1 );
if ( namespace.length() == 0 ) {
throw new IllegalArgumentException(
"encodedAppIdNamespace with empty namespace may not contain a '" +
NamespaceResources.NAMESPACE_SEPARATOR + "'" );
}
return new AppIdNamespace( appId, namespace );
}
|
java
|
public static AppIdNamespace parseEncodedAppIdNamespace( String encodedAppIdNamespace ) {
if ( encodedAppIdNamespace == null ) {
throw new IllegalArgumentException( "appIdNamespaceString may not be null" );
}
int index = encodedAppIdNamespace.indexOf( NamespaceResources.NAMESPACE_SEPARATOR );
if ( index == -1 ) {
return new AppIdNamespace( encodedAppIdNamespace, "" );
}
String appId = encodedAppIdNamespace.substring( 0, index );
String namespace = encodedAppIdNamespace.substring( index + 1 );
if ( namespace.length() == 0 ) {
throw new IllegalArgumentException(
"encodedAppIdNamespace with empty namespace may not contain a '" +
NamespaceResources.NAMESPACE_SEPARATOR + "'" );
}
return new AppIdNamespace( appId, namespace );
}
|
[
"public",
"static",
"AppIdNamespace",
"parseEncodedAppIdNamespace",
"(",
"String",
"encodedAppIdNamespace",
")",
"{",
"if",
"(",
"encodedAppIdNamespace",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"appIdNamespaceString may not be null\"",
")",
";",
"}",
"int",
"index",
"=",
"encodedAppIdNamespace",
".",
"indexOf",
"(",
"NamespaceResources",
".",
"NAMESPACE_SEPARATOR",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"return",
"new",
"AppIdNamespace",
"(",
"encodedAppIdNamespace",
",",
"\"\"",
")",
";",
"}",
"String",
"appId",
"=",
"encodedAppIdNamespace",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"String",
"namespace",
"=",
"encodedAppIdNamespace",
".",
"substring",
"(",
"index",
"+",
"1",
")",
";",
"if",
"(",
"namespace",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"encodedAppIdNamespace with empty namespace may not contain a '\"",
"+",
"NamespaceResources",
".",
"NAMESPACE_SEPARATOR",
"+",
"\"'\"",
")",
";",
"}",
"return",
"new",
"AppIdNamespace",
"(",
"appId",
",",
"namespace",
")",
";",
"}"
] |
Converts an encoded appId/namespace to {@link AppIdNamespace}.
<p>
<p>Only one form of an appId/namespace pair will be allowed. i.e. "app!"
is an illegal form and must be encoded as "app".
<p>
<p>An appId/namespace pair may contain at most one "!" character.
@param encodedAppIdNamespace The encoded application Id/namespace string.
|
[
"Converts",
"an",
"encoded",
"appId",
"/",
"namespace",
"to",
"{",
"@link",
"AppIdNamespace",
"}",
".",
"<p",
">",
"<p",
">",
"Only",
"one",
"form",
"of",
"an",
"appId",
"/",
"namespace",
"pair",
"will",
"be",
"allowed",
".",
"i",
".",
"e",
".",
"app!",
"is",
"an",
"illegal",
"form",
"and",
"must",
"be",
"encoded",
"as",
"app",
".",
"<p",
">",
"<p",
">",
"An",
"appId",
"/",
"namespace",
"pair",
"may",
"contain",
"at",
"most",
"one",
"!",
"character",
"."
] |
train
|
https://github.com/nmorel/gwt-jackson/blob/3fdc4350a27a9b64fc437d5fe516bf9191b74824/extensions/objectify/src/main/resources/com/github/nmorel/gwtjackson/objectify/super/com/google/appengine/api/datastore/AppIdNamespace.java#L48-L64
|
Ordinastie/MalisisCore
|
src/main/java/net/malisis/core/registry/MalisisRegistry.java
|
MalisisRegistry.registerSound
|
public static SoundEvent registerSound(String modId, String soundId) {
"""
Registers a new {@link SoundEvent}.
@param modId the mod id
@param soundId the sound id
@return the sound event
"""
ResourceLocation rl = new ResourceLocation(modId, soundId);
SoundEvent sound = new SoundEvent(rl);
sound.setRegistryName(rl);
ForgeRegistries.SOUND_EVENTS.register(sound);
return sound;
}
|
java
|
public static SoundEvent registerSound(String modId, String soundId)
{
ResourceLocation rl = new ResourceLocation(modId, soundId);
SoundEvent sound = new SoundEvent(rl);
sound.setRegistryName(rl);
ForgeRegistries.SOUND_EVENTS.register(sound);
return sound;
}
|
[
"public",
"static",
"SoundEvent",
"registerSound",
"(",
"String",
"modId",
",",
"String",
"soundId",
")",
"{",
"ResourceLocation",
"rl",
"=",
"new",
"ResourceLocation",
"(",
"modId",
",",
"soundId",
")",
";",
"SoundEvent",
"sound",
"=",
"new",
"SoundEvent",
"(",
"rl",
")",
";",
"sound",
".",
"setRegistryName",
"(",
"rl",
")",
";",
"ForgeRegistries",
".",
"SOUND_EVENTS",
".",
"register",
"(",
"sound",
")",
";",
"return",
"sound",
";",
"}"
] |
Registers a new {@link SoundEvent}.
@param modId the mod id
@param soundId the sound id
@return the sound event
|
[
"Registers",
"a",
"new",
"{",
"@link",
"SoundEvent",
"}",
"."
] |
train
|
https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/registry/MalisisRegistry.java#L260-L267
|
chhh/MSFTBX
|
MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRange.java
|
LCMSRange.create
|
public static final LCMSRange create(Range<Integer> scanRange, Integer msLevel) {
"""
A range that will contain all scans with the scan number range, but only at a specific
MS-Level.
@param scanRange null means the whole range of scan numbers in the run
@param msLevel null means any ms-level
"""
return new LCMSRange(scanRange, msLevel, null);
}
|
java
|
public static final LCMSRange create(Range<Integer> scanRange, Integer msLevel) {
return new LCMSRange(scanRange, msLevel, null);
}
|
[
"public",
"static",
"final",
"LCMSRange",
"create",
"(",
"Range",
"<",
"Integer",
">",
"scanRange",
",",
"Integer",
"msLevel",
")",
"{",
"return",
"new",
"LCMSRange",
"(",
"scanRange",
",",
"msLevel",
",",
"null",
")",
";",
"}"
] |
A range that will contain all scans with the scan number range, but only at a specific
MS-Level.
@param scanRange null means the whole range of scan numbers in the run
@param msLevel null means any ms-level
|
[
"A",
"range",
"that",
"will",
"contain",
"all",
"scans",
"with",
"the",
"scan",
"number",
"range",
"but",
"only",
"at",
"a",
"specific",
"MS",
"-",
"Level",
"."
] |
train
|
https://github.com/chhh/MSFTBX/blob/e53ae6be982e2de3123292be7d5297715bec70bb/MSFileToolbox/src/main/java/umich/ms/datatypes/LCMSRange.java#L98-L100
|
square/tape
|
tape/src/main/java/com/squareup/tape2/QueueFile.java
|
QueueFile.ringWrite
|
private void ringWrite(long position, byte[] buffer, int offset, int count) throws IOException {
"""
Writes count bytes from buffer to position in file. Automatically wraps write if position is
past the end of the file or if buffer overlaps it.
@param position in file to write to
@param buffer to write from
@param count # of bytes to write
"""
position = wrapPosition(position);
if (position + count <= fileLength) {
raf.seek(position);
raf.write(buffer, offset, count);
} else {
// The write overlaps the EOF.
// # of bytes to write before the EOF. Guaranteed to be less than Integer.MAX_VALUE.
int beforeEof = (int) (fileLength - position);
raf.seek(position);
raf.write(buffer, offset, beforeEof);
raf.seek(headerLength);
raf.write(buffer, offset + beforeEof, count - beforeEof);
}
}
|
java
|
private void ringWrite(long position, byte[] buffer, int offset, int count) throws IOException {
position = wrapPosition(position);
if (position + count <= fileLength) {
raf.seek(position);
raf.write(buffer, offset, count);
} else {
// The write overlaps the EOF.
// # of bytes to write before the EOF. Guaranteed to be less than Integer.MAX_VALUE.
int beforeEof = (int) (fileLength - position);
raf.seek(position);
raf.write(buffer, offset, beforeEof);
raf.seek(headerLength);
raf.write(buffer, offset + beforeEof, count - beforeEof);
}
}
|
[
"private",
"void",
"ringWrite",
"(",
"long",
"position",
",",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
",",
"int",
"count",
")",
"throws",
"IOException",
"{",
"position",
"=",
"wrapPosition",
"(",
"position",
")",
";",
"if",
"(",
"position",
"+",
"count",
"<=",
"fileLength",
")",
"{",
"raf",
".",
"seek",
"(",
"position",
")",
";",
"raf",
".",
"write",
"(",
"buffer",
",",
"offset",
",",
"count",
")",
";",
"}",
"else",
"{",
"// The write overlaps the EOF.",
"// # of bytes to write before the EOF. Guaranteed to be less than Integer.MAX_VALUE.",
"int",
"beforeEof",
"=",
"(",
"int",
")",
"(",
"fileLength",
"-",
"position",
")",
";",
"raf",
".",
"seek",
"(",
"position",
")",
";",
"raf",
".",
"write",
"(",
"buffer",
",",
"offset",
",",
"beforeEof",
")",
";",
"raf",
".",
"seek",
"(",
"headerLength",
")",
";",
"raf",
".",
"write",
"(",
"buffer",
",",
"offset",
"+",
"beforeEof",
",",
"count",
"-",
"beforeEof",
")",
";",
"}",
"}"
] |
Writes count bytes from buffer to position in file. Automatically wraps write if position is
past the end of the file or if buffer overlaps it.
@param position in file to write to
@param buffer to write from
@param count # of bytes to write
|
[
"Writes",
"count",
"bytes",
"from",
"buffer",
"to",
"position",
"in",
"file",
".",
"Automatically",
"wraps",
"write",
"if",
"position",
"is",
"past",
"the",
"end",
"of",
"the",
"file",
"or",
"if",
"buffer",
"overlaps",
"it",
"."
] |
train
|
https://github.com/square/tape/blob/445cd3fd0a7b3ec48c9ea3e0e86663fe6d3735d8/tape/src/main/java/com/squareup/tape2/QueueFile.java#L308-L322
|
agmip/translator-dssat
|
src/main/java/org/agmip/translators/dssat/DssatCommonOutput.java
|
DssatCommonOutput.getPdate
|
protected String getPdate(Map result) {
"""
Get plating date from experiment management event
@param result the experiment data object
@return plating date
"""
HashMap management = getObjectOr(result, "management", new HashMap());
ArrayList<HashMap> events = getObjectOr(management, "events", new ArrayList<HashMap>());
for (HashMap event : events) {
if (getValueOr(event, "event", "").equals("planting")) {
return getValueOr(event, "date", "");
}
}
return "";
}
|
java
|
protected String getPdate(Map result) {
HashMap management = getObjectOr(result, "management", new HashMap());
ArrayList<HashMap> events = getObjectOr(management, "events", new ArrayList<HashMap>());
for (HashMap event : events) {
if (getValueOr(event, "event", "").equals("planting")) {
return getValueOr(event, "date", "");
}
}
return "";
}
|
[
"protected",
"String",
"getPdate",
"(",
"Map",
"result",
")",
"{",
"HashMap",
"management",
"=",
"getObjectOr",
"(",
"result",
",",
"\"management\"",
",",
"new",
"HashMap",
"(",
")",
")",
";",
"ArrayList",
"<",
"HashMap",
">",
"events",
"=",
"getObjectOr",
"(",
"management",
",",
"\"events\"",
",",
"new",
"ArrayList",
"<",
"HashMap",
">",
"(",
")",
")",
";",
"for",
"(",
"HashMap",
"event",
":",
"events",
")",
"{",
"if",
"(",
"getValueOr",
"(",
"event",
",",
"\"event\"",
",",
"\"\"",
")",
".",
"equals",
"(",
"\"planting\"",
")",
")",
"{",
"return",
"getValueOr",
"(",
"event",
",",
"\"date\"",
",",
"\"\"",
")",
";",
"}",
"}",
"return",
"\"\"",
";",
"}"
] |
Get plating date from experiment management event
@param result the experiment data object
@return plating date
|
[
"Get",
"plating",
"date",
"from",
"experiment",
"management",
"event"
] |
train
|
https://github.com/agmip/translator-dssat/blob/4be61d998f106eb7234ea8701b63c3746ae688f4/src/main/java/org/agmip/translators/dssat/DssatCommonOutput.java#L395-L406
|
kuali/ojb-1.0.4
|
src/java/org/apache/ojb/broker/cache/ObjectCacheTwoLevelImpl.java
|
ObjectCacheTwoLevelImpl.putToSessionCache
|
private void putToSessionCache(Identity oid, CacheEntry entry, boolean onlyIfNew) {
"""
Put object to session cache.
@param oid The {@link org.apache.ojb.broker.Identity} of the object to cache
@param entry The {@link org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl.CacheEntry} of the object
@param onlyIfNew Flag, if set <em>true</em> only new objects (not already in session cache) be cached.
"""
if(onlyIfNew)
{
// no synchronization needed, because session cache was used per broker instance
if(!sessionCache.containsKey(oid)) sessionCache.put(oid, entry);
}
else
{
sessionCache.put(oid, entry);
}
}
|
java
|
private void putToSessionCache(Identity oid, CacheEntry entry, boolean onlyIfNew)
{
if(onlyIfNew)
{
// no synchronization needed, because session cache was used per broker instance
if(!sessionCache.containsKey(oid)) sessionCache.put(oid, entry);
}
else
{
sessionCache.put(oid, entry);
}
}
|
[
"private",
"void",
"putToSessionCache",
"(",
"Identity",
"oid",
",",
"CacheEntry",
"entry",
",",
"boolean",
"onlyIfNew",
")",
"{",
"if",
"(",
"onlyIfNew",
")",
"{",
"// no synchronization needed, because session cache was used per broker instance\r",
"if",
"(",
"!",
"sessionCache",
".",
"containsKey",
"(",
"oid",
")",
")",
"sessionCache",
".",
"put",
"(",
"oid",
",",
"entry",
")",
";",
"}",
"else",
"{",
"sessionCache",
".",
"put",
"(",
"oid",
",",
"entry",
")",
";",
"}",
"}"
] |
Put object to session cache.
@param oid The {@link org.apache.ojb.broker.Identity} of the object to cache
@param entry The {@link org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl.CacheEntry} of the object
@param onlyIfNew Flag, if set <em>true</em> only new objects (not already in session cache) be cached.
|
[
"Put",
"object",
"to",
"session",
"cache",
"."
] |
train
|
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/broker/cache/ObjectCacheTwoLevelImpl.java#L461-L472
|
sawano/java-commons
|
src/main/java/se/sawano/java/commons/lang/validate/Validate.java
|
Validate.matchesPattern
|
public static CharSequence matchesPattern(final CharSequence input, final String pattern, final String message, final Object... values) {
"""
<p>Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception with the specified message.</p>
<pre>Validate.matchesPattern("hi", "[a-z]*", "%s does not match %s", "hi" "[a-z]*");</pre>
<p>The syntax of the pattern is the one used in the {@link Pattern} class.</p>
@param input
the character sequence to validate, not null
@param pattern
the regular expression pattern, not null
@param message
the {@link String#format(String, Object...)} exception message if invalid, not null
@param values
the optional values for the formatted exception message, null array not recommended
@return the input
@throws IllegalArgumentValidationException
if the character sequence does not match the pattern
@see #matchesPattern(CharSequence, String)
"""
return INSTANCE.matchesPattern(input, pattern, message, values);
}
|
java
|
public static CharSequence matchesPattern(final CharSequence input, final String pattern, final String message, final Object... values) {
return INSTANCE.matchesPattern(input, pattern, message, values);
}
|
[
"public",
"static",
"CharSequence",
"matchesPattern",
"(",
"final",
"CharSequence",
"input",
",",
"final",
"String",
"pattern",
",",
"final",
"String",
"message",
",",
"final",
"Object",
"...",
"values",
")",
"{",
"return",
"INSTANCE",
".",
"matchesPattern",
"(",
"input",
",",
"pattern",
",",
"message",
",",
"values",
")",
";",
"}"
] |
<p>Validate that the specified argument character sequence matches the specified regular expression pattern; otherwise throwing an exception with the specified message.</p>
<pre>Validate.matchesPattern("hi", "[a-z]*", "%s does not match %s", "hi" "[a-z]*");</pre>
<p>The syntax of the pattern is the one used in the {@link Pattern} class.</p>
@param input
the character sequence to validate, not null
@param pattern
the regular expression pattern, not null
@param message
the {@link String#format(String, Object...)} exception message if invalid, not null
@param values
the optional values for the formatted exception message, null array not recommended
@return the input
@throws IllegalArgumentValidationException
if the character sequence does not match the pattern
@see #matchesPattern(CharSequence, String)
|
[
"<p",
">",
"Validate",
"that",
"the",
"specified",
"argument",
"character",
"sequence",
"matches",
"the",
"specified",
"regular",
"expression",
"pattern",
";",
"otherwise",
"throwing",
"an",
"exception",
"with",
"the",
"specified",
"message",
".",
"<",
"/",
"p",
">",
"<pre",
">",
"Validate",
".",
"matchesPattern",
"(",
"hi",
"[",
"a",
"-",
"z",
"]",
"*",
"%s",
"does",
"not",
"match",
"%s",
"hi",
"[",
"a",
"-",
"z",
"]",
"*",
")",
";",
"<",
"/",
"pre",
">",
"<p",
">",
"The",
"syntax",
"of",
"the",
"pattern",
"is",
"the",
"one",
"used",
"in",
"the",
"{",
"@link",
"Pattern",
"}",
"class",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/sawano/java-commons/blob/6f219c9e8dec4401dbe528d17ae6ec1ef9c0d284/src/main/java/se/sawano/java/commons/lang/validate/Validate.java#L1402-L1404
|
aNNiMON/Lightweight-Stream-API
|
stream/src/main/java/com/annimon/stream/Collectors.java
|
Collectors.partitioningBy
|
@NotNull
public static <T, D, A> Collector<T, ?, Map<Boolean, D>> partitioningBy(
@NotNull final Predicate<? super T> predicate,
@NotNull final Collector<? super T, A, D> downstream) {
"""
Returns a {@code Collector} that performs partitioning operation according to a predicate.
The returned {@code Map} always contains mappings for both {@code false} and {@code true} keys.
@param <T> the type of the input elements
@param <D> the result type of downstream reduction
@param <A> the accumulation type
@param predicate a predicate used for classifying input elements
@param downstream the collector of partitioned elements
@return a {@code Collector}
@since 1.1.9
"""
final BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator();
return new CollectorsImpl<T, Tuple2<A>, Map<Boolean, D>>(
new Supplier<Tuple2<A>>() {
@NotNull
@Override
public Tuple2<A> get() {
return new Tuple2<A>(
downstream.supplier().get(),
downstream.supplier().get());
}
},
new BiConsumer<Tuple2<A>, T>() {
@Override
public void accept(@NotNull Tuple2<A> container, T t) {
downstreamAccumulator.accept(
predicate.test(t) ? container.a : container.b, t);
}
},
new Function<Tuple2<A>, Map<Boolean, D>>() {
@NotNull
@Override
public Map<Boolean, D> apply(@NotNull Tuple2<A> container) {
final Function<A, D> finisher = downstream.finisher();
Map<Boolean, D> result = new HashMap<Boolean, D>(2);
result.put(Boolean.TRUE, finisher.apply(container.a));
result.put(Boolean.FALSE, finisher.apply(container.b));
return result;
}
}
);
}
|
java
|
@NotNull
public static <T, D, A> Collector<T, ?, Map<Boolean, D>> partitioningBy(
@NotNull final Predicate<? super T> predicate,
@NotNull final Collector<? super T, A, D> downstream) {
final BiConsumer<A, ? super T> downstreamAccumulator = downstream.accumulator();
return new CollectorsImpl<T, Tuple2<A>, Map<Boolean, D>>(
new Supplier<Tuple2<A>>() {
@NotNull
@Override
public Tuple2<A> get() {
return new Tuple2<A>(
downstream.supplier().get(),
downstream.supplier().get());
}
},
new BiConsumer<Tuple2<A>, T>() {
@Override
public void accept(@NotNull Tuple2<A> container, T t) {
downstreamAccumulator.accept(
predicate.test(t) ? container.a : container.b, t);
}
},
new Function<Tuple2<A>, Map<Boolean, D>>() {
@NotNull
@Override
public Map<Boolean, D> apply(@NotNull Tuple2<A> container) {
final Function<A, D> finisher = downstream.finisher();
Map<Boolean, D> result = new HashMap<Boolean, D>(2);
result.put(Boolean.TRUE, finisher.apply(container.a));
result.put(Boolean.FALSE, finisher.apply(container.b));
return result;
}
}
);
}
|
[
"@",
"NotNull",
"public",
"static",
"<",
"T",
",",
"D",
",",
"A",
">",
"Collector",
"<",
"T",
",",
"?",
",",
"Map",
"<",
"Boolean",
",",
"D",
">",
">",
"partitioningBy",
"(",
"@",
"NotNull",
"final",
"Predicate",
"<",
"?",
"super",
"T",
">",
"predicate",
",",
"@",
"NotNull",
"final",
"Collector",
"<",
"?",
"super",
"T",
",",
"A",
",",
"D",
">",
"downstream",
")",
"{",
"final",
"BiConsumer",
"<",
"A",
",",
"?",
"super",
"T",
">",
"downstreamAccumulator",
"=",
"downstream",
".",
"accumulator",
"(",
")",
";",
"return",
"new",
"CollectorsImpl",
"<",
"T",
",",
"Tuple2",
"<",
"A",
">",
",",
"Map",
"<",
"Boolean",
",",
"D",
">",
">",
"(",
"new",
"Supplier",
"<",
"Tuple2",
"<",
"A",
">",
">",
"(",
")",
"{",
"@",
"NotNull",
"@",
"Override",
"public",
"Tuple2",
"<",
"A",
">",
"get",
"(",
")",
"{",
"return",
"new",
"Tuple2",
"<",
"A",
">",
"(",
"downstream",
".",
"supplier",
"(",
")",
".",
"get",
"(",
")",
",",
"downstream",
".",
"supplier",
"(",
")",
".",
"get",
"(",
")",
")",
";",
"}",
"}",
",",
"new",
"BiConsumer",
"<",
"Tuple2",
"<",
"A",
">",
",",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"accept",
"(",
"@",
"NotNull",
"Tuple2",
"<",
"A",
">",
"container",
",",
"T",
"t",
")",
"{",
"downstreamAccumulator",
".",
"accept",
"(",
"predicate",
".",
"test",
"(",
"t",
")",
"?",
"container",
".",
"a",
":",
"container",
".",
"b",
",",
"t",
")",
";",
"}",
"}",
",",
"new",
"Function",
"<",
"Tuple2",
"<",
"A",
">",
",",
"Map",
"<",
"Boolean",
",",
"D",
">",
">",
"(",
")",
"{",
"@",
"NotNull",
"@",
"Override",
"public",
"Map",
"<",
"Boolean",
",",
"D",
">",
"apply",
"(",
"@",
"NotNull",
"Tuple2",
"<",
"A",
">",
"container",
")",
"{",
"final",
"Function",
"<",
"A",
",",
"D",
">",
"finisher",
"=",
"downstream",
".",
"finisher",
"(",
")",
";",
"Map",
"<",
"Boolean",
",",
"D",
">",
"result",
"=",
"new",
"HashMap",
"<",
"Boolean",
",",
"D",
">",
"(",
"2",
")",
";",
"result",
".",
"put",
"(",
"Boolean",
".",
"TRUE",
",",
"finisher",
".",
"apply",
"(",
"container",
".",
"a",
")",
")",
";",
"result",
".",
"put",
"(",
"Boolean",
".",
"FALSE",
",",
"finisher",
".",
"apply",
"(",
"container",
".",
"b",
")",
")",
";",
"return",
"result",
";",
"}",
"}",
")",
";",
"}"
] |
Returns a {@code Collector} that performs partitioning operation according to a predicate.
The returned {@code Map} always contains mappings for both {@code false} and {@code true} keys.
@param <T> the type of the input elements
@param <D> the result type of downstream reduction
@param <A> the accumulation type
@param predicate a predicate used for classifying input elements
@param downstream the collector of partitioned elements
@return a {@code Collector}
@since 1.1.9
|
[
"Returns",
"a",
"{",
"@code",
"Collector",
"}",
"that",
"performs",
"partitioning",
"operation",
"according",
"to",
"a",
"predicate",
".",
"The",
"returned",
"{",
"@code",
"Map",
"}",
"always",
"contains",
"mappings",
"for",
"both",
"{",
"@code",
"false",
"}",
"and",
"{",
"@code",
"true",
"}",
"keys",
"."
] |
train
|
https://github.com/aNNiMON/Lightweight-Stream-API/blob/f29fd57208c20252a4549b084d55ed082c3e58f0/stream/src/main/java/com/annimon/stream/Collectors.java#L1015-L1050
|
inkstand-io/scribble
|
scribble-file/src/main/java/io/inkstand/scribble/rules/builder/ZipFileBuilder.java
|
ZipFileBuilder.addClasspathResource
|
public ZipFileBuilder addClasspathResource(final String zipEntryPath, final String pathToResource) {
"""
Adds an entry to the zip file from a classpath resource.
@param zipEntryPath
the path of the entry in the zip file. If the path denotes a path (ends with '/') the resource is put
under its own name on that location. If it denotes a file, it will be put as this file into the zip. Note
that even if the path ist defined absolute, starting with a '/', the created entry in the zip file won't
start with a '/'
@param pathToResource
the path to the resource in the classpath
@return this builder
"""
final Class<?> callerClass = getCallerClass();
final URL resource = resolver.resolve(pathToResource, callerClass);
addResource(zipEntryPath, resource);
return this;
}
|
java
|
public ZipFileBuilder addClasspathResource(final String zipEntryPath, final String pathToResource) {
final Class<?> callerClass = getCallerClass();
final URL resource = resolver.resolve(pathToResource, callerClass);
addResource(zipEntryPath, resource);
return this;
}
|
[
"public",
"ZipFileBuilder",
"addClasspathResource",
"(",
"final",
"String",
"zipEntryPath",
",",
"final",
"String",
"pathToResource",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"callerClass",
"=",
"getCallerClass",
"(",
")",
";",
"final",
"URL",
"resource",
"=",
"resolver",
".",
"resolve",
"(",
"pathToResource",
",",
"callerClass",
")",
";",
"addResource",
"(",
"zipEntryPath",
",",
"resource",
")",
";",
"return",
"this",
";",
"}"
] |
Adds an entry to the zip file from a classpath resource.
@param zipEntryPath
the path of the entry in the zip file. If the path denotes a path (ends with '/') the resource is put
under its own name on that location. If it denotes a file, it will be put as this file into the zip. Note
that even if the path ist defined absolute, starting with a '/', the created entry in the zip file won't
start with a '/'
@param pathToResource
the path to the resource in the classpath
@return this builder
|
[
"Adds",
"an",
"entry",
"to",
"the",
"zip",
"file",
"from",
"a",
"classpath",
"resource",
"."
] |
train
|
https://github.com/inkstand-io/scribble/blob/66e67553bad4b1ff817e1715fd1d3dd833406744/scribble-file/src/main/java/io/inkstand/scribble/rules/builder/ZipFileBuilder.java#L68-L74
|
wso2/transport-http
|
components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/common/states/Http2StateUtil.java
|
Http2StateUtil.validatePromisedStreamState
|
public static void validatePromisedStreamState(int originalStreamId, int streamId, Http2Connection conn,
HttpCarbonMessage inboundRequestMsg) throws Http2Exception {
"""
Validates the state of promised stream with the original stream id and given stream id.
@param originalStreamId the original id of the stream
@param streamId the id of the stream to be validated
@param conn HTTP2 connection
@param inboundRequestMsg request message received from the client
@throws Http2Exception throws if stream id is not valid for given connection
"""
if (streamId == originalStreamId) { // Not a promised stream, no need to validate
return;
}
if (!isValidStreamId(streamId, conn)) {
inboundRequestMsg.getHttpOutboundRespStatusFuture().
notifyHttpListener(new ServerConnectorException(PROMISED_STREAM_REJECTED_ERROR));
throw new Http2Exception(Http2Error.REFUSED_STREAM, PROMISED_STREAM_REJECTED_ERROR);
}
}
|
java
|
public static void validatePromisedStreamState(int originalStreamId, int streamId, Http2Connection conn,
HttpCarbonMessage inboundRequestMsg) throws Http2Exception {
if (streamId == originalStreamId) { // Not a promised stream, no need to validate
return;
}
if (!isValidStreamId(streamId, conn)) {
inboundRequestMsg.getHttpOutboundRespStatusFuture().
notifyHttpListener(new ServerConnectorException(PROMISED_STREAM_REJECTED_ERROR));
throw new Http2Exception(Http2Error.REFUSED_STREAM, PROMISED_STREAM_REJECTED_ERROR);
}
}
|
[
"public",
"static",
"void",
"validatePromisedStreamState",
"(",
"int",
"originalStreamId",
",",
"int",
"streamId",
",",
"Http2Connection",
"conn",
",",
"HttpCarbonMessage",
"inboundRequestMsg",
")",
"throws",
"Http2Exception",
"{",
"if",
"(",
"streamId",
"==",
"originalStreamId",
")",
"{",
"// Not a promised stream, no need to validate",
"return",
";",
"}",
"if",
"(",
"!",
"isValidStreamId",
"(",
"streamId",
",",
"conn",
")",
")",
"{",
"inboundRequestMsg",
".",
"getHttpOutboundRespStatusFuture",
"(",
")",
".",
"notifyHttpListener",
"(",
"new",
"ServerConnectorException",
"(",
"PROMISED_STREAM_REJECTED_ERROR",
")",
")",
";",
"throw",
"new",
"Http2Exception",
"(",
"Http2Error",
".",
"REFUSED_STREAM",
",",
"PROMISED_STREAM_REJECTED_ERROR",
")",
";",
"}",
"}"
] |
Validates the state of promised stream with the original stream id and given stream id.
@param originalStreamId the original id of the stream
@param streamId the id of the stream to be validated
@param conn HTTP2 connection
@param inboundRequestMsg request message received from the client
@throws Http2Exception throws if stream id is not valid for given connection
|
[
"Validates",
"the",
"state",
"of",
"promised",
"stream",
"with",
"the",
"original",
"stream",
"id",
"and",
"given",
"stream",
"id",
"."
] |
train
|
https://github.com/wso2/transport-http/blob/c51aa715b473db6c1b82a7d7b22f6e65f74df4c9/components/org.wso2.transport.http.netty/src/main/java/org/wso2/transport/http/netty/contractimpl/common/states/Http2StateUtil.java#L200-L210
|
apiman/apiman
|
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java
|
ExceptionFactory.apiDefinitionNotFoundException
|
public static final ApiDefinitionNotFoundException apiDefinitionNotFoundException(String apiId, String version) {
"""
Creates an exception from an API id and version.
@param apiId the API id
@param version the API version
@return the exception
"""
return new ApiDefinitionNotFoundException(Messages.i18n.format("ApiDefinitionDoesNotExist", apiId, version)); //$NON-NLS-1$
}
|
java
|
public static final ApiDefinitionNotFoundException apiDefinitionNotFoundException(String apiId, String version) {
return new ApiDefinitionNotFoundException(Messages.i18n.format("ApiDefinitionDoesNotExist", apiId, version)); //$NON-NLS-1$
}
|
[
"public",
"static",
"final",
"ApiDefinitionNotFoundException",
"apiDefinitionNotFoundException",
"(",
"String",
"apiId",
",",
"String",
"version",
")",
"{",
"return",
"new",
"ApiDefinitionNotFoundException",
"(",
"Messages",
".",
"i18n",
".",
"format",
"(",
"\"ApiDefinitionDoesNotExist\"",
",",
"apiId",
",",
"version",
")",
")",
";",
"//$NON-NLS-1$",
"}"
] |
Creates an exception from an API id and version.
@param apiId the API id
@param version the API version
@return the exception
|
[
"Creates",
"an",
"exception",
"from",
"an",
"API",
"id",
"and",
"version",
"."
] |
train
|
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java#L239-L241
|
rhuss/jolokia
|
client/java/src/main/java/org/jolokia/client/request/J4pSearchResponse.java
|
J4pSearchResponse.getObjectNames
|
public List<ObjectName> getObjectNames() {
"""
Get the found names as a list of {@link ObjectName} objects.
@return list of MBean object names or an empty list.
"""
List<String> names = getMBeanNames();
List<ObjectName> ret = new ArrayList<ObjectName>(names.size());
for (String name : names) {
try {
ret.add(new ObjectName(name));
} catch (MalformedObjectNameException e) {
// Should never happen since the names returned by the server must
// be valid ObjectNames for sure
throw new IllegalStateException("Cannot convert search result '" + name + "' to an ObjectName",e);
}
}
return ret;
}
|
java
|
public List<ObjectName> getObjectNames() {
List<String> names = getMBeanNames();
List<ObjectName> ret = new ArrayList<ObjectName>(names.size());
for (String name : names) {
try {
ret.add(new ObjectName(name));
} catch (MalformedObjectNameException e) {
// Should never happen since the names returned by the server must
// be valid ObjectNames for sure
throw new IllegalStateException("Cannot convert search result '" + name + "' to an ObjectName",e);
}
}
return ret;
}
|
[
"public",
"List",
"<",
"ObjectName",
">",
"getObjectNames",
"(",
")",
"{",
"List",
"<",
"String",
">",
"names",
"=",
"getMBeanNames",
"(",
")",
";",
"List",
"<",
"ObjectName",
">",
"ret",
"=",
"new",
"ArrayList",
"<",
"ObjectName",
">",
"(",
"names",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"String",
"name",
":",
"names",
")",
"{",
"try",
"{",
"ret",
".",
"add",
"(",
"new",
"ObjectName",
"(",
"name",
")",
")",
";",
"}",
"catch",
"(",
"MalformedObjectNameException",
"e",
")",
"{",
"// Should never happen since the names returned by the server must",
"// be valid ObjectNames for sure",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot convert search result '\"",
"+",
"name",
"+",
"\"' to an ObjectName\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Get the found names as a list of {@link ObjectName} objects.
@return list of MBean object names or an empty list.
|
[
"Get",
"the",
"found",
"names",
"as",
"a",
"list",
"of",
"{",
"@link",
"ObjectName",
"}",
"objects",
"."
] |
train
|
https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/client/java/src/main/java/org/jolokia/client/request/J4pSearchResponse.java#L45-L58
|
Netflix/conductor
|
core/src/main/java/com/netflix/conductor/service/utils/ServiceUtils.java
|
ServiceUtils.checkNotNullOrEmpty
|
public static void checkNotNullOrEmpty(Collection<?> collection, String errorMessage) {
"""
/*
This method checks if the collection is null or is empty.
@param collection input of type {@link Collection}
@param errorMessage The exception message use if the collection is empty or null
@throws com.netflix.conductor.core.execution.ApplicationException if input Collection is not valid
"""
if(collection == null || collection.isEmpty()) {
throw new ApplicationException(ApplicationException.Code.INVALID_INPUT, errorMessage);
}
}
|
java
|
public static void checkNotNullOrEmpty(Collection<?> collection, String errorMessage){
if(collection == null || collection.isEmpty()) {
throw new ApplicationException(ApplicationException.Code.INVALID_INPUT, errorMessage);
}
}
|
[
"public",
"static",
"void",
"checkNotNullOrEmpty",
"(",
"Collection",
"<",
"?",
">",
"collection",
",",
"String",
"errorMessage",
")",
"{",
"if",
"(",
"collection",
"==",
"null",
"||",
"collection",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"ApplicationException",
"(",
"ApplicationException",
".",
"Code",
".",
"INVALID_INPUT",
",",
"errorMessage",
")",
";",
"}",
"}"
] |
/*
This method checks if the collection is null or is empty.
@param collection input of type {@link Collection}
@param errorMessage The exception message use if the collection is empty or null
@throws com.netflix.conductor.core.execution.ApplicationException if input Collection is not valid
|
[
"/",
"*",
"This",
"method",
"checks",
"if",
"the",
"collection",
"is",
"null",
"or",
"is",
"empty",
"."
] |
train
|
https://github.com/Netflix/conductor/blob/78fae0ed9ddea22891f9eebb96a2ec0b2783dca0/core/src/main/java/com/netflix/conductor/service/utils/ServiceUtils.java#L62-L66
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-dbaaslogs/src/main/java/net/minidev/ovh/api/ApiOvhDbaaslogs.java
|
ApiOvhDbaaslogs.serviceName_output_graylog_stream_streamId_PUT
|
public OvhOperation serviceName_output_graylog_stream_streamId_PUT(String serviceName, String streamId, OvhStreamColdStorageCompressionEnum coldStorageCompression, Boolean coldStorageEnabled, Boolean coldStorageNotifyEnabled, Long coldStorageRetention, String description, Boolean indexingEnabled, String optionId, String title, Boolean webSocketEnabled) throws IOException {
"""
Update information of specified graylog stream
REST: PUT /dbaas/logs/{serviceName}/output/graylog/stream/{streamId}
@param serviceName [required] Service name
@param streamId [required] Stream ID
@param webSocketEnabled [required] Web socket enabled
@param indexingEnabled [required] ES indexing enabled
@param coldStorageRetention [required] Cold storage retention time
@param coldStorageCompression [required] Cold storage compression
@param description [required] Description
@param coldStorageNotifyEnabled [required] Cold storage notify enabled
@param optionId [required] Option ID
@param title [required] Title
@param coldStorageEnabled [required] Cold storage enabled
"""
String qPath = "/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}";
StringBuilder sb = path(qPath, serviceName, streamId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "coldStorageCompression", coldStorageCompression);
addBody(o, "coldStorageEnabled", coldStorageEnabled);
addBody(o, "coldStorageNotifyEnabled", coldStorageNotifyEnabled);
addBody(o, "coldStorageRetention", coldStorageRetention);
addBody(o, "description", description);
addBody(o, "indexingEnabled", indexingEnabled);
addBody(o, "optionId", optionId);
addBody(o, "title", title);
addBody(o, "webSocketEnabled", webSocketEnabled);
String resp = exec(qPath, "PUT", sb.toString(), o);
return convertTo(resp, OvhOperation.class);
}
|
java
|
public OvhOperation serviceName_output_graylog_stream_streamId_PUT(String serviceName, String streamId, OvhStreamColdStorageCompressionEnum coldStorageCompression, Boolean coldStorageEnabled, Boolean coldStorageNotifyEnabled, Long coldStorageRetention, String description, Boolean indexingEnabled, String optionId, String title, Boolean webSocketEnabled) throws IOException {
String qPath = "/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}";
StringBuilder sb = path(qPath, serviceName, streamId);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "coldStorageCompression", coldStorageCompression);
addBody(o, "coldStorageEnabled", coldStorageEnabled);
addBody(o, "coldStorageNotifyEnabled", coldStorageNotifyEnabled);
addBody(o, "coldStorageRetention", coldStorageRetention);
addBody(o, "description", description);
addBody(o, "indexingEnabled", indexingEnabled);
addBody(o, "optionId", optionId);
addBody(o, "title", title);
addBody(o, "webSocketEnabled", webSocketEnabled);
String resp = exec(qPath, "PUT", sb.toString(), o);
return convertTo(resp, OvhOperation.class);
}
|
[
"public",
"OvhOperation",
"serviceName_output_graylog_stream_streamId_PUT",
"(",
"String",
"serviceName",
",",
"String",
"streamId",
",",
"OvhStreamColdStorageCompressionEnum",
"coldStorageCompression",
",",
"Boolean",
"coldStorageEnabled",
",",
"Boolean",
"coldStorageNotifyEnabled",
",",
"Long",
"coldStorageRetention",
",",
"String",
"description",
",",
"Boolean",
"indexingEnabled",
",",
"String",
"optionId",
",",
"String",
"title",
",",
"Boolean",
"webSocketEnabled",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/dbaas/logs/{serviceName}/output/graylog/stream/{streamId}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
",",
"streamId",
")",
";",
"HashMap",
"<",
"String",
",",
"Object",
">",
"o",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"addBody",
"(",
"o",
",",
"\"coldStorageCompression\"",
",",
"coldStorageCompression",
")",
";",
"addBody",
"(",
"o",
",",
"\"coldStorageEnabled\"",
",",
"coldStorageEnabled",
")",
";",
"addBody",
"(",
"o",
",",
"\"coldStorageNotifyEnabled\"",
",",
"coldStorageNotifyEnabled",
")",
";",
"addBody",
"(",
"o",
",",
"\"coldStorageRetention\"",
",",
"coldStorageRetention",
")",
";",
"addBody",
"(",
"o",
",",
"\"description\"",
",",
"description",
")",
";",
"addBody",
"(",
"o",
",",
"\"indexingEnabled\"",
",",
"indexingEnabled",
")",
";",
"addBody",
"(",
"o",
",",
"\"optionId\"",
",",
"optionId",
")",
";",
"addBody",
"(",
"o",
",",
"\"title\"",
",",
"title",
")",
";",
"addBody",
"(",
"o",
",",
"\"webSocketEnabled\"",
",",
"webSocketEnabled",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"o",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"OvhOperation",
".",
"class",
")",
";",
"}"
] |
Update information of specified graylog stream
REST: PUT /dbaas/logs/{serviceName}/output/graylog/stream/{streamId}
@param serviceName [required] Service name
@param streamId [required] Stream ID
@param webSocketEnabled [required] Web socket enabled
@param indexingEnabled [required] ES indexing enabled
@param coldStorageRetention [required] Cold storage retention time
@param coldStorageCompression [required] Cold storage compression
@param description [required] Description
@param coldStorageNotifyEnabled [required] Cold storage notify enabled
@param optionId [required] Option ID
@param title [required] Title
@param coldStorageEnabled [required] Cold storage enabled
|
[
"Update",
"information",
"of",
"specified",
"graylog",
"stream"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-dbaaslogs/src/main/java/net/minidev/ovh/api/ApiOvhDbaaslogs.java#L1309-L1324
|
Bernardo-MG/repository-pattern-java
|
src/main/java/com/wandrell/pattern/repository/jpa/JpaRepository.java
|
JpaRepository.getCollection
|
@SuppressWarnings("unchecked")
@Override
public final Collection<V> getCollection(
final NamedParameterQueryData query,
final PaginationData pagination) {
"""
Queries the entities in the repository and returns a paginated subset of
them.
<p>
The collection is created by building a query from the received
{@code QueryData} and executing it.
@param query
the query user to acquire the entities
@return the queried and paginated subset of entities
"""
final Query builtQuery; // Query created from the query data
checkNotNull(query, "Received a null pointer as the query");
checkNotNull(pagination,
"Received a null pointer as the pagination data");
builtQuery = buildQuery(query);
// Sets the pagination
applyPagination(builtQuery, pagination);
// Processes the query
return builtQuery.getResultList();
}
|
java
|
@SuppressWarnings("unchecked")
@Override
public final Collection<V> getCollection(
final NamedParameterQueryData query,
final PaginationData pagination) {
final Query builtQuery; // Query created from the query data
checkNotNull(query, "Received a null pointer as the query");
checkNotNull(pagination,
"Received a null pointer as the pagination data");
builtQuery = buildQuery(query);
// Sets the pagination
applyPagination(builtQuery, pagination);
// Processes the query
return builtQuery.getResultList();
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"public",
"final",
"Collection",
"<",
"V",
">",
"getCollection",
"(",
"final",
"NamedParameterQueryData",
"query",
",",
"final",
"PaginationData",
"pagination",
")",
"{",
"final",
"Query",
"builtQuery",
";",
"// Query created from the query data",
"checkNotNull",
"(",
"query",
",",
"\"Received a null pointer as the query\"",
")",
";",
"checkNotNull",
"(",
"pagination",
",",
"\"Received a null pointer as the pagination data\"",
")",
";",
"builtQuery",
"=",
"buildQuery",
"(",
"query",
")",
";",
"// Sets the pagination",
"applyPagination",
"(",
"builtQuery",
",",
"pagination",
")",
";",
"// Processes the query",
"return",
"builtQuery",
".",
"getResultList",
"(",
")",
";",
"}"
] |
Queries the entities in the repository and returns a paginated subset of
them.
<p>
The collection is created by building a query from the received
{@code QueryData} and executing it.
@param query
the query user to acquire the entities
@return the queried and paginated subset of entities
|
[
"Queries",
"the",
"entities",
"in",
"the",
"repository",
"and",
"returns",
"a",
"paginated",
"subset",
"of",
"them",
".",
"<p",
">",
"The",
"collection",
"is",
"created",
"by",
"building",
"a",
"query",
"from",
"the",
"received",
"{",
"@code",
"QueryData",
"}",
"and",
"executing",
"it",
"."
] |
train
|
https://github.com/Bernardo-MG/repository-pattern-java/blob/e94d5bbf9aeeb45acc8485f3686a6e791b082ea8/src/main/java/com/wandrell/pattern/repository/jpa/JpaRepository.java#L218-L236
|
apache/flink
|
flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java
|
ZooKeeperUtils.startCuratorFramework
|
public static CuratorFramework startCuratorFramework(Configuration configuration) {
"""
Starts a {@link CuratorFramework} instance and connects it to the given ZooKeeper
quorum.
@param configuration {@link Configuration} object containing the configuration values
@return {@link CuratorFramework} instance
"""
Preconditions.checkNotNull(configuration, "configuration");
String zkQuorum = configuration.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM);
if (zkQuorum == null || StringUtils.isBlank(zkQuorum)) {
throw new RuntimeException("No valid ZooKeeper quorum has been specified. " +
"You can specify the quorum via the configuration key '" +
HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM.key() + "'.");
}
int sessionTimeout = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_SESSION_TIMEOUT);
int connectionTimeout = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_CONNECTION_TIMEOUT);
int retryWait = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_RETRY_WAIT);
int maxRetryAttempts = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_MAX_RETRY_ATTEMPTS);
String root = configuration.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_ROOT);
String namespace = configuration.getValue(HighAvailabilityOptions.HA_CLUSTER_ID);
boolean disableSaslClient = configuration.getBoolean(SecurityOptions.ZOOKEEPER_SASL_DISABLE);
ACLProvider aclProvider;
ZkClientACLMode aclMode = ZkClientACLMode.fromConfig(configuration);
if (disableSaslClient && aclMode == ZkClientACLMode.CREATOR) {
String errorMessage = "Cannot set ACL role to " + aclMode + " since SASL authentication is " +
"disabled through the " + SecurityOptions.ZOOKEEPER_SASL_DISABLE.key() + " property";
LOG.warn(errorMessage);
throw new IllegalConfigurationException(errorMessage);
}
if (aclMode == ZkClientACLMode.CREATOR) {
LOG.info("Enforcing creator for ZK connections");
aclProvider = new SecureAclProvider();
} else {
LOG.info("Enforcing default ACL for ZK connections");
aclProvider = new DefaultACLProvider();
}
String rootWithNamespace = generateZookeeperPath(root, namespace);
LOG.info("Using '{}' as Zookeeper namespace.", rootWithNamespace);
CuratorFramework cf = CuratorFrameworkFactory.builder()
.connectString(zkQuorum)
.sessionTimeoutMs(sessionTimeout)
.connectionTimeoutMs(connectionTimeout)
.retryPolicy(new ExponentialBackoffRetry(retryWait, maxRetryAttempts))
// Curator prepends a '/' manually and throws an Exception if the
// namespace starts with a '/'.
.namespace(rootWithNamespace.startsWith("/") ? rootWithNamespace.substring(1) : rootWithNamespace)
.aclProvider(aclProvider)
.build();
cf.start();
return cf;
}
|
java
|
public static CuratorFramework startCuratorFramework(Configuration configuration) {
Preconditions.checkNotNull(configuration, "configuration");
String zkQuorum = configuration.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM);
if (zkQuorum == null || StringUtils.isBlank(zkQuorum)) {
throw new RuntimeException("No valid ZooKeeper quorum has been specified. " +
"You can specify the quorum via the configuration key '" +
HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM.key() + "'.");
}
int sessionTimeout = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_SESSION_TIMEOUT);
int connectionTimeout = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_CONNECTION_TIMEOUT);
int retryWait = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_RETRY_WAIT);
int maxRetryAttempts = configuration.getInteger(HighAvailabilityOptions.ZOOKEEPER_MAX_RETRY_ATTEMPTS);
String root = configuration.getValue(HighAvailabilityOptions.HA_ZOOKEEPER_ROOT);
String namespace = configuration.getValue(HighAvailabilityOptions.HA_CLUSTER_ID);
boolean disableSaslClient = configuration.getBoolean(SecurityOptions.ZOOKEEPER_SASL_DISABLE);
ACLProvider aclProvider;
ZkClientACLMode aclMode = ZkClientACLMode.fromConfig(configuration);
if (disableSaslClient && aclMode == ZkClientACLMode.CREATOR) {
String errorMessage = "Cannot set ACL role to " + aclMode + " since SASL authentication is " +
"disabled through the " + SecurityOptions.ZOOKEEPER_SASL_DISABLE.key() + " property";
LOG.warn(errorMessage);
throw new IllegalConfigurationException(errorMessage);
}
if (aclMode == ZkClientACLMode.CREATOR) {
LOG.info("Enforcing creator for ZK connections");
aclProvider = new SecureAclProvider();
} else {
LOG.info("Enforcing default ACL for ZK connections");
aclProvider = new DefaultACLProvider();
}
String rootWithNamespace = generateZookeeperPath(root, namespace);
LOG.info("Using '{}' as Zookeeper namespace.", rootWithNamespace);
CuratorFramework cf = CuratorFrameworkFactory.builder()
.connectString(zkQuorum)
.sessionTimeoutMs(sessionTimeout)
.connectionTimeoutMs(connectionTimeout)
.retryPolicy(new ExponentialBackoffRetry(retryWait, maxRetryAttempts))
// Curator prepends a '/' manually and throws an Exception if the
// namespace starts with a '/'.
.namespace(rootWithNamespace.startsWith("/") ? rootWithNamespace.substring(1) : rootWithNamespace)
.aclProvider(aclProvider)
.build();
cf.start();
return cf;
}
|
[
"public",
"static",
"CuratorFramework",
"startCuratorFramework",
"(",
"Configuration",
"configuration",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"configuration",
",",
"\"configuration\"",
")",
";",
"String",
"zkQuorum",
"=",
"configuration",
".",
"getValue",
"(",
"HighAvailabilityOptions",
".",
"HA_ZOOKEEPER_QUORUM",
")",
";",
"if",
"(",
"zkQuorum",
"==",
"null",
"||",
"StringUtils",
".",
"isBlank",
"(",
"zkQuorum",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"No valid ZooKeeper quorum has been specified. \"",
"+",
"\"You can specify the quorum via the configuration key '\"",
"+",
"HighAvailabilityOptions",
".",
"HA_ZOOKEEPER_QUORUM",
".",
"key",
"(",
")",
"+",
"\"'.\"",
")",
";",
"}",
"int",
"sessionTimeout",
"=",
"configuration",
".",
"getInteger",
"(",
"HighAvailabilityOptions",
".",
"ZOOKEEPER_SESSION_TIMEOUT",
")",
";",
"int",
"connectionTimeout",
"=",
"configuration",
".",
"getInteger",
"(",
"HighAvailabilityOptions",
".",
"ZOOKEEPER_CONNECTION_TIMEOUT",
")",
";",
"int",
"retryWait",
"=",
"configuration",
".",
"getInteger",
"(",
"HighAvailabilityOptions",
".",
"ZOOKEEPER_RETRY_WAIT",
")",
";",
"int",
"maxRetryAttempts",
"=",
"configuration",
".",
"getInteger",
"(",
"HighAvailabilityOptions",
".",
"ZOOKEEPER_MAX_RETRY_ATTEMPTS",
")",
";",
"String",
"root",
"=",
"configuration",
".",
"getValue",
"(",
"HighAvailabilityOptions",
".",
"HA_ZOOKEEPER_ROOT",
")",
";",
"String",
"namespace",
"=",
"configuration",
".",
"getValue",
"(",
"HighAvailabilityOptions",
".",
"HA_CLUSTER_ID",
")",
";",
"boolean",
"disableSaslClient",
"=",
"configuration",
".",
"getBoolean",
"(",
"SecurityOptions",
".",
"ZOOKEEPER_SASL_DISABLE",
")",
";",
"ACLProvider",
"aclProvider",
";",
"ZkClientACLMode",
"aclMode",
"=",
"ZkClientACLMode",
".",
"fromConfig",
"(",
"configuration",
")",
";",
"if",
"(",
"disableSaslClient",
"&&",
"aclMode",
"==",
"ZkClientACLMode",
".",
"CREATOR",
")",
"{",
"String",
"errorMessage",
"=",
"\"Cannot set ACL role to \"",
"+",
"aclMode",
"+",
"\" since SASL authentication is \"",
"+",
"\"disabled through the \"",
"+",
"SecurityOptions",
".",
"ZOOKEEPER_SASL_DISABLE",
".",
"key",
"(",
")",
"+",
"\" property\"",
";",
"LOG",
".",
"warn",
"(",
"errorMessage",
")",
";",
"throw",
"new",
"IllegalConfigurationException",
"(",
"errorMessage",
")",
";",
"}",
"if",
"(",
"aclMode",
"==",
"ZkClientACLMode",
".",
"CREATOR",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Enforcing creator for ZK connections\"",
")",
";",
"aclProvider",
"=",
"new",
"SecureAclProvider",
"(",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"Enforcing default ACL for ZK connections\"",
")",
";",
"aclProvider",
"=",
"new",
"DefaultACLProvider",
"(",
")",
";",
"}",
"String",
"rootWithNamespace",
"=",
"generateZookeeperPath",
"(",
"root",
",",
"namespace",
")",
";",
"LOG",
".",
"info",
"(",
"\"Using '{}' as Zookeeper namespace.\"",
",",
"rootWithNamespace",
")",
";",
"CuratorFramework",
"cf",
"=",
"CuratorFrameworkFactory",
".",
"builder",
"(",
")",
".",
"connectString",
"(",
"zkQuorum",
")",
".",
"sessionTimeoutMs",
"(",
"sessionTimeout",
")",
".",
"connectionTimeoutMs",
"(",
"connectionTimeout",
")",
".",
"retryPolicy",
"(",
"new",
"ExponentialBackoffRetry",
"(",
"retryWait",
",",
"maxRetryAttempts",
")",
")",
"// Curator prepends a '/' manually and throws an Exception if the",
"// namespace starts with a '/'.",
".",
"namespace",
"(",
"rootWithNamespace",
".",
"startsWith",
"(",
"\"/\"",
")",
"?",
"rootWithNamespace",
".",
"substring",
"(",
"1",
")",
":",
"rootWithNamespace",
")",
".",
"aclProvider",
"(",
"aclProvider",
")",
".",
"build",
"(",
")",
";",
"cf",
".",
"start",
"(",
")",
";",
"return",
"cf",
";",
"}"
] |
Starts a {@link CuratorFramework} instance and connects it to the given ZooKeeper
quorum.
@param configuration {@link Configuration} object containing the configuration values
@return {@link CuratorFramework} instance
|
[
"Starts",
"a",
"{",
"@link",
"CuratorFramework",
"}",
"instance",
"and",
"connects",
"it",
"to",
"the",
"given",
"ZooKeeper",
"quorum",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-runtime/src/main/java/org/apache/flink/runtime/util/ZooKeeperUtils.java#L73-L134
|
emilsjolander/sprinkles
|
library/src/main/java/se/emilsjolander/sprinkles/Sprinkles.java
|
Sprinkles.getDatabase
|
static synchronized SQLiteDatabase getDatabase() {
"""
Throws SprinklesNotInitializedException if you try to access the database before initializing Sprinkles.
@return the SQL Database used by Sprinkles.
"""
if(sInstance == null) {
throw new SprinklesNotInitializedException();
}
if(sDatabase == null) {
DbOpenHelper dbOpenHelper = new DbOpenHelper(sInstance.mContext, sInstance.databaseName, sInstance.initialDatabaseVersion);
sDatabase = dbOpenHelper.getWritableDatabase();
}
return sDatabase;
}
|
java
|
static synchronized SQLiteDatabase getDatabase() {
if(sInstance == null) {
throw new SprinklesNotInitializedException();
}
if(sDatabase == null) {
DbOpenHelper dbOpenHelper = new DbOpenHelper(sInstance.mContext, sInstance.databaseName, sInstance.initialDatabaseVersion);
sDatabase = dbOpenHelper.getWritableDatabase();
}
return sDatabase;
}
|
[
"static",
"synchronized",
"SQLiteDatabase",
"getDatabase",
"(",
")",
"{",
"if",
"(",
"sInstance",
"==",
"null",
")",
"{",
"throw",
"new",
"SprinklesNotInitializedException",
"(",
")",
";",
"}",
"if",
"(",
"sDatabase",
"==",
"null",
")",
"{",
"DbOpenHelper",
"dbOpenHelper",
"=",
"new",
"DbOpenHelper",
"(",
"sInstance",
".",
"mContext",
",",
"sInstance",
".",
"databaseName",
",",
"sInstance",
".",
"initialDatabaseVersion",
")",
";",
"sDatabase",
"=",
"dbOpenHelper",
".",
"getWritableDatabase",
"(",
")",
";",
"}",
"return",
"sDatabase",
";",
"}"
] |
Throws SprinklesNotInitializedException if you try to access the database before initializing Sprinkles.
@return the SQL Database used by Sprinkles.
|
[
"Throws",
"SprinklesNotInitializedException",
"if",
"you",
"try",
"to",
"access",
"the",
"database",
"before",
"initializing",
"Sprinkles",
"."
] |
train
|
https://github.com/emilsjolander/sprinkles/blob/3a666f18ee5158db6fe3b4f4346b470481559606/library/src/main/java/se/emilsjolander/sprinkles/Sprinkles.java#L113-L124
|
aspectran/aspectran
|
core/src/main/java/com/aspectran/core/component/session/AbstractSessionHandler.java
|
AbstractSessionHandler.bindValue
|
private void bindValue(Session session, String name, Object value) {
"""
Bind value if value implements {@link SessionBindingListener}
(calls {@link SessionBindingListener#valueBound(Session, String, Object)})
@param session the basic session
@param name the name with which the object is bound or unbound
@param value the bound value
"""
if (value instanceof SessionBindingListener) {
((SessionBindingListener)value).valueBound(session, name, value);
}
}
|
java
|
private void bindValue(Session session, String name, Object value) {
if (value instanceof SessionBindingListener) {
((SessionBindingListener)value).valueBound(session, name, value);
}
}
|
[
"private",
"void",
"bindValue",
"(",
"Session",
"session",
",",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"SessionBindingListener",
")",
"{",
"(",
"(",
"SessionBindingListener",
")",
"value",
")",
".",
"valueBound",
"(",
"session",
",",
"name",
",",
"value",
")",
";",
"}",
"}"
] |
Bind value if value implements {@link SessionBindingListener}
(calls {@link SessionBindingListener#valueBound(Session, String, Object)})
@param session the basic session
@param name the name with which the object is bound or unbound
@param value the bound value
|
[
"Bind",
"value",
"if",
"value",
"implements",
"{",
"@link",
"SessionBindingListener",
"}",
"(",
"calls",
"{",
"@link",
"SessionBindingListener#valueBound",
"(",
"Session",
"String",
"Object",
")",
"}",
")"
] |
train
|
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/AbstractSessionHandler.java#L300-L304
|
Azure/azure-sdk-for-java
|
cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java
|
ModelsImpl.deleteCompositeEntityRoleAsync
|
public Observable<OperationStatus> deleteCompositeEntityRoleAsync(UUID appId, String versionId, UUID cEntityId, UUID roleId) {
"""
Delete an entity role.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@param roleId The entity role Id.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object
"""
return deleteCompositeEntityRoleWithServiceResponseAsync(appId, versionId, cEntityId, roleId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
}
|
java
|
public Observable<OperationStatus> deleteCompositeEntityRoleAsync(UUID appId, String versionId, UUID cEntityId, UUID roleId) {
return deleteCompositeEntityRoleWithServiceResponseAsync(appId, versionId, cEntityId, roleId).map(new Func1<ServiceResponse<OperationStatus>, OperationStatus>() {
@Override
public OperationStatus call(ServiceResponse<OperationStatus> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"OperationStatus",
">",
"deleteCompositeEntityRoleAsync",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"cEntityId",
",",
"UUID",
"roleId",
")",
"{",
"return",
"deleteCompositeEntityRoleWithServiceResponseAsync",
"(",
"appId",
",",
"versionId",
",",
"cEntityId",
",",
"roleId",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"OperationStatus",
">",
",",
"OperationStatus",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OperationStatus",
"call",
"(",
"ServiceResponse",
"<",
"OperationStatus",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Delete an entity role.
@param appId The application ID.
@param versionId The version ID.
@param cEntityId The composite entity extractor ID.
@param roleId The entity role Id.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the OperationStatus object
|
[
"Delete",
"an",
"entity",
"role",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L12688-L12695
|
TinkoffCreditSystems/decoro
|
library/src/main/java/ru/tinkoff/decoro/MaskImpl.java
|
MaskImpl.validSlotIndexOffset
|
private SlotIndexOffset validSlotIndexOffset(Slot slot, final char value) {
"""
Looks for a slot to insert {@code value}. Search moves to the right from the specified one
(including it). While searching it checks whether the're any non-hardcoded slots that cannot
accept pending input if such slots are found it is marked in a resulting object.
@param slot slot from where to start
@param value value to be inserted to slot
@return wrapper around index offset to the found slot and flag showing did search skip any
non-hardcoded slots
"""
final SlotIndexOffset result = new SlotIndexOffset();
while (slot != null && !slot.canInsertHere(value)) {
if (!result.nonHarcodedSlotSkipped && !slot.hardcoded()) {
result.nonHarcodedSlotSkipped = true;
}
slot = slot.getNextSlot();
result.indexOffset++;
}
return result;
}
|
java
|
private SlotIndexOffset validSlotIndexOffset(Slot slot, final char value) {
final SlotIndexOffset result = new SlotIndexOffset();
while (slot != null && !slot.canInsertHere(value)) {
if (!result.nonHarcodedSlotSkipped && !slot.hardcoded()) {
result.nonHarcodedSlotSkipped = true;
}
slot = slot.getNextSlot();
result.indexOffset++;
}
return result;
}
|
[
"private",
"SlotIndexOffset",
"validSlotIndexOffset",
"(",
"Slot",
"slot",
",",
"final",
"char",
"value",
")",
"{",
"final",
"SlotIndexOffset",
"result",
"=",
"new",
"SlotIndexOffset",
"(",
")",
";",
"while",
"(",
"slot",
"!=",
"null",
"&&",
"!",
"slot",
".",
"canInsertHere",
"(",
"value",
")",
")",
"{",
"if",
"(",
"!",
"result",
".",
"nonHarcodedSlotSkipped",
"&&",
"!",
"slot",
".",
"hardcoded",
"(",
")",
")",
"{",
"result",
".",
"nonHarcodedSlotSkipped",
"=",
"true",
";",
"}",
"slot",
"=",
"slot",
".",
"getNextSlot",
"(",
")",
";",
"result",
".",
"indexOffset",
"++",
";",
"}",
"return",
"result",
";",
"}"
] |
Looks for a slot to insert {@code value}. Search moves to the right from the specified one
(including it). While searching it checks whether the're any non-hardcoded slots that cannot
accept pending input if such slots are found it is marked in a resulting object.
@param slot slot from where to start
@param value value to be inserted to slot
@return wrapper around index offset to the found slot and flag showing did search skip any
non-hardcoded slots
|
[
"Looks",
"for",
"a",
"slot",
"to",
"insert",
"{",
"@code",
"value",
"}",
".",
"Search",
"moves",
"to",
"the",
"right",
"from",
"the",
"specified",
"one",
"(",
"including",
"it",
")",
".",
"While",
"searching",
"it",
"checks",
"whether",
"the",
"re",
"any",
"non",
"-",
"hardcoded",
"slots",
"that",
"cannot",
"accept",
"pending",
"input",
"if",
"such",
"slots",
"are",
"found",
"it",
"is",
"marked",
"in",
"a",
"resulting",
"object",
"."
] |
train
|
https://github.com/TinkoffCreditSystems/decoro/blob/f2693d0b3def13aabf59cf642fc0b6f5c8c94f63/library/src/main/java/ru/tinkoff/decoro/MaskImpl.java#L454-L466
|
alkacon/opencms-core
|
src/org/opencms/ade/configuration/CmsADEManager.java
|
CmsADEManager.isDetailPage
|
public boolean isDetailPage(CmsObject cms, CmsResource resource) {
"""
Checks whether the given resource is configured as a detail page.<p>
@param cms the current CMS context
@param resource the resource which should be tested
@return true if the resource is configured as a detail page
"""
return getCache(isOnline(cms)).isDetailPage(cms, resource);
}
|
java
|
public boolean isDetailPage(CmsObject cms, CmsResource resource) {
return getCache(isOnline(cms)).isDetailPage(cms, resource);
}
|
[
"public",
"boolean",
"isDetailPage",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
")",
"{",
"return",
"getCache",
"(",
"isOnline",
"(",
"cms",
")",
")",
".",
"isDetailPage",
"(",
"cms",
",",
"resource",
")",
";",
"}"
] |
Checks whether the given resource is configured as a detail page.<p>
@param cms the current CMS context
@param resource the resource which should be tested
@return true if the resource is configured as a detail page
|
[
"Checks",
"whether",
"the",
"given",
"resource",
"is",
"configured",
"as",
"a",
"detail",
"page",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ade/configuration/CmsADEManager.java#L1104-L1107
|
elki-project/elki
|
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/ListParameterization.java
|
ListParameterization.addFlag
|
public ListParameterization addFlag(OptionID optionid) {
"""
Add a flag to the parameter list
@param optionid Option ID
@return this, for chaining
"""
parameters.add(new ParameterPair(optionid, Flag.SET));
return this;
}
|
java
|
public ListParameterization addFlag(OptionID optionid) {
parameters.add(new ParameterPair(optionid, Flag.SET));
return this;
}
|
[
"public",
"ListParameterization",
"addFlag",
"(",
"OptionID",
"optionid",
")",
"{",
"parameters",
".",
"add",
"(",
"new",
"ParameterPair",
"(",
"optionid",
",",
"Flag",
".",
"SET",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Add a flag to the parameter list
@param optionid Option ID
@return this, for chaining
|
[
"Add",
"a",
"flag",
"to",
"the",
"parameter",
"list"
] |
train
|
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/ListParameterization.java#L77-L80
|
wdullaer/SwipeActionAdapter
|
library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java
|
SwipeActionAdapter.onSwipeStarted
|
@Override
public void onSwipeStarted(ListView listView, int position, SwipeDirection direction) {
"""
Called once the user touches the screen and starts swiping in any direction
@param listView The originating {@link ListView}.
@param position The position to perform the action on, sorted in descending order
for convenience.
@param direction The type of swipe that triggered the action
"""
if(mSwipeActionListener != null) mSwipeActionListener.onSwipeStarted(listView, position, direction);
}
|
java
|
@Override
public void onSwipeStarted(ListView listView, int position, SwipeDirection direction) {
if(mSwipeActionListener != null) mSwipeActionListener.onSwipeStarted(listView, position, direction);
}
|
[
"@",
"Override",
"public",
"void",
"onSwipeStarted",
"(",
"ListView",
"listView",
",",
"int",
"position",
",",
"SwipeDirection",
"direction",
")",
"{",
"if",
"(",
"mSwipeActionListener",
"!=",
"null",
")",
"mSwipeActionListener",
".",
"onSwipeStarted",
"(",
"listView",
",",
"position",
",",
"direction",
")",
";",
"}"
] |
Called once the user touches the screen and starts swiping in any direction
@param listView The originating {@link ListView}.
@param position The position to perform the action on, sorted in descending order
for convenience.
@param direction The type of swipe that triggered the action
|
[
"Called",
"once",
"the",
"user",
"touches",
"the",
"screen",
"and",
"starts",
"swiping",
"in",
"any",
"direction"
] |
train
|
https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeActionAdapter.java#L118-L121
|
grpc/grpc-java
|
api/src/main/java/io/grpc/ServerInterceptors.java
|
ServerInterceptors.useMarshalledMessages
|
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1712")
public static <T> ServerServiceDefinition useMarshalledMessages(
final ServerServiceDefinition serviceDef,
final MethodDescriptor.Marshaller<T> marshaller) {
"""
Create a new {@code ServerServiceDefinition} whose {@link MethodDescriptor} serializes to
and from T for all methods. The {@code ServerCallHandler} created will automatically
convert back to the original types for request and response before calling the existing
{@code ServerCallHandler}. Calling this method combined with the intercept methods will
allow the developer to choose whether to intercept messages of T, or the modeled types
of their application. This can also be chained to allow for interceptors to handle messages
as multiple different T types within the chain if the added cost of serialization is not
a concern.
@param serviceDef the service definition to convert messages to T
@return a wrapped version of {@code serviceDef} with the T conversion applied.
"""
List<ServerMethodDefinition<?, ?>> wrappedMethods =
new ArrayList<>();
List<MethodDescriptor<?, ?>> wrappedDescriptors =
new ArrayList<>();
// Wrap the descriptors
for (final ServerMethodDefinition<?, ?> definition : serviceDef.getMethods()) {
final MethodDescriptor<?, ?> originalMethodDescriptor = definition.getMethodDescriptor();
final MethodDescriptor<T, T> wrappedMethodDescriptor =
originalMethodDescriptor.toBuilder(marshaller, marshaller).build();
wrappedDescriptors.add(wrappedMethodDescriptor);
wrappedMethods.add(wrapMethod(definition, wrappedMethodDescriptor));
}
// Build the new service descriptor
final ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition
.builder(new ServiceDescriptor(serviceDef.getServiceDescriptor().getName(),
wrappedDescriptors));
// Create the new service definiton.
for (ServerMethodDefinition<?, ?> definition : wrappedMethods) {
serviceBuilder.addMethod(definition);
}
return serviceBuilder.build();
}
|
java
|
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1712")
public static <T> ServerServiceDefinition useMarshalledMessages(
final ServerServiceDefinition serviceDef,
final MethodDescriptor.Marshaller<T> marshaller) {
List<ServerMethodDefinition<?, ?>> wrappedMethods =
new ArrayList<>();
List<MethodDescriptor<?, ?>> wrappedDescriptors =
new ArrayList<>();
// Wrap the descriptors
for (final ServerMethodDefinition<?, ?> definition : serviceDef.getMethods()) {
final MethodDescriptor<?, ?> originalMethodDescriptor = definition.getMethodDescriptor();
final MethodDescriptor<T, T> wrappedMethodDescriptor =
originalMethodDescriptor.toBuilder(marshaller, marshaller).build();
wrappedDescriptors.add(wrappedMethodDescriptor);
wrappedMethods.add(wrapMethod(definition, wrappedMethodDescriptor));
}
// Build the new service descriptor
final ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition
.builder(new ServiceDescriptor(serviceDef.getServiceDescriptor().getName(),
wrappedDescriptors));
// Create the new service definiton.
for (ServerMethodDefinition<?, ?> definition : wrappedMethods) {
serviceBuilder.addMethod(definition);
}
return serviceBuilder.build();
}
|
[
"@",
"ExperimentalApi",
"(",
"\"https://github.com/grpc/grpc-java/issues/1712\"",
")",
"public",
"static",
"<",
"T",
">",
"ServerServiceDefinition",
"useMarshalledMessages",
"(",
"final",
"ServerServiceDefinition",
"serviceDef",
",",
"final",
"MethodDescriptor",
".",
"Marshaller",
"<",
"T",
">",
"marshaller",
")",
"{",
"List",
"<",
"ServerMethodDefinition",
"<",
"?",
",",
"?",
">",
">",
"wrappedMethods",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"MethodDescriptor",
"<",
"?",
",",
"?",
">",
">",
"wrappedDescriptors",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// Wrap the descriptors",
"for",
"(",
"final",
"ServerMethodDefinition",
"<",
"?",
",",
"?",
">",
"definition",
":",
"serviceDef",
".",
"getMethods",
"(",
")",
")",
"{",
"final",
"MethodDescriptor",
"<",
"?",
",",
"?",
">",
"originalMethodDescriptor",
"=",
"definition",
".",
"getMethodDescriptor",
"(",
")",
";",
"final",
"MethodDescriptor",
"<",
"T",
",",
"T",
">",
"wrappedMethodDescriptor",
"=",
"originalMethodDescriptor",
".",
"toBuilder",
"(",
"marshaller",
",",
"marshaller",
")",
".",
"build",
"(",
")",
";",
"wrappedDescriptors",
".",
"add",
"(",
"wrappedMethodDescriptor",
")",
";",
"wrappedMethods",
".",
"add",
"(",
"wrapMethod",
"(",
"definition",
",",
"wrappedMethodDescriptor",
")",
")",
";",
"}",
"// Build the new service descriptor",
"final",
"ServerServiceDefinition",
".",
"Builder",
"serviceBuilder",
"=",
"ServerServiceDefinition",
".",
"builder",
"(",
"new",
"ServiceDescriptor",
"(",
"serviceDef",
".",
"getServiceDescriptor",
"(",
")",
".",
"getName",
"(",
")",
",",
"wrappedDescriptors",
")",
")",
";",
"// Create the new service definiton.",
"for",
"(",
"ServerMethodDefinition",
"<",
"?",
",",
"?",
">",
"definition",
":",
"wrappedMethods",
")",
"{",
"serviceBuilder",
".",
"addMethod",
"(",
"definition",
")",
";",
"}",
"return",
"serviceBuilder",
".",
"build",
"(",
")",
";",
"}"
] |
Create a new {@code ServerServiceDefinition} whose {@link MethodDescriptor} serializes to
and from T for all methods. The {@code ServerCallHandler} created will automatically
convert back to the original types for request and response before calling the existing
{@code ServerCallHandler}. Calling this method combined with the intercept methods will
allow the developer to choose whether to intercept messages of T, or the modeled types
of their application. This can also be chained to allow for interceptors to handle messages
as multiple different T types within the chain if the added cost of serialization is not
a concern.
@param serviceDef the service definition to convert messages to T
@return a wrapped version of {@code serviceDef} with the T conversion applied.
|
[
"Create",
"a",
"new",
"{",
"@code",
"ServerServiceDefinition",
"}",
"whose",
"{",
"@link",
"MethodDescriptor",
"}",
"serializes",
"to",
"and",
"from",
"T",
"for",
"all",
"methods",
".",
"The",
"{",
"@code",
"ServerCallHandler",
"}",
"created",
"will",
"automatically",
"convert",
"back",
"to",
"the",
"original",
"types",
"for",
"request",
"and",
"response",
"before",
"calling",
"the",
"existing",
"{",
"@code",
"ServerCallHandler",
"}",
".",
"Calling",
"this",
"method",
"combined",
"with",
"the",
"intercept",
"methods",
"will",
"allow",
"the",
"developer",
"to",
"choose",
"whether",
"to",
"intercept",
"messages",
"of",
"T",
"or",
"the",
"modeled",
"types",
"of",
"their",
"application",
".",
"This",
"can",
"also",
"be",
"chained",
"to",
"allow",
"for",
"interceptors",
"to",
"handle",
"messages",
"as",
"multiple",
"different",
"T",
"types",
"within",
"the",
"chain",
"if",
"the",
"added",
"cost",
"of",
"serialization",
"is",
"not",
"a",
"concern",
"."
] |
train
|
https://github.com/grpc/grpc-java/blob/973885457f9609de232d2553b82c67f6c3ff57bf/api/src/main/java/io/grpc/ServerInterceptors.java#L173-L198
|
phax/ph-css
|
ph-css/src/main/java/com/helger/css/handler/CSSHandler.java
|
CSSHandler.readCascadingStyleSheetFromNode
|
@Nonnull
public static CascadingStyleSheet readCascadingStyleSheetFromNode (@Nonnull final ECSSVersion eVersion,
@Nonnull final CSSNode aNode,
@Nonnull final ICSSInterpretErrorHandler aErrorHandler) {
"""
Create a {@link CascadingStyleSheet} object from a parsed object.
@param eVersion
The CSS version to use. May not be <code>null</code>.
@param aNode
The parsed CSS object to read. May not be <code>null</code>.
@param aErrorHandler
The error handler to be used. May not be <code>null</code>.
@return Never <code>null</code>.
@since 5.0.2
"""
ValueEnforcer.notNull (eVersion, "Version");
ValueEnforcer.notNull (aNode, "Node");
if (!ECSSNodeType.ROOT.isNode (aNode, eVersion))
throw new CSSHandlingException (aNode, "Passed node is not a root node!");
ValueEnforcer.notNull (aErrorHandler, "ErrorHandler");
return new CSSNodeToDomainObject (eVersion, aErrorHandler).createCascadingStyleSheetFromNode (aNode);
}
|
java
|
@Nonnull
public static CascadingStyleSheet readCascadingStyleSheetFromNode (@Nonnull final ECSSVersion eVersion,
@Nonnull final CSSNode aNode,
@Nonnull final ICSSInterpretErrorHandler aErrorHandler)
{
ValueEnforcer.notNull (eVersion, "Version");
ValueEnforcer.notNull (aNode, "Node");
if (!ECSSNodeType.ROOT.isNode (aNode, eVersion))
throw new CSSHandlingException (aNode, "Passed node is not a root node!");
ValueEnforcer.notNull (aErrorHandler, "ErrorHandler");
return new CSSNodeToDomainObject (eVersion, aErrorHandler).createCascadingStyleSheetFromNode (aNode);
}
|
[
"@",
"Nonnull",
"public",
"static",
"CascadingStyleSheet",
"readCascadingStyleSheetFromNode",
"(",
"@",
"Nonnull",
"final",
"ECSSVersion",
"eVersion",
",",
"@",
"Nonnull",
"final",
"CSSNode",
"aNode",
",",
"@",
"Nonnull",
"final",
"ICSSInterpretErrorHandler",
"aErrorHandler",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"eVersion",
",",
"\"Version\"",
")",
";",
"ValueEnforcer",
".",
"notNull",
"(",
"aNode",
",",
"\"Node\"",
")",
";",
"if",
"(",
"!",
"ECSSNodeType",
".",
"ROOT",
".",
"isNode",
"(",
"aNode",
",",
"eVersion",
")",
")",
"throw",
"new",
"CSSHandlingException",
"(",
"aNode",
",",
"\"Passed node is not a root node!\"",
")",
";",
"ValueEnforcer",
".",
"notNull",
"(",
"aErrorHandler",
",",
"\"ErrorHandler\"",
")",
";",
"return",
"new",
"CSSNodeToDomainObject",
"(",
"eVersion",
",",
"aErrorHandler",
")",
".",
"createCascadingStyleSheetFromNode",
"(",
"aNode",
")",
";",
"}"
] |
Create a {@link CascadingStyleSheet} object from a parsed object.
@param eVersion
The CSS version to use. May not be <code>null</code>.
@param aNode
The parsed CSS object to read. May not be <code>null</code>.
@param aErrorHandler
The error handler to be used. May not be <code>null</code>.
@return Never <code>null</code>.
@since 5.0.2
|
[
"Create",
"a",
"{",
"@link",
"CascadingStyleSheet",
"}",
"object",
"from",
"a",
"parsed",
"object",
"."
] |
train
|
https://github.com/phax/ph-css/blob/c9da5bb4decc681de6e27ce31712aad4c00adafa/ph-css/src/main/java/com/helger/css/handler/CSSHandler.java#L75-L87
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java
|
ApiOvhTelephony.billingAccount_PUT
|
public void billingAccount_PUT(String billingAccount, OvhBillingAccount body) throws IOException {
"""
Alter this object properties
REST: PUT /telephony/{billingAccount}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
"""
String qPath = "/telephony/{billingAccount}";
StringBuilder sb = path(qPath, billingAccount);
exec(qPath, "PUT", sb.toString(), body);
}
|
java
|
public void billingAccount_PUT(String billingAccount, OvhBillingAccount body) throws IOException {
String qPath = "/telephony/{billingAccount}";
StringBuilder sb = path(qPath, billingAccount);
exec(qPath, "PUT", sb.toString(), body);
}
|
[
"public",
"void",
"billingAccount_PUT",
"(",
"String",
"billingAccount",
",",
"OvhBillingAccount",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"billingAccount",
")",
";",
"exec",
"(",
"qPath",
",",
"\"PUT\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"body",
")",
";",
"}"
] |
Alter this object properties
REST: PUT /telephony/{billingAccount}
@param body [required] New object properties
@param billingAccount [required] The name of your billingAccount
|
[
"Alter",
"this",
"object",
"properties"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L3675-L3679
|
intive-FDV/DynamicJasper
|
src/main/java/ar/com/fdvs/dj/domain/chart/dataset/XYDataset.java
|
XYDataset.addSerie
|
public void addSerie(AbstractColumn column, StringExpression labelExpression) {
"""
Adds the specified serie column to the dataset with custom label expression.
@param column the serie column
@param labelExpression column the custom label expression
"""
series.add(column);
seriesLabels.put(column, labelExpression);
}
|
java
|
public void addSerie(AbstractColumn column, StringExpression labelExpression) {
series.add(column);
seriesLabels.put(column, labelExpression);
}
|
[
"public",
"void",
"addSerie",
"(",
"AbstractColumn",
"column",
",",
"StringExpression",
"labelExpression",
")",
"{",
"series",
".",
"add",
"(",
"column",
")",
";",
"seriesLabels",
".",
"put",
"(",
"column",
",",
"labelExpression",
")",
";",
"}"
] |
Adds the specified serie column to the dataset with custom label expression.
@param column the serie column
@param labelExpression column the custom label expression
|
[
"Adds",
"the",
"specified",
"serie",
"column",
"to",
"the",
"dataset",
"with",
"custom",
"label",
"expression",
"."
] |
train
|
https://github.com/intive-FDV/DynamicJasper/blob/63919574cc401ae40574d13129f628e66d1682a3/src/main/java/ar/com/fdvs/dj/domain/chart/dataset/XYDataset.java#L99-L102
|
alkacon/opencms-core
|
src/org/opencms/ui/CmsVaadinUtils.java
|
CmsVaadinUtils.getMessageText
|
public static String getMessageText(String key, Object... args) {
"""
Gets the workplace message for the current locale and the given key and arguments.<p>
@param key the message key
@param args the message arguments
@return the message text for the current locale
"""
return getWpMessagesForCurrentLocale().key(key, args);
}
|
java
|
public static String getMessageText(String key, Object... args) {
return getWpMessagesForCurrentLocale().key(key, args);
}
|
[
"public",
"static",
"String",
"getMessageText",
"(",
"String",
"key",
",",
"Object",
"...",
"args",
")",
"{",
"return",
"getWpMessagesForCurrentLocale",
"(",
")",
".",
"key",
"(",
"key",
",",
"args",
")",
";",
"}"
] |
Gets the workplace message for the current locale and the given key and arguments.<p>
@param key the message key
@param args the message arguments
@return the message text for the current locale
|
[
"Gets",
"the",
"workplace",
"message",
"for",
"the",
"current",
"locale",
"and",
"the",
"given",
"key",
"and",
"arguments",
".",
"<p",
">"
] |
train
|
https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/ui/CmsVaadinUtils.java#L644-L647
|
lessthanoptimal/BoofCV
|
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
|
FDistort.setRefs
|
public FDistort setRefs( ImageBase input, ImageBase output ) {
"""
All this does is set the references to the images. Nothing else is changed and its up to the
user to correctly update everything else.
If called the first time you need to do the following
<pre>
1) specify the interpolation method
2) specify the transform
3) specify the border
</pre>
If called again and the image shape has changed you need to do the following:
<pre>
1) Update the transform
</pre>
"""
this.input = input;
this.output = output;
inputType = input.getImageType();
return this;
}
|
java
|
public FDistort setRefs( ImageBase input, ImageBase output ) {
this.input = input;
this.output = output;
inputType = input.getImageType();
return this;
}
|
[
"public",
"FDistort",
"setRefs",
"(",
"ImageBase",
"input",
",",
"ImageBase",
"output",
")",
"{",
"this",
".",
"input",
"=",
"input",
";",
"this",
".",
"output",
"=",
"output",
";",
"inputType",
"=",
"input",
".",
"getImageType",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
All this does is set the references to the images. Nothing else is changed and its up to the
user to correctly update everything else.
If called the first time you need to do the following
<pre>
1) specify the interpolation method
2) specify the transform
3) specify the border
</pre>
If called again and the image shape has changed you need to do the following:
<pre>
1) Update the transform
</pre>
|
[
"All",
"this",
"does",
"is",
"set",
"the",
"references",
"to",
"the",
"images",
".",
"Nothing",
"else",
"is",
"changed",
"and",
"its",
"up",
"to",
"the",
"user",
"to",
"correctly",
"update",
"everything",
"else",
"."
] |
train
|
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L128-L134
|
pravega/pravega
|
segmentstore/server/src/main/java/io/pravega/segmentstore/server/reading/StreamSegmentReadIndex.java
|
StreamSegmentReadIndex.readDirect
|
InputStream readDirect(long startOffset, int length) {
"""
Reads a contiguous sequence of bytes of the given length starting at the given offset. Every byte in the range
must meet the following conditions:
<ul>
<li> It must exist in this segment. This excludes bytes from merged transactions and future reads.
<li> It must be part of data that is not yet committed to Storage (tail part) - as such, it must be fully in the cache.
</ul>
Note: This method will not cause cache statistics to be updated. As such, Cache entry generations will not be
updated for those entries that are touched.
@param startOffset The offset in the StreamSegment where to start reading.
@param length The number of bytes to read.
@return An InputStream containing the requested data, or null if all of the conditions of this read cannot be met.
@throws IllegalStateException If the read index is in recovery mode.
@throws IllegalArgumentException If the parameters are invalid (offset, length or offset+length are not in the Segment's range).
"""
Exceptions.checkNotClosed(this.closed, this);
Preconditions.checkState(!this.recoveryMode, "StreamSegmentReadIndex is in Recovery Mode.");
Preconditions.checkArgument(length >= 0, "length must be a non-negative number");
Preconditions.checkArgument(startOffset >= this.metadata.getStorageLength(), "startOffset must refer to an offset beyond the Segment's StorageLength offset.");
Preconditions.checkArgument(startOffset + length <= this.metadata.getLength(), "startOffset+length must be less than the length of the Segment.");
Preconditions.checkArgument(startOffset >= Math.min(this.metadata.getStartOffset(), this.metadata.getStorageLength()),
"startOffset is before the Segment's StartOffset.");
// Get the first entry. This one is trickier because the requested start offset may not fall on an entry boundary.
CompletableReadResultEntry nextEntry;
synchronized (this.lock) {
ReadIndexEntry indexEntry = this.indexEntries.getFloor(startOffset);
if (indexEntry == null || startOffset > indexEntry.getLastStreamSegmentOffset() || !indexEntry.isDataEntry()) {
// Data not available or data exist in a partially merged transaction.
return null;
} else {
// Fetch data from the cache for the first entry, but do not update the cache hit stats.
nextEntry = createMemoryRead(indexEntry, startOffset, length, false);
}
}
// Collect the contents of congruent Index Entries into a list, as long as we still encounter data in the cache.
// Since we know all entries should be in the cache and are contiguous, there is no need
assert Futures.isSuccessful(nextEntry.getContent()) : "Found CacheReadResultEntry that is not completed yet: " + nextEntry;
val entryContents = nextEntry.getContent().join();
ArrayList<InputStream> contents = new ArrayList<>();
contents.add(entryContents.getData());
int readLength = entryContents.getLength();
while (readLength < length) {
// No need to search the index; from now on, we know each offset we are looking for is at the beginning of a cache entry.
// Also, no need to acquire the lock there. The cache itself is thread safe, and if the entry we are about to fetch
// has just been evicted, we'll just get null back and stop reading (which is acceptable).
byte[] entryData = this.cache.get(new CacheKey(this.metadata.getId(), startOffset + readLength));
if (entryData == null) {
// Could not find the 'next' cache entry: this means the requested range is not fully cached.
return null;
}
int entryReadLength = Math.min(entryData.length, length - readLength);
assert entryReadLength > 0 : "about to have fetched zero bytes from a cache entry";
contents.add(new ByteArrayInputStream(entryData, 0, entryReadLength));
readLength += entryReadLength;
}
// Coalesce the results into a single InputStream and return the result.
return new SequenceInputStream(Iterators.asEnumeration(contents.iterator()));
}
|
java
|
InputStream readDirect(long startOffset, int length) {
Exceptions.checkNotClosed(this.closed, this);
Preconditions.checkState(!this.recoveryMode, "StreamSegmentReadIndex is in Recovery Mode.");
Preconditions.checkArgument(length >= 0, "length must be a non-negative number");
Preconditions.checkArgument(startOffset >= this.metadata.getStorageLength(), "startOffset must refer to an offset beyond the Segment's StorageLength offset.");
Preconditions.checkArgument(startOffset + length <= this.metadata.getLength(), "startOffset+length must be less than the length of the Segment.");
Preconditions.checkArgument(startOffset >= Math.min(this.metadata.getStartOffset(), this.metadata.getStorageLength()),
"startOffset is before the Segment's StartOffset.");
// Get the first entry. This one is trickier because the requested start offset may not fall on an entry boundary.
CompletableReadResultEntry nextEntry;
synchronized (this.lock) {
ReadIndexEntry indexEntry = this.indexEntries.getFloor(startOffset);
if (indexEntry == null || startOffset > indexEntry.getLastStreamSegmentOffset() || !indexEntry.isDataEntry()) {
// Data not available or data exist in a partially merged transaction.
return null;
} else {
// Fetch data from the cache for the first entry, but do not update the cache hit stats.
nextEntry = createMemoryRead(indexEntry, startOffset, length, false);
}
}
// Collect the contents of congruent Index Entries into a list, as long as we still encounter data in the cache.
// Since we know all entries should be in the cache and are contiguous, there is no need
assert Futures.isSuccessful(nextEntry.getContent()) : "Found CacheReadResultEntry that is not completed yet: " + nextEntry;
val entryContents = nextEntry.getContent().join();
ArrayList<InputStream> contents = new ArrayList<>();
contents.add(entryContents.getData());
int readLength = entryContents.getLength();
while (readLength < length) {
// No need to search the index; from now on, we know each offset we are looking for is at the beginning of a cache entry.
// Also, no need to acquire the lock there. The cache itself is thread safe, and if the entry we are about to fetch
// has just been evicted, we'll just get null back and stop reading (which is acceptable).
byte[] entryData = this.cache.get(new CacheKey(this.metadata.getId(), startOffset + readLength));
if (entryData == null) {
// Could not find the 'next' cache entry: this means the requested range is not fully cached.
return null;
}
int entryReadLength = Math.min(entryData.length, length - readLength);
assert entryReadLength > 0 : "about to have fetched zero bytes from a cache entry";
contents.add(new ByteArrayInputStream(entryData, 0, entryReadLength));
readLength += entryReadLength;
}
// Coalesce the results into a single InputStream and return the result.
return new SequenceInputStream(Iterators.asEnumeration(contents.iterator()));
}
|
[
"InputStream",
"readDirect",
"(",
"long",
"startOffset",
",",
"int",
"length",
")",
"{",
"Exceptions",
".",
"checkNotClosed",
"(",
"this",
".",
"closed",
",",
"this",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"this",
".",
"recoveryMode",
",",
"\"StreamSegmentReadIndex is in Recovery Mode.\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"length",
">=",
"0",
",",
"\"length must be a non-negative number\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"startOffset",
">=",
"this",
".",
"metadata",
".",
"getStorageLength",
"(",
")",
",",
"\"startOffset must refer to an offset beyond the Segment's StorageLength offset.\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"startOffset",
"+",
"length",
"<=",
"this",
".",
"metadata",
".",
"getLength",
"(",
")",
",",
"\"startOffset+length must be less than the length of the Segment.\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"startOffset",
">=",
"Math",
".",
"min",
"(",
"this",
".",
"metadata",
".",
"getStartOffset",
"(",
")",
",",
"this",
".",
"metadata",
".",
"getStorageLength",
"(",
")",
")",
",",
"\"startOffset is before the Segment's StartOffset.\"",
")",
";",
"// Get the first entry. This one is trickier because the requested start offset may not fall on an entry boundary.",
"CompletableReadResultEntry",
"nextEntry",
";",
"synchronized",
"(",
"this",
".",
"lock",
")",
"{",
"ReadIndexEntry",
"indexEntry",
"=",
"this",
".",
"indexEntries",
".",
"getFloor",
"(",
"startOffset",
")",
";",
"if",
"(",
"indexEntry",
"==",
"null",
"||",
"startOffset",
">",
"indexEntry",
".",
"getLastStreamSegmentOffset",
"(",
")",
"||",
"!",
"indexEntry",
".",
"isDataEntry",
"(",
")",
")",
"{",
"// Data not available or data exist in a partially merged transaction.",
"return",
"null",
";",
"}",
"else",
"{",
"// Fetch data from the cache for the first entry, but do not update the cache hit stats.",
"nextEntry",
"=",
"createMemoryRead",
"(",
"indexEntry",
",",
"startOffset",
",",
"length",
",",
"false",
")",
";",
"}",
"}",
"// Collect the contents of congruent Index Entries into a list, as long as we still encounter data in the cache.",
"// Since we know all entries should be in the cache and are contiguous, there is no need",
"assert",
"Futures",
".",
"isSuccessful",
"(",
"nextEntry",
".",
"getContent",
"(",
")",
")",
":",
"\"Found CacheReadResultEntry that is not completed yet: \"",
"+",
"nextEntry",
";",
"val",
"entryContents",
"=",
"nextEntry",
".",
"getContent",
"(",
")",
".",
"join",
"(",
")",
";",
"ArrayList",
"<",
"InputStream",
">",
"contents",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"contents",
".",
"add",
"(",
"entryContents",
".",
"getData",
"(",
")",
")",
";",
"int",
"readLength",
"=",
"entryContents",
".",
"getLength",
"(",
")",
";",
"while",
"(",
"readLength",
"<",
"length",
")",
"{",
"// No need to search the index; from now on, we know each offset we are looking for is at the beginning of a cache entry.",
"// Also, no need to acquire the lock there. The cache itself is thread safe, and if the entry we are about to fetch",
"// has just been evicted, we'll just get null back and stop reading (which is acceptable).",
"byte",
"[",
"]",
"entryData",
"=",
"this",
".",
"cache",
".",
"get",
"(",
"new",
"CacheKey",
"(",
"this",
".",
"metadata",
".",
"getId",
"(",
")",
",",
"startOffset",
"+",
"readLength",
")",
")",
";",
"if",
"(",
"entryData",
"==",
"null",
")",
"{",
"// Could not find the 'next' cache entry: this means the requested range is not fully cached.",
"return",
"null",
";",
"}",
"int",
"entryReadLength",
"=",
"Math",
".",
"min",
"(",
"entryData",
".",
"length",
",",
"length",
"-",
"readLength",
")",
";",
"assert",
"entryReadLength",
">",
"0",
":",
"\"about to have fetched zero bytes from a cache entry\"",
";",
"contents",
".",
"add",
"(",
"new",
"ByteArrayInputStream",
"(",
"entryData",
",",
"0",
",",
"entryReadLength",
")",
")",
";",
"readLength",
"+=",
"entryReadLength",
";",
"}",
"// Coalesce the results into a single InputStream and return the result.",
"return",
"new",
"SequenceInputStream",
"(",
"Iterators",
".",
"asEnumeration",
"(",
"contents",
".",
"iterator",
"(",
")",
")",
")",
";",
"}"
] |
Reads a contiguous sequence of bytes of the given length starting at the given offset. Every byte in the range
must meet the following conditions:
<ul>
<li> It must exist in this segment. This excludes bytes from merged transactions and future reads.
<li> It must be part of data that is not yet committed to Storage (tail part) - as such, it must be fully in the cache.
</ul>
Note: This method will not cause cache statistics to be updated. As such, Cache entry generations will not be
updated for those entries that are touched.
@param startOffset The offset in the StreamSegment where to start reading.
@param length The number of bytes to read.
@return An InputStream containing the requested data, or null if all of the conditions of this read cannot be met.
@throws IllegalStateException If the read index is in recovery mode.
@throws IllegalArgumentException If the parameters are invalid (offset, length or offset+length are not in the Segment's range).
|
[
"Reads",
"a",
"contiguous",
"sequence",
"of",
"bytes",
"of",
"the",
"given",
"length",
"starting",
"at",
"the",
"given",
"offset",
".",
"Every",
"byte",
"in",
"the",
"range",
"must",
"meet",
"the",
"following",
"conditions",
":",
"<ul",
">",
"<li",
">",
"It",
"must",
"exist",
"in",
"this",
"segment",
".",
"This",
"excludes",
"bytes",
"from",
"merged",
"transactions",
"and",
"future",
"reads",
".",
"<li",
">",
"It",
"must",
"be",
"part",
"of",
"data",
"that",
"is",
"not",
"yet",
"committed",
"to",
"Storage",
"(",
"tail",
"part",
")",
"-",
"as",
"such",
"it",
"must",
"be",
"fully",
"in",
"the",
"cache",
".",
"<",
"/",
"ul",
">",
"Note",
":",
"This",
"method",
"will",
"not",
"cause",
"cache",
"statistics",
"to",
"be",
"updated",
".",
"As",
"such",
"Cache",
"entry",
"generations",
"will",
"not",
"be",
"updated",
"for",
"those",
"entries",
"that",
"are",
"touched",
"."
] |
train
|
https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/segmentstore/server/src/main/java/io/pravega/segmentstore/server/reading/StreamSegmentReadIndex.java#L622-L670
|
kuali/ojb-1.0.4
|
src/java/org/apache/ojb/odmg/locking/RemoteLockMapImpl.java
|
RemoteLockMapImpl.addReader
|
public boolean addReader(TransactionImpl tx, Object obj) {
"""
Add a reader lock entry for transaction tx on object obj
to the persistent storage.
"""
try
{
LockEntry lock = new LockEntry(new Identity(obj,getBroker()).toString(),
tx.getGUID(),
System.currentTimeMillis(),
LockStrategyFactory.getIsolationLevel(obj),
LockEntry.LOCK_READ);
addReaderRemote(lock);
return true;
}
catch (Throwable t)
{
log.error("Cannot store LockEntry for object " + obj + " in transaction " + tx, t);
return false;
}
}
|
java
|
public boolean addReader(TransactionImpl tx, Object obj)
{
try
{
LockEntry lock = new LockEntry(new Identity(obj,getBroker()).toString(),
tx.getGUID(),
System.currentTimeMillis(),
LockStrategyFactory.getIsolationLevel(obj),
LockEntry.LOCK_READ);
addReaderRemote(lock);
return true;
}
catch (Throwable t)
{
log.error("Cannot store LockEntry for object " + obj + " in transaction " + tx, t);
return false;
}
}
|
[
"public",
"boolean",
"addReader",
"(",
"TransactionImpl",
"tx",
",",
"Object",
"obj",
")",
"{",
"try",
"{",
"LockEntry",
"lock",
"=",
"new",
"LockEntry",
"(",
"new",
"Identity",
"(",
"obj",
",",
"getBroker",
"(",
")",
")",
".",
"toString",
"(",
")",
",",
"tx",
".",
"getGUID",
"(",
")",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
",",
"LockStrategyFactory",
".",
"getIsolationLevel",
"(",
"obj",
")",
",",
"LockEntry",
".",
"LOCK_READ",
")",
";",
"addReaderRemote",
"(",
"lock",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"log",
".",
"error",
"(",
"\"Cannot store LockEntry for object \"",
"+",
"obj",
"+",
"\" in transaction \"",
"+",
"tx",
",",
"t",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Add a reader lock entry for transaction tx on object obj
to the persistent storage.
|
[
"Add",
"a",
"reader",
"lock",
"entry",
"for",
"transaction",
"tx",
"on",
"object",
"obj",
"to",
"the",
"persistent",
"storage",
"."
] |
train
|
https://github.com/kuali/ojb-1.0.4/blob/9a544372f67ce965f662cdc71609dd03683c8f04/src/java/org/apache/ojb/odmg/locking/RemoteLockMapImpl.java#L184-L201
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/xml/XMLOutputUtil.java
|
XMLOutputUtil.writeCollection
|
public static void writeCollection(XMLOutput xmlOutput, Collection<? extends XMLWriteable> collection) throws IOException {
"""
Write a Collection of XMLWriteable objects.
@param xmlOutput
the XMLOutput object to write to
@param collection
Collection of XMLWriteable objects
"""
for (XMLWriteable obj : collection) {
obj.writeXML(xmlOutput);
}
}
|
java
|
public static void writeCollection(XMLOutput xmlOutput, Collection<? extends XMLWriteable> collection) throws IOException {
for (XMLWriteable obj : collection) {
obj.writeXML(xmlOutput);
}
}
|
[
"public",
"static",
"void",
"writeCollection",
"(",
"XMLOutput",
"xmlOutput",
",",
"Collection",
"<",
"?",
"extends",
"XMLWriteable",
">",
"collection",
")",
"throws",
"IOException",
"{",
"for",
"(",
"XMLWriteable",
"obj",
":",
"collection",
")",
"{",
"obj",
".",
"writeXML",
"(",
"xmlOutput",
")",
";",
"}",
"}"
] |
Write a Collection of XMLWriteable objects.
@param xmlOutput
the XMLOutput object to write to
@param collection
Collection of XMLWriteable objects
|
[
"Write",
"a",
"Collection",
"of",
"XMLWriteable",
"objects",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/xml/XMLOutputUtil.java#L109-L113
|
graphql-java/graphql-java
|
src/main/java/graphql/introspection/Introspection.java
|
Introspection.getFieldDef
|
public static GraphQLFieldDefinition getFieldDef(GraphQLSchema schema, GraphQLCompositeType parentType, String fieldName) {
"""
This will look up a field definition by name, and understand that fields like __typename and __schema are special
and take precedence in field resolution
@param schema the schema to use
@param parentType the type of the parent object
@param fieldName the field to look up
@return a field definition otherwise throws an assertion exception if its null
"""
if (schema.getQueryType() == parentType) {
if (fieldName.equals(SchemaMetaFieldDef.getName())) {
return SchemaMetaFieldDef;
}
if (fieldName.equals(TypeMetaFieldDef.getName())) {
return TypeMetaFieldDef;
}
}
if (fieldName.equals(TypeNameMetaFieldDef.getName())) {
return TypeNameMetaFieldDef;
}
assertTrue(parentType instanceof GraphQLFieldsContainer, "should not happen : parent type must be an object or interface %s", parentType);
GraphQLFieldsContainer fieldsContainer = (GraphQLFieldsContainer) parentType;
GraphQLFieldDefinition fieldDefinition = schema.getCodeRegistry().getFieldVisibility().getFieldDefinition(fieldsContainer, fieldName);
Assert.assertTrue(fieldDefinition != null, "Unknown field '%s'", fieldName);
return fieldDefinition;
}
|
java
|
public static GraphQLFieldDefinition getFieldDef(GraphQLSchema schema, GraphQLCompositeType parentType, String fieldName) {
if (schema.getQueryType() == parentType) {
if (fieldName.equals(SchemaMetaFieldDef.getName())) {
return SchemaMetaFieldDef;
}
if (fieldName.equals(TypeMetaFieldDef.getName())) {
return TypeMetaFieldDef;
}
}
if (fieldName.equals(TypeNameMetaFieldDef.getName())) {
return TypeNameMetaFieldDef;
}
assertTrue(parentType instanceof GraphQLFieldsContainer, "should not happen : parent type must be an object or interface %s", parentType);
GraphQLFieldsContainer fieldsContainer = (GraphQLFieldsContainer) parentType;
GraphQLFieldDefinition fieldDefinition = schema.getCodeRegistry().getFieldVisibility().getFieldDefinition(fieldsContainer, fieldName);
Assert.assertTrue(fieldDefinition != null, "Unknown field '%s'", fieldName);
return fieldDefinition;
}
|
[
"public",
"static",
"GraphQLFieldDefinition",
"getFieldDef",
"(",
"GraphQLSchema",
"schema",
",",
"GraphQLCompositeType",
"parentType",
",",
"String",
"fieldName",
")",
"{",
"if",
"(",
"schema",
".",
"getQueryType",
"(",
")",
"==",
"parentType",
")",
"{",
"if",
"(",
"fieldName",
".",
"equals",
"(",
"SchemaMetaFieldDef",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"SchemaMetaFieldDef",
";",
"}",
"if",
"(",
"fieldName",
".",
"equals",
"(",
"TypeMetaFieldDef",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"TypeMetaFieldDef",
";",
"}",
"}",
"if",
"(",
"fieldName",
".",
"equals",
"(",
"TypeNameMetaFieldDef",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"TypeNameMetaFieldDef",
";",
"}",
"assertTrue",
"(",
"parentType",
"instanceof",
"GraphQLFieldsContainer",
",",
"\"should not happen : parent type must be an object or interface %s\"",
",",
"parentType",
")",
";",
"GraphQLFieldsContainer",
"fieldsContainer",
"=",
"(",
"GraphQLFieldsContainer",
")",
"parentType",
";",
"GraphQLFieldDefinition",
"fieldDefinition",
"=",
"schema",
".",
"getCodeRegistry",
"(",
")",
".",
"getFieldVisibility",
"(",
")",
".",
"getFieldDefinition",
"(",
"fieldsContainer",
",",
"fieldName",
")",
";",
"Assert",
".",
"assertTrue",
"(",
"fieldDefinition",
"!=",
"null",
",",
"\"Unknown field '%s'\"",
",",
"fieldName",
")",
";",
"return",
"fieldDefinition",
";",
"}"
] |
This will look up a field definition by name, and understand that fields like __typename and __schema are special
and take precedence in field resolution
@param schema the schema to use
@param parentType the type of the parent object
@param fieldName the field to look up
@return a field definition otherwise throws an assertion exception if its null
|
[
"This",
"will",
"look",
"up",
"a",
"field",
"definition",
"by",
"name",
"and",
"understand",
"that",
"fields",
"like",
"__typename",
"and",
"__schema",
"are",
"special",
"and",
"take",
"precedence",
"in",
"field",
"resolution"
] |
train
|
https://github.com/graphql-java/graphql-java/blob/9214b6044317849388bd88a14b54fc1c18c9f29f/src/main/java/graphql/introspection/Introspection.java#L534-L553
|
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java
|
ServerUtility.pingServer
|
public static boolean pingServer(String protocol, String user, String pass) {
"""
Tell whether the server is running by pinging it as a client.
"""
try {
getServerResponse(protocol, user, pass, "/describe");
return true;
} catch (Exception e) {
logger.debug("Assuming the server isn't running because "
+ "describe request failed", e);
return false;
}
}
|
java
|
public static boolean pingServer(String protocol, String user, String pass) {
try {
getServerResponse(protocol, user, pass, "/describe");
return true;
} catch (Exception e) {
logger.debug("Assuming the server isn't running because "
+ "describe request failed", e);
return false;
}
}
|
[
"public",
"static",
"boolean",
"pingServer",
"(",
"String",
"protocol",
",",
"String",
"user",
",",
"String",
"pass",
")",
"{",
"try",
"{",
"getServerResponse",
"(",
"protocol",
",",
"user",
",",
"pass",
",",
"\"/describe\"",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Assuming the server isn't running because \"",
"+",
"\"describe request failed\"",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Tell whether the server is running by pinging it as a client.
|
[
"Tell",
"whether",
"the",
"server",
"is",
"running",
"by",
"pinging",
"it",
"as",
"a",
"client",
"."
] |
train
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/utilities/ServerUtility.java#L85-L94
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/lang/PatternPool.java
|
PatternPool.remove
|
public static Pattern remove(String regex, int flags) {
"""
移除缓存
@param regex 正则
@param flags 标识
@return 移除的{@link Pattern},可能为{@code null}
"""
return POOL.remove(new RegexWithFlag(regex, flags));
}
|
java
|
public static Pattern remove(String regex, int flags) {
return POOL.remove(new RegexWithFlag(regex, flags));
}
|
[
"public",
"static",
"Pattern",
"remove",
"(",
"String",
"regex",
",",
"int",
"flags",
")",
"{",
"return",
"POOL",
".",
"remove",
"(",
"new",
"RegexWithFlag",
"(",
"regex",
",",
"flags",
")",
")",
";",
"}"
] |
移除缓存
@param regex 正则
@param flags 标识
@return 移除的{@link Pattern},可能为{@code null}
|
[
"移除缓存"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/lang/PatternPool.java#L100-L102
|
infinispan/infinispan
|
object-filter/src/main/java/org/infinispan/objectfilter/impl/util/IntervalTree.java
|
IntervalTree.stab
|
public List<Node<K, V>> stab(K k) {
"""
Find all Intervals that contain a given value.
@param k the value to search for
@return a non-null List of intervals that contain the value
"""
Interval<K> i = new Interval<K>(k, true, k, true);
final List<Node<K, V>> nodes = new ArrayList<Node<K, V>>();
findOverlap(root.left, i, new NodeCallback<K, V>() {
@Override
public void handle(Node<K, V> node) {
nodes.add(node);
}
});
return nodes;
}
|
java
|
public List<Node<K, V>> stab(K k) {
Interval<K> i = new Interval<K>(k, true, k, true);
final List<Node<K, V>> nodes = new ArrayList<Node<K, V>>();
findOverlap(root.left, i, new NodeCallback<K, V>() {
@Override
public void handle(Node<K, V> node) {
nodes.add(node);
}
});
return nodes;
}
|
[
"public",
"List",
"<",
"Node",
"<",
"K",
",",
"V",
">",
">",
"stab",
"(",
"K",
"k",
")",
"{",
"Interval",
"<",
"K",
">",
"i",
"=",
"new",
"Interval",
"<",
"K",
">",
"(",
"k",
",",
"true",
",",
"k",
",",
"true",
")",
";",
"final",
"List",
"<",
"Node",
"<",
"K",
",",
"V",
">",
">",
"nodes",
"=",
"new",
"ArrayList",
"<",
"Node",
"<",
"K",
",",
"V",
">",
">",
"(",
")",
";",
"findOverlap",
"(",
"root",
".",
"left",
",",
"i",
",",
"new",
"NodeCallback",
"<",
"K",
",",
"V",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"handle",
"(",
"Node",
"<",
"K",
",",
"V",
">",
"node",
")",
"{",
"nodes",
".",
"add",
"(",
"node",
")",
";",
"}",
"}",
")",
";",
"return",
"nodes",
";",
"}"
] |
Find all Intervals that contain a given value.
@param k the value to search for
@return a non-null List of intervals that contain the value
|
[
"Find",
"all",
"Intervals",
"that",
"contain",
"a",
"given",
"value",
"."
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/object-filter/src/main/java/org/infinispan/objectfilter/impl/util/IntervalTree.java#L426-L436
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.