repository_name stringlengths 7 54 | func_path_in_repository stringlengths 18 196 | func_name stringlengths 7 107 | whole_func_string stringlengths 76 3.82k | language stringclasses 1
value | func_code_string stringlengths 76 3.82k | func_code_tokens listlengths 22 717 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 508 | split_name stringclasses 1
value | func_code_url stringlengths 111 310 |
|---|---|---|---|---|---|---|---|---|---|---|
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.renamePathHandleLocalFSRace | public static boolean renamePathHandleLocalFSRace(FileSystem fs, Path src, Path dst) throws IOException {
if (DecoratorUtils.resolveUnderlyingObject(fs) instanceof LocalFileSystem && fs.isDirectory(src)) {
LocalFileSystem localFs = (LocalFileSystem) DecoratorUtils.resolveUnderlyingObject(fs);
File srcFile = localFs.pathToFile(src);
File dstFile = localFs.pathToFile(dst);
return srcFile.renameTo(dstFile);
}
else {
return fs.rename(src, dst);
}
} | java | public static boolean renamePathHandleLocalFSRace(FileSystem fs, Path src, Path dst) throws IOException {
if (DecoratorUtils.resolveUnderlyingObject(fs) instanceof LocalFileSystem && fs.isDirectory(src)) {
LocalFileSystem localFs = (LocalFileSystem) DecoratorUtils.resolveUnderlyingObject(fs);
File srcFile = localFs.pathToFile(src);
File dstFile = localFs.pathToFile(dst);
return srcFile.renameTo(dstFile);
}
else {
return fs.rename(src, dst);
}
} | [
"public",
"static",
"boolean",
"renamePathHandleLocalFSRace",
"(",
"FileSystem",
"fs",
",",
"Path",
"src",
",",
"Path",
"dst",
")",
"throws",
"IOException",
"{",
"if",
"(",
"DecoratorUtils",
".",
"resolveUnderlyingObject",
"(",
"fs",
")",
"instanceof",
"LocalFileS... | Renames a src {@link Path} on fs {@link FileSystem} to a dst {@link Path}. If fs is a {@link LocalFileSystem} and
src is a directory then {@link File#renameTo} is called directly to avoid a directory rename race condition where
{@link org.apache.hadoop.fs.RawLocalFileSystem#rename} copies the conflicting src directory into dst resulting in
an extra nested level, such as /root/a/b/c/e/e where e is repeated.
@param fs the {@link FileSystem} where the src {@link Path} exists
@param src the source {@link Path} which will be renamed
@param dst the {@link Path} to rename to
@return true if rename succeeded, false if rename failed.
@throws IOException if rename failed for reasons other than target exists. | [
"Renames",
"a",
"src",
"{",
"@link",
"Path",
"}",
"on",
"fs",
"{",
"@link",
"FileSystem",
"}",
"to",
"a",
"dst",
"{",
"@link",
"Path",
"}",
".",
"If",
"fs",
"is",
"a",
"{",
"@link",
"LocalFileSystem",
"}",
"and",
"src",
"is",
"a",
"directory",
"the... | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L227-L238 |
gallandarakhneorg/afc | core/vmutils/src/main/java/org/arakhne/afc/vmutil/StringEscaper.java | StringEscaper.setValidCharRange | public void setValidCharRange(int minValidChar, int maxValidChar) {
if (minValidChar <= maxValidChar) {
this.minValidChar = minValidChar;
this.maxValidChar = maxValidChar;
} else {
this.maxValidChar = minValidChar;
this.minValidChar = maxValidChar;
}
} | java | public void setValidCharRange(int minValidChar, int maxValidChar) {
if (minValidChar <= maxValidChar) {
this.minValidChar = minValidChar;
this.maxValidChar = maxValidChar;
} else {
this.maxValidChar = minValidChar;
this.minValidChar = maxValidChar;
}
} | [
"public",
"void",
"setValidCharRange",
"(",
"int",
"minValidChar",
",",
"int",
"maxValidChar",
")",
"{",
"if",
"(",
"minValidChar",
"<=",
"maxValidChar",
")",
"{",
"this",
".",
"minValidChar",
"=",
"minValidChar",
";",
"this",
".",
"maxValidChar",
"=",
"maxVal... | Change the range of the valid characters that should not be escaped.
Any character outside the given range is automatically escaped.
<p>If {@code maxValidChar} is lower or equal to zero, the invalid characters
are not put within the result of the escaping.
@param minValidChar the code of the minimal valid character.
@param maxValidChar the code of the maximal valid character. | [
"Change",
"the",
"range",
"of",
"the",
"valid",
"characters",
"that",
"should",
"not",
"be",
"escaped",
".",
"Any",
"character",
"outside",
"the",
"given",
"range",
"is",
"automatically",
"escaped",
"."
] | train | https://github.com/gallandarakhneorg/afc/blob/0c7d2e1ddefd4167ef788416d970a6c1ef6f8bbb/core/vmutils/src/main/java/org/arakhne/afc/vmutil/StringEscaper.java#L135-L143 |
Lucas3oo/jicunit | src/jicunit-framework/src/main/java/org/jicunit/framework/internal/JicUnitServletClient.java | JicUnitServletClient.processResults | public void processResults(Document document) throws Throwable {
Element root = document.getDocumentElement();
root.normalize();
// top element should testcase which has attributes for the outcome of the test
// e.g <testcase classname="TheClass" name="theName(TheClass)" status="Error"><exception message="message" type="type">some text</exception></testcase>
NamedNodeMap attributes = root.getAttributes();
String statusAsStr = attributes.getNamedItem("status").getNodeValue();
Status status = Status.valueOf(statusAsStr);
if (status.equals(Status.Error) || status.equals(Status.Failure)) {
throw getException(root, status);
}
} | java | public void processResults(Document document) throws Throwable {
Element root = document.getDocumentElement();
root.normalize();
// top element should testcase which has attributes for the outcome of the test
// e.g <testcase classname="TheClass" name="theName(TheClass)" status="Error"><exception message="message" type="type">some text</exception></testcase>
NamedNodeMap attributes = root.getAttributes();
String statusAsStr = attributes.getNamedItem("status").getNodeValue();
Status status = Status.valueOf(statusAsStr);
if (status.equals(Status.Error) || status.equals(Status.Failure)) {
throw getException(root, status);
}
} | [
"public",
"void",
"processResults",
"(",
"Document",
"document",
")",
"throws",
"Throwable",
"{",
"Element",
"root",
"=",
"document",
".",
"getDocumentElement",
"(",
")",
";",
"root",
".",
"normalize",
"(",
")",
";",
"// top element should testcase which has attribu... | Processes the actual XML result and generate exceptions in case there was
an issue on the server side.
@param document
@throws Throwable | [
"Processes",
"the",
"actual",
"XML",
"result",
"and",
"generate",
"exceptions",
"in",
"case",
"there",
"was",
"an",
"issue",
"on",
"the",
"server",
"side",
"."
] | train | https://github.com/Lucas3oo/jicunit/blob/1ed41891ccf8e5c6068c6b544d214280bb93945b/src/jicunit-framework/src/main/java/org/jicunit/framework/internal/JicUnitServletClient.java#L70-L82 |
kevoree/kevoree-library | centralizedwsgroup/src/main/java/org/kevoree/library/server/ServerFragment.java | ServerFragment.kevsTpl | private String kevsTpl(String kevs, String nodeName) {
return kevs
.replaceAll("\\{\\{nodeName\\}\\}", nodeName)
.replaceAll("\\{\\{groupName\\}\\}", instance.getName());
} | java | private String kevsTpl(String kevs, String nodeName) {
return kevs
.replaceAll("\\{\\{nodeName\\}\\}", nodeName)
.replaceAll("\\{\\{groupName\\}\\}", instance.getName());
} | [
"private",
"String",
"kevsTpl",
"(",
"String",
"kevs",
",",
"String",
"nodeName",
")",
"{",
"return",
"kevs",
".",
"replaceAll",
"(",
"\"\\\\{\\\\{nodeName\\\\}\\\\}\"",
",",
"nodeName",
")",
".",
"replaceAll",
"(",
"\"\\\\{\\\\{groupName\\\\}\\\\}\"",
",",
"instanc... | Replaces {{groupName}} by the current group instance name and {{nodeName}} by the given nodeName in parameter
@param kevs the KevScript to interpolate
@param nodeName the value to replace {{nodeName}} with
@return interpolated kevscript | [
"Replaces",
"{{",
"groupName",
"}}",
"by",
"the",
"current",
"group",
"instance",
"name",
"and",
"{{",
"nodeName",
"}}",
"by",
"the",
"given",
"nodeName",
"in",
"parameter"
] | train | https://github.com/kevoree/kevoree-library/blob/617460e6c5881902ebc488a31ecdea179024d8f1/centralizedwsgroup/src/main/java/org/kevoree/library/server/ServerFragment.java#L153-L157 |
acromusashi/acromusashi-stream | src/main/java/acromusashi/stream/entity/StreamMessageHeader.java | StreamMessageHeader.addAdditionalHeader | public void addAdditionalHeader(String key, String value)
{
if (this.additionalHeader == null)
{
this.additionalHeader = Maps.newLinkedHashMap();
}
this.additionalHeader.put(key, value);
} | java | public void addAdditionalHeader(String key, String value)
{
if (this.additionalHeader == null)
{
this.additionalHeader = Maps.newLinkedHashMap();
}
this.additionalHeader.put(key, value);
} | [
"public",
"void",
"addAdditionalHeader",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"this",
".",
"additionalHeader",
"==",
"null",
")",
"{",
"this",
".",
"additionalHeader",
"=",
"Maps",
".",
"newLinkedHashMap",
"(",
")",
";",
"}",
... | Add value to additional header.
@param key key
@param value value | [
"Add",
"value",
"to",
"additional",
"header",
"."
] | train | https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/entity/StreamMessageHeader.java#L217-L225 |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java | AbstractKMeans.nearestMeans | protected static void nearestMeans(double[][] cdist, int[][] cnum) {
final int k = cdist.length;
double[] buf = new double[k - 1];
for(int i = 0; i < k; i++) {
System.arraycopy(cdist[i], 0, buf, 0, i);
System.arraycopy(cdist[i], i + 1, buf, i, k - i - 1);
for(int j = 0; j < buf.length; j++) {
cnum[i][j] = j < i ? j : (j + 1);
}
DoubleIntegerArrayQuickSort.sort(buf, cnum[i], k - 1);
}
} | java | protected static void nearestMeans(double[][] cdist, int[][] cnum) {
final int k = cdist.length;
double[] buf = new double[k - 1];
for(int i = 0; i < k; i++) {
System.arraycopy(cdist[i], 0, buf, 0, i);
System.arraycopy(cdist[i], i + 1, buf, i, k - i - 1);
for(int j = 0; j < buf.length; j++) {
cnum[i][j] = j < i ? j : (j + 1);
}
DoubleIntegerArrayQuickSort.sort(buf, cnum[i], k - 1);
}
} | [
"protected",
"static",
"void",
"nearestMeans",
"(",
"double",
"[",
"]",
"[",
"]",
"cdist",
",",
"int",
"[",
"]",
"[",
"]",
"cnum",
")",
"{",
"final",
"int",
"k",
"=",
"cdist",
".",
"length",
";",
"double",
"[",
"]",
"buf",
"=",
"new",
"double",
"... | Recompute the separation of cluster means.
<p>
Used by sort, and our exponion implementation.
@param cdist Center-to-Center distances
@param cnum Center numbers | [
"Recompute",
"the",
"separation",
"of",
"cluster",
"means",
".",
"<p",
">",
"Used",
"by",
"sort",
"and",
"our",
"exponion",
"implementation",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java#L257-L268 |
RoaringBitmap/RoaringBitmap | roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java | RoaringBitmap.flip | @Deprecated
public static RoaringBitmap flip(RoaringBitmap rb, final int rangeStart, final int rangeEnd) {
if (rangeStart >= 0) {
return flip(rb, (long) rangeStart, (long) rangeEnd);
}
// rangeStart being -ve and rangeEnd being positive is not expected)
// so assume both -ve
return flip(rb, rangeStart & 0xFFFFFFFFL, rangeEnd & 0xFFFFFFFFL);
} | java | @Deprecated
public static RoaringBitmap flip(RoaringBitmap rb, final int rangeStart, final int rangeEnd) {
if (rangeStart >= 0) {
return flip(rb, (long) rangeStart, (long) rangeEnd);
}
// rangeStart being -ve and rangeEnd being positive is not expected)
// so assume both -ve
return flip(rb, rangeStart & 0xFFFFFFFFL, rangeEnd & 0xFFFFFFFFL);
} | [
"@",
"Deprecated",
"public",
"static",
"RoaringBitmap",
"flip",
"(",
"RoaringBitmap",
"rb",
",",
"final",
"int",
"rangeStart",
",",
"final",
"int",
"rangeEnd",
")",
"{",
"if",
"(",
"rangeStart",
">=",
"0",
")",
"{",
"return",
"flip",
"(",
"rb",
",",
"(",... | Complements the bits in the given range, from rangeStart (inclusive) rangeEnd (exclusive). The
given bitmap is unchanged.
@param rb bitmap being negated
@param rangeStart inclusive beginning of range, in [0, 0xffffffff]
@param rangeEnd exclusive ending of range, in [0, 0xffffffff + 1]
@return a new Bitmap
@deprecated use the version where longs specify the range | [
"Complements",
"the",
"bits",
"in",
"the",
"given",
"range",
"from",
"rangeStart",
"(",
"inclusive",
")",
"rangeEnd",
"(",
"exclusive",
")",
".",
"The",
"given",
"bitmap",
"is",
"unchanged",
"."
] | train | https://github.com/RoaringBitmap/RoaringBitmap/blob/b26fd0a1330fd4d2877f4d74feb69ceb812e9efa/roaringbitmap/src/main/java/org/roaringbitmap/RoaringBitmap.java#L603-L611 |
spring-projects/spring-hateoas | src/main/java/org/springframework/hateoas/server/mvc/WebMvcLinkBuilder.java | WebMvcLinkBuilder.linkTo | public static WebMvcLinkBuilder linkTo(Class<?> controller, Object... parameters) {
Assert.notNull(controller, "Controller must not be null!");
Assert.notNull(parameters, "Parameters must not be null!");
String mapping = DISCOVERER.getMapping(controller);
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(mapping == null ? "/" : mapping);
UriComponents uriComponents = HANDLER.expandAndEncode(builder, parameters);
return new WebMvcLinkBuilder(UriComponentsBuilderFactory.getBuilder()).slash(uriComponents, true);
} | java | public static WebMvcLinkBuilder linkTo(Class<?> controller, Object... parameters) {
Assert.notNull(controller, "Controller must not be null!");
Assert.notNull(parameters, "Parameters must not be null!");
String mapping = DISCOVERER.getMapping(controller);
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(mapping == null ? "/" : mapping);
UriComponents uriComponents = HANDLER.expandAndEncode(builder, parameters);
return new WebMvcLinkBuilder(UriComponentsBuilderFactory.getBuilder()).slash(uriComponents, true);
} | [
"public",
"static",
"WebMvcLinkBuilder",
"linkTo",
"(",
"Class",
"<",
"?",
">",
"controller",
",",
"Object",
"...",
"parameters",
")",
"{",
"Assert",
".",
"notNull",
"(",
"controller",
",",
"\"Controller must not be null!\"",
")",
";",
"Assert",
".",
"notNull",
... | Creates a new {@link WebMvcLinkBuilder} with a base of the mapping annotated to the given controller class. The
additional parameters are used to fill up potentially available path variables in the class scop request mapping.
@param controller the class to discover the annotation on, must not be {@literal null}.
@param parameters additional parameters to bind to the URI template declared in the annotation, must not be
{@literal null}.
@return | [
"Creates",
"a",
"new",
"{",
"@link",
"WebMvcLinkBuilder",
"}",
"with",
"a",
"base",
"of",
"the",
"mapping",
"annotated",
"to",
"the",
"given",
"controller",
"class",
".",
"The",
"additional",
"parameters",
"are",
"used",
"to",
"fill",
"up",
"potentially",
"a... | train | https://github.com/spring-projects/spring-hateoas/blob/70ebff9309f086cd8d6a97daf67e0dc215c87d9c/src/main/java/org/springframework/hateoas/server/mvc/WebMvcLinkBuilder.java#L95-L106 |
arakelian/more-commons | src/main/java/com/arakelian/core/utils/XmlStreamReaderUtils.java | XmlStreamReaderUtils.requiredShortAttribute | public static short requiredShortAttribute(final XMLStreamReader reader, final String localName)
throws XMLStreamException {
return requiredShortAttribute(reader, null, localName);
} | java | public static short requiredShortAttribute(final XMLStreamReader reader, final String localName)
throws XMLStreamException {
return requiredShortAttribute(reader, null, localName);
} | [
"public",
"static",
"short",
"requiredShortAttribute",
"(",
"final",
"XMLStreamReader",
"reader",
",",
"final",
"String",
"localName",
")",
"throws",
"XMLStreamException",
"{",
"return",
"requiredShortAttribute",
"(",
"reader",
",",
"null",
",",
"localName",
")",
";... | Returns the value of an attribute as a short. If the attribute is empty, this method throws
an exception.
@param reader
<code>XMLStreamReader</code> that contains attribute values.
@param localName
local name of attribute (the namespace is ignored).
@return value of attribute as short
@throws XMLStreamException
if attribute is empty. | [
"Returns",
"the",
"value",
"of",
"an",
"attribute",
"as",
"a",
"short",
".",
"If",
"the",
"attribute",
"is",
"empty",
"this",
"method",
"throws",
"an",
"exception",
"."
] | train | https://github.com/arakelian/more-commons/blob/83c607044f64a7f6c005a67866c0ef7cb68d6e29/src/main/java/com/arakelian/core/utils/XmlStreamReaderUtils.java#L1303-L1306 |
gitblit/fathom | fathom-x509/src/main/java/fathom/x509/X509Utils.java | X509Utils.openKeyStore | public static KeyStore openKeyStore(File storeFile, String storePassword) {
String lc = storeFile.getName().toLowerCase();
String type = "JKS";
String provider = null;
if (lc.endsWith(".p12") || lc.endsWith(".pfx")) {
type = "PKCS12";
provider = BC;
}
try {
KeyStore store;
if (provider == null) {
store = KeyStore.getInstance(type);
} else {
store = KeyStore.getInstance(type, provider);
}
storeFile.getParentFile().mkdirs();
if (storeFile.exists()) {
FileInputStream fis = null;
try {
fis = new FileInputStream(storeFile);
store.load(fis, storePassword.toCharArray());
} finally {
if (fis != null) {
fis.close();
}
}
} else {
store.load(null);
}
return store;
} catch (Exception e) {
throw new RuntimeException("Could not open keystore " + storeFile, e);
}
} | java | public static KeyStore openKeyStore(File storeFile, String storePassword) {
String lc = storeFile.getName().toLowerCase();
String type = "JKS";
String provider = null;
if (lc.endsWith(".p12") || lc.endsWith(".pfx")) {
type = "PKCS12";
provider = BC;
}
try {
KeyStore store;
if (provider == null) {
store = KeyStore.getInstance(type);
} else {
store = KeyStore.getInstance(type, provider);
}
storeFile.getParentFile().mkdirs();
if (storeFile.exists()) {
FileInputStream fis = null;
try {
fis = new FileInputStream(storeFile);
store.load(fis, storePassword.toCharArray());
} finally {
if (fis != null) {
fis.close();
}
}
} else {
store.load(null);
}
return store;
} catch (Exception e) {
throw new RuntimeException("Could not open keystore " + storeFile, e);
}
} | [
"public",
"static",
"KeyStore",
"openKeyStore",
"(",
"File",
"storeFile",
",",
"String",
"storePassword",
")",
"{",
"String",
"lc",
"=",
"storeFile",
".",
"getName",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"String",
"type",
"=",
"\"JKS\"",
";",
"Strin... | Open a keystore. Store type is determined by file extension of name. If
undetermined, JKS is assumed. The keystore does not need to exist.
@param storeFile
@param storePassword
@return a KeyStore | [
"Open",
"a",
"keystore",
".",
"Store",
"type",
"is",
"determined",
"by",
"file",
"extension",
"of",
"name",
".",
"If",
"undetermined",
"JKS",
"is",
"assumed",
".",
"The",
"keystore",
"does",
"not",
"need",
"to",
"exist",
"."
] | train | https://github.com/gitblit/fathom/blob/f2f820eb16e9fea1e36ad4eda4ed51b35f056538/fathom-x509/src/main/java/fathom/x509/X509Utils.java#L305-L339 |
schallee/alib4j | core/src/main/java/net/darkmist/alib/res/PkgRes.java | PkgRes.appendResourcePathPrefixFor | protected static StringBuilder appendResourcePathPrefixFor(StringBuilder sb, String pkgName)
{
if(pkgName == null)
throw new NullPointerException("pkgName is null");
if(sb == null)
sb = new StringBuilder(pkgName.length() + 2);
sb.append('/');
if(pkgName.length() == 0)
return sb;
sb.append(pkgName.replace('.','/'));
pkgName = null;
sb.append('/');
return sb;
} | java | protected static StringBuilder appendResourcePathPrefixFor(StringBuilder sb, String pkgName)
{
if(pkgName == null)
throw new NullPointerException("pkgName is null");
if(sb == null)
sb = new StringBuilder(pkgName.length() + 2);
sb.append('/');
if(pkgName.length() == 0)
return sb;
sb.append(pkgName.replace('.','/'));
pkgName = null;
sb.append('/');
return sb;
} | [
"protected",
"static",
"StringBuilder",
"appendResourcePathPrefixFor",
"(",
"StringBuilder",
"sb",
",",
"String",
"pkgName",
")",
"{",
"if",
"(",
"pkgName",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"pkgName is null\"",
")",
";",
"if",
"(",... | Apend a package name converted to a resource path prefix.
@param sb what to append to. If this is null, a new
StringBuilder is created.
@param pkgName The name of the package.
@return Path, starting and ending with a slash, for resources
prefixed by pkgName.
@throws NullPointerException if pkgName is null. | [
"Apend",
"a",
"package",
"name",
"converted",
"to",
"a",
"resource",
"path",
"prefix",
"."
] | train | https://github.com/schallee/alib4j/blob/0e0718aee574bbb62268e1cf58e99286529ce529/core/src/main/java/net/darkmist/alib/res/PkgRes.java#L132-L145 |
Omertron/api-themoviedb | src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java | TmdbSearch.searchCollection | public ResultList<Collection> searchCollection(String query, Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.QUERY, query);
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.SEARCH).subMethod(MethodSub.COLLECTION).buildUrl(parameters);
WrapperGenericList<Collection> wrapper = processWrapper(getTypeReference(Collection.class), url, "collection");
return wrapper.getResultsList();
} | java | public ResultList<Collection> searchCollection(String query, Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.QUERY, query);
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.SEARCH).subMethod(MethodSub.COLLECTION).buildUrl(parameters);
WrapperGenericList<Collection> wrapper = processWrapper(getTypeReference(Collection.class), url, "collection");
return wrapper.getResultsList();
} | [
"public",
"ResultList",
"<",
"Collection",
">",
"searchCollection",
"(",
"String",
"query",
",",
"Integer",
"page",
",",
"String",
"language",
")",
"throws",
"MovieDbException",
"{",
"TmdbParameters",
"parameters",
"=",
"new",
"TmdbParameters",
"(",
")",
";",
"p... | Search for collections by name.
@param query
@param language
@param page
@return
@throws MovieDbException | [
"Search",
"for",
"collections",
"by",
"name",
"."
] | train | https://github.com/Omertron/api-themoviedb/blob/bf132d7c7271734e13b58ba3bc92bba46f220118/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java#L94-L103 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/VMath.java | VMath.mahalanobisDistance | @Reference(authors = "P. C. Mahalanobis", //
title = "On the generalized distance in statistics", //
booktitle = "Proceedings of the National Institute of Sciences of India. 2 (1)", //
bibkey = "journals/misc/Mahalanobis36")
public static double mahalanobisDistance(final double[][] B, final double[] a, final double[] c) {
final int rowdim = B.length, coldim = getColumnDimensionality(B);
assert rowdim == a.length : ERR_MATRIX_INNERDIM;
assert coldim == c.length : ERR_MATRIX_INNERDIM;
assert a.length == c.length : ERR_VEC_DIMENSIONS;
double sum = 0.0;
for(int k = 0; k < rowdim; k++) {
final double[] B_k = B[k];
double s = 0;
for(int j = 0; j < coldim; j++) {
s += (a[j] - c[j]) * B_k[j];
}
sum += (a[k] - c[k]) * s;
}
return sum;
} | java | @Reference(authors = "P. C. Mahalanobis", //
title = "On the generalized distance in statistics", //
booktitle = "Proceedings of the National Institute of Sciences of India. 2 (1)", //
bibkey = "journals/misc/Mahalanobis36")
public static double mahalanobisDistance(final double[][] B, final double[] a, final double[] c) {
final int rowdim = B.length, coldim = getColumnDimensionality(B);
assert rowdim == a.length : ERR_MATRIX_INNERDIM;
assert coldim == c.length : ERR_MATRIX_INNERDIM;
assert a.length == c.length : ERR_VEC_DIMENSIONS;
double sum = 0.0;
for(int k = 0; k < rowdim; k++) {
final double[] B_k = B[k];
double s = 0;
for(int j = 0; j < coldim; j++) {
s += (a[j] - c[j]) * B_k[j];
}
sum += (a[k] - c[k]) * s;
}
return sum;
} | [
"@",
"Reference",
"(",
"authors",
"=",
"\"P. C. Mahalanobis\"",
",",
"//",
"title",
"=",
"\"On the generalized distance in statistics\"",
",",
"//",
"booktitle",
"=",
"\"Proceedings of the National Institute of Sciences of India. 2 (1)\"",
",",
"//",
"bibkey",
"=",
"\"journal... | Matrix multiplication, (a-c)<sup>T</sup> * B * (a-c)
<p>
Note: it may (or may not) be more efficient to materialize (a-c), then use
{@code transposeTimesTimes(a_minus_c, B, a_minus_c)} instead.
@param B matrix
@param a First vector
@param c Center vector
@return Matrix product, (a-c)<sup>T</sup> * B * (a-c) | [
"Matrix",
"multiplication",
"(",
"a",
"-",
"c",
")",
"<sup",
">",
"T<",
"/",
"sup",
">",
"*",
"B",
"*",
"(",
"a",
"-",
"c",
")",
"<p",
">",
"Note",
":",
"it",
"may",
"(",
"or",
"may",
"not",
")",
"be",
"more",
"efficient",
"to",
"materialize",
... | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/VMath.java#L1528-L1547 |
DDTH/ddth-queue | ddth-queue-core/src/main/java/com/github/ddth/queue/impl/JdbcQueue.java | JdbcQueue.take | @Override
public IQueueMessage<ID, DATA> take() throws QueueException.EphemeralIsFull {
try {
try (Connection conn = jdbcHelper.getConnection()) {
if (!isEphemeralDisabled()) {
int ephemeralMaxSize = getEphemeralMaxSize();
if (ephemeralMaxSize > 0 && ephemeralSize(conn) >= ephemeralMaxSize) {
throw new QueueException.EphemeralIsFull(ephemeralMaxSize);
}
}
return _takeWithRetries(conn, 0, this.maxRetries);
}
} catch (Exception e) {
final String logMsg = "(take) Exception [" + e.getClass().getName() + "]: "
+ e.getMessage();
LOGGER.error(logMsg, e);
throw e instanceof QueueException ? (QueueException) e : new QueueException(e);
}
} | java | @Override
public IQueueMessage<ID, DATA> take() throws QueueException.EphemeralIsFull {
try {
try (Connection conn = jdbcHelper.getConnection()) {
if (!isEphemeralDisabled()) {
int ephemeralMaxSize = getEphemeralMaxSize();
if (ephemeralMaxSize > 0 && ephemeralSize(conn) >= ephemeralMaxSize) {
throw new QueueException.EphemeralIsFull(ephemeralMaxSize);
}
}
return _takeWithRetries(conn, 0, this.maxRetries);
}
} catch (Exception e) {
final String logMsg = "(take) Exception [" + e.getClass().getName() + "]: "
+ e.getMessage();
LOGGER.error(logMsg, e);
throw e instanceof QueueException ? (QueueException) e : new QueueException(e);
}
} | [
"@",
"Override",
"public",
"IQueueMessage",
"<",
"ID",
",",
"DATA",
">",
"take",
"(",
")",
"throws",
"QueueException",
".",
"EphemeralIsFull",
"{",
"try",
"{",
"try",
"(",
"Connection",
"conn",
"=",
"jdbcHelper",
".",
"getConnection",
"(",
")",
")",
"{",
... | {@inheritDoc}
@throws QueueException.EphemeralIsFull
if the ephemeral storage is full | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/DDTH/ddth-queue/blob/b20776850d23111d3d71fc8ed6023c590bc3621f/ddth-queue-core/src/main/java/com/github/ddth/queue/impl/JdbcQueue.java#L698-L716 |
bazaarvoice/emodb | common/dropwizard/src/main/java/com/bazaarvoice/emodb/common/dropwizard/discovery/DropwizardResourceRegistry.java | DropwizardResourceRegistry.addResource | @Override
public void addResource(String namespace, String service, Object resource) {
ServiceEndPoint endPoint = toEndPoint(namespace, service, resource);
_environment.lifecycle().manage(new ManagedRegistration(_serviceRegistry, endPoint));
_environment.jersey().register(resource);
} | java | @Override
public void addResource(String namespace, String service, Object resource) {
ServiceEndPoint endPoint = toEndPoint(namespace, service, resource);
_environment.lifecycle().manage(new ManagedRegistration(_serviceRegistry, endPoint));
_environment.jersey().register(resource);
} | [
"@",
"Override",
"public",
"void",
"addResource",
"(",
"String",
"namespace",
",",
"String",
"service",
",",
"Object",
"resource",
")",
"{",
"ServiceEndPoint",
"endPoint",
"=",
"toEndPoint",
"(",
"namespace",
",",
"service",
",",
"resource",
")",
";",
"_enviro... | Adds a Jersey resource annotated with the {@link javax.ws.rs.Path} annotation to the Dropwizard environment and
registers it with the SOA {@link com.bazaarvoice.ostrich.ServiceRegistry}. | [
"Adds",
"a",
"Jersey",
"resource",
"annotated",
"with",
"the",
"{"
] | train | https://github.com/bazaarvoice/emodb/blob/97ec7671bc78b47fc2a1c11298c0c872bd5ec7fb/common/dropwizard/src/main/java/com/bazaarvoice/emodb/common/dropwizard/discovery/DropwizardResourceRegistry.java#L39-L44 |
att/AAF | authz/authz-certman/src/main/java/com/att/authz/cm/service/CertManAPI.java | CertManAPI.route | public void route(HttpMethods meth, String path, API api, Code code) throws Exception {
String version = "1.0";
// Get Correct API Class from Mapper
Class<?> respCls = facade1_0.mapper().getClass(api);
if(respCls==null) throw new Exception("Unknown class associated with " + api.getClass().getName() + ' ' + api.name());
// setup Application API HTML ContentTypes for JSON and Route
String application = applicationJSON(respCls, version);
route(env,meth,path,code,application,"application/json;version="+version,"*/*");
// setup Application API HTML ContentTypes for XML and Route
application = applicationXML(respCls, version);
route(env,meth,path,code.clone(facade1_0_XML),application,"application/xml;version="+version);
// Add other Supported APIs here as created
} | java | public void route(HttpMethods meth, String path, API api, Code code) throws Exception {
String version = "1.0";
// Get Correct API Class from Mapper
Class<?> respCls = facade1_0.mapper().getClass(api);
if(respCls==null) throw new Exception("Unknown class associated with " + api.getClass().getName() + ' ' + api.name());
// setup Application API HTML ContentTypes for JSON and Route
String application = applicationJSON(respCls, version);
route(env,meth,path,code,application,"application/json;version="+version,"*/*");
// setup Application API HTML ContentTypes for XML and Route
application = applicationXML(respCls, version);
route(env,meth,path,code.clone(facade1_0_XML),application,"application/xml;version="+version);
// Add other Supported APIs here as created
} | [
"public",
"void",
"route",
"(",
"HttpMethods",
"meth",
",",
"String",
"path",
",",
"API",
"api",
",",
"Code",
"code",
")",
"throws",
"Exception",
"{",
"String",
"version",
"=",
"\"1.0\"",
";",
"// Get Correct API Class from Mapper",
"Class",
"<",
"?",
">",
"... | Setup XML and JSON implementations for each supported Version type
We do this by taking the Code passed in and creating clones of these with the appropriate Facades and properties
to do Versions and Content switches | [
"Setup",
"XML",
"and",
"JSON",
"implementations",
"for",
"each",
"supported",
"Version",
"type"
] | train | https://github.com/att/AAF/blob/090562e956c0035db972aafba844dc6d3fc948ee/authz/authz-certman/src/main/java/com/att/authz/cm/service/CertManAPI.java#L170-L184 |
apache/groovy | subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/extensions/DateUtilExtensions.java | DateUtilExtensions.plus | public static Timestamp plus(Timestamp self, int days) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(self);
calendar.add(Calendar.DATE, days);
Timestamp ts = new Timestamp(calendar.getTime().getTime());
ts.setNanos(self.getNanos());
return ts;
} | java | public static Timestamp plus(Timestamp self, int days) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(self);
calendar.add(Calendar.DATE, days);
Timestamp ts = new Timestamp(calendar.getTime().getTime());
ts.setNanos(self.getNanos());
return ts;
} | [
"public",
"static",
"Timestamp",
"plus",
"(",
"Timestamp",
"self",
",",
"int",
"days",
")",
"{",
"Calendar",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"calendar",
".",
"setTime",
"(",
"self",
")",
";",
"calendar",
".",
"add",
"(",
... | Add number of days to this Timestamp and returns the new Timestamp object.
@param self a Timestamp
@param days the number of days to increase
@return the new Timestamp | [
"Add",
"number",
"of",
"days",
"to",
"this",
"Timestamp",
"and",
"returns",
"the",
"new",
"Timestamp",
"object",
"."
] | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/extensions/DateUtilExtensions.java#L403-L410 |
auth0/Auth0.Android | auth0/src/main/java/com/auth0/android/provider/CallbackHelper.java | CallbackHelper.getCallbackUri | public static String getCallbackUri(@NonNull String scheme, @NonNull String packageName, @NonNull String domain) {
if (!URLUtil.isValidUrl(domain)) {
Log.e(TAG, "The Domain is invalid and the Callback URI will not be set. You used: " + domain);
return null;
}
Uri uri = Uri.parse(domain)
.buildUpon()
.scheme(scheme)
.appendPath("android")
.appendPath(packageName)
.appendPath("callback")
.build();
Log.v(TAG, "The Callback URI is: " + uri);
return uri.toString();
} | java | public static String getCallbackUri(@NonNull String scheme, @NonNull String packageName, @NonNull String domain) {
if (!URLUtil.isValidUrl(domain)) {
Log.e(TAG, "The Domain is invalid and the Callback URI will not be set. You used: " + domain);
return null;
}
Uri uri = Uri.parse(domain)
.buildUpon()
.scheme(scheme)
.appendPath("android")
.appendPath(packageName)
.appendPath("callback")
.build();
Log.v(TAG, "The Callback URI is: " + uri);
return uri.toString();
} | [
"public",
"static",
"String",
"getCallbackUri",
"(",
"@",
"NonNull",
"String",
"scheme",
",",
"@",
"NonNull",
"String",
"packageName",
",",
"@",
"NonNull",
"String",
"domain",
")",
"{",
"if",
"(",
"!",
"URLUtil",
".",
"isValidUrl",
"(",
"domain",
")",
")",... | Generates the callback Uri for the given domain.
@return the callback Uri. | [
"Generates",
"the",
"callback",
"Uri",
"for",
"the",
"given",
"domain",
"."
] | train | https://github.com/auth0/Auth0.Android/blob/ee37b7f94d989c1fbab2cb1378c87fdcaf7a8156/auth0/src/main/java/com/auth0/android/provider/CallbackHelper.java#L45-L61 |
firebase/geofire-java | common/src/main/java/com/firebase/geofire/GeoQuery.java | GeoQuery.setLocation | public synchronized void setLocation(GeoLocation center, double radius) {
this.center = center;
// convert radius to meters
this.radius = capRadius(radius) * KILOMETER_TO_METER;
if (this.hasListeners()) {
this.setupQueries();
}
} | java | public synchronized void setLocation(GeoLocation center, double radius) {
this.center = center;
// convert radius to meters
this.radius = capRadius(radius) * KILOMETER_TO_METER;
if (this.hasListeners()) {
this.setupQueries();
}
} | [
"public",
"synchronized",
"void",
"setLocation",
"(",
"GeoLocation",
"center",
",",
"double",
"radius",
")",
"{",
"this",
".",
"center",
"=",
"center",
";",
"// convert radius to meters",
"this",
".",
"radius",
"=",
"capRadius",
"(",
"radius",
")",
"*",
"KILOM... | Sets the center and radius (in kilometers) of this query, and triggers new events if necessary.
@param center The new center
@param radius The radius of the query, in kilometers. The maximum radius that is
supported is about 8587km. If a radius bigger than this is passed we'll cap it. | [
"Sets",
"the",
"center",
"and",
"radius",
"(",
"in",
"kilometers",
")",
"of",
"this",
"query",
"and",
"triggers",
"new",
"events",
"if",
"necessary",
"."
] | train | https://github.com/firebase/geofire-java/blob/c46ff339060d150741a8d0d40c8e73b78edca6c3/common/src/main/java/com/firebase/geofire/GeoQuery.java#L466-L473 |
jbundle/jbundle | thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/TableProxy.java | TableProxy.get | public Object get(int iRowIndex, int iRowCount) throws DBException, RemoteException
{
BaseTransport transport = this.createProxyTransport(GET);
transport.addParam(INDEX, iRowIndex);
transport.addParam(COUNT, iRowCount);
Object strReturn = transport.sendMessageAndGetReply();
Object objReturn = transport.convertReturnObject(strReturn);
return this.checkDBException(objReturn);
} | java | public Object get(int iRowIndex, int iRowCount) throws DBException, RemoteException
{
BaseTransport transport = this.createProxyTransport(GET);
transport.addParam(INDEX, iRowIndex);
transport.addParam(COUNT, iRowCount);
Object strReturn = transport.sendMessageAndGetReply();
Object objReturn = transport.convertReturnObject(strReturn);
return this.checkDBException(objReturn);
} | [
"public",
"Object",
"get",
"(",
"int",
"iRowIndex",
",",
"int",
"iRowCount",
")",
"throws",
"DBException",
",",
"RemoteException",
"{",
"BaseTransport",
"transport",
"=",
"this",
".",
"createProxyTransport",
"(",
"GET",
")",
";",
"transport",
".",
"addParam",
... | Receive this relative record in the table.
<p>Note: This is usually used only by thin clients, as thick clients have the code to
fake absolute access.
@param iRowIndex The row to retrieve.
@param iRowCount The number of rows to retrieve (Used only by CachedRemoteTable).
@return The record(s) or an error code as an Integer.
@exception Exception File exception. | [
"Receive",
"this",
"relative",
"record",
"in",
"the",
"table",
".",
"<p",
">",
"Note",
":",
"This",
"is",
"usually",
"used",
"only",
"by",
"thin",
"clients",
"as",
"thick",
"clients",
"have",
"the",
"code",
"to",
"fake",
"absolute",
"access",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/TableProxy.java#L226-L234 |
Wadpam/guja | guja-core/src/main/java/com/wadpam/guja/oauth2/api/OAuth2AuthorizationResource.java | OAuth2AuthorizationResource.refreshAccessToken | @POST
@Path("refresh")
@Consumes(MediaType.APPLICATION_JSON)
public Response refreshAccessToken(RefreshTokenRequest refreshToken) {
// Perform all validation here to control the exact error message returned to comply with the Oauth2 standard
if (null == refreshToken.getRefresh_token() ||
null == refreshToken.getGrant_type()) {
throw new BadRequestRestException(ImmutableMap.of("error", "invalid_request"));
}
if (!REFRESH_TOKEN_GRANT_TYPE.equals(refreshToken.getGrant_type())) {
// Unsupported grant type
throw new BadRequestRestException(ImmutableMap.of("error", "unsupported_grant_type"));
}
DConnection connection = connectionDao.findByRefreshToken(refreshToken.getRefresh_token());
if (null == connection) {
throw new BadRequestRestException(ImmutableMap.of("error", "invalid_grant"));
}
// Invalidate the old cache key
connectionDao.invalidateCacheKey(connection.getAccessToken());
connection.setAccessToken(accessTokenGenerator.generate());
connection.setExpireTime(calculateExpirationDate(tokenExpiresIn));
connectionDao.putWithCacheKey(connection.getAccessToken(), connection);
return Response.ok(ImmutableMap.builder()
.put("access_token", connection.getAccessToken())
.put("refresh_token", connection.getRefreshToken())
.put("expires_in", tokenExpiresIn)
.build())
.cookie(createCookie(connection.getAccessToken(), tokenExpiresIn))
.build();
} | java | @POST
@Path("refresh")
@Consumes(MediaType.APPLICATION_JSON)
public Response refreshAccessToken(RefreshTokenRequest refreshToken) {
// Perform all validation here to control the exact error message returned to comply with the Oauth2 standard
if (null == refreshToken.getRefresh_token() ||
null == refreshToken.getGrant_type()) {
throw new BadRequestRestException(ImmutableMap.of("error", "invalid_request"));
}
if (!REFRESH_TOKEN_GRANT_TYPE.equals(refreshToken.getGrant_type())) {
// Unsupported grant type
throw new BadRequestRestException(ImmutableMap.of("error", "unsupported_grant_type"));
}
DConnection connection = connectionDao.findByRefreshToken(refreshToken.getRefresh_token());
if (null == connection) {
throw new BadRequestRestException(ImmutableMap.of("error", "invalid_grant"));
}
// Invalidate the old cache key
connectionDao.invalidateCacheKey(connection.getAccessToken());
connection.setAccessToken(accessTokenGenerator.generate());
connection.setExpireTime(calculateExpirationDate(tokenExpiresIn));
connectionDao.putWithCacheKey(connection.getAccessToken(), connection);
return Response.ok(ImmutableMap.builder()
.put("access_token", connection.getAccessToken())
.put("refresh_token", connection.getRefreshToken())
.put("expires_in", tokenExpiresIn)
.build())
.cookie(createCookie(connection.getAccessToken(), tokenExpiresIn))
.build();
} | [
"@",
"POST",
"@",
"Path",
"(",
"\"refresh\"",
")",
"@",
"Consumes",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"public",
"Response",
"refreshAccessToken",
"(",
"RefreshTokenRequest",
"refreshToken",
")",
"{",
"// Perform all validation here to control the exact error... | Refresh an access_token using the refresh token
@param refreshToken refresh token
@return @return access_token and refresh token if successful.
Success response http://tools.ietf.org/html/rfc6749#section-5.1
Failure response http://tools.ietf.org/html/rfc6749#section-5.2 | [
"Refresh",
"an",
"access_token",
"using",
"the",
"refresh",
"token"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-core/src/main/java/com/wadpam/guja/oauth2/api/OAuth2AuthorizationResource.java#L206-L243 |
legsem/legstar-core2 | legstar-base/src/main/java/com/legstar/base/type/primitive/CobolPrimitiveType.java | CobolPrimitiveType.fromHost | public FromHostPrimitiveResult < T > fromHost(CobolContext cobolContext,
byte[] hostData, int start) {
return fromHost(javaClass, cobolContext, hostData, start);
} | java | public FromHostPrimitiveResult < T > fromHost(CobolContext cobolContext,
byte[] hostData, int start) {
return fromHost(javaClass, cobolContext, hostData, start);
} | [
"public",
"FromHostPrimitiveResult",
"<",
"T",
">",
"fromHost",
"(",
"CobolContext",
"cobolContext",
",",
"byte",
"[",
"]",
"hostData",
",",
"int",
"start",
")",
"{",
"return",
"fromHost",
"(",
"javaClass",
",",
"cobolContext",
",",
"hostData",
",",
"start",
... | Convert mainframe data into a Java object.
@param cobolContext host COBOL configuration parameters
@param hostData the byte array containing mainframe data
@param start the start position for the expected type in the byte array
@return the mainframe value as a java object | [
"Convert",
"mainframe",
"data",
"into",
"a",
"Java",
"object",
"."
] | train | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-base/src/main/java/com/legstar/base/type/primitive/CobolPrimitiveType.java#L79-L82 |
marvinlabs/android-floatinglabel-widgets | library/src/main/java/com/marvinlabs/widget/floatinglabel/instantpicker/TimePickerFragment.java | TimePickerFragment.newInstance | public static <TimeInstantT extends TimeInstant> TimePickerFragment newInstance(int pickerId, TimeInstantT selectedInstant) {
TimePickerFragment f = new TimePickerFragment();
Bundle args = new Bundle();
args.putInt(ARG_PICKER_ID, pickerId);
args.putParcelable(ARG_SELECTED_INSTANT, selectedInstant);
f.setArguments(args);
return f;
} | java | public static <TimeInstantT extends TimeInstant> TimePickerFragment newInstance(int pickerId, TimeInstantT selectedInstant) {
TimePickerFragment f = new TimePickerFragment();
Bundle args = new Bundle();
args.putInt(ARG_PICKER_ID, pickerId);
args.putParcelable(ARG_SELECTED_INSTANT, selectedInstant);
f.setArguments(args);
return f;
} | [
"public",
"static",
"<",
"TimeInstantT",
"extends",
"TimeInstant",
">",
"TimePickerFragment",
"newInstance",
"(",
"int",
"pickerId",
",",
"TimeInstantT",
"selectedInstant",
")",
"{",
"TimePickerFragment",
"f",
"=",
"new",
"TimePickerFragment",
"(",
")",
";",
"Bundle... | Create a new time picker
@param pickerId The id of the item picker
@param selectedInstant The positions of the items already selected
@return The arguments bundle | [
"Create",
"a",
"new",
"time",
"picker"
] | train | https://github.com/marvinlabs/android-floatinglabel-widgets/blob/bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f/library/src/main/java/com/marvinlabs/widget/floatinglabel/instantpicker/TimePickerFragment.java#L33-L42 |
mboudreau/Alternator | src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java | DynamoDBMapper.getVersionAttributeValue | private AttributeValue getVersionAttributeValue(final Method getter, Object getterReturnResult) {
ArgumentMarshaller marshaller = reflector.getVersionedArgumentMarshaller(getter, getterReturnResult);
return marshaller.marshall(getterReturnResult);
} | java | private AttributeValue getVersionAttributeValue(final Method getter, Object getterReturnResult) {
ArgumentMarshaller marshaller = reflector.getVersionedArgumentMarshaller(getter, getterReturnResult);
return marshaller.marshall(getterReturnResult);
} | [
"private",
"AttributeValue",
"getVersionAttributeValue",
"(",
"final",
"Method",
"getter",
",",
"Object",
"getterReturnResult",
")",
"{",
"ArgumentMarshaller",
"marshaller",
"=",
"reflector",
".",
"getVersionedArgumentMarshaller",
"(",
"getter",
",",
"getterReturnResult",
... | Gets the attribute value object corresponding to the
{@link DynamoDBVersionAttribute} getter, and its result, given. Null
values are assumed to be new objects and given the smallest possible
positive value. Non-null values are incremented from their current value. | [
"Gets",
"the",
"attribute",
"value",
"object",
"corresponding",
"to",
"the",
"{"
] | train | https://github.com/mboudreau/Alternator/blob/4b230ac843494cb10e46ddc2848f5b5d377d7b72/src/main/java/com/amazonaws/services/dynamodb/datamodeling/DynamoDBMapper.java#L1020-L1023 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/fs/CreateOptions.java | CreateOptions.getOpt | public static CreateOptions getOpt(Class<? extends CreateOptions> theClass, CreateOptions... opts) {
if (opts == null)
return null;
CreateOptions result = null;
for (int i = 0; i < opts.length; ++i) {
if (opts[i].getClass() == theClass) {
if (result != null)
throw new IllegalArgumentException("Multiple args with type " + theClass);
result = opts[i];
}
}
return result;
} | java | public static CreateOptions getOpt(Class<? extends CreateOptions> theClass, CreateOptions... opts) {
if (opts == null)
return null;
CreateOptions result = null;
for (int i = 0; i < opts.length; ++i) {
if (opts[i].getClass() == theClass) {
if (result != null)
throw new IllegalArgumentException("Multiple args with type " + theClass);
result = opts[i];
}
}
return result;
} | [
"public",
"static",
"CreateOptions",
"getOpt",
"(",
"Class",
"<",
"?",
"extends",
"CreateOptions",
">",
"theClass",
",",
"CreateOptions",
"...",
"opts",
")",
"{",
"if",
"(",
"opts",
"==",
"null",
")",
"return",
"null",
";",
"CreateOptions",
"result",
"=",
... | Get an option of desired type
@param theClass
is the desired class of the opt
@param opts
- not null - at least one opt must be passed
@return an opt from one of the opts of type theClass.
returns null if there isn't any | [
"Get",
"an",
"option",
"of",
"desired",
"type"
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/fs/CreateOptions.java#L145-L157 |
Metatavu/edelphi | edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/AbstractReportPageCommentProcessor.java | AbstractReportPageCommentProcessor.setCommentLabel | protected void setCommentLabel(Long id, String caption, String value) {
Map<String, String> valueMap = answers.get(id);
if (valueMap == null) {
valueMap = new LinkedHashMap<>();
}
valueMap.put(caption, value);
answers.put(id, valueMap);
} | java | protected void setCommentLabel(Long id, String caption, String value) {
Map<String, String> valueMap = answers.get(id);
if (valueMap == null) {
valueMap = new LinkedHashMap<>();
}
valueMap.put(caption, value);
answers.put(id, valueMap);
} | [
"protected",
"void",
"setCommentLabel",
"(",
"Long",
"id",
",",
"String",
"caption",
",",
"String",
"value",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"valueMap",
"=",
"answers",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"valueMap",
"==",
... | Sets a label for a specified comment
@param id comment id
@param caption caption
@param value value | [
"Sets",
"a",
"label",
"for",
"a",
"specified",
"comment"
] | train | https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/comments/AbstractReportPageCommentProcessor.java#L101-L109 |
lessthanoptimal/ejml | main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java | CommonOps_DSCC.removeZeros | public static void removeZeros( DMatrixSparseCSC input , DMatrixSparseCSC output , double tol ) {
ImplCommonOps_DSCC.removeZeros(input,output,tol);
} | java | public static void removeZeros( DMatrixSparseCSC input , DMatrixSparseCSC output , double tol ) {
ImplCommonOps_DSCC.removeZeros(input,output,tol);
} | [
"public",
"static",
"void",
"removeZeros",
"(",
"DMatrixSparseCSC",
"input",
",",
"DMatrixSparseCSC",
"output",
",",
"double",
"tol",
")",
"{",
"ImplCommonOps_DSCC",
".",
"removeZeros",
"(",
"input",
",",
"output",
",",
"tol",
")",
";",
"}"
] | Copies all elements from input into output which are > tol.
@param input (Input) input matrix. Not modified.
@param output (Output) Output matrix. Modified and shaped to match input.
@param tol Tolerance for defining zero | [
"Copies",
"all",
"elements",
"from",
"input",
"into",
"output",
"which",
"are",
">",
";",
"tol",
"."
] | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-dsparse/src/org/ejml/sparse/csc/CommonOps_DSCC.java#L1761-L1763 |
logic-ng/LogicNG | src/main/java/org/logicng/collections/LNGBooleanVector.java | LNGBooleanVector.growTo | public void growTo(int size, boolean pad) {
if (this.size >= size)
return;
this.ensure(size);
for (int i = this.size; i < size; i++)
this.elements[i] = pad;
this.size = size;
} | java | public void growTo(int size, boolean pad) {
if (this.size >= size)
return;
this.ensure(size);
for (int i = this.size; i < size; i++)
this.elements[i] = pad;
this.size = size;
} | [
"public",
"void",
"growTo",
"(",
"int",
"size",
",",
"boolean",
"pad",
")",
"{",
"if",
"(",
"this",
".",
"size",
">=",
"size",
")",
"return",
";",
"this",
".",
"ensure",
"(",
"size",
")",
";",
"for",
"(",
"int",
"i",
"=",
"this",
".",
"size",
"... | Grows the vector to a new size and initializes the new elements with a given value.
@param size the new size
@param pad the value for new elements | [
"Grows",
"the",
"vector",
"to",
"a",
"new",
"size",
"and",
"initializes",
"the",
"new",
"elements",
"with",
"a",
"given",
"value",
"."
] | train | https://github.com/logic-ng/LogicNG/blob/bb9eb88a768be4be8e02a76cfc4a59e6c3fb7f2e/src/main/java/org/logicng/collections/LNGBooleanVector.java#L176-L183 |
apereo/cas | core/cas-server-core-authentication-mfa-api/src/main/java/org/apereo/cas/authentication/MultifactorAuthenticationUtils.java | MultifactorAuthenticationUtils.resolveEventViaSingleAttribute | @SneakyThrows
public static Set<Event> resolveEventViaSingleAttribute(final Principal principal,
final Object attributeValue,
final RegisteredService service,
final Optional<RequestContext> context,
final MultifactorAuthenticationProvider provider,
final Predicate<String> predicate) {
if (!(attributeValue instanceof Collection)) {
LOGGER.debug("Attribute value [{}] is a single-valued attribute", attributeValue);
if (predicate.test(attributeValue.toString())) {
LOGGER.debug("Attribute value predicate [{}] has matched the [{}]", predicate, attributeValue);
return evaluateEventForProviderInContext(principal, service, context, provider);
}
LOGGER.debug("Attribute value predicate [{}] could not match the [{}]", predicate, attributeValue);
}
LOGGER.debug("Attribute value [{}] is not a single-valued attribute", attributeValue);
return null;
} | java | @SneakyThrows
public static Set<Event> resolveEventViaSingleAttribute(final Principal principal,
final Object attributeValue,
final RegisteredService service,
final Optional<RequestContext> context,
final MultifactorAuthenticationProvider provider,
final Predicate<String> predicate) {
if (!(attributeValue instanceof Collection)) {
LOGGER.debug("Attribute value [{}] is a single-valued attribute", attributeValue);
if (predicate.test(attributeValue.toString())) {
LOGGER.debug("Attribute value predicate [{}] has matched the [{}]", predicate, attributeValue);
return evaluateEventForProviderInContext(principal, service, context, provider);
}
LOGGER.debug("Attribute value predicate [{}] could not match the [{}]", predicate, attributeValue);
}
LOGGER.debug("Attribute value [{}] is not a single-valued attribute", attributeValue);
return null;
} | [
"@",
"SneakyThrows",
"public",
"static",
"Set",
"<",
"Event",
">",
"resolveEventViaSingleAttribute",
"(",
"final",
"Principal",
"principal",
",",
"final",
"Object",
"attributeValue",
",",
"final",
"RegisteredService",
"service",
",",
"final",
"Optional",
"<",
"Reque... | Resolve event via single attribute set.
@param principal the principal
@param attributeValue the attribute value
@param service the service
@param context the context
@param provider the provider
@param predicate the predicate
@return the set | [
"Resolve",
"event",
"via",
"single",
"attribute",
"set",
"."
] | train | https://github.com/apereo/cas/blob/b4b306433a8782cef803a39bea5b1f96740e0e9b/core/cas-server-core-authentication-mfa-api/src/main/java/org/apereo/cas/authentication/MultifactorAuthenticationUtils.java#L156-L174 |
carewebframework/carewebframework-core | org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/property/PropertyUtil.java | PropertyUtil.saveValues | public static void saveValues(String propertyName, String instanceName, boolean asGlobal, List<String> value) {
getPropertyService().saveValues(propertyName, instanceName, asGlobal, value);
} | java | public static void saveValues(String propertyName, String instanceName, boolean asGlobal, List<String> value) {
getPropertyService().saveValues(propertyName, instanceName, asGlobal, value);
} | [
"public",
"static",
"void",
"saveValues",
"(",
"String",
"propertyName",
",",
"String",
"instanceName",
",",
"boolean",
"asGlobal",
",",
"List",
"<",
"String",
">",
"value",
")",
"{",
"getPropertyService",
"(",
")",
".",
"saveValues",
"(",
"propertyName",
",",... | Saves a value list to the underlying property store.
@param propertyName Name of the property to be saved.
@param instanceName An optional instance name. Specify null to indicate the default instance.
@param asGlobal If true, save as a global property. If false, save as a user property.
@param value Value to be saved. If null or empty, any existing values are removed.
@see IPropertyService#getValues | [
"Saves",
"a",
"value",
"list",
"to",
"the",
"underlying",
"property",
"store",
"."
] | train | https://github.com/carewebframework/carewebframework-core/blob/fa3252d4f7541dbe151b92c3d4f6f91433cd1673/org.carewebframework.api-parent/org.carewebframework.api.core/src/main/java/org/carewebframework/api/property/PropertyUtil.java#L132-L134 |
tvesalainen/util | util/src/main/java/org/vesalainen/nio/IntArray.java | IntArray.getInstance | public static IntArray getInstance(byte[] buffer, int offset, int length, int bitCount, ByteOrder order)
{
ByteBuffer bb = ByteBuffer.wrap(buffer, offset, length).order(order);
switch (bitCount)
{
case 8:
return getInstance(bb);
case 16:
return getInstance(bb.asShortBuffer());
case 32:
return getInstance(bb.asIntBuffer());
default:
throw new UnsupportedOperationException(bitCount+" not supported");
}
} | java | public static IntArray getInstance(byte[] buffer, int offset, int length, int bitCount, ByteOrder order)
{
ByteBuffer bb = ByteBuffer.wrap(buffer, offset, length).order(order);
switch (bitCount)
{
case 8:
return getInstance(bb);
case 16:
return getInstance(bb.asShortBuffer());
case 32:
return getInstance(bb.asIntBuffer());
default:
throw new UnsupportedOperationException(bitCount+" not supported");
}
} | [
"public",
"static",
"IntArray",
"getInstance",
"(",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
",",
"int",
"length",
",",
"int",
"bitCount",
",",
"ByteOrder",
"order",
")",
"{",
"ByteBuffer",
"bb",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"buffer",
",... | Creates IntArray backed by byte array with given bit-count and byte-order.
@param buffer
@param offset
@param length
@param bitCount
@param order
@return | [
"Creates",
"IntArray",
"backed",
"by",
"byte",
"array",
"with",
"given",
"bit",
"-",
"count",
"and",
"byte",
"-",
"order",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/IntArray.java#L86-L100 |
Metatavu/edelphi | edelphi/src/main/java/fi/metatavu/edelphi/utils/MaterialUtils.java | MaterialUtils.createIndexPageDocument | public static LocalDocument createIndexPageDocument(Delfoi delfoi, Locale locale, User user) {
LocalDocumentDAO localDocumentDAO = new LocalDocumentDAO();
String urlName = String.format("%s-%s", INDEX_PAGE_URLNAME, locale.getLanguage());
return localDocumentDAO.create(urlName, urlName, delfoi.getRootFolder(), user, 0);
} | java | public static LocalDocument createIndexPageDocument(Delfoi delfoi, Locale locale, User user) {
LocalDocumentDAO localDocumentDAO = new LocalDocumentDAO();
String urlName = String.format("%s-%s", INDEX_PAGE_URLNAME, locale.getLanguage());
return localDocumentDAO.create(urlName, urlName, delfoi.getRootFolder(), user, 0);
} | [
"public",
"static",
"LocalDocument",
"createIndexPageDocument",
"(",
"Delfoi",
"delfoi",
",",
"Locale",
"locale",
",",
"User",
"user",
")",
"{",
"LocalDocumentDAO",
"localDocumentDAO",
"=",
"new",
"LocalDocumentDAO",
"(",
")",
";",
"String",
"urlName",
"=",
"Strin... | Creates index page document
@param delfoi delfoi
@param locale locale
@param user logged user
@return created document | [
"Creates",
"index",
"page",
"document"
] | train | https://github.com/Metatavu/edelphi/blob/d91a0b54f954b33b4ee674a1bdf03612d76c3305/edelphi/src/main/java/fi/metatavu/edelphi/utils/MaterialUtils.java#L96-L100 |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java | HSMDependenceMeasure.drawLine | private static void drawLine(int x0, int y0, int x1, int y1, boolean[][] pic) {
final int xres = pic.length, yres = pic[0].length;
// Ensure bounds
y0 = (y0 < 0) ? 0 : (y0 >= yres) ? (yres - 1) : y0;
y1 = (y1 < 0) ? 0 : (y1 >= yres) ? (yres - 1) : y1;
x0 = (x0 < 0) ? 0 : (x0 >= xres) ? (xres - 1) : x0;
x1 = (x1 < 0) ? 0 : (x1 >= xres) ? (xres - 1) : x1;
// Default slope
final int dx = +Math.abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
final int dy = -Math.abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
// Error counter
int err = dx + dy;
for(;;) {
pic[x0][y0] = true;
if(x0 == x1 && y0 == y1) {
break;
}
final int e2 = err << 1;
if(e2 > dy) {
err += dy;
x0 += sx;
}
if(e2 < dx) {
err += dx;
y0 += sy;
}
}
} | java | private static void drawLine(int x0, int y0, int x1, int y1, boolean[][] pic) {
final int xres = pic.length, yres = pic[0].length;
// Ensure bounds
y0 = (y0 < 0) ? 0 : (y0 >= yres) ? (yres - 1) : y0;
y1 = (y1 < 0) ? 0 : (y1 >= yres) ? (yres - 1) : y1;
x0 = (x0 < 0) ? 0 : (x0 >= xres) ? (xres - 1) : x0;
x1 = (x1 < 0) ? 0 : (x1 >= xres) ? (xres - 1) : x1;
// Default slope
final int dx = +Math.abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
final int dy = -Math.abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
// Error counter
int err = dx + dy;
for(;;) {
pic[x0][y0] = true;
if(x0 == x1 && y0 == y1) {
break;
}
final int e2 = err << 1;
if(e2 > dy) {
err += dy;
x0 += sx;
}
if(e2 < dx) {
err += dx;
y0 += sy;
}
}
} | [
"private",
"static",
"void",
"drawLine",
"(",
"int",
"x0",
",",
"int",
"y0",
",",
"int",
"x1",
",",
"int",
"y1",
",",
"boolean",
"[",
"]",
"[",
"]",
"pic",
")",
"{",
"final",
"int",
"xres",
"=",
"pic",
".",
"length",
",",
"yres",
"=",
"pic",
"[... | Draw a line onto the array, using the classic Bresenham algorithm.
@param x0 Start X
@param y0 Start Y
@param x1 End X
@param y1 End Y
@param pic Picture array | [
"Draw",
"a",
"line",
"onto",
"the",
"array",
"using",
"the",
"classic",
"Bresenham",
"algorithm",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java#L197-L226 |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_add | @Inline(value = "$1.putAll($2)", statementExpression = true)
public static <K, V> void operator_add(Map<K, V> outputMap, Map<? extends K, ? extends V> inputMap) {
outputMap.putAll(inputMap);
} | java | @Inline(value = "$1.putAll($2)", statementExpression = true)
public static <K, V> void operator_add(Map<K, V> outputMap, Map<? extends K, ? extends V> inputMap) {
outputMap.putAll(inputMap);
} | [
"@",
"Inline",
"(",
"value",
"=",
"\"$1.putAll($2)\"",
",",
"statementExpression",
"=",
"true",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"void",
"operator_add",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"outputMap",
",",
"Map",
"<",
"?",
"extends",... | Add the given entries of the input map into the output map.
<p>
If a key in the inputMap already exists in the outputMap, its value is
replaced in the outputMap by the value from the inputMap.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param outputMap the map to update.
@param inputMap the entries to add.
@since 2.15 | [
"Add",
"the",
"given",
"entries",
"of",
"the",
"input",
"map",
"into",
"the",
"output",
"map",
"."
] | train | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L137-L140 |
apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.subSequence | public Bytes subSequence(int start, int end) {
if (start > end || start < 0 || end > length) {
throw new IndexOutOfBoundsException("Bad start and/end start = " + start + " end=" + end
+ " offset=" + offset + " length=" + length);
}
return new Bytes(data, offset + start, end - start);
} | java | public Bytes subSequence(int start, int end) {
if (start > end || start < 0 || end > length) {
throw new IndexOutOfBoundsException("Bad start and/end start = " + start + " end=" + end
+ " offset=" + offset + " length=" + length);
}
return new Bytes(data, offset + start, end - start);
} | [
"public",
"Bytes",
"subSequence",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
">",
"end",
"||",
"start",
"<",
"0",
"||",
"end",
">",
"length",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"Bad start and/end start ... | Returns a portion of the Bytes object
@param start index of subsequence start (inclusive)
@param end index of subsequence end (exclusive) | [
"Returns",
"a",
"portion",
"of",
"the",
"Bytes",
"object"
] | train | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L129-L135 |
jenkinsci/jenkins | core/src/main/java/hudson/util/DescriptorList.java | DescriptorList.newInstanceFromRadioList | @CheckForNull
public T newInstanceFromRadioList(JSONObject parent, String name) throws FormException {
return newInstanceFromRadioList(parent.getJSONObject(name));
} | java | @CheckForNull
public T newInstanceFromRadioList(JSONObject parent, String name) throws FormException {
return newInstanceFromRadioList(parent.getJSONObject(name));
} | [
"@",
"CheckForNull",
"public",
"T",
"newInstanceFromRadioList",
"(",
"JSONObject",
"parent",
",",
"String",
"name",
")",
"throws",
"FormException",
"{",
"return",
"newInstanceFromRadioList",
"(",
"parent",
".",
"getJSONObject",
"(",
"name",
")",
")",
";",
"}"
] | Creates a new instance of a {@link Describable}
from the structured form submission data posted
by a radio button group.
@param parent JSON, which contains the configuration entry for the radio list
@param name Name of the configuration entry for the radio list
@return new instance or {@code null} if none was selected in the radio list
@throws FormException Data submission error | [
"Creates",
"a",
"new",
"instance",
"of",
"a",
"{"
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/util/DescriptorList.java#L177-L180 |
ehcache/ehcache3 | core/src/main/java/org/ehcache/core/spi/service/ServiceUtils.java | ServiceUtils.findOptionalAmongst | public static <T> Optional<T> findOptionalAmongst(Class<T> clazz, Object ... instances) {
return findOptionalAmongst(clazz, Arrays.asList(instances));
} | java | public static <T> Optional<T> findOptionalAmongst(Class<T> clazz, Object ... instances) {
return findOptionalAmongst(clazz, Arrays.asList(instances));
} | [
"public",
"static",
"<",
"T",
">",
"Optional",
"<",
"T",
">",
"findOptionalAmongst",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"Object",
"...",
"instances",
")",
"{",
"return",
"findOptionalAmongst",
"(",
"clazz",
",",
"Arrays",
".",
"asList",
"(",
"ins... | Find the only expected instance of {@code clazz} among the {@code instances}.
@param clazz searched class
@param instances instances looked at
@param <T> type of the searched instance
@return the optionally found compatible instance
@throws IllegalArgumentException if more than one matching instance | [
"Find",
"the",
"only",
"expected",
"instance",
"of",
"{",
"@code",
"clazz",
"}",
"among",
"the",
"{",
"@code",
"instances",
"}",
"."
] | train | https://github.com/ehcache/ehcache3/blob/3cceda57185e522f8d241ddb75146d67ee2af898/core/src/main/java/org/ehcache/core/spi/service/ServiceUtils.java#L118-L120 |
actorapp/actor-platform | actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/collections/SparseBooleanArray.java | SparseBooleanArray.put | public void put(int key, boolean value) {
int i = ContainerHelpers.binarySearch(mKeys, mSize, key);
if (i >= 0) {
mValues[i] = value;
} else {
i = ~i;
mKeys = GrowingArrayUtils.insert(mKeys, mSize, i, key);
mValues = GrowingArrayUtils.insert(mValues, mSize, i, value);
mSize++;
}
} | java | public void put(int key, boolean value) {
int i = ContainerHelpers.binarySearch(mKeys, mSize, key);
if (i >= 0) {
mValues[i] = value;
} else {
i = ~i;
mKeys = GrowingArrayUtils.insert(mKeys, mSize, i, key);
mValues = GrowingArrayUtils.insert(mValues, mSize, i, value);
mSize++;
}
} | [
"public",
"void",
"put",
"(",
"int",
"key",
",",
"boolean",
"value",
")",
"{",
"int",
"i",
"=",
"ContainerHelpers",
".",
"binarySearch",
"(",
"mKeys",
",",
"mSize",
",",
"key",
")",
";",
"if",
"(",
"i",
">=",
"0",
")",
"{",
"mValues",
"[",
"i",
"... | Adds a mapping from the specified key to the specified value,
replacing the previous mapping from the specified key if there
was one. | [
"Adds",
"a",
"mapping",
"from",
"the",
"specified",
"key",
"to",
"the",
"specified",
"value",
"replacing",
"the",
"previous",
"mapping",
"from",
"the",
"specified",
"key",
"if",
"there",
"was",
"one",
"."
] | train | https://github.com/actorapp/actor-platform/blob/5123c1584757c6eeea0ed2a0e7e043629871a0c6/actor-sdk/sdk-core/runtime/runtime-shared/src/main/java/im/actor/runtime/collections/SparseBooleanArray.java#L121-L131 |
sdl/odata | odata_renderer/src/main/java/com/sdl/odata/renderer/AbstractRenderer.java | AbstractRenderer.scoreByFormat | protected int scoreByFormat(Option<FormatOption> formatOption, MediaType requiredMediaType) {
if (!formatOption.isDefined()) {
return DEFAULT_SCORE;
}
if (formatOption.get().mediaType().matches(requiredMediaType)) {
return MAXIMUM_FORMAT_SCORE;
}
return DEFAULT_SCORE;
} | java | protected int scoreByFormat(Option<FormatOption> formatOption, MediaType requiredMediaType) {
if (!formatOption.isDefined()) {
return DEFAULT_SCORE;
}
if (formatOption.get().mediaType().matches(requiredMediaType)) {
return MAXIMUM_FORMAT_SCORE;
}
return DEFAULT_SCORE;
} | [
"protected",
"int",
"scoreByFormat",
"(",
"Option",
"<",
"FormatOption",
">",
"formatOption",
",",
"MediaType",
"requiredMediaType",
")",
"{",
"if",
"(",
"!",
"formatOption",
".",
"isDefined",
"(",
")",
")",
"{",
"return",
"DEFAULT_SCORE",
";",
"}",
"if",
"(... | Computes a score by checking the value of the '$format' parameter (if present) against a required media type.
@param formatOption The option containing the '$format' parameter.
@param requiredMediaType The required media type.
@return A score that indicates if the media type present in the '$format' parameter
matches the required media type. | [
"Computes",
"a",
"score",
"by",
"checking",
"the",
"value",
"of",
"the",
"$format",
"parameter",
"(",
"if",
"present",
")",
"against",
"a",
"required",
"media",
"type",
"."
] | train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_renderer/src/main/java/com/sdl/odata/renderer/AbstractRenderer.java#L140-L148 |
finmath/finmath-lib | src/main/java6/net/finmath/montecarlo/interestrate/LIBORMarketModelStandard.java | LIBORMarketModelStandard.getDrift | private RandomVariableInterface getDrift(int timeIndex, int componentIndex, RandomVariableInterface[] realizationAtTimeIndex, RandomVariableInterface[] realizationPredictor) {
// Check if this LIBOR is already fixed
if(getTime(timeIndex) >= this.getLiborPeriod(componentIndex)) {
return null;
}
/*
* We implemented several different methods to calculate the drift
*/
if(driftApproximationMethod == Driftapproximation.PREDICTOR_CORRECTOR && realizationPredictor != null) {
RandomVariableInterface drift = getDriftEuler(timeIndex, componentIndex, realizationAtTimeIndex);
RandomVariableInterface driftEulerWithPredictor = getDriftEuler(timeIndex, componentIndex, realizationPredictor);
drift = drift.add(driftEulerWithPredictor).div(2.0);
return drift;
}
else if(driftApproximationMethod == Driftapproximation.LINE_INTEGRAL && realizationPredictor != null) {
return getDriftLineIntegral(timeIndex, componentIndex, realizationAtTimeIndex, realizationPredictor);
}
else {
return getDriftEuler(timeIndex, componentIndex, realizationAtTimeIndex);
}
} | java | private RandomVariableInterface getDrift(int timeIndex, int componentIndex, RandomVariableInterface[] realizationAtTimeIndex, RandomVariableInterface[] realizationPredictor) {
// Check if this LIBOR is already fixed
if(getTime(timeIndex) >= this.getLiborPeriod(componentIndex)) {
return null;
}
/*
* We implemented several different methods to calculate the drift
*/
if(driftApproximationMethod == Driftapproximation.PREDICTOR_CORRECTOR && realizationPredictor != null) {
RandomVariableInterface drift = getDriftEuler(timeIndex, componentIndex, realizationAtTimeIndex);
RandomVariableInterface driftEulerWithPredictor = getDriftEuler(timeIndex, componentIndex, realizationPredictor);
drift = drift.add(driftEulerWithPredictor).div(2.0);
return drift;
}
else if(driftApproximationMethod == Driftapproximation.LINE_INTEGRAL && realizationPredictor != null) {
return getDriftLineIntegral(timeIndex, componentIndex, realizationAtTimeIndex, realizationPredictor);
}
else {
return getDriftEuler(timeIndex, componentIndex, realizationAtTimeIndex);
}
} | [
"private",
"RandomVariableInterface",
"getDrift",
"(",
"int",
"timeIndex",
",",
"int",
"componentIndex",
",",
"RandomVariableInterface",
"[",
"]",
"realizationAtTimeIndex",
",",
"RandomVariableInterface",
"[",
"]",
"realizationPredictor",
")",
"{",
"// Check if this LIBOR i... | Alternative implementation for the drift. For experimental purposes.
@param timeIndex
@param componentIndex
@param realizationAtTimeIndex
@param realizationPredictor
@return | [
"Alternative",
"implementation",
"for",
"the",
"drift",
".",
"For",
"experimental",
"purposes",
"."
] | train | https://github.com/finmath/finmath-lib/blob/a3c067d52dd33feb97d851df6cab130e4116759f/src/main/java6/net/finmath/montecarlo/interestrate/LIBORMarketModelStandard.java#L638-L661 |
Azure/azure-sdk-for-java | cognitiveservices/resource-manager/v2017_04_18/src/main/java/com/microsoft/azure/management/cognitiveservices/v2017_04_18/implementation/AccountsInner.java | AccountsInner.createAsync | public Observable<CognitiveServicesAccountInner> createAsync(String resourceGroupName, String accountName, CognitiveServicesAccountCreateParameters parameters) {
return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1<ServiceResponse<CognitiveServicesAccountInner>, CognitiveServicesAccountInner>() {
@Override
public CognitiveServicesAccountInner call(ServiceResponse<CognitiveServicesAccountInner> response) {
return response.body();
}
});
} | java | public Observable<CognitiveServicesAccountInner> createAsync(String resourceGroupName, String accountName, CognitiveServicesAccountCreateParameters parameters) {
return createWithServiceResponseAsync(resourceGroupName, accountName, parameters).map(new Func1<ServiceResponse<CognitiveServicesAccountInner>, CognitiveServicesAccountInner>() {
@Override
public CognitiveServicesAccountInner call(ServiceResponse<CognitiveServicesAccountInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"CognitiveServicesAccountInner",
">",
"createAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"accountName",
",",
"CognitiveServicesAccountCreateParameters",
"parameters",
")",
"{",
"return",
"createWithServiceResponseAsync",
"(",
"resou... | Create Cognitive Services Account. Accounts is a resource group wide resource type. It holds the keys for developer to access intelligent APIs. It's also the resource type for billing.
@param resourceGroupName The name of the resource group within the user's subscription.
@param accountName The name of Cognitive Services account.
@param parameters The parameters to provide for the created account.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the CognitiveServicesAccountInner object | [
"Create",
"Cognitive",
"Services",
"Account",
".",
"Accounts",
"is",
"a",
"resource",
"group",
"wide",
"resource",
"type",
".",
"It",
"holds",
"the",
"keys",
"for",
"developer",
"to",
"access",
"intelligent",
"APIs",
".",
"It",
"s",
"also",
"the",
"resource"... | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/resource-manager/v2017_04_18/src/main/java/com/microsoft/azure/management/cognitiveservices/v2017_04_18/implementation/AccountsInner.java#L163-L170 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectInputStream.java | ObjectInputStream.readFieldDescriptors | private void readFieldDescriptors(ObjectStreamClass cDesc)
throws ClassNotFoundException, IOException {
short numFields = input.readShort();
ObjectStreamField[] fields = new ObjectStreamField[numFields];
// We set it now, but each element will be inserted in the array further
// down
cDesc.setLoadFields(fields);
// Check ObjectOutputStream.writeFieldDescriptors
for (short i = 0; i < numFields; i++) {
char typecode = (char) input.readByte();
String fieldName = input.readUTF();
boolean isPrimType = ObjectStreamClass.isPrimitiveType(typecode);
String classSig;
if (isPrimType) {
classSig = String.valueOf(typecode);
} else {
// The spec says it is a UTF, but experience shows they dump
// this String using writeObject (unlike the field name, which
// is saved with writeUTF).
// And if resolveObject is enabled, the classSig may be modified
// so that the original class descriptor cannot be read
// properly, so it is disabled.
boolean old = enableResolve;
try {
enableResolve = false;
classSig = (String) readObject();
} finally {
enableResolve = old;
}
}
classSig = formatClassSig(classSig);
ObjectStreamField f = new ObjectStreamField(classSig, fieldName);
fields[i] = f;
}
} | java | private void readFieldDescriptors(ObjectStreamClass cDesc)
throws ClassNotFoundException, IOException {
short numFields = input.readShort();
ObjectStreamField[] fields = new ObjectStreamField[numFields];
// We set it now, but each element will be inserted in the array further
// down
cDesc.setLoadFields(fields);
// Check ObjectOutputStream.writeFieldDescriptors
for (short i = 0; i < numFields; i++) {
char typecode = (char) input.readByte();
String fieldName = input.readUTF();
boolean isPrimType = ObjectStreamClass.isPrimitiveType(typecode);
String classSig;
if (isPrimType) {
classSig = String.valueOf(typecode);
} else {
// The spec says it is a UTF, but experience shows they dump
// this String using writeObject (unlike the field name, which
// is saved with writeUTF).
// And if resolveObject is enabled, the classSig may be modified
// so that the original class descriptor cannot be read
// properly, so it is disabled.
boolean old = enableResolve;
try {
enableResolve = false;
classSig = (String) readObject();
} finally {
enableResolve = old;
}
}
classSig = formatClassSig(classSig);
ObjectStreamField f = new ObjectStreamField(classSig, fieldName);
fields[i] = f;
}
} | [
"private",
"void",
"readFieldDescriptors",
"(",
"ObjectStreamClass",
"cDesc",
")",
"throws",
"ClassNotFoundException",
",",
"IOException",
"{",
"short",
"numFields",
"=",
"input",
".",
"readShort",
"(",
")",
";",
"ObjectStreamField",
"[",
"]",
"fields",
"=",
"new"... | Reads a collection of field descriptors (name, type name, etc) for the
class descriptor {@code cDesc} (an {@code ObjectStreamClass})
@param cDesc
The class descriptor (an {@code ObjectStreamClass})
for which to write field information
@throws IOException
If an IO exception happened when reading the field
descriptors.
@throws ClassNotFoundException
If a class for one of the field types could not be found
@see #readObject() | [
"Reads",
"a",
"collection",
"of",
"field",
"descriptors",
"(",
"name",
"type",
"name",
"etc",
")",
"for",
"the",
"class",
"descriptor",
"{",
"@code",
"cDesc",
"}",
"(",
"an",
"{",
"@code",
"ObjectStreamClass",
"}",
")"
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/io/ObjectInputStream.java#L911-L948 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/AccessControlEntryImpl.java | AccessControlEntryImpl.combineRecursively | protected boolean combineRecursively( List<Privilege> list,
Privilege[] privileges ) {
boolean res = false;
for (Privilege p : privileges) {
if (p.isAggregate()) {
res = combineRecursively(list, p.getAggregatePrivileges());
} else if (!contains(list, p)) {
list.add(p);
res = true;
}
}
return res;
} | java | protected boolean combineRecursively( List<Privilege> list,
Privilege[] privileges ) {
boolean res = false;
for (Privilege p : privileges) {
if (p.isAggregate()) {
res = combineRecursively(list, p.getAggregatePrivileges());
} else if (!contains(list, p)) {
list.add(p);
res = true;
}
}
return res;
} | [
"protected",
"boolean",
"combineRecursively",
"(",
"List",
"<",
"Privilege",
">",
"list",
",",
"Privilege",
"[",
"]",
"privileges",
")",
"{",
"boolean",
"res",
"=",
"false",
";",
"for",
"(",
"Privilege",
"p",
":",
"privileges",
")",
"{",
"if",
"(",
"p",
... | Adds specified privileges to the given list.
@param list the result list of combined privileges.
@param privileges privileges to add.
@return true if at least one of privileges was added. | [
"Adds",
"specified",
"privileges",
"to",
"the",
"given",
"list",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/security/acl/AccessControlEntryImpl.java#L114-L127 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/util/NameUtil.java | NameUtil.getLocalImplClassName | public static String getLocalImplClassName(EnterpriseBean enterpriseBean, boolean isPost11DD) // d114199
{
String localInterfaceName = getLocalInterfaceName(enterpriseBean);
if (localInterfaceName == null) {
return null;
}
String packageName = packageName(localInterfaceName);
String localName = encodeBeanInterfacesName(enterpriseBean, isPost11DD, true, false, false); //d114199 d147734
StringBuffer result = new StringBuffer();
if (packageName != null) {
result.append(packageName);
result.append('.');
}
result.append(localPrefix);
result.append(getUniquePrefix(enterpriseBean));
result.append(localName);
return result.toString();
} | java | public static String getLocalImplClassName(EnterpriseBean enterpriseBean, boolean isPost11DD) // d114199
{
String localInterfaceName = getLocalInterfaceName(enterpriseBean);
if (localInterfaceName == null) {
return null;
}
String packageName = packageName(localInterfaceName);
String localName = encodeBeanInterfacesName(enterpriseBean, isPost11DD, true, false, false); //d114199 d147734
StringBuffer result = new StringBuffer();
if (packageName != null) {
result.append(packageName);
result.append('.');
}
result.append(localPrefix);
result.append(getUniquePrefix(enterpriseBean));
result.append(localName);
return result.toString();
} | [
"public",
"static",
"String",
"getLocalImplClassName",
"(",
"EnterpriseBean",
"enterpriseBean",
",",
"boolean",
"isPost11DD",
")",
"// d114199",
"{",
"String",
"localInterfaceName",
"=",
"getLocalInterfaceName",
"(",
"enterpriseBean",
")",
";",
"if",
"(",
"localInterfac... | Return the name of the deployed class that implements the local
interface of the bean. <p>
@param enterpriseBean bean impl class
@param isPost11DD true if bean is defined using later than 1.1 deployment description. | [
"Return",
"the",
"name",
"of",
"the",
"deployed",
"class",
"that",
"implements",
"the",
"local",
"interface",
"of",
"the",
"bean",
".",
"<p",
">"
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/util/NameUtil.java#L228-L248 |
overturetool/overture | core/interpreter/src/main/java/org/overture/interpreter/assistant/definition/PDefinitionAssistantInterpreter.java | PDefinitionAssistantInterpreter.getValues | public ValueList getValues(PDefinition def, ObjectContext ctxt)
{
try
{
return def.apply(af.getValuesDefinitionLocator(), ctxt);
} catch (AnalysisException e)
{
return null;
}
} | java | public ValueList getValues(PDefinition def, ObjectContext ctxt)
{
try
{
return def.apply(af.getValuesDefinitionLocator(), ctxt);
} catch (AnalysisException e)
{
return null;
}
} | [
"public",
"ValueList",
"getValues",
"(",
"PDefinition",
"def",
",",
"ObjectContext",
"ctxt",
")",
"{",
"try",
"{",
"return",
"def",
".",
"apply",
"(",
"af",
".",
"getValuesDefinitionLocator",
"(",
")",
",",
"ctxt",
")",
";",
"}",
"catch",
"(",
"AnalysisExc... | Return a list of external values that are read by the definition.
@param def
@param ctxt
The context in which to evaluate the expressions.
@return A list of values read. | [
"Return",
"a",
"list",
"of",
"external",
"values",
"that",
"are",
"read",
"by",
"the",
"definition",
"."
] | train | https://github.com/overturetool/overture/blob/83175dc6c24fa171cde4fcf61ecb648eba3bdbc1/core/interpreter/src/main/java/org/overture/interpreter/assistant/definition/PDefinitionAssistantInterpreter.java#L67-L77 |
looly/hutool | hutool-core/src/main/java/cn/hutool/core/util/ClassLoaderUtil.java | ClassLoaderUtil.loadClass | public static Class<?> loadClass(String name, boolean isInitialized) throws UtilException {
return loadClass(name, null, isInitialized);
} | java | public static Class<?> loadClass(String name, boolean isInitialized) throws UtilException {
return loadClass(name, null, isInitialized);
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"loadClass",
"(",
"String",
"name",
",",
"boolean",
"isInitialized",
")",
"throws",
"UtilException",
"{",
"return",
"loadClass",
"(",
"name",
",",
"null",
",",
"isInitialized",
")",
";",
"}"
] | 加载类,通过传入类的字符串,返回其对应的类名,使用默认ClassLoader<br>
扩展{@link Class#forName(String, boolean, ClassLoader)}方法,支持以下几类类名的加载:
<pre>
1、原始类型,例如:int
2、数组类型,例如:int[]、Long[]、String[]
3、内部类,例如:java.lang.Thread.State会被转为java.lang.Thread$State加载
</pre>
@param name 类名
@param isInitialized 是否初始化类(调用static模块内容和初始化static属性)
@return 类名对应的类
@throws UtilException 包装{@link ClassNotFoundException},没有类名对应的类时抛出此异常 | [
"加载类,通过传入类的字符串,返回其对应的类名,使用默认ClassLoader<br",
">",
"扩展",
"{",
"@link",
"Class#forName",
"(",
"String",
"boolean",
"ClassLoader",
")",
"}",
"方法,支持以下几类类名的加载:"
] | train | https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/util/ClassLoaderUtil.java#L125-L127 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/DdosProtectionPlansInner.java | DdosProtectionPlansInner.getByResourceGroup | public DdosProtectionPlanInner getByResourceGroup(String resourceGroupName, String ddosProtectionPlanName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, ddosProtectionPlanName).toBlocking().single().body();
} | java | public DdosProtectionPlanInner getByResourceGroup(String resourceGroupName, String ddosProtectionPlanName) {
return getByResourceGroupWithServiceResponseAsync(resourceGroupName, ddosProtectionPlanName).toBlocking().single().body();
} | [
"public",
"DdosProtectionPlanInner",
"getByResourceGroup",
"(",
"String",
"resourceGroupName",
",",
"String",
"ddosProtectionPlanName",
")",
"{",
"return",
"getByResourceGroupWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"ddosProtectionPlanName",
")",
".",
"toBlocki... | Gets information about the specified DDoS protection plan.
@param resourceGroupName The name of the resource group.
@param ddosProtectionPlanName The name of the DDoS protection plan.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the DdosProtectionPlanInner object if successful. | [
"Gets",
"information",
"about",
"the",
"specified",
"DDoS",
"protection",
"plan",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/DdosProtectionPlansInner.java#L266-L268 |
inferred/FreeBuilder | src/main/java/org/inferred/freebuilder/processor/naming/PrefixlessConvention.java | PrefixlessConvention.methodIsAbstractGetter | private boolean methodIsAbstractGetter(TypeElement valueType, ExecutableElement method) {
Set<Modifier> modifiers = method.getModifiers();
if (!modifiers.contains(Modifier.ABSTRACT)) {
return false;
}
boolean declaredOnValueType = method.getEnclosingElement().equals(valueType);
TypeMirror returnType = getReturnType(valueType, method, types);
if (returnType.getKind() == TypeKind.VOID || !method.getParameters().isEmpty()) {
if (declaredOnValueType) {
messager.printMessage(
ERROR,
"Only getter methods may be declared abstract on FreeBuilder types",
method);
} else {
printNoImplementationMessage(valueType, method);
}
return false;
}
return true;
} | java | private boolean methodIsAbstractGetter(TypeElement valueType, ExecutableElement method) {
Set<Modifier> modifiers = method.getModifiers();
if (!modifiers.contains(Modifier.ABSTRACT)) {
return false;
}
boolean declaredOnValueType = method.getEnclosingElement().equals(valueType);
TypeMirror returnType = getReturnType(valueType, method, types);
if (returnType.getKind() == TypeKind.VOID || !method.getParameters().isEmpty()) {
if (declaredOnValueType) {
messager.printMessage(
ERROR,
"Only getter methods may be declared abstract on FreeBuilder types",
method);
} else {
printNoImplementationMessage(valueType, method);
}
return false;
}
return true;
} | [
"private",
"boolean",
"methodIsAbstractGetter",
"(",
"TypeElement",
"valueType",
",",
"ExecutableElement",
"method",
")",
"{",
"Set",
"<",
"Modifier",
">",
"modifiers",
"=",
"method",
".",
"getModifiers",
"(",
")",
";",
"if",
"(",
"!",
"modifiers",
".",
"conta... | Verifies {@code method} is an abstract getter. Any deviations will be logged as an error. | [
"Verifies",
"{"
] | train | https://github.com/inferred/FreeBuilder/blob/d5a222f90648aece135da4b971c55a60afe8649c/src/main/java/org/inferred/freebuilder/processor/naming/PrefixlessConvention.java#L63-L82 |
hazelcast/hazelcast | hazelcast/src/main/java/com/hazelcast/cache/impl/MXBeanUtil.java | MXBeanUtil.calculateObjectName | public static ObjectName calculateObjectName(String cacheManagerName, String name, boolean stats) {
String cacheManagerNameSafe = mbeanSafe(cacheManagerName);
String cacheName = mbeanSafe(name);
try {
String objectNameType = stats ? "Statistics" : "Configuration";
return new ObjectName(
"javax.cache:type=Cache" + objectNameType + ",CacheManager=" + cacheManagerNameSafe + ",Cache=" + cacheName);
} catch (MalformedObjectNameException e) {
throw new CacheException(
"Illegal ObjectName for Management Bean. " + "CacheManager=[" + cacheManagerNameSafe + "], Cache=["
+ cacheName + "]", e);
}
} | java | public static ObjectName calculateObjectName(String cacheManagerName, String name, boolean stats) {
String cacheManagerNameSafe = mbeanSafe(cacheManagerName);
String cacheName = mbeanSafe(name);
try {
String objectNameType = stats ? "Statistics" : "Configuration";
return new ObjectName(
"javax.cache:type=Cache" + objectNameType + ",CacheManager=" + cacheManagerNameSafe + ",Cache=" + cacheName);
} catch (MalformedObjectNameException e) {
throw new CacheException(
"Illegal ObjectName for Management Bean. " + "CacheManager=[" + cacheManagerNameSafe + "], Cache=["
+ cacheName + "]", e);
}
} | [
"public",
"static",
"ObjectName",
"calculateObjectName",
"(",
"String",
"cacheManagerName",
",",
"String",
"name",
",",
"boolean",
"stats",
")",
"{",
"String",
"cacheManagerNameSafe",
"=",
"mbeanSafe",
"(",
"cacheManagerName",
")",
";",
"String",
"cacheName",
"=",
... | Creates an object name using the scheme.
"javax.cache:type=Cache<Statistics|Configuration>,name=<cacheName>" | [
"Creates",
"an",
"object",
"name",
"using",
"the",
"scheme",
".",
"javax",
".",
"cache",
":",
"type",
"=",
"Cache<",
";",
"Statistics|Configuration>",
";",
"name",
"=",
"<",
";",
"cacheName>",
";"
] | train | https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/cache/impl/MXBeanUtil.java#L105-L118 |
liferay/com-liferay-commerce | commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceEntryPersistenceImpl.java | CommercePriceEntryPersistenceImpl.removeByUUID_G | @Override
public CommercePriceEntry removeByUUID_G(String uuid, long groupId)
throws NoSuchPriceEntryException {
CommercePriceEntry commercePriceEntry = findByUUID_G(uuid, groupId);
return remove(commercePriceEntry);
} | java | @Override
public CommercePriceEntry removeByUUID_G(String uuid, long groupId)
throws NoSuchPriceEntryException {
CommercePriceEntry commercePriceEntry = findByUUID_G(uuid, groupId);
return remove(commercePriceEntry);
} | [
"@",
"Override",
"public",
"CommercePriceEntry",
"removeByUUID_G",
"(",
"String",
"uuid",
",",
"long",
"groupId",
")",
"throws",
"NoSuchPriceEntryException",
"{",
"CommercePriceEntry",
"commercePriceEntry",
"=",
"findByUUID_G",
"(",
"uuid",
",",
"groupId",
")",
";",
... | Removes the commerce price entry where uuid = ? and groupId = ? from the database.
@param uuid the uuid
@param groupId the group ID
@return the commerce price entry that was removed | [
"Removes",
"the",
"commerce",
"price",
"entry",
"where",
"uuid",
"=",
"?",
";",
"and",
"groupId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceEntryPersistenceImpl.java#L815-L821 |
google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java | MultimapWithProtoValuesSubject.ignoringFieldDescriptorsForValues | public MultimapWithProtoValuesFluentAssertion<M> ignoringFieldDescriptorsForValues(
FieldDescriptor firstFieldDescriptor, FieldDescriptor... rest) {
return ignoringFieldDescriptorsForValues(asList(firstFieldDescriptor, rest));
} | java | public MultimapWithProtoValuesFluentAssertion<M> ignoringFieldDescriptorsForValues(
FieldDescriptor firstFieldDescriptor, FieldDescriptor... rest) {
return ignoringFieldDescriptorsForValues(asList(firstFieldDescriptor, rest));
} | [
"public",
"MultimapWithProtoValuesFluentAssertion",
"<",
"M",
">",
"ignoringFieldDescriptorsForValues",
"(",
"FieldDescriptor",
"firstFieldDescriptor",
",",
"FieldDescriptor",
"...",
"rest",
")",
"{",
"return",
"ignoringFieldDescriptorsForValues",
"(",
"asList",
"(",
"firstFi... | Excludes all message fields matching the given {@link FieldDescriptor}s from the comparison.
<p>This method adds on any previous {@link FieldScope} related settings, overriding previous
changes to ensure the specified fields are ignored recursively. All sub-fields of these field
descriptors are ignored, no matter where they occur in the tree.
<p>If a field descriptor which does not, or cannot occur in the proto structure is supplied, it
is silently ignored. | [
"Excludes",
"all",
"message",
"fields",
"matching",
"the",
"given",
"{",
"@link",
"FieldDescriptor",
"}",
"s",
"from",
"the",
"comparison",
"."
] | train | https://github.com/google/truth/blob/60eceffd2e8c3297655d33ed87d965cf5af51108/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java#L736-L739 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.getIterationPerformanceAsync | public Observable<IterationPerformance> getIterationPerformanceAsync(UUID projectId, UUID iterationId, GetIterationPerformanceOptionalParameter getIterationPerformanceOptionalParameter) {
return getIterationPerformanceWithServiceResponseAsync(projectId, iterationId, getIterationPerformanceOptionalParameter).map(new Func1<ServiceResponse<IterationPerformance>, IterationPerformance>() {
@Override
public IterationPerformance call(ServiceResponse<IterationPerformance> response) {
return response.body();
}
});
} | java | public Observable<IterationPerformance> getIterationPerformanceAsync(UUID projectId, UUID iterationId, GetIterationPerformanceOptionalParameter getIterationPerformanceOptionalParameter) {
return getIterationPerformanceWithServiceResponseAsync(projectId, iterationId, getIterationPerformanceOptionalParameter).map(new Func1<ServiceResponse<IterationPerformance>, IterationPerformance>() {
@Override
public IterationPerformance call(ServiceResponse<IterationPerformance> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"IterationPerformance",
">",
"getIterationPerformanceAsync",
"(",
"UUID",
"projectId",
",",
"UUID",
"iterationId",
",",
"GetIterationPerformanceOptionalParameter",
"getIterationPerformanceOptionalParameter",
")",
"{",
"return",
"getIterationPerformanc... | Get detailed performance information about an iteration.
@param projectId The id of the project the iteration belongs to
@param iterationId The id of the iteration to get
@param getIterationPerformanceOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the IterationPerformance object | [
"Get",
"detailed",
"performance",
"information",
"about",
"an",
"iteration",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L1643-L1650 |
wildfly/wildfly-core | server/src/main/java/org/jboss/as/server/parsing/InterfacesXml.java | InterfacesXml.writeInterfaces | void writeInterfaces(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException {
writer.writeStartElement(Element.INTERFACES.getLocalName());
final Set<String> interfaces = modelNode.keys();
for (String ifaceName : interfaces) {
final ModelNode iface = modelNode.get(ifaceName);
writer.writeStartElement(Element.INTERFACE.getLocalName());
writeAttribute(writer, Attribute.NAME, ifaceName);
// <any-* /> is just handled at the root
if (iface.get(Element.ANY_ADDRESS.getLocalName()).asBoolean(false)) {
writer.writeEmptyElement(Element.ANY_ADDRESS.getLocalName());
} else {
// Write the other criteria elements
writeInterfaceCriteria(writer, iface, false);
}
writer.writeEndElement();
}
writer.writeEndElement();
} | java | void writeInterfaces(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException {
writer.writeStartElement(Element.INTERFACES.getLocalName());
final Set<String> interfaces = modelNode.keys();
for (String ifaceName : interfaces) {
final ModelNode iface = modelNode.get(ifaceName);
writer.writeStartElement(Element.INTERFACE.getLocalName());
writeAttribute(writer, Attribute.NAME, ifaceName);
// <any-* /> is just handled at the root
if (iface.get(Element.ANY_ADDRESS.getLocalName()).asBoolean(false)) {
writer.writeEmptyElement(Element.ANY_ADDRESS.getLocalName());
} else {
// Write the other criteria elements
writeInterfaceCriteria(writer, iface, false);
}
writer.writeEndElement();
}
writer.writeEndElement();
} | [
"void",
"writeInterfaces",
"(",
"final",
"XMLExtendedStreamWriter",
"writer",
",",
"final",
"ModelNode",
"modelNode",
")",
"throws",
"XMLStreamException",
"{",
"writer",
".",
"writeStartElement",
"(",
"Element",
".",
"INTERFACES",
".",
"getLocalName",
"(",
")",
")",... | Write the interfaces including the criteria elements.
@param writer the xml stream writer
@param modelNode the model
@throws XMLStreamException | [
"Write",
"the",
"interfaces",
"including",
"the",
"criteria",
"elements",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/server/src/main/java/org/jboss/as/server/parsing/InterfacesXml.java#L253-L270 |
h2oai/h2o-3 | h2o-automl/src/main/java/ai/h2o/automl/targetencoding/TargetEncoder.java | TargetEncoder.applyTargetEncoding | public Frame applyTargetEncoding(Frame data,
String targetColumnName,
Map<String, Frame> targetEncodingMap,
byte dataLeakageHandlingStrategy,
String foldColumn,
boolean withBlendedAvg,
boolean imputeNAs,
long seed) {
double defaultNoiseLevel = 0.01;
int targetIndex = data.find(targetColumnName);
Vec targetVec = data.vec(targetIndex);
double noiseLevel = targetVec.isNumeric() ? defaultNoiseLevel * (targetVec.max() - targetVec.min()) : defaultNoiseLevel;
return applyTargetEncoding(data, targetColumnName, targetEncodingMap, dataLeakageHandlingStrategy, foldColumn, withBlendedAvg, noiseLevel, true, seed);
} | java | public Frame applyTargetEncoding(Frame data,
String targetColumnName,
Map<String, Frame> targetEncodingMap,
byte dataLeakageHandlingStrategy,
String foldColumn,
boolean withBlendedAvg,
boolean imputeNAs,
long seed) {
double defaultNoiseLevel = 0.01;
int targetIndex = data.find(targetColumnName);
Vec targetVec = data.vec(targetIndex);
double noiseLevel = targetVec.isNumeric() ? defaultNoiseLevel * (targetVec.max() - targetVec.min()) : defaultNoiseLevel;
return applyTargetEncoding(data, targetColumnName, targetEncodingMap, dataLeakageHandlingStrategy, foldColumn, withBlendedAvg, noiseLevel, true, seed);
} | [
"public",
"Frame",
"applyTargetEncoding",
"(",
"Frame",
"data",
",",
"String",
"targetColumnName",
",",
"Map",
"<",
"String",
",",
"Frame",
">",
"targetEncodingMap",
",",
"byte",
"dataLeakageHandlingStrategy",
",",
"String",
"foldColumn",
",",
"boolean",
"withBlende... | Overloaded for the case when user had not specified the noise parameter | [
"Overloaded",
"for",
"the",
"case",
"when",
"user",
"had",
"not",
"specified",
"the",
"noise",
"parameter"
] | train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-automl/src/main/java/ai/h2o/automl/targetencoding/TargetEncoder.java#L706-L719 |
kaazing/java.client | ws/ws/src/main/java/org/kaazing/gateway/client/util/WrappedByteBuffer.java | WrappedByteBuffer.putShortAt | public WrappedByteBuffer putShortAt(int index, short v) {
_checkForWriteAt(index, 2);
_buf.putShort(index, v);
return this;
} | java | public WrappedByteBuffer putShortAt(int index, short v) {
_checkForWriteAt(index, 2);
_buf.putShort(index, v);
return this;
} | [
"public",
"WrappedByteBuffer",
"putShortAt",
"(",
"int",
"index",
",",
"short",
"v",
")",
"{",
"_checkForWriteAt",
"(",
"index",
",",
"2",
")",
";",
"_buf",
".",
"putShort",
"(",
"index",
",",
"v",
")",
";",
"return",
"this",
";",
"}"
] | Puts a two-byte short into the buffer at the specified index.
@param index the index
@param v the two-byte short
@return the buffer | [
"Puts",
"a",
"two",
"-",
"byte",
"short",
"into",
"the",
"buffer",
"at",
"the",
"specified",
"index",
"."
] | train | https://github.com/kaazing/java.client/blob/25ad2ae5bb24aa9d6b79400fce649b518dcfbe26/ws/ws/src/main/java/org/kaazing/gateway/client/util/WrappedByteBuffer.java#L440-L444 |
symphonyoss/messageml-utils | src/main/java/org/symphonyoss/symphony/messageml/markdown/MarkdownRenderer.java | MarkdownRenderer.visitChildren | private void visitChildren(Node parent, Collection<Class<? extends Node>> includeNodes) {
Node child = parent.getFirstChild();
while (child != null) {
// A subclass of this visitor might modify the node, resulting in getNext returning a different node or no
// node after visiting it. So get the next node before visiting.
Node next = child.getNext();
if (includeNodes.contains(child.getClass())) {
child.accept(this);
} else {
visitChildren(child, includeNodes);
}
child = next;
}
} | java | private void visitChildren(Node parent, Collection<Class<? extends Node>> includeNodes) {
Node child = parent.getFirstChild();
while (child != null) {
// A subclass of this visitor might modify the node, resulting in getNext returning a different node or no
// node after visiting it. So get the next node before visiting.
Node next = child.getNext();
if (includeNodes.contains(child.getClass())) {
child.accept(this);
} else {
visitChildren(child, includeNodes);
}
child = next;
}
} | [
"private",
"void",
"visitChildren",
"(",
"Node",
"parent",
",",
"Collection",
"<",
"Class",
"<",
"?",
"extends",
"Node",
">",
">",
"includeNodes",
")",
"{",
"Node",
"child",
"=",
"parent",
".",
"getFirstChild",
"(",
")",
";",
"while",
"(",
"child",
"!=",... | Recursively visit the children of the node, processing only those specified by the parameter "includeNodes". | [
"Recursively",
"visit",
"the",
"children",
"of",
"the",
"node",
"processing",
"only",
"those",
"specified",
"by",
"the",
"parameter",
"includeNodes",
"."
] | train | https://github.com/symphonyoss/messageml-utils/blob/68daed66267062d144a05b3ee9a9bf4b715e3f95/src/main/java/org/symphonyoss/symphony/messageml/markdown/MarkdownRenderer.java#L341-L354 |
OpenTSDB/opentsdb | src/tsd/HttpSerializer.java | HttpSerializer.formatPutV1 | public ChannelBuffer formatPutV1(final Map<String, Object> results) {
throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED,
"The requested API endpoint has not been implemented",
this.getClass().getCanonicalName() +
" has not implemented formatPutV1");
} | java | public ChannelBuffer formatPutV1(final Map<String, Object> results) {
throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED,
"The requested API endpoint has not been implemented",
this.getClass().getCanonicalName() +
" has not implemented formatPutV1");
} | [
"public",
"ChannelBuffer",
"formatPutV1",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"results",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"NOT_IMPLEMENTED",
",",
"\"The requested API endpoint has not been implemented\"",... | Formats the results of an HTTP data point storage request
@param results A map of results. The map will consist of:
<ul><li>success - (long) the number of successfully parsed datapoints</li>
<li>failed - (long) the number of datapoint parsing failures</li>
<li>errors - (ArrayList<HashMap<String, Object>>) an optional list of
datapoints that had errors. The nested map has these fields:
<ul><li>error - (String) the error that occurred</li>
<li>datapoint - (IncomingDatapoint) the datapoint that generated the error
</li></ul></li></ul>
@return A ChannelBuffer object to pass on to the caller
@throws BadRequestException if the plugin has not implemented this method | [
"Formats",
"the",
"results",
"of",
"an",
"HTTP",
"data",
"point",
"storage",
"request"
] | train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpSerializer.java#L392-L397 |
square/jna-gmp | jnagmp/src/main/java/com/squareup/jnagmp/LibGmp.java | LibGmp.__gmpz_import | public static void __gmpz_import(mpz_t rop, int count, int order, int size, int endian, int nails,
Pointer buffer) {
if (SIZE_T_CLASS == SizeT4.class) {
SizeT4.__gmpz_import(rop, count, order, size, endian, nails, buffer);
} else {
SizeT8.__gmpz_import(rop, count, order, size, endian, nails, buffer);
}
} | java | public static void __gmpz_import(mpz_t rop, int count, int order, int size, int endian, int nails,
Pointer buffer) {
if (SIZE_T_CLASS == SizeT4.class) {
SizeT4.__gmpz_import(rop, count, order, size, endian, nails, buffer);
} else {
SizeT8.__gmpz_import(rop, count, order, size, endian, nails, buffer);
}
} | [
"public",
"static",
"void",
"__gmpz_import",
"(",
"mpz_t",
"rop",
",",
"int",
"count",
",",
"int",
"order",
",",
"int",
"size",
",",
"int",
"endian",
",",
"int",
"nails",
",",
"Pointer",
"buffer",
")",
"{",
"if",
"(",
"SIZE_T_CLASS",
"==",
"SizeT4",
".... | Set rop from an array of word data at op.
The parameters specify the format of the data. count many words are read, each size bytes.
order can be 1 for most significant word first or -1 for least significant first. Within each
word endian can be 1 for most significant byte first, -1 for least significant first, or 0 for
the native endianness of the host CPU. The most significant nails bits of each word are
skipped, this can be 0 to use the full words.
There is no sign taken from the data, rop will simply be a positive integer. An application can
handle any sign itself, and apply it for instance with mpz_neg.
There are no data alignment restrictions on op, any address is allowed.
Here's an example converting an array of unsigned long data, most significant element first,
and host byte order within each value.
<pre>{@code
unsigned long a[20];
// Initialize z and a
mpzImport (z, 20, 1, sizeof(a[0]), 0, 0, a);
}</pre>
This example assumes the full sizeof bytes are used for data in the given type, which is
usually true, and certainly true for unsigned long everywhere we know of. However on Cray
vector systems it may be noted that short and int are always stored in 8 bytes (and with sizeof
indicating that) but use only 32 or 46 bits. The nails feature can account for this, by passing
for instance 8*sizeof(int)-INT_BIT. | [
"Set",
"rop",
"from",
"an",
"array",
"of",
"word",
"data",
"at",
"op",
"."
] | train | https://github.com/square/jna-gmp/blob/192d26d97d6773bc3c68ccfa97450f4257d54838/jnagmp/src/main/java/com/squareup/jnagmp/LibGmp.java#L200-L207 |
alkacon/opencms-core | src/org/opencms/db/CmsDriverManager.java | CmsDriverManager.saveAliases | public void saveAliases(CmsDbContext dbc, CmsProject project, CmsUUID structureId, List<CmsAlias> aliases)
throws CmsException {
for (CmsAlias alias : aliases) {
if (!structureId.equals(alias.getStructureId())) {
throw new IllegalArgumentException("Aliases to replace must have the same structure id!");
}
}
I_CmsVfsDriver vfsDriver = getVfsDriver(dbc);
vfsDriver.deleteAliases(dbc, project, new CmsAliasFilter(null, null, structureId));
for (CmsAlias alias : aliases) {
String aliasPath = alias.getAliasPath();
if (CmsAlias.ALIAS_PATTERN.matcher(aliasPath).matches()) {
vfsDriver.insertAlias(dbc, project, alias);
} else {
LOG.error("Invalid alias path: " + aliasPath);
}
}
} | java | public void saveAliases(CmsDbContext dbc, CmsProject project, CmsUUID structureId, List<CmsAlias> aliases)
throws CmsException {
for (CmsAlias alias : aliases) {
if (!structureId.equals(alias.getStructureId())) {
throw new IllegalArgumentException("Aliases to replace must have the same structure id!");
}
}
I_CmsVfsDriver vfsDriver = getVfsDriver(dbc);
vfsDriver.deleteAliases(dbc, project, new CmsAliasFilter(null, null, structureId));
for (CmsAlias alias : aliases) {
String aliasPath = alias.getAliasPath();
if (CmsAlias.ALIAS_PATTERN.matcher(aliasPath).matches()) {
vfsDriver.insertAlias(dbc, project, alias);
} else {
LOG.error("Invalid alias path: " + aliasPath);
}
}
} | [
"public",
"void",
"saveAliases",
"(",
"CmsDbContext",
"dbc",
",",
"CmsProject",
"project",
",",
"CmsUUID",
"structureId",
",",
"List",
"<",
"CmsAlias",
">",
"aliases",
")",
"throws",
"CmsException",
"{",
"for",
"(",
"CmsAlias",
"alias",
":",
"aliases",
")",
... | Saves a list of aliases for the same structure id, replacing any aliases for the same structure id.<p>
@param dbc the current database context
@param project the current project
@param structureId the structure id for which the aliases should be saved
@param aliases the list of aliases to save
@throws CmsException if something goes wrong | [
"Saves",
"a",
"list",
"of",
"aliases",
"for",
"the",
"same",
"structure",
"id",
"replacing",
"any",
"aliases",
"for",
"the",
"same",
"structure",
"id",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/db/CmsDriverManager.java#L8765-L8783 |
liferay/com-liferay-commerce | commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountRulePersistenceImpl.java | CommerceDiscountRulePersistenceImpl.findAll | @Override
public List<CommerceDiscountRule> findAll(int start, int end) {
return findAll(start, end, null);
} | java | @Override
public List<CommerceDiscountRule> findAll(int start, int end) {
return findAll(start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceDiscountRule",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the commerce discount rules.
<p>
Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link CommerceDiscountRuleModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
</p>
@param start the lower bound of the range of commerce discount rules
@param end the upper bound of the range of commerce discount rules (not inclusive)
@return the range of commerce discount rules | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"discount",
"rules",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-discount-service/src/main/java/com/liferay/commerce/discount/service/persistence/impl/CommerceDiscountRulePersistenceImpl.java#L1158-L1161 |
onelogin/onelogin-java-sdk | src/main/java/com/onelogin/sdk/conn/Client.java | Client.getUsersAssignedToPrivilegesBatch | public OneLoginResponse<Long> getUsersAssignedToPrivilegesBatch(String id, int batchSize) throws OAuthSystemException, OAuthProblemException, URISyntaxException {
return getUsersAssignedToPrivilegesBatch(id, batchSize, null);
} | java | public OneLoginResponse<Long> getUsersAssignedToPrivilegesBatch(String id, int batchSize) throws OAuthSystemException, OAuthProblemException, URISyntaxException {
return getUsersAssignedToPrivilegesBatch(id, batchSize, null);
} | [
"public",
"OneLoginResponse",
"<",
"Long",
">",
"getUsersAssignedToPrivilegesBatch",
"(",
"String",
"id",
",",
"int",
"batchSize",
")",
"throws",
"OAuthSystemException",
",",
"OAuthProblemException",
",",
"URISyntaxException",
"{",
"return",
"getUsersAssignedToPrivilegesBat... | Get a batch of users assigned to privilege.
This is usually the first version of the users assigned to privilege batching methods to call as it requires no after-cursor information.
@param id Id of the privilege
@param batchSize Size of the Batch
@return OneLoginResponse of Long (Batch)
@throws OAuthSystemException - if there is a IOException reading parameters of the httpURLConnection
@throws OAuthProblemException - if there are errors validating the OneloginOAuthJSONResourceResponse and throwOAuthProblemException is enabled
@throws URISyntaxException - if there is an error when generating the target URL at the getResource call
@see <a target="_blank" href="https://developers.onelogin.com/api-docs/1/privileges/get-users">Get Assigned Users documentation</a> | [
"Get",
"a",
"batch",
"of",
"users",
"assigned",
"to",
"privilege",
"."
] | train | https://github.com/onelogin/onelogin-java-sdk/blob/1570b78033dcc1c7387099e77fe41b6b0638df8c/src/main/java/com/onelogin/sdk/conn/Client.java#L3722-L3724 |
netty/netty | codec/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java | LengthFieldBasedFrameDecoder.getUnadjustedFrameLength | protected long getUnadjustedFrameLength(ByteBuf buf, int offset, int length, ByteOrder order) {
buf = buf.order(order);
long frameLength;
switch (length) {
case 1:
frameLength = buf.getUnsignedByte(offset);
break;
case 2:
frameLength = buf.getUnsignedShort(offset);
break;
case 3:
frameLength = buf.getUnsignedMedium(offset);
break;
case 4:
frameLength = buf.getUnsignedInt(offset);
break;
case 8:
frameLength = buf.getLong(offset);
break;
default:
throw new DecoderException(
"unsupported lengthFieldLength: " + lengthFieldLength + " (expected: 1, 2, 3, 4, or 8)");
}
return frameLength;
} | java | protected long getUnadjustedFrameLength(ByteBuf buf, int offset, int length, ByteOrder order) {
buf = buf.order(order);
long frameLength;
switch (length) {
case 1:
frameLength = buf.getUnsignedByte(offset);
break;
case 2:
frameLength = buf.getUnsignedShort(offset);
break;
case 3:
frameLength = buf.getUnsignedMedium(offset);
break;
case 4:
frameLength = buf.getUnsignedInt(offset);
break;
case 8:
frameLength = buf.getLong(offset);
break;
default:
throw new DecoderException(
"unsupported lengthFieldLength: " + lengthFieldLength + " (expected: 1, 2, 3, 4, or 8)");
}
return frameLength;
} | [
"protected",
"long",
"getUnadjustedFrameLength",
"(",
"ByteBuf",
"buf",
",",
"int",
"offset",
",",
"int",
"length",
",",
"ByteOrder",
"order",
")",
"{",
"buf",
"=",
"buf",
".",
"order",
"(",
"order",
")",
";",
"long",
"frameLength",
";",
"switch",
"(",
"... | Decodes the specified region of the buffer into an unadjusted frame length. The default implementation is
capable of decoding the specified region into an unsigned 8/16/24/32/64 bit integer. Override this method to
decode the length field encoded differently. Note that this method must not modify the state of the specified
buffer (e.g. {@code readerIndex}, {@code writerIndex}, and the content of the buffer.)
@throws DecoderException if failed to decode the specified region | [
"Decodes",
"the",
"specified",
"region",
"of",
"the",
"buffer",
"into",
"an",
"unadjusted",
"frame",
"length",
".",
"The",
"default",
"implementation",
"is",
"capable",
"of",
"decoding",
"the",
"specified",
"region",
"into",
"an",
"unsigned",
"8",
"/",
"16",
... | train | https://github.com/netty/netty/blob/ba06eafa1c1824bd154f1a380019e7ea2edf3c4c/codec/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java#L452-L476 |
alkacon/opencms-core | src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java | CmsDefaultXmlContentHandler.initNestedFormatters | protected void initNestedFormatters(Element element, CmsXmlContentDefinition contentDefinition)
throws CmsXmlException {
Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(element, APPINFO_NESTED_FORMATTER);
while (i.hasNext()) {
// iterate all "default" elements in the "defaults" node
Element handlerElement = i.next();
String formatterElement = handlerElement.attributeValue(APPINFO_ATTR_ELEMENT);
addNestedFormatter(formatterElement, contentDefinition);
}
} | java | protected void initNestedFormatters(Element element, CmsXmlContentDefinition contentDefinition)
throws CmsXmlException {
Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(element, APPINFO_NESTED_FORMATTER);
while (i.hasNext()) {
// iterate all "default" elements in the "defaults" node
Element handlerElement = i.next();
String formatterElement = handlerElement.attributeValue(APPINFO_ATTR_ELEMENT);
addNestedFormatter(formatterElement, contentDefinition);
}
} | [
"protected",
"void",
"initNestedFormatters",
"(",
"Element",
"element",
",",
"CmsXmlContentDefinition",
"contentDefinition",
")",
"throws",
"CmsXmlException",
"{",
"Iterator",
"<",
"Element",
">",
"i",
"=",
"CmsXmlGenericWrapper",
".",
"elementIterator",
"(",
"element",... | Initializes the nested formatter fields.<p>
@param element the formatters element
@param contentDefinition the content definition
@throws CmsXmlException in case something goes wron | [
"Initializes",
"the",
"nested",
"formatter",
"fields",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsDefaultXmlContentHandler.java#L2782-L2792 |
sd4324530/fastweixin | src/main/java/com/github/sd4324530/fastweixin/util/StreamUtil.java | StreamUtil.copy | public static int copy(InputStream in, OutputStream out) throws IOException {
BeanUtil.requireNonNull(in, "No InputStream specified");
BeanUtil.requireNonNull(out, "No OutputStream specified");
int byteCount = 0;
byte[] buffer = new byte[4096];
int bytesRead1;
for (; (bytesRead1 = in.read(buffer)) != -1; byteCount += bytesRead1) {
out.write(buffer, 0, bytesRead1);
}
out.flush();
return byteCount;
} | java | public static int copy(InputStream in, OutputStream out) throws IOException {
BeanUtil.requireNonNull(in, "No InputStream specified");
BeanUtil.requireNonNull(out, "No OutputStream specified");
int byteCount = 0;
byte[] buffer = new byte[4096];
int bytesRead1;
for (; (bytesRead1 = in.read(buffer)) != -1; byteCount += bytesRead1) {
out.write(buffer, 0, bytesRead1);
}
out.flush();
return byteCount;
} | [
"public",
"static",
"int",
"copy",
"(",
"InputStream",
"in",
",",
"OutputStream",
"out",
")",
"throws",
"IOException",
"{",
"BeanUtil",
".",
"requireNonNull",
"(",
"in",
",",
"\"No InputStream specified\"",
")",
";",
"BeanUtil",
".",
"requireNonNull",
"(",
"out"... | 将输入流的内容复制到输出流里
@param in 输入流
@param out 输出流
@return 复制的数据字节数
@throws IOException IO异常 | [
"将输入流的内容复制到输出流里"
] | train | https://github.com/sd4324530/fastweixin/blob/6bc0a7abfa23aad0dbad4c3123a47a7fb53f3447/src/main/java/com/github/sd4324530/fastweixin/util/StreamUtil.java#L31-L42 |
osiam/connector4java | src/main/java/org/osiam/client/OsiamConnector.java | OsiamConnector.updateGroup | @Deprecated
public Group updateGroup(String id, UpdateGroup updateGroup, AccessToken accessToken) {
return getGroupService().updateGroup(id, updateGroup, accessToken);
} | java | @Deprecated
public Group updateGroup(String id, UpdateGroup updateGroup, AccessToken accessToken) {
return getGroupService().updateGroup(id, updateGroup, accessToken);
} | [
"@",
"Deprecated",
"public",
"Group",
"updateGroup",
"(",
"String",
"id",
",",
"UpdateGroup",
"updateGroup",
",",
"AccessToken",
"accessToken",
")",
"{",
"return",
"getGroupService",
"(",
")",
".",
"updateGroup",
"(",
"id",
",",
"updateGroup",
",",
"accessToken"... | update the group of the given id with the values given in the Group Object. For more detailed information how to
set new field. Update Fields or to delete Fields please look in the documentation
@param id id of the Group to be updated
@param updateGroup all Fields that need to be updated
@param accessToken the OSIAM access token from for the current session
@return the updated group Object
@throws UnauthorizedException if the request could not be authorized.
@throws ConflictException if the Group could not be updated
@throws NoResultException if no group with the given id can be found
@throws ForbiddenException if the scope doesn't allow this request
@throws ConnectionInitializationException if the connection to the given OSIAM service could not be initialized
@throws IllegalStateException if OSIAM's endpoint(s) are not properly configured
@see <a href="https://github.com/osiam/connector4java/docs/working-with-groups
.md#search-for-groups">Working with groups</a>
@deprecated Updating with PATCH has been removed in OSIAM 3.0. This method is going to go away with version 1.12 or 2.0. | [
"update",
"the",
"group",
"of",
"the",
"given",
"id",
"with",
"the",
"values",
"given",
"in",
"the",
"Group",
"Object",
".",
"For",
"more",
"detailed",
"information",
"how",
"to",
"set",
"new",
"field",
".",
"Update",
"Fields",
"or",
"to",
"delete",
"Fie... | train | https://github.com/osiam/connector4java/blob/a5e6ae1e706f4889d662a069fe2f3bf8e3848d12/src/main/java/org/osiam/client/OsiamConnector.java#L566-L569 |
bingoohuang/excel2javabeans | src/main/java/com/github/bingoohuang/excel2beans/PoiUtil.java | PoiUtil.shiftRows | public static int shiftRows(Sheet sheet, int itemSize, int targetRowNum) {
int lastRowNum = sheet.getLastRowNum();
if (itemSize == 0 && targetRowNum == lastRowNum) { // 没有写入行,直接删除模板行
sheet.removeRow(sheet.getRow(targetRowNum));
} else if (itemSize != 1 && targetRowNum < lastRowNum) {
sheet.shiftRows(targetRowNum + 1, lastRowNum, itemSize - 1, true, true);
}
return itemSize;
} | java | public static int shiftRows(Sheet sheet, int itemSize, int targetRowNum) {
int lastRowNum = sheet.getLastRowNum();
if (itemSize == 0 && targetRowNum == lastRowNum) { // 没有写入行,直接删除模板行
sheet.removeRow(sheet.getRow(targetRowNum));
} else if (itemSize != 1 && targetRowNum < lastRowNum) {
sheet.shiftRows(targetRowNum + 1, lastRowNum, itemSize - 1, true, true);
}
return itemSize;
} | [
"public",
"static",
"int",
"shiftRows",
"(",
"Sheet",
"sheet",
",",
"int",
"itemSize",
",",
"int",
"targetRowNum",
")",
"{",
"int",
"lastRowNum",
"=",
"sheet",
".",
"getLastRowNum",
"(",
")",
";",
"if",
"(",
"itemSize",
"==",
"0",
"&&",
"targetRowNum",
"... | 插入新的行(向下移动表格中的行),方便写入数据。
@param sheet 表单页。
@param itemSize 插入行数列。
@param targetRowNum 模板行号。
@return 插入行数列。 | [
"插入新的行(向下移动表格中的行),方便写入数据。"
] | train | https://github.com/bingoohuang/excel2javabeans/blob/db136d460b93b649814366c0d84a982698b96dc3/src/main/java/com/github/bingoohuang/excel2beans/PoiUtil.java#L129-L138 |
GenesysPureEngage/workspace-client-java | src/main/java/com/genesys/internal/workspace/api/UcsApi.java | UcsApi.assignInteractionToContact | public ApiSuccessResponse assignInteractionToContact(String id, AssignInteractionToContactData assignInteractionToContactData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = assignInteractionToContactWithHttpInfo(id, assignInteractionToContactData);
return resp.getData();
} | java | public ApiSuccessResponse assignInteractionToContact(String id, AssignInteractionToContactData assignInteractionToContactData) throws ApiException {
ApiResponse<ApiSuccessResponse> resp = assignInteractionToContactWithHttpInfo(id, assignInteractionToContactData);
return resp.getData();
} | [
"public",
"ApiSuccessResponse",
"assignInteractionToContact",
"(",
"String",
"id",
",",
"AssignInteractionToContactData",
"assignInteractionToContactData",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"ApiSuccessResponse",
">",
"resp",
"=",
"assignInteractionToContac... | Assign the interaction to a contact
@param id id of the Interaction (required)
@param assignInteractionToContactData (required)
@return ApiSuccessResponse
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body | [
"Assign",
"the",
"interaction",
"to",
"a",
"contact"
] | train | https://github.com/GenesysPureEngage/workspace-client-java/blob/509fdd9e89b9359d012f9a72be95037a3cef53e6/src/main/java/com/genesys/internal/workspace/api/UcsApi.java#L154-L157 |
NordicSemiconductor/Android-DFU-Library | dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java | DfuBaseService.refreshDeviceCache | protected void refreshDeviceCache(final BluetoothGatt gatt, final boolean force) {
/*
* If the device is bonded this is up to the Service Changed characteristic to notify Android that the services has changed.
* There is no need for this trick in that case.
* If not bonded, the Android should not keep the services cached when the Service Changed characteristic is present in the target device database.
* However, due to the Android bug (still exists in Android 5.0.1), it is keeping them anyway and the only way to clear services is by using this hidden refresh method.
*/
if (force || gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
sendLogBroadcast(LOG_LEVEL_DEBUG, "gatt.refresh() (hidden)");
/*
* There is a refresh() method in BluetoothGatt class but for now it's hidden. We will call it using reflections.
*/
try {
//noinspection JavaReflectionMemberAccess
final Method refresh = gatt.getClass().getMethod("refresh");
final boolean success = (Boolean) refresh.invoke(gatt);
logi("Refreshing result: " + success);
} catch (Exception e) {
loge("An exception occurred while refreshing device", e);
sendLogBroadcast(LOG_LEVEL_WARNING, "Refreshing failed");
}
}
} | java | protected void refreshDeviceCache(final BluetoothGatt gatt, final boolean force) {
/*
* If the device is bonded this is up to the Service Changed characteristic to notify Android that the services has changed.
* There is no need for this trick in that case.
* If not bonded, the Android should not keep the services cached when the Service Changed characteristic is present in the target device database.
* However, due to the Android bug (still exists in Android 5.0.1), it is keeping them anyway and the only way to clear services is by using this hidden refresh method.
*/
if (force || gatt.getDevice().getBondState() == BluetoothDevice.BOND_NONE) {
sendLogBroadcast(LOG_LEVEL_DEBUG, "gatt.refresh() (hidden)");
/*
* There is a refresh() method in BluetoothGatt class but for now it's hidden. We will call it using reflections.
*/
try {
//noinspection JavaReflectionMemberAccess
final Method refresh = gatt.getClass().getMethod("refresh");
final boolean success = (Boolean) refresh.invoke(gatt);
logi("Refreshing result: " + success);
} catch (Exception e) {
loge("An exception occurred while refreshing device", e);
sendLogBroadcast(LOG_LEVEL_WARNING, "Refreshing failed");
}
}
} | [
"protected",
"void",
"refreshDeviceCache",
"(",
"final",
"BluetoothGatt",
"gatt",
",",
"final",
"boolean",
"force",
")",
"{",
"/*\n\t\t * If the device is bonded this is up to the Service Changed characteristic to notify Android that the services has changed.\n\t\t * There is no need for t... | Clears the device cache. After uploading new firmware the DFU target will have other
services than before.
@param gatt the GATT device to be refreshed.
@param force <code>true</code> to force the refresh. | [
"Clears",
"the",
"device",
"cache",
".",
"After",
"uploading",
"new",
"firmware",
"the",
"DFU",
"target",
"will",
"have",
"other",
"services",
"than",
"before",
"."
] | train | https://github.com/NordicSemiconductor/Android-DFU-Library/blob/ec14c8c522bebe801a9a4c3dfbbeb1f53262c03f/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java#L1607-L1629 |
deeplearning4j/deeplearning4j | deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/loader/WordVectorSerializer.java | WordVectorSerializer.writeWordVectors | @Deprecated
public static void writeWordVectors(InMemoryLookupTable lookupTable, InMemoryLookupCache cache, String path)
throws IOException {
try (BufferedWriter write = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(path, false), StandardCharsets.UTF_8))) {
for (int i = 0; i < lookupTable.getSyn0().rows(); i++) {
String word = cache.wordAtIndex(i);
if (word == null) {
continue;
}
StringBuilder sb = new StringBuilder();
sb.append(word.replaceAll(" ", WHITESPACE_REPLACEMENT));
sb.append(" ");
INDArray wordVector = lookupTable.vector(word);
for (int j = 0; j < wordVector.length(); j++) {
sb.append(wordVector.getDouble(j));
if (j < wordVector.length() - 1) {
sb.append(" ");
}
}
sb.append("\n");
write.write(sb.toString());
}
}
} | java | @Deprecated
public static void writeWordVectors(InMemoryLookupTable lookupTable, InMemoryLookupCache cache, String path)
throws IOException {
try (BufferedWriter write = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(path, false), StandardCharsets.UTF_8))) {
for (int i = 0; i < lookupTable.getSyn0().rows(); i++) {
String word = cache.wordAtIndex(i);
if (word == null) {
continue;
}
StringBuilder sb = new StringBuilder();
sb.append(word.replaceAll(" ", WHITESPACE_REPLACEMENT));
sb.append(" ");
INDArray wordVector = lookupTable.vector(word);
for (int j = 0; j < wordVector.length(); j++) {
sb.append(wordVector.getDouble(j));
if (j < wordVector.length() - 1) {
sb.append(" ");
}
}
sb.append("\n");
write.write(sb.toString());
}
}
} | [
"@",
"Deprecated",
"public",
"static",
"void",
"writeWordVectors",
"(",
"InMemoryLookupTable",
"lookupTable",
",",
"InMemoryLookupCache",
"cache",
",",
"String",
"path",
")",
"throws",
"IOException",
"{",
"try",
"(",
"BufferedWriter",
"write",
"=",
"new",
"BufferedW... | Writes the word vectors to the given path. Note that this assumes an in memory cache
@param lookupTable
@param cache
@param path the path to write
@throws IOException
@deprecated Use {@link #writeWord2VecModel(Word2Vec, File)} instead | [
"Writes",
"the",
"word",
"vectors",
"to",
"the",
"given",
"path",
".",
"Note",
"that",
"this",
"assumes",
"an",
"in",
"memory",
"cache"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/loader/WordVectorSerializer.java#L1193-L1218 |
OpenLiberty/open-liberty | dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/LogFileHandle.java | LogFileHandle.fileExists | protected boolean fileExists()
{
if (tc.isEntryEnabled())
Tr.entry(tc, "fileExists", this);
boolean fileAlreadyExists = true;
File file = new File(_logDirectory, _fileName);
fileAlreadyExists = (file.exists() && (file.length() > 0));
if (tc.isEntryEnabled())
Tr.exit(tc, "fileExists", new Boolean(fileAlreadyExists));
return fileAlreadyExists;
} | java | protected boolean fileExists()
{
if (tc.isEntryEnabled())
Tr.entry(tc, "fileExists", this);
boolean fileAlreadyExists = true;
File file = new File(_logDirectory, _fileName);
fileAlreadyExists = (file.exists() && (file.length() > 0));
if (tc.isEntryEnabled())
Tr.exit(tc, "fileExists", new Boolean(fileAlreadyExists));
return fileAlreadyExists;
} | [
"protected",
"boolean",
"fileExists",
"(",
")",
"{",
"if",
"(",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"Tr",
".",
"entry",
"(",
"tc",
",",
"\"fileExists\"",
",",
"this",
")",
";",
"boolean",
"fileAlreadyExists",
"=",
"true",
";",
"File",
"file",
"... | /*
Determine if the file managed by this LogFileHandle instance currently exists
on disk.
@return boolean true if the file currently exists. | [
"/",
"*",
"Determine",
"if",
"the",
"file",
"managed",
"by",
"this",
"LogFileHandle",
"instance",
"currently",
"exists",
"on",
"disk",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.recoverylog/src/com/ibm/ws/recoverylog/spi/LogFileHandle.java#L562-L575 |
dita-ot/dita-ot | src/main/java/org/dita/dost/module/KeyrefModule.java | KeyrefModule.processTopic | private ResolveTask processTopic(final FileInfo f, final KeyScope scope, final boolean isResourceOnly) {
final int increment = isResourceOnly ? 0 : 1;
final Integer used = usage.containsKey(f.uri) ? usage.get(f.uri) + increment : increment;
usage.put(f.uri, used);
if (used > 1) {
final URI result = addSuffix(f.result, "-" + (used - 1));
final URI out = tempFileNameScheme.generateTempFileName(result);
final FileInfo fo = new FileInfo.Builder(f)
.uri(out)
.result(result)
.build();
// TODO: Should this be added when content is actually generated?
job.add(fo);
return new ResolveTask(scope, f, fo);
} else {
return new ResolveTask(scope, f, null);
}
} | java | private ResolveTask processTopic(final FileInfo f, final KeyScope scope, final boolean isResourceOnly) {
final int increment = isResourceOnly ? 0 : 1;
final Integer used = usage.containsKey(f.uri) ? usage.get(f.uri) + increment : increment;
usage.put(f.uri, used);
if (used > 1) {
final URI result = addSuffix(f.result, "-" + (used - 1));
final URI out = tempFileNameScheme.generateTempFileName(result);
final FileInfo fo = new FileInfo.Builder(f)
.uri(out)
.result(result)
.build();
// TODO: Should this be added when content is actually generated?
job.add(fo);
return new ResolveTask(scope, f, fo);
} else {
return new ResolveTask(scope, f, null);
}
} | [
"private",
"ResolveTask",
"processTopic",
"(",
"final",
"FileInfo",
"f",
",",
"final",
"KeyScope",
"scope",
",",
"final",
"boolean",
"isResourceOnly",
")",
"{",
"final",
"int",
"increment",
"=",
"isResourceOnly",
"?",
"0",
":",
"1",
";",
"final",
"Integer",
... | Determine how topic is processed for key reference processing.
@return key reference processing | [
"Determine",
"how",
"topic",
"is",
"processed",
"for",
"key",
"reference",
"processing",
"."
] | train | https://github.com/dita-ot/dita-ot/blob/ea776b3c60c03d9f033b6f7ea072349e49dbcdd2/src/main/java/org/dita/dost/module/KeyrefModule.java#L316-L334 |
mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java | LatLongUtils.nearestSegmentPoint | public static Point nearestSegmentPoint(double startX, double startY, double endX, double endY, double pointX, double pointY) {
double xDiff = endX - startX;
double yDiff = endY - startY;
double length2 = xDiff * xDiff + yDiff * yDiff;
if (length2 == 0) return new Point(startX, startY);
double t = ((pointX - startX) * (endX - startX) + (pointY - startY) * (endY - startY)) / length2;
if (t < 0) return new Point(startX, startY);
if (t > 1) return new Point(endX, endY);
return new Point(startX + t * (endX - startX), startY + t * (endY - startY));
} | java | public static Point nearestSegmentPoint(double startX, double startY, double endX, double endY, double pointX, double pointY) {
double xDiff = endX - startX;
double yDiff = endY - startY;
double length2 = xDiff * xDiff + yDiff * yDiff;
if (length2 == 0) return new Point(startX, startY);
double t = ((pointX - startX) * (endX - startX) + (pointY - startY) * (endY - startY)) / length2;
if (t < 0) return new Point(startX, startY);
if (t > 1) return new Point(endX, endY);
return new Point(startX + t * (endX - startX), startY + t * (endY - startY));
} | [
"public",
"static",
"Point",
"nearestSegmentPoint",
"(",
"double",
"startX",
",",
"double",
"startY",
",",
"double",
"endX",
",",
"double",
"endY",
",",
"double",
"pointX",
",",
"double",
"pointY",
")",
"{",
"double",
"xDiff",
"=",
"endX",
"-",
"startX",
"... | Returns a point on the segment nearest to the specified point.
<p>
libGDX (Apache 2.0) | [
"Returns",
"a",
"point",
"on",
"the",
"segment",
"nearest",
"to",
"the",
"specified",
"point",
".",
"<p",
">",
"libGDX",
"(",
"Apache",
"2",
".",
"0",
")"
] | train | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/LatLongUtils.java#L230-L239 |
Twitter4J/Twitter4J | twitter4j-core/src/internal-http/java/twitter4j/HttpClientImpl.java | HttpClientImpl.setHeaders | private void setHeaders(HttpRequest req, HttpURLConnection connection) {
if (logger.isDebugEnabled()) {
logger.debug("Request: ");
logger.debug(req.getMethod().name() + " ", req.getURL());
}
String authorizationHeader;
if (req.getAuthorization() != null && (authorizationHeader = req.getAuthorization().getAuthorizationHeader(req)) != null) {
if (logger.isDebugEnabled()) {
logger.debug("Authorization: ", authorizationHeader.replaceAll(".", "*"));
}
connection.addRequestProperty("Authorization", authorizationHeader);
}
if (req.getRequestHeaders() != null) {
for (String key : req.getRequestHeaders().keySet()) {
connection.addRequestProperty(key, req.getRequestHeaders().get(key));
logger.debug(key + ": " + req.getRequestHeaders().get(key));
}
}
} | java | private void setHeaders(HttpRequest req, HttpURLConnection connection) {
if (logger.isDebugEnabled()) {
logger.debug("Request: ");
logger.debug(req.getMethod().name() + " ", req.getURL());
}
String authorizationHeader;
if (req.getAuthorization() != null && (authorizationHeader = req.getAuthorization().getAuthorizationHeader(req)) != null) {
if (logger.isDebugEnabled()) {
logger.debug("Authorization: ", authorizationHeader.replaceAll(".", "*"));
}
connection.addRequestProperty("Authorization", authorizationHeader);
}
if (req.getRequestHeaders() != null) {
for (String key : req.getRequestHeaders().keySet()) {
connection.addRequestProperty(key, req.getRequestHeaders().get(key));
logger.debug(key + ": " + req.getRequestHeaders().get(key));
}
}
} | [
"private",
"void",
"setHeaders",
"(",
"HttpRequest",
"req",
",",
"HttpURLConnection",
"connection",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Request: \"",
")",
";",
"logger",
".",
"debug",
"(... | sets HTTP headers
@param req The request
@param connection HttpURLConnection | [
"sets",
"HTTP",
"headers"
] | train | https://github.com/Twitter4J/Twitter4J/blob/8376fade8d557896bb9319fb46e39a55b134b166/twitter4j-core/src/internal-http/java/twitter4j/HttpClientImpl.java#L207-L226 |
vkostyukov/la4j | src/main/java/org/la4j/Matrices.java | Matrices.mkMaxAccumulator | public static MatrixAccumulator mkMaxAccumulator() {
return new MatrixAccumulator() {
private double result = Double.NEGATIVE_INFINITY;
@Override
public void update(int i, int j, double value) {
result = Math.max(result, value);
}
@Override
public double accumulate() {
double value = result;
result = Double.NEGATIVE_INFINITY;
return value;
}
};
} | java | public static MatrixAccumulator mkMaxAccumulator() {
return new MatrixAccumulator() {
private double result = Double.NEGATIVE_INFINITY;
@Override
public void update(int i, int j, double value) {
result = Math.max(result, value);
}
@Override
public double accumulate() {
double value = result;
result = Double.NEGATIVE_INFINITY;
return value;
}
};
} | [
"public",
"static",
"MatrixAccumulator",
"mkMaxAccumulator",
"(",
")",
"{",
"return",
"new",
"MatrixAccumulator",
"(",
")",
"{",
"private",
"double",
"result",
"=",
"Double",
".",
"NEGATIVE_INFINITY",
";",
"@",
"Override",
"public",
"void",
"update",
"(",
"int",... | Makes a maximum matrix accumulator that accumulates the maximum of matrix elements.
@return a maximum vector accumulator | [
"Makes",
"a",
"maximum",
"matrix",
"accumulator",
"that",
"accumulates",
"the",
"maximum",
"of",
"matrix",
"elements",
"."
] | train | https://github.com/vkostyukov/la4j/blob/dd1b917caf9606399a49afa6b0d738934cd3a7b3/src/main/java/org/la4j/Matrices.java#L540-L556 |
sriharshachilakapati/WebGL4J | webgl4j/src/main/java/com/shc/webgl4j/client/WebGL10.java | WebGL10.glBufferSubData | public static void glBufferSubData(int target, int offset, ArrayBufferView data)
{
checkContextCompatibility();
nglBufferSubData(target, offset, data);
} | java | public static void glBufferSubData(int target, int offset, ArrayBufferView data)
{
checkContextCompatibility();
nglBufferSubData(target, offset, data);
} | [
"public",
"static",
"void",
"glBufferSubData",
"(",
"int",
"target",
",",
"int",
"offset",
",",
"ArrayBufferView",
"data",
")",
"{",
"checkContextCompatibility",
"(",
")",
";",
"nglBufferSubData",
"(",
"target",
",",
"offset",
",",
"data",
")",
";",
"}"
] | <p>{@code glBufferSubData} redefines some or all of the data store for the buffer object currently bound to
{@code target}. Data starting at byte offset {@code offset} and extending for {@code sizeof data} bytes is copied
to the data store from the memory pointed to by {@code data}. An error is thrown if {@code offset} and {@code
size} together define a range beyond the bounds of the buffer object's data store.</p>
<p>{@link #GL_INVALID_ENUM} is generated if target is not {@link #GL_ARRAY_BUFFER} or {@link
#GL_ELEMENT_ARRAY_BUFFER}.</p>
<p>{@link #GL_INVALID_VALUE} is generated if offset or size is negative, or if together they define a region of
memory that extends beyond the buffer object's allocated data store.</p>
<p>{@link #GL_INVALID_OPERATION} is generated if the reserved buffer object name 0 is bound to target.</p>
@param target Specifies the target buffer object. The symbolic constant must be {@link #GL_ARRAY_BUFFER} or
{@link #GL_ELEMENT_ARRAY_BUFFER}.
@param offset Specifies the offset into the buffer object's data store where data replacement will begin,
measured in bytes.
@param data Specifies the new data that will be copied into the data store. | [
"<p",
">",
"{",
"@code",
"glBufferSubData",
"}",
"redefines",
"some",
"or",
"all",
"of",
"the",
"data",
"store",
"for",
"the",
"buffer",
"object",
"currently",
"bound",
"to",
"{",
"@code",
"target",
"}",
".",
"Data",
"starting",
"at",
"byte",
"offset",
"... | train | https://github.com/sriharshachilakapati/WebGL4J/blob/7daa425300b08b338b50cef2935289849c92d415/webgl4j/src/main/java/com/shc/webgl4j/client/WebGL10.java#L942-L946 |
apache/groovy | subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java | Sql.callWithAllRows | public List<List<GroovyRowResult>> callWithAllRows(String sql, List<Object> params, Closure closure) throws SQLException {
return callWithRows(sql, params, ALL_RESULT_SETS, closure);
} | java | public List<List<GroovyRowResult>> callWithAllRows(String sql, List<Object> params, Closure closure) throws SQLException {
return callWithRows(sql, params, ALL_RESULT_SETS, closure);
} | [
"public",
"List",
"<",
"List",
"<",
"GroovyRowResult",
">",
">",
"callWithAllRows",
"(",
"String",
"sql",
",",
"List",
"<",
"Object",
">",
"params",
",",
"Closure",
"closure",
")",
"throws",
"SQLException",
"{",
"return",
"callWithRows",
"(",
"sql",
",",
"... | Performs a stored procedure call with the given parameters,
calling the closure once with all result objects,
and also returning a list of lists with the rows of the ResultSet(s).
<p>
Use this when calling a stored procedure that utilizes both
output parameters and returns multiple ResultSets.
<p>
Once created, the stored procedure can be called like this:
<pre>
def rowsList = sql.callWithAllRows '{call Hemisphere2(?, ?, ?)}', ['Guillaume', 'Laforge', Sql.VARCHAR], { dwells {@code ->}
println dwells
}
</pre>
<p>
Resource handling is performed automatically where appropriate.
@param sql the sql statement
@param params a list of parameters
@param closure called once with all out parameter results
@return a list containing lists of GroovyRowResult objects
@throws SQLException if a database access error occurs
@see #callWithRows(GString, Closure) | [
"Performs",
"a",
"stored",
"procedure",
"call",
"with",
"the",
"given",
"parameters",
"calling",
"the",
"closure",
"once",
"with",
"all",
"result",
"objects",
"and",
"also",
"returning",
"a",
"list",
"of",
"lists",
"with",
"the",
"rows",
"of",
"the",
"Result... | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java#L3325-L3327 |
aspectran/aspectran | core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java | TokenExpression.getBeanProperty | protected Object getBeanProperty(final Object object, String propertyName) {
Object value;
try {
value = BeanUtils.getProperty(object, propertyName);
} catch (InvocationTargetException e) {
// ignore
value = null;
}
return value;
} | java | protected Object getBeanProperty(final Object object, String propertyName) {
Object value;
try {
value = BeanUtils.getProperty(object, propertyName);
} catch (InvocationTargetException e) {
// ignore
value = null;
}
return value;
} | [
"protected",
"Object",
"getBeanProperty",
"(",
"final",
"Object",
"object",
",",
"String",
"propertyName",
")",
"{",
"Object",
"value",
";",
"try",
"{",
"value",
"=",
"BeanUtils",
".",
"getProperty",
"(",
"object",
",",
"propertyName",
")",
";",
"}",
"catch"... | Invoke bean's property.
@param object the object
@param propertyName the property name
@return the object | [
"Invoke",
"bean",
"s",
"property",
"."
] | train | https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java#L425-L434 |
xebia/Xebium | src/main/java/com/xebia/incubator/xebium/ScreenCapture.java | ScreenCapture.updateIndexFile | private void updateIndexFile(int stepNumber, File file, String methodName,
String[] values) throws IOException {
File indexFile = initializeIndexIfNeeded();
BufferedWriter w = new BufferedWriter(new FileWriter(indexFile, stepNumber > INITIAL_STEP_NUMBER));
try {
String title = "| " + methodName + " | " + (values.length > 0 ? values[0] : "") + " | " + (values.length > 1 ? values[1] : "") + " |";
w.write("<h2>" + stepNumber + ". " + title + "</h2>\n");
w.write("<img src='" + file.getName() +"' alt='" + title + "'/>\n");
} finally {
try {
w.close();
} catch (IOException e) {
LOG.error("Unable to close screenshot file " + file.getPath(), e);
}
}
} | java | private void updateIndexFile(int stepNumber, File file, String methodName,
String[] values) throws IOException {
File indexFile = initializeIndexIfNeeded();
BufferedWriter w = new BufferedWriter(new FileWriter(indexFile, stepNumber > INITIAL_STEP_NUMBER));
try {
String title = "| " + methodName + " | " + (values.length > 0 ? values[0] : "") + " | " + (values.length > 1 ? values[1] : "") + " |";
w.write("<h2>" + stepNumber + ". " + title + "</h2>\n");
w.write("<img src='" + file.getName() +"' alt='" + title + "'/>\n");
} finally {
try {
w.close();
} catch (IOException e) {
LOG.error("Unable to close screenshot file " + file.getPath(), e);
}
}
} | [
"private",
"void",
"updateIndexFile",
"(",
"int",
"stepNumber",
",",
"File",
"file",
",",
"String",
"methodName",
",",
"String",
"[",
"]",
"values",
")",
"throws",
"IOException",
"{",
"File",
"indexFile",
"=",
"initializeIndexIfNeeded",
"(",
")",
";",
"Buffere... | <p>Provide an easy to use index.html file for viewing the screenshots.
</p>
<p>The base directory is expected to exist at this point.
</p>
@throws IOException | [
"<p",
">",
"Provide",
"an",
"easy",
"to",
"use",
"index",
".",
"html",
"file",
"for",
"viewing",
"the",
"screenshots",
".",
"<",
"/",
"p",
">",
"<p",
">",
"The",
"base",
"directory",
"is",
"expected",
"to",
"exist",
"at",
"this",
"point",
".",
"<",
... | train | https://github.com/xebia/Xebium/blob/594f6d9e65622acdbd03dba0700b17645981da1f/src/main/java/com/xebia/incubator/xebium/ScreenCapture.java#L145-L161 |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/ColumnLayoutRenderer.java | ColumnLayoutRenderer.doRender | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPanel panel = (WPanel) component;
XmlStringBuilder xml = renderContext.getWriter();
ColumnLayout layout = (ColumnLayout) panel.getLayout();
int childCount = panel.getChildCount();
Size hgap = layout.getHorizontalGap();
String hgapString = hgap == null ? null : hgap.toString();
Size vgap = layout.getVerticalGap();
String vgapString = vgap == null ? null : vgap.toString();
int cols = layout.getColumnCount();
xml.appendTagOpen("ui:columnlayout");
xml.appendOptionalAttribute("hgap", hgapString);
xml.appendOptionalAttribute("vgap", vgapString);
xml.appendClose();
// Column Definitions
for (int col = 0; col < cols; col++) {
xml.appendTagOpen("ui:column");
int width = layout.getColumnWidth(col);
xml.appendOptionalAttribute("width", width > 0, width);
switch (layout.getColumnAlignment(col)) {
case LEFT:
// left is assumed if omitted
break;
case RIGHT:
xml.appendAttribute("align", "right");
break;
case CENTER:
xml.appendAttribute("align", "center");
break;
default:
throw new IllegalArgumentException("Invalid alignment: " + layout.
getColumnAlignment(col));
}
xml.appendEnd();
}
for (int i = 0; i < childCount; i++) {
xml.appendTag("ui:cell");
WComponent child = panel.getChildAt(i);
child.paint(renderContext);
xml.appendEndTag("ui:cell");
}
xml.appendEndTag("ui:columnlayout");
} | java | @Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPanel panel = (WPanel) component;
XmlStringBuilder xml = renderContext.getWriter();
ColumnLayout layout = (ColumnLayout) panel.getLayout();
int childCount = panel.getChildCount();
Size hgap = layout.getHorizontalGap();
String hgapString = hgap == null ? null : hgap.toString();
Size vgap = layout.getVerticalGap();
String vgapString = vgap == null ? null : vgap.toString();
int cols = layout.getColumnCount();
xml.appendTagOpen("ui:columnlayout");
xml.appendOptionalAttribute("hgap", hgapString);
xml.appendOptionalAttribute("vgap", vgapString);
xml.appendClose();
// Column Definitions
for (int col = 0; col < cols; col++) {
xml.appendTagOpen("ui:column");
int width = layout.getColumnWidth(col);
xml.appendOptionalAttribute("width", width > 0, width);
switch (layout.getColumnAlignment(col)) {
case LEFT:
// left is assumed if omitted
break;
case RIGHT:
xml.appendAttribute("align", "right");
break;
case CENTER:
xml.appendAttribute("align", "center");
break;
default:
throw new IllegalArgumentException("Invalid alignment: " + layout.
getColumnAlignment(col));
}
xml.appendEnd();
}
for (int i = 0; i < childCount; i++) {
xml.appendTag("ui:cell");
WComponent child = panel.getChildAt(i);
child.paint(renderContext);
xml.appendEndTag("ui:cell");
}
xml.appendEndTag("ui:columnlayout");
} | [
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WPanel",
"panel",
"=",
"(",
"WPanel",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
... | Paints the given WPanel's children.
@param component the container to paint.
@param renderContext the RenderContext to paint to. | [
"Paints",
"the",
"given",
"WPanel",
"s",
"children",
"."
] | train | https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/ColumnLayoutRenderer.java#L26-L78 |
morfologik/morfologik-stemming | morfologik-fsa/src/main/java/morfologik/fsa/FSA.java | FSA.visitInPostOrder | public <T extends StateVisitor> T visitInPostOrder(T v, int node) {
visitInPostOrder(v, node, new BitSet());
return v;
} | java | public <T extends StateVisitor> T visitInPostOrder(T v, int node) {
visitInPostOrder(v, node, new BitSet());
return v;
} | [
"public",
"<",
"T",
"extends",
"StateVisitor",
">",
"T",
"visitInPostOrder",
"(",
"T",
"v",
",",
"int",
"node",
")",
"{",
"visitInPostOrder",
"(",
"v",
",",
"node",
",",
"new",
"BitSet",
"(",
")",
")",
";",
"return",
"v",
";",
"}"
] | Visits all states reachable from <code>node</code> in postorder. Returning
false from {@link StateVisitor#accept(int)} immediately terminates the
traversal.
@param v Visitor to receive traversal calls.
@param <T> A subclass of {@link StateVisitor}.
@param node Identifier of the node.
@return Returns the argument (for access to anonymous class fields). | [
"Visits",
"all",
"states",
"reachable",
"from",
"<code",
">",
"node<",
"/",
"code",
">",
"in",
"postorder",
".",
"Returning",
"false",
"from",
"{",
"@link",
"StateVisitor#accept",
"(",
"int",
")",
"}",
"immediately",
"terminates",
"the",
"traversal",
"."
] | train | https://github.com/morfologik/morfologik-stemming/blob/9d9099cc5ec4155a0eb8dfecdc23d01cbd734f6e/morfologik-fsa/src/main/java/morfologik/fsa/FSA.java#L220-L223 |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/fastoptics/RandomProjectedNeighborsAndDensities.java | RandomProjectedNeighborsAndDensities.splitupNoSort | public void splitupNoSort(ArrayModifiableDBIDs ind, int begin, int end, int dim, Random rand) {
final int nele = end - begin;
dim = dim % projectedPoints.length;// choose a projection of points
DoubleDataStore tpro = projectedPoints[dim];
// save set such that used for density or neighborhood computation
// sets should be roughly minSplitSize
if(nele > minSplitSize * (1 - sizeTolerance) && nele < minSplitSize * (1 + sizeTolerance)) {
// sort set, since need median element later
ind.sort(begin, end, new DataStoreUtil.AscendingByDoubleDataStore(tpro));
splitsets.add(DBIDUtil.newArray(ind.slice(begin, end)));
}
// compute splitting element
// do not store set or even sort set, since it is too large
if(nele > minSplitSize) {
// splits can be performed either by distance (between min,maxCoord) or by
// picking a point randomly(picking index of point)
// outcome is similar
// int minInd splitByDistance(ind, nele, tpro);
int minInd = splitRandomly(ind, begin, end, tpro, rand);
// split set recursively
// position used for splitting the projected points into two
// sets used for recursive splitting
int splitpos = minInd + 1;
splitupNoSort(ind, begin, splitpos, dim + 1, rand);
splitupNoSort(ind, splitpos, end, dim + 1, rand);
}
} | java | public void splitupNoSort(ArrayModifiableDBIDs ind, int begin, int end, int dim, Random rand) {
final int nele = end - begin;
dim = dim % projectedPoints.length;// choose a projection of points
DoubleDataStore tpro = projectedPoints[dim];
// save set such that used for density or neighborhood computation
// sets should be roughly minSplitSize
if(nele > minSplitSize * (1 - sizeTolerance) && nele < minSplitSize * (1 + sizeTolerance)) {
// sort set, since need median element later
ind.sort(begin, end, new DataStoreUtil.AscendingByDoubleDataStore(tpro));
splitsets.add(DBIDUtil.newArray(ind.slice(begin, end)));
}
// compute splitting element
// do not store set or even sort set, since it is too large
if(nele > minSplitSize) {
// splits can be performed either by distance (between min,maxCoord) or by
// picking a point randomly(picking index of point)
// outcome is similar
// int minInd splitByDistance(ind, nele, tpro);
int minInd = splitRandomly(ind, begin, end, tpro, rand);
// split set recursively
// position used for splitting the projected points into two
// sets used for recursive splitting
int splitpos = minInd + 1;
splitupNoSort(ind, begin, splitpos, dim + 1, rand);
splitupNoSort(ind, splitpos, end, dim + 1, rand);
}
} | [
"public",
"void",
"splitupNoSort",
"(",
"ArrayModifiableDBIDs",
"ind",
",",
"int",
"begin",
",",
"int",
"end",
",",
"int",
"dim",
",",
"Random",
"rand",
")",
"{",
"final",
"int",
"nele",
"=",
"end",
"-",
"begin",
";",
"dim",
"=",
"dim",
"%",
"projected... | Recursively splits entire point set until the set is below a threshold
@param ind points that are in the current set
@param begin Interval begin in the ind array
@param end Interval end in the ind array
@param dim depth of projection (how many times point set has been split
already)
@param rand Random generator | [
"Recursively",
"splits",
"entire",
"point",
"set",
"until",
"the",
"set",
"is",
"below",
"a",
"threshold"
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/fastoptics/RandomProjectedNeighborsAndDensities.java#L246-L276 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java | TrainingsImpl.createProjectAsync | public Observable<Project> createProjectAsync(String name, CreateProjectOptionalParameter createProjectOptionalParameter) {
return createProjectWithServiceResponseAsync(name, createProjectOptionalParameter).map(new Func1<ServiceResponse<Project>, Project>() {
@Override
public Project call(ServiceResponse<Project> response) {
return response.body();
}
});
} | java | public Observable<Project> createProjectAsync(String name, CreateProjectOptionalParameter createProjectOptionalParameter) {
return createProjectWithServiceResponseAsync(name, createProjectOptionalParameter).map(new Func1<ServiceResponse<Project>, Project>() {
@Override
public Project call(ServiceResponse<Project> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Project",
">",
"createProjectAsync",
"(",
"String",
"name",
",",
"CreateProjectOptionalParameter",
"createProjectOptionalParameter",
")",
"{",
"return",
"createProjectWithServiceResponseAsync",
"(",
"name",
",",
"createProjectOptionalParameter",
... | Create a project.
@param name Name of the project
@param createProjectOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the Project object | [
"Create",
"a",
"project",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/vision/customvision/training/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/training/implementation/TrainingsImpl.java#L2384-L2391 |
j-a-w-r/jawr-main-repo | jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundlePropertySerializer.java | JoinableResourceBundlePropertySerializer.serializeVariantSets | private static String serializeVariantSets(Map<String, VariantSet> map) {
StringBuilder result = new StringBuilder();
for (Entry<String, VariantSet> entry : map.entrySet()) {
result.append(entry.getKey()).append(":");
VariantSet variantSet = (VariantSet) entry.getValue();
result.append(variantSet.getDefaultVariant()).append(":");
result.append(getCommaSeparatedString(variantSet));
result.append(";");
}
return result.toString();
} | java | private static String serializeVariantSets(Map<String, VariantSet> map) {
StringBuilder result = new StringBuilder();
for (Entry<String, VariantSet> entry : map.entrySet()) {
result.append(entry.getKey()).append(":");
VariantSet variantSet = (VariantSet) entry.getValue();
result.append(variantSet.getDefaultVariant()).append(":");
result.append(getCommaSeparatedString(variantSet));
result.append(";");
}
return result.toString();
} | [
"private",
"static",
"String",
"serializeVariantSets",
"(",
"Map",
"<",
"String",
",",
"VariantSet",
">",
"map",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"VariantSet",
">",
"e... | Serialize the variant sets.
@param map
the map to serialize
@return the serialized variant sets | [
"Serialize",
"the",
"variant",
"sets",
"."
] | train | https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/JoinableResourceBundlePropertySerializer.java#L198-L210 |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/segmentation/slic/SegmentSlic.java | SegmentSlic.perturbCenter | protected void perturbCenter( Cluster c , int x , int y ) {
float best = Float.MAX_VALUE;
int bestX=0,bestY=0;
for( int dy = -1; dy <= 1; dy++ ) {
for( int dx = -1; dx <= 1; dx++ ) {
float d = gradient(x + dx, y + dy);
if( d < best ) {
best = d;
bestX = dx;
bestY = dy;
}
}
}
c.x = x+bestX;
c.y = y+bestY;
setColor(c.color,x+bestX,y+bestY);
} | java | protected void perturbCenter( Cluster c , int x , int y ) {
float best = Float.MAX_VALUE;
int bestX=0,bestY=0;
for( int dy = -1; dy <= 1; dy++ ) {
for( int dx = -1; dx <= 1; dx++ ) {
float d = gradient(x + dx, y + dy);
if( d < best ) {
best = d;
bestX = dx;
bestY = dy;
}
}
}
c.x = x+bestX;
c.y = y+bestY;
setColor(c.color,x+bestX,y+bestY);
} | [
"protected",
"void",
"perturbCenter",
"(",
"Cluster",
"c",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"float",
"best",
"=",
"Float",
".",
"MAX_VALUE",
";",
"int",
"bestX",
"=",
"0",
",",
"bestY",
"=",
"0",
";",
"for",
"(",
"int",
"dy",
"=",
"-",... | Set the cluster's center to be the pixel in a 3x3 neighborhood with the smallest gradient | [
"Set",
"the",
"cluster",
"s",
"center",
"to",
"be",
"the",
"pixel",
"in",
"a",
"3x3",
"neighborhood",
"with",
"the",
"smallest",
"gradient"
] | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/slic/SegmentSlic.java#L220-L238 |
Azure/autorest-clientruntime-for-java | client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java | CustomHeadersInterceptor.addHeader | public CustomHeadersInterceptor addHeader(String name, String value) {
if (!this.headers.containsKey(name)) {
this.headers.put(name, new ArrayList<String>());
}
this.headers.get(name).add(value);
return this;
} | java | public CustomHeadersInterceptor addHeader(String name, String value) {
if (!this.headers.containsKey(name)) {
this.headers.put(name, new ArrayList<String>());
}
this.headers.get(name).add(value);
return this;
} | [
"public",
"CustomHeadersInterceptor",
"addHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"if",
"(",
"!",
"this",
".",
"headers",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"this",
".",
"headers",
".",
"put",
"(",
"name",
",",
"n... | Add a single header key-value pair. If one with the name already exists,
both stay in the header map.
@param name the name of the header.
@param value the value of the header.
@return the interceptor instance itself. | [
"Add",
"a",
"single",
"header",
"key",
"-",
"value",
"pair",
".",
"If",
"one",
"with",
"the",
"name",
"already",
"exists",
"both",
"stay",
"in",
"the",
"header",
"map",
"."
] | train | https://github.com/Azure/autorest-clientruntime-for-java/blob/04621e07dbb0456dd5459dd641f06a9fd4f3abad/client-runtime/src/main/java/com/microsoft/rest/interceptors/CustomHeadersInterceptor.java#L78-L84 |
mebigfatguy/fb-contrib | src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java | PresizeCollections.visitCode | @Override
public void visitCode(Code obj) {
stack.resetForMethodEntry(this);
nextAllocNumber = 1;
storeToUserValue.clear();
allocLocation.clear();
allocToAddPCs.clear();
optionalRanges.clear();
addExceptionRanges(obj);
super.visitCode(obj);
for (List<Integer> pcs : allocToAddPCs.values()) {
if (pcs.size() > 16) {
bugReporter.reportBug(new BugInstance(this, BugType.PSC_PRESIZE_COLLECTIONS.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
.addSourceLine(this, pcs.get(0).intValue()));
}
}
} | java | @Override
public void visitCode(Code obj) {
stack.resetForMethodEntry(this);
nextAllocNumber = 1;
storeToUserValue.clear();
allocLocation.clear();
allocToAddPCs.clear();
optionalRanges.clear();
addExceptionRanges(obj);
super.visitCode(obj);
for (List<Integer> pcs : allocToAddPCs.values()) {
if (pcs.size() > 16) {
bugReporter.reportBug(new BugInstance(this, BugType.PSC_PRESIZE_COLLECTIONS.name(), NORMAL_PRIORITY).addClass(this).addMethod(this)
.addSourceLine(this, pcs.get(0).intValue()));
}
}
} | [
"@",
"Override",
"public",
"void",
"visitCode",
"(",
"Code",
"obj",
")",
"{",
"stack",
".",
"resetForMethodEntry",
"(",
"this",
")",
";",
"nextAllocNumber",
"=",
"1",
";",
"storeToUserValue",
".",
"clear",
"(",
")",
";",
"allocLocation",
".",
"clear",
"(",... | implements the visitor to reset the opcode stack
@param obj
the context object of the currently parsed code block | [
"implements",
"the",
"visitor",
"to",
"reset",
"the",
"opcode",
"stack"
] | train | https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java#L148-L167 |
RKumsher/utils | src/main/java/com/github/rkumsher/collection/ArrayUtils.java | ArrayUtils.randomFrom | public static <T> T randomFrom(T[] array, Collection<T> excludes) {
checkArgument(isNotEmpty(array), "Array cannot be empty");
List<T> list = Arrays.asList(array);
Iterable<T> copy = Lists.newArrayList(list);
Iterables.removeAll(copy, excludes);
checkArgument(!Iterables.isEmpty(copy), "Array only consists of the given excludes");
return IterableUtils.randomFrom(list, excludes);
} | java | public static <T> T randomFrom(T[] array, Collection<T> excludes) {
checkArgument(isNotEmpty(array), "Array cannot be empty");
List<T> list = Arrays.asList(array);
Iterable<T> copy = Lists.newArrayList(list);
Iterables.removeAll(copy, excludes);
checkArgument(!Iterables.isEmpty(copy), "Array only consists of the given excludes");
return IterableUtils.randomFrom(list, excludes);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"randomFrom",
"(",
"T",
"[",
"]",
"array",
",",
"Collection",
"<",
"T",
">",
"excludes",
")",
"{",
"checkArgument",
"(",
"isNotEmpty",
"(",
"array",
")",
",",
"\"Array cannot be empty\"",
")",
";",
"List",
"<",
"... | Returns a random element from the given array that's not in the values to exclude.
@param array array to return random element from
@param excludes values to exclude
@param <T> the type of elements in the given array
@return random element from the given array that's not in the values to exclude
@throws IllegalArgumentException if the array is empty | [
"Returns",
"a",
"random",
"element",
"from",
"the",
"given",
"array",
"that",
"s",
"not",
"in",
"the",
"values",
"to",
"exclude",
"."
] | train | https://github.com/RKumsher/utils/blob/fcdb190569cd0288249bf4b46fd418f8c01d1caf/src/main/java/com/github/rkumsher/collection/ArrayUtils.java#L54-L61 |
mozilla/rhino | src/org/mozilla/javascript/WrapFactory.java | WrapFactory.wrapJavaClass | public Scriptable wrapJavaClass(Context cx, Scriptable scope,
Class<?> javaClass)
{
return new NativeJavaClass(scope, javaClass);
} | java | public Scriptable wrapJavaClass(Context cx, Scriptable scope,
Class<?> javaClass)
{
return new NativeJavaClass(scope, javaClass);
} | [
"public",
"Scriptable",
"wrapJavaClass",
"(",
"Context",
"cx",
",",
"Scriptable",
"scope",
",",
"Class",
"<",
"?",
">",
"javaClass",
")",
"{",
"return",
"new",
"NativeJavaClass",
"(",
"scope",
",",
"javaClass",
")",
";",
"}"
] | Wrap a Java class as Scriptable instance to allow access to its static
members and fields and use as constructor from JavaScript.
<p>
Subclasses can override this method to provide custom wrappers for
Java classes.
@param cx the current Context for this thread
@param scope the scope of the executing script
@param javaClass the class to be wrapped
@return the wrapped value which shall not be null
@since 1.7R3 | [
"Wrap",
"a",
"Java",
"class",
"as",
"Scriptable",
"instance",
"to",
"allow",
"access",
"to",
"its",
"static",
"members",
"and",
"fields",
"and",
"use",
"as",
"constructor",
"from",
"JavaScript",
".",
"<p",
">",
"Subclasses",
"can",
"override",
"this",
"metho... | train | https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/WrapFactory.java#L136-L140 |
infinispan/infinispan | server/integration/commons/src/main/java/org/infinispan/server/commons/dmr/ModelNodes.java | ModelNodes.asFloat | public static float asFloat(ModelNode value, float defaultValue) {
return Double.valueOf(value.asDouble(defaultValue)).floatValue();
} | java | public static float asFloat(ModelNode value, float defaultValue) {
return Double.valueOf(value.asDouble(defaultValue)).floatValue();
} | [
"public",
"static",
"float",
"asFloat",
"(",
"ModelNode",
"value",
",",
"float",
"defaultValue",
")",
"{",
"return",
"Double",
".",
"valueOf",
"(",
"value",
".",
"asDouble",
"(",
"defaultValue",
")",
")",
".",
"floatValue",
"(",
")",
";",
"}"
] | Returns the value of the node as a string, or the specified default value if the node is undefined.
@param value a model node
@return the value of the node as a string, or the specified default value if the node is undefined. | [
"Returns",
"the",
"value",
"of",
"the",
"node",
"as",
"a",
"string",
"or",
"the",
"specified",
"default",
"value",
"if",
"the",
"node",
"is",
"undefined",
"."
] | train | https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/server/integration/commons/src/main/java/org/infinispan/server/commons/dmr/ModelNodes.java#L66-L68 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Math.java | Math.nextAfter | public static double nextAfter(double start, double direction) {
/*
* The cases:
*
* nextAfter(+infinity, 0) == MAX_VALUE
* nextAfter(+infinity, +infinity) == +infinity
* nextAfter(-infinity, 0) == -MAX_VALUE
* nextAfter(-infinity, -infinity) == -infinity
*
* are naturally handled without any additional testing
*/
// First check for NaN values
if (Double.isNaN(start) || Double.isNaN(direction)) {
// return a NaN derived from the input NaN(s)
return start + direction;
} else if (start == direction) {
return direction;
} else { // start > direction or start < direction
// Add +0.0 to get rid of a -0.0 (+0.0 + -0.0 => +0.0)
// then bitwise convert start to integer.
long transducer = Double.doubleToRawLongBits(start + 0.0d);
/*
* IEEE 754 floating-point numbers are lexicographically
* ordered if treated as signed- magnitude integers .
* Since Java's integers are two's complement,
* incrementing" the two's complement representation of a
* logically negative floating-point value *decrements*
* the signed-magnitude representation. Therefore, when
* the integer representation of a floating-point values
* is less than zero, the adjustment to the representation
* is in the opposite direction than would be expected at
* first .
*/
if (direction > start) { // Calculate next greater value
transducer = transducer + (transducer >= 0L ? 1L:-1L);
} else { // Calculate next lesser value
assert direction < start;
if (transducer > 0L)
--transducer;
else
if (transducer < 0L )
++transducer;
/*
* transducer==0, the result is -MIN_VALUE
*
* The transition from zero (implicitly
* positive) to the smallest negative
* signed magnitude value must be done
* explicitly.
*/
else
transducer = DoubleConsts.SIGN_BIT_MASK | 1L;
}
return Double.longBitsToDouble(transducer);
}
} | java | public static double nextAfter(double start, double direction) {
/*
* The cases:
*
* nextAfter(+infinity, 0) == MAX_VALUE
* nextAfter(+infinity, +infinity) == +infinity
* nextAfter(-infinity, 0) == -MAX_VALUE
* nextAfter(-infinity, -infinity) == -infinity
*
* are naturally handled without any additional testing
*/
// First check for NaN values
if (Double.isNaN(start) || Double.isNaN(direction)) {
// return a NaN derived from the input NaN(s)
return start + direction;
} else if (start == direction) {
return direction;
} else { // start > direction or start < direction
// Add +0.0 to get rid of a -0.0 (+0.0 + -0.0 => +0.0)
// then bitwise convert start to integer.
long transducer = Double.doubleToRawLongBits(start + 0.0d);
/*
* IEEE 754 floating-point numbers are lexicographically
* ordered if treated as signed- magnitude integers .
* Since Java's integers are two's complement,
* incrementing" the two's complement representation of a
* logically negative floating-point value *decrements*
* the signed-magnitude representation. Therefore, when
* the integer representation of a floating-point values
* is less than zero, the adjustment to the representation
* is in the opposite direction than would be expected at
* first .
*/
if (direction > start) { // Calculate next greater value
transducer = transducer + (transducer >= 0L ? 1L:-1L);
} else { // Calculate next lesser value
assert direction < start;
if (transducer > 0L)
--transducer;
else
if (transducer < 0L )
++transducer;
/*
* transducer==0, the result is -MIN_VALUE
*
* The transition from zero (implicitly
* positive) to the smallest negative
* signed magnitude value must be done
* explicitly.
*/
else
transducer = DoubleConsts.SIGN_BIT_MASK | 1L;
}
return Double.longBitsToDouble(transducer);
}
} | [
"public",
"static",
"double",
"nextAfter",
"(",
"double",
"start",
",",
"double",
"direction",
")",
"{",
"/*\n * The cases:\n *\n * nextAfter(+infinity, 0) == MAX_VALUE\n * nextAfter(+infinity, +infinity) == +infinity\n * nextAfter(-infinity, 0) == ... | Returns the floating-point number adjacent to the first
argument in the direction of the second argument. If both
arguments compare as equal the second argument is returned.
<p>
Special cases:
<ul>
<li> If either argument is a NaN, then NaN is returned.
<li> If both arguments are signed zeros, {@code direction}
is returned unchanged (as implied by the requirement of
returning the second argument if the arguments compare as
equal).
<li> If {@code start} is
±{@link Double#MIN_VALUE} and {@code direction}
has a value such that the result should have a smaller
magnitude, then a zero with the same sign as {@code start}
is returned.
<li> If {@code start} is infinite and
{@code direction} has a value such that the result should
have a smaller magnitude, {@link Double#MAX_VALUE} with the
same sign as {@code start} is returned.
<li> If {@code start} is equal to ±
{@link Double#MAX_VALUE} and {@code direction} has a
value such that the result should have a larger magnitude, an
infinity with same sign as {@code start} is returned.
</ul>
@param start starting floating-point value
@param direction value indicating which of
{@code start}'s neighbors or {@code start} should
be returned
@return The floating-point number adjacent to {@code start} in the
direction of {@code direction}.
@since 1.6 | [
"Returns",
"the",
"floating",
"-",
"point",
"number",
"adjacent",
"to",
"the",
"first",
"argument",
"in",
"the",
"direction",
"of",
"the",
"second",
"argument",
".",
"If",
"both",
"arguments",
"compare",
"as",
"equal",
"the",
"second",
"argument",
"is",
"ret... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/lang/Math.java#L1889-L1947 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_canTransferSecurityDeposit_POST | public Boolean billingAccount_canTransferSecurityDeposit_POST(String billingAccount, String billingAccountDestination) throws IOException {
String qPath = "/telephony/{billingAccount}/canTransferSecurityDeposit";
StringBuilder sb = path(qPath, billingAccount);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "billingAccountDestination", billingAccountDestination);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, Boolean.class);
} | java | public Boolean billingAccount_canTransferSecurityDeposit_POST(String billingAccount, String billingAccountDestination) throws IOException {
String qPath = "/telephony/{billingAccount}/canTransferSecurityDeposit";
StringBuilder sb = path(qPath, billingAccount);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "billingAccountDestination", billingAccountDestination);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, Boolean.class);
} | [
"public",
"Boolean",
"billingAccount_canTransferSecurityDeposit_POST",
"(",
"String",
"billingAccount",
",",
"String",
"billingAccountDestination",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/canTransferSecurityDeposit\"",
";",
"Strin... | Check if security deposit transfer is possible between two billing accounts
REST: POST /telephony/{billingAccount}/canTransferSecurityDeposit
@param billingAccountDestination [required] The destination billing account
@param billingAccount [required] The name of your billingAccount | [
"Check",
"if",
"security",
"deposit",
"transfer",
"is",
"possible",
"between",
"two",
"billing",
"accounts"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L501-L508 |
moparisthebest/beehive | beehive-jdbc-control/src/main/java/org/apache/beehive/controls/system/jdbc/RowMapperFactory.java | RowMapperFactory.addRowMapping | public static void addRowMapping(Class returnTypeClass, Class<? extends RowMapper> rowMapperClass) {
_rowMappings.put(returnTypeClass, rowMapperClass);
} | java | public static void addRowMapping(Class returnTypeClass, Class<? extends RowMapper> rowMapperClass) {
_rowMappings.put(returnTypeClass, rowMapperClass);
} | [
"public",
"static",
"void",
"addRowMapping",
"(",
"Class",
"returnTypeClass",
",",
"Class",
"<",
"?",
"extends",
"RowMapper",
">",
"rowMapperClass",
")",
"{",
"_rowMappings",
".",
"put",
"(",
"returnTypeClass",
",",
"rowMapperClass",
")",
";",
"}"
] | Add a new row mapper to the list of available row mappers. The getRowMapper method traverses the
list of mappers from beginning to end, checking to see if a mapper can handle the specified
returnTypeClass. There is a default mapper which is used if a match cannot be found in the list.
@param returnTypeClass Class which this mapper maps a row to.
@param rowMapperClass The row mapper class. | [
"Add",
"a",
"new",
"row",
"mapper",
"to",
"the",
"list",
"of",
"available",
"row",
"mappers",
".",
"The",
"getRowMapper",
"method",
"traverses",
"the",
"list",
"of",
"mappers",
"from",
"beginning",
"to",
"end",
"checking",
"to",
"see",
"if",
"a",
"mapper",... | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-jdbc-control/src/main/java/org/apache/beehive/controls/system/jdbc/RowMapperFactory.java#L97-L99 |
grails/gorm-hibernate5 | grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateCriteriaBuilder.java | AbstractHibernateCriteriaBuilder.eqAll | @SuppressWarnings({ "unchecked", "rawtypes" })
public org.grails.datastore.mapping.query.api.Criteria eqAll(String propertyName, Closure<?> propertyValue) {
return eqAll(propertyName, new grails.gorm.DetachedCriteria(targetClass).build(propertyValue));
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
public org.grails.datastore.mapping.query.api.Criteria eqAll(String propertyName, Closure<?> propertyValue) {
return eqAll(propertyName, new grails.gorm.DetachedCriteria(targetClass).build(propertyValue));
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"org",
".",
"grails",
".",
"datastore",
".",
"mapping",
".",
"query",
".",
"api",
".",
"Criteria",
"eqAll",
"(",
"String",
"propertyName",
",",
"Closure",
"<",
"?"... | Creates a subquery criterion that ensures the given property is equal to all the given returned values
@param propertyName The property name
@param propertyValue The property value
@return A Criterion instance | [
"Creates",
"a",
"subquery",
"criterion",
"that",
"ensures",
"the",
"given",
"property",
"is",
"equal",
"to",
"all",
"the",
"given",
"returned",
"values"
] | train | https://github.com/grails/gorm-hibernate5/blob/0ebb80cd769ef2bea955723d4543828a3e9542ef/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateCriteriaBuilder.java#L701-L704 |
h2oai/h2o-3 | h2o-core/src/main/java/water/rapids/ast/prims/mungers/AstFillNA.java | AstFillNA.apply | @Override
public Val apply(Env env, Env.StackHelp stk, AstRoot asts[]) {
// Argument parsing and sanity checking
// Whole frame being imputed
Frame fr = stk.track(asts[1].exec(env)).getFrame();
// Column within frame being imputed
final String method = asts[2].exec(env).getStr();
if (!(Arrays.asList("forward","backward")).contains(method.toLowerCase()))
throw new IllegalArgumentException("Method must be forward or backward");
final int axis = (int) asts[3].exec(env).getNum();
if (!(Arrays.asList(0,1)).contains(axis))
throw new IllegalArgumentException("Axis must be 0 for columnar 1 for row");
final int limit = (int) asts[4].exec(env).getNum();
assert limit >= 0:"The maxlen/limit parameter should be >= 0.";
if (limit == 0) // fast short cut to do nothing if user set zero limit
return new ValFrame(fr.deepCopy(Key.make().toString()));
Frame res;
if (axis == 0) {
res = (METHOD_BACKWARD.equalsIgnoreCase(method.trim()))?
new FillBackwardTaskCol(limit, fr.anyVec().nChunks()).doAll(fr.numCols(), Vec.T_NUM, fr).outputFrame():
new FillForwardTaskCol(limit).doAll(fr.numCols(), Vec.T_NUM, fr).outputFrame();
} else {
res = (METHOD_BACKWARD.equalsIgnoreCase(method.trim()))?
new FillBackwardTaskRow(limit).doAll(fr.numCols(), Vec.T_NUM, fr).outputFrame():
new FillForwardTaskRow(limit).doAll(fr.numCols(), Vec.T_NUM, fr).outputFrame();
}
res._key = Key.<Frame>make();
return new ValFrame(res);
} | java | @Override
public Val apply(Env env, Env.StackHelp stk, AstRoot asts[]) {
// Argument parsing and sanity checking
// Whole frame being imputed
Frame fr = stk.track(asts[1].exec(env)).getFrame();
// Column within frame being imputed
final String method = asts[2].exec(env).getStr();
if (!(Arrays.asList("forward","backward")).contains(method.toLowerCase()))
throw new IllegalArgumentException("Method must be forward or backward");
final int axis = (int) asts[3].exec(env).getNum();
if (!(Arrays.asList(0,1)).contains(axis))
throw new IllegalArgumentException("Axis must be 0 for columnar 1 for row");
final int limit = (int) asts[4].exec(env).getNum();
assert limit >= 0:"The maxlen/limit parameter should be >= 0.";
if (limit == 0) // fast short cut to do nothing if user set zero limit
return new ValFrame(fr.deepCopy(Key.make().toString()));
Frame res;
if (axis == 0) {
res = (METHOD_BACKWARD.equalsIgnoreCase(method.trim()))?
new FillBackwardTaskCol(limit, fr.anyVec().nChunks()).doAll(fr.numCols(), Vec.T_NUM, fr).outputFrame():
new FillForwardTaskCol(limit).doAll(fr.numCols(), Vec.T_NUM, fr).outputFrame();
} else {
res = (METHOD_BACKWARD.equalsIgnoreCase(method.trim()))?
new FillBackwardTaskRow(limit).doAll(fr.numCols(), Vec.T_NUM, fr).outputFrame():
new FillForwardTaskRow(limit).doAll(fr.numCols(), Vec.T_NUM, fr).outputFrame();
}
res._key = Key.<Frame>make();
return new ValFrame(res);
} | [
"@",
"Override",
"public",
"Val",
"apply",
"(",
"Env",
"env",
",",
"Env",
".",
"StackHelp",
"stk",
",",
"AstRoot",
"asts",
"[",
"]",
")",
"{",
"// Argument parsing and sanity checking",
"// Whole frame being imputed",
"Frame",
"fr",
"=",
"stk",
".",
"track",
"... | (h2o.impute data col method combine_method groupby groupByFrame values) | [
"(",
"h2o",
".",
"impute",
"data",
"col",
"method",
"combine_method",
"groupby",
"groupByFrame",
"values",
")"
] | train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-core/src/main/java/water/rapids/ast/prims/mungers/AstFillNA.java#L47-L80 |
joniles/mpxj | src/main/java/net/sf/mpxj/ProjectCalendar.java | ProjectCalendar.isWorkingDate | private boolean isWorkingDate(Date date, Day day)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, day);
return ranges.getRangeCount() != 0;
} | java | private boolean isWorkingDate(Date date, Day day)
{
ProjectCalendarDateRanges ranges = getRanges(date, null, day);
return ranges.getRangeCount() != 0;
} | [
"private",
"boolean",
"isWorkingDate",
"(",
"Date",
"date",
",",
"Day",
"day",
")",
"{",
"ProjectCalendarDateRanges",
"ranges",
"=",
"getRanges",
"(",
"date",
",",
"null",
",",
"day",
")",
";",
"return",
"ranges",
".",
"getRangeCount",
"(",
")",
"!=",
"0",... | This private method allows the caller to determine if a given date is a
working day. This method takes account of calendar exceptions. It assumes
that the caller has already calculated the day of the week on which
the given day falls.
@param date Date to be tested
@param day Day of the week for the date under test
@return boolean flag | [
"This",
"private",
"method",
"allows",
"the",
"caller",
"to",
"determine",
"if",
"a",
"given",
"date",
"is",
"a",
"working",
"day",
".",
"This",
"method",
"takes",
"account",
"of",
"calendar",
"exceptions",
".",
"It",
"assumes",
"that",
"the",
"caller",
"h... | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendar.java#L961-L965 |
EvidentSolutions/dalesbred | dalesbred/src/main/java/org/dalesbred/query/SqlQuery.java | SqlQuery.namedQuery | public static @NotNull SqlQuery namedQuery(@NotNull @SQL String sql, @NotNull VariableResolver variableResolver) {
return NamedParameterSqlParser.parseSqlStatement(sql).toQuery(variableResolver);
} | java | public static @NotNull SqlQuery namedQuery(@NotNull @SQL String sql, @NotNull VariableResolver variableResolver) {
return NamedParameterSqlParser.parseSqlStatement(sql).toQuery(variableResolver);
} | [
"public",
"static",
"@",
"NotNull",
"SqlQuery",
"namedQuery",
"(",
"@",
"NotNull",
"@",
"SQL",
"String",
"sql",
",",
"@",
"NotNull",
"VariableResolver",
"variableResolver",
")",
"{",
"return",
"NamedParameterSqlParser",
".",
"parseSqlStatement",
"(",
"sql",
")",
... | Creates a new {@link SqlQuery} consisting of given SQL statement and a provider for named arguments.
The argument names in SQL should be prefixed by a colon, e.g. ":argument".
@throws SqlSyntaxException if SQL is malformed
@throws VariableResolutionException if variableResolver can't provide values for named parameters | [
"Creates",
"a",
"new",
"{",
"@link",
"SqlQuery",
"}",
"consisting",
"of",
"given",
"SQL",
"statement",
"and",
"a",
"provider",
"for",
"named",
"arguments",
".",
"The",
"argument",
"names",
"in",
"SQL",
"should",
"be",
"prefixed",
"by",
"a",
"colon",
"e",
... | train | https://github.com/EvidentSolutions/dalesbred/blob/713f5b6e152d97e1672ca68b9ff9c7c6c288ceb1/dalesbred/src/main/java/org/dalesbred/query/SqlQuery.java#L102-L104 |
mapbox/mapbox-java | services-turf/src/main/java/com/mapbox/turf/TurfMisc.java | TurfMisc.lineSlice | @NonNull
public static LineString lineSlice(@NonNull Point startPt, @NonNull Point stopPt,
@NonNull Feature line) {
if (line.geometry() == null) {
throw new NullPointerException("Feature.geometry() == null");
}
if (!line.geometry().type().equals("LineString")) {
throw new TurfException("input must be a LineString Feature or Geometry");
}
return lineSlice(startPt, stopPt, (LineString) line.geometry());
} | java | @NonNull
public static LineString lineSlice(@NonNull Point startPt, @NonNull Point stopPt,
@NonNull Feature line) {
if (line.geometry() == null) {
throw new NullPointerException("Feature.geometry() == null");
}
if (!line.geometry().type().equals("LineString")) {
throw new TurfException("input must be a LineString Feature or Geometry");
}
return lineSlice(startPt, stopPt, (LineString) line.geometry());
} | [
"@",
"NonNull",
"public",
"static",
"LineString",
"lineSlice",
"(",
"@",
"NonNull",
"Point",
"startPt",
",",
"@",
"NonNull",
"Point",
"stopPt",
",",
"@",
"NonNull",
"Feature",
"line",
")",
"{",
"if",
"(",
"line",
".",
"geometry",
"(",
")",
"==",
"null",
... | Takes a line, a start {@link Point}, and a stop point and returns the line in between those
points.
@param startPt Starting point.
@param stopPt Stopping point.
@param line Line to slice.
@return Sliced line.
@throws TurfException signals that a Turf exception of some sort has occurred.
@see <a href="http://turfjs.org/docs/#lineslice">Turf Line slice documentation</a>
@since 1.2.0 | [
"Takes",
"a",
"line",
"a",
"start",
"{",
"@link",
"Point",
"}",
"and",
"a",
"stop",
"point",
"and",
"returns",
"the",
"line",
"in",
"between",
"those",
"points",
"."
] | train | https://github.com/mapbox/mapbox-java/blob/c0be138f462f91441388584c668f3760ba0e18e2/services-turf/src/main/java/com/mapbox/turf/TurfMisc.java#L39-L49 |
CenturyLinkCloud/mdw | mdw-common/src/com/centurylink/mdw/util/StringHelper.java | StringHelper.makeFormattedString | public static String makeFormattedString(String aAttrName, Object[] anObjArray) {
return makeFormattedString(aAttrName, anObjArray, true);
} | java | public static String makeFormattedString(String aAttrName, Object[] anObjArray) {
return makeFormattedString(aAttrName, anObjArray, true);
} | [
"public",
"static",
"String",
"makeFormattedString",
"(",
"String",
"aAttrName",
",",
"Object",
"[",
"]",
"anObjArray",
")",
"{",
"return",
"makeFormattedString",
"(",
"aAttrName",
",",
"anObjArray",
",",
"true",
")",
";",
"}"
] | Overloaded method with <code>aPrependSeparator = true</code>.
@see #makeFormattedString(String, Object[], boolean)
@param aAttrName A String attribute name value.
@param anObjArray An Object array value.
@return A formatted String. | [
"Overloaded",
"method",
"with",
"<code",
">",
"aPrependSeparator",
"=",
"true<",
"/",
"code",
">",
"."
] | train | https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/util/StringHelper.java#L594-L596 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Timer.java | Timer.scheduleAtFixedRate | public void scheduleAtFixedRate(TimerTask task, long delay, long period) {
if (delay < 0)
throw new IllegalArgumentException("Negative delay.");
if (period <= 0)
throw new IllegalArgumentException("Non-positive period.");
sched(task, System.currentTimeMillis()+delay, period);
} | java | public void scheduleAtFixedRate(TimerTask task, long delay, long period) {
if (delay < 0)
throw new IllegalArgumentException("Negative delay.");
if (period <= 0)
throw new IllegalArgumentException("Non-positive period.");
sched(task, System.currentTimeMillis()+delay, period);
} | [
"public",
"void",
"scheduleAtFixedRate",
"(",
"TimerTask",
"task",
",",
"long",
"delay",
",",
"long",
"period",
")",
"{",
"if",
"(",
"delay",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Negative delay.\"",
")",
";",
"if",
"(",
"period"... | Schedules the specified task for repeated <i>fixed-rate execution</i>,
beginning after the specified delay. Subsequent executions take place
at approximately regular intervals, separated by the specified period.
<p>In fixed-rate execution, each execution is scheduled relative to the
scheduled execution time of the initial execution. If an execution is
delayed for any reason (such as garbage collection or other background
activity), two or more executions will occur in rapid succession to
"catch up." In the long run, the frequency of execution will be
exactly the reciprocal of the specified period (assuming the system
clock underlying <tt>Object.wait(long)</tt> is accurate).
<p>Fixed-rate execution is appropriate for recurring activities that
are sensitive to <i>absolute</i> time, such as ringing a chime every
hour on the hour, or running scheduled maintenance every day at a
particular time. It is also appropriate for recurring activities
where the total time to perform a fixed number of executions is
important, such as a countdown timer that ticks once every second for
ten seconds. Finally, fixed-rate execution is appropriate for
scheduling multiple repeating timer tasks that must remain synchronized
with respect to one another.
@param task task to be scheduled.
@param delay delay in milliseconds before task is to be executed.
@param period time in milliseconds between successive task executions.
@throws IllegalArgumentException if {@code delay < 0}, or
{@code delay + System.currentTimeMillis() < 0}, or
{@code period <= 0}
@throws IllegalStateException if task was already scheduled or
cancelled, timer was cancelled, or timer thread terminated.
@throws NullPointerException if {@code task} is null | [
"Schedules",
"the",
"specified",
"task",
"for",
"repeated",
"<i",
">",
"fixed",
"-",
"rate",
"execution<",
"/",
"i",
">",
"beginning",
"after",
"the",
"specified",
"delay",
".",
"Subsequent",
"executions",
"take",
"place",
"at",
"approximately",
"regular",
"in... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/Timer.java#L325-L331 |
netplex/json-smart-v2 | json-smart/src/main/java/net/minidev/json/JSONNavi.java | JSONNavi.atNext | public JSONNavi<?> atNext() {
if (failure)
return this;
if (!(current instanceof List))
return failure("current node is not an Array", null);
@SuppressWarnings("unchecked")
List<Object> lst = ((List<Object>) current);
return at(lst.size());
} | java | public JSONNavi<?> atNext() {
if (failure)
return this;
if (!(current instanceof List))
return failure("current node is not an Array", null);
@SuppressWarnings("unchecked")
List<Object> lst = ((List<Object>) current);
return at(lst.size());
} | [
"public",
"JSONNavi",
"<",
"?",
">",
"atNext",
"(",
")",
"{",
"if",
"(",
"failure",
")",
"return",
"this",
";",
"if",
"(",
"!",
"(",
"current",
"instanceof",
"List",
")",
")",
"return",
"failure",
"(",
"\"current node is not an Array\"",
",",
"null",
")"... | Access to last + 1 the index position.
this method can only be used in writing mode. | [
"Access",
"to",
"last",
"+",
"1",
"the",
"index",
"position",
"."
] | train | https://github.com/netplex/json-smart-v2/blob/bfb3daef039e22a7bbff5f76bf14ea23330cd70e/json-smart/src/main/java/net/minidev/json/JSONNavi.java#L634-L642 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.