repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 201 | func_name stringlengths 4 126 | whole_func_string stringlengths 75 3.57k | language stringclasses 1
value | func_code_string stringlengths 75 3.57k | func_code_tokens listlengths 21 599 | func_documentation_string stringlengths 61 1.95k | func_documentation_tokens listlengths 1 478 | split_name stringclasses 1
value | func_code_url stringlengths 111 308 |
|---|---|---|---|---|---|---|---|---|---|---|
fozziethebeat/S-Space | src/main/java/edu/ucla/sspace/common/OnDiskSemanticSpace.java | OnDiskSemanticSpace.loadOffsetsFromFormat | private void loadOffsetsFromFormat(File file, SSpaceFormat format)
throws IOException {
this.format = format;
spaceName = file.getName();
// NOTE: Use a LinkedHashMap here because this will ensure that the
// words are returned in the same row-order as the matrix. This
// generates better disk I/O behavior for accessing the matrix since
// each word is directly after the previous on disk.
termToOffset = new LinkedHashMap<String,Long>();
long start = System.currentTimeMillis();
int dims = -1;
RandomAccessFile raf = null;
RandomAccessBufferedReader lnr = null;
switch (format) {
case TEXT:
lnr = new RandomAccessBufferedReader(file);
dims = loadTextOffsets(lnr);
break;
case BINARY:
raf = new RandomAccessFile(file, "r");
dims = loadBinaryOffsets(raf);
break;
case SPARSE_TEXT:
lnr = new RandomAccessBufferedReader(file);
dims = loadSparseTextOffsets(lnr);
break;
case SPARSE_BINARY:
raf = new RandomAccessFile(file, "r");
dims = loadSparseBinaryOffsets(raf);
break;
default:
assert false : format;
}
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("loaded " + format + " .sspace file in " +
(System.currentTimeMillis() - start) + "ms");
}
this.dimensions = dims;
this.binarySSpace = raf;
this.textSSpace = lnr;
} | java | private void loadOffsetsFromFormat(File file, SSpaceFormat format)
throws IOException {
this.format = format;
spaceName = file.getName();
// NOTE: Use a LinkedHashMap here because this will ensure that the
// words are returned in the same row-order as the matrix. This
// generates better disk I/O behavior for accessing the matrix since
// each word is directly after the previous on disk.
termToOffset = new LinkedHashMap<String,Long>();
long start = System.currentTimeMillis();
int dims = -1;
RandomAccessFile raf = null;
RandomAccessBufferedReader lnr = null;
switch (format) {
case TEXT:
lnr = new RandomAccessBufferedReader(file);
dims = loadTextOffsets(lnr);
break;
case BINARY:
raf = new RandomAccessFile(file, "r");
dims = loadBinaryOffsets(raf);
break;
case SPARSE_TEXT:
lnr = new RandomAccessBufferedReader(file);
dims = loadSparseTextOffsets(lnr);
break;
case SPARSE_BINARY:
raf = new RandomAccessFile(file, "r");
dims = loadSparseBinaryOffsets(raf);
break;
default:
assert false : format;
}
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("loaded " + format + " .sspace file in " +
(System.currentTimeMillis() - start) + "ms");
}
this.dimensions = dims;
this.binarySSpace = raf;
this.textSSpace = lnr;
} | [
"private",
"void",
"loadOffsetsFromFormat",
"(",
"File",
"file",
",",
"SSpaceFormat",
"format",
")",
"throws",
"IOException",
"{",
"this",
".",
"format",
"=",
"format",
";",
"spaceName",
"=",
"file",
".",
"getName",
"(",
")",
";",
"// NOTE: Use a LinkedHashMap h... | Loads the words and offets for each word's vector in the semantic space
file using the format as a guide to how the semantic space data is stored
in the file.
@param file a file containing semantic space data
@param format the format of the data in the file
@throws IOException if any I/O exception occurs when reading the semantic
space data from the file | [
"Loads",
"the",
"words",
"and",
"offets",
"for",
"each",
"word",
"s",
"vector",
"in",
"the",
"semantic",
"space",
"file",
"using",
"the",
"format",
"as",
"a",
"guide",
"to",
"how",
"the",
"semantic",
"space",
"data",
"is",
"stored",
"in",
"the",
"file",
... | train | https://github.com/fozziethebeat/S-Space/blob/a608102737dfd3d59038a9ead33fe60356bc6029/src/main/java/edu/ucla/sspace/common/OnDiskSemanticSpace.java#L191-L233 |
spring-projects/spring-android | spring-android-core/src/main/java/org/springframework/util/StreamUtils.java | StreamUtils.copyToString | public static String copyToString(InputStream in, Charset charset) throws IOException {
Assert.notNull(in, "No InputStream specified");
StringBuilder out = new StringBuilder();
InputStreamReader reader = new InputStreamReader(in, charset);
char[] buffer = new char[BUFFER_SIZE];
int bytesRead = -1;
while ((bytesRead = reader.read(buffer)) != -1) {
out.append(buffer, 0, bytesRead);
}
return out.toString();
} | java | public static String copyToString(InputStream in, Charset charset) throws IOException {
Assert.notNull(in, "No InputStream specified");
StringBuilder out = new StringBuilder();
InputStreamReader reader = new InputStreamReader(in, charset);
char[] buffer = new char[BUFFER_SIZE];
int bytesRead = -1;
while ((bytesRead = reader.read(buffer)) != -1) {
out.append(buffer, 0, bytesRead);
}
return out.toString();
} | [
"public",
"static",
"String",
"copyToString",
"(",
"InputStream",
"in",
",",
"Charset",
"charset",
")",
"throws",
"IOException",
"{",
"Assert",
".",
"notNull",
"(",
"in",
",",
"\"No InputStream specified\"",
")",
";",
"StringBuilder",
"out",
"=",
"new",
"StringB... | Copy the contents of the given InputStream into a String.
Leaves the stream open when done.
@param in the InputStream to copy from
@return the String that has been copied to
@throws IOException in case of I/O errors | [
"Copy",
"the",
"contents",
"of",
"the",
"given",
"InputStream",
"into",
"a",
"String",
".",
"Leaves",
"the",
"stream",
"open",
"when",
"done",
"."
] | train | https://github.com/spring-projects/spring-android/blob/941296e152d49a40e0745a3e81628a974f72b7e4/spring-android-core/src/main/java/org/springframework/util/StreamUtils.java#L68-L78 |
windup/windup | reporting/api/src/main/java/org/jboss/windup/reporting/TagUtil.java | TagUtil.strictCheckMatchingTags | public static boolean strictCheckMatchingTags(Collection<String> tags, Set<String> includeTags, Set<String> excludeTags)
{
boolean includeTagsEnabled = !includeTags.isEmpty();
for (String tag : tags)
{
boolean isIncluded = includeTags.contains(tag);
boolean isExcluded = excludeTags.contains(tag);
if ((includeTagsEnabled && isIncluded) || (!includeTagsEnabled && !isExcluded))
{
return true;
}
}
return false;
} | java | public static boolean strictCheckMatchingTags(Collection<String> tags, Set<String> includeTags, Set<String> excludeTags)
{
boolean includeTagsEnabled = !includeTags.isEmpty();
for (String tag : tags)
{
boolean isIncluded = includeTags.contains(tag);
boolean isExcluded = excludeTags.contains(tag);
if ((includeTagsEnabled && isIncluded) || (!includeTagsEnabled && !isExcluded))
{
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"strictCheckMatchingTags",
"(",
"Collection",
"<",
"String",
">",
"tags",
",",
"Set",
"<",
"String",
">",
"includeTags",
",",
"Set",
"<",
"String",
">",
"excludeTags",
")",
"{",
"boolean",
"includeTagsEnabled",
"=",
"!",
"include... | Returns true if
- includeTags is not empty and tag is in includeTags
- includeTags is empty and tag is not in excludeTags
@param tags Hint tags
@param includeTags Include tags
@param excludeTags Exclude tags
@return has tag match | [
"Returns",
"true",
"if",
"-",
"includeTags",
"is",
"not",
"empty",
"and",
"tag",
"is",
"in",
"includeTags",
"-",
"includeTags",
"is",
"empty",
"and",
"tag",
"is",
"not",
"in",
"excludeTags"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/reporting/api/src/main/java/org/jboss/windup/reporting/TagUtil.java#L35-L51 |
craftercms/commons | git/src/main/java/org/craftercms/commons/git/auth/AbstractSshAuthConfigurator.java | AbstractSshAuthConfigurator.setHostKeyType | protected void setHostKeyType(OpenSshConfig.Host host, Session session) {
HostKey[] hostKeys = session.getHostKeyRepository().getHostKey();
for(HostKey hostKey : hostKeys) {
if(hostKey.getHost().contains(host.getHostName())) {
session.setConfig(KEY_TYPE_CONFIG, hostKey.getType());
}
}
} | java | protected void setHostKeyType(OpenSshConfig.Host host, Session session) {
HostKey[] hostKeys = session.getHostKeyRepository().getHostKey();
for(HostKey hostKey : hostKeys) {
if(hostKey.getHost().contains(host.getHostName())) {
session.setConfig(KEY_TYPE_CONFIG, hostKey.getType());
}
}
} | [
"protected",
"void",
"setHostKeyType",
"(",
"OpenSshConfig",
".",
"Host",
"host",
",",
"Session",
"session",
")",
"{",
"HostKey",
"[",
"]",
"hostKeys",
"=",
"session",
".",
"getHostKeyRepository",
"(",
")",
".",
"getHostKey",
"(",
")",
";",
"for",
"(",
"Ho... | /*
Iterates through the known hosts (host key repository).
If one of the know hosts matches the current host we're trying to connect too,
it configures the session to use that key's algorithm
(thus avoiding conflicts between JSch wanting RSA and the key being ECDSA) | [
"/",
"*",
"Iterates",
"through",
"the",
"known",
"hosts",
"(",
"host",
"key",
"repository",
")",
".",
"If",
"one",
"of",
"the",
"know",
"hosts",
"matches",
"the",
"current",
"host",
"we",
"re",
"trying",
"to",
"connect",
"too",
"it",
"configures",
"the",... | train | https://github.com/craftercms/commons/blob/3074fe49e56c2a4aae0832f40b17ae563335dc83/git/src/main/java/org/craftercms/commons/git/auth/AbstractSshAuthConfigurator.java#L50-L57 |
doubledutch/LazyJSON | src/main/java/me/doubledutch/lazyjson/LazyObject.java | LazyObject.getBoolean | public boolean getBoolean(String key){
LazyNode token=getFieldToken(key);
if(token.type==LazyNode.VALUE_STRING || token.type==LazyNode.VALUE_ESTRING){
String str=token.getStringValue().toLowerCase().trim();
if(str.equals("true"))return true;
if(str.equals("false"))return false;
throw new LazyException("Requested value is not a boolean",token);
}
if(token.type==LazyNode.VALUE_TRUE)return true;
if(token.type==LazyNode.VALUE_FALSE)return false;
throw new LazyException("Requested value is not a boolean",token);
} | java | public boolean getBoolean(String key){
LazyNode token=getFieldToken(key);
if(token.type==LazyNode.VALUE_STRING || token.type==LazyNode.VALUE_ESTRING){
String str=token.getStringValue().toLowerCase().trim();
if(str.equals("true"))return true;
if(str.equals("false"))return false;
throw new LazyException("Requested value is not a boolean",token);
}
if(token.type==LazyNode.VALUE_TRUE)return true;
if(token.type==LazyNode.VALUE_FALSE)return false;
throw new LazyException("Requested value is not a boolean",token);
} | [
"public",
"boolean",
"getBoolean",
"(",
"String",
"key",
")",
"{",
"LazyNode",
"token",
"=",
"getFieldToken",
"(",
"key",
")",
";",
"if",
"(",
"token",
".",
"type",
"==",
"LazyNode",
".",
"VALUE_STRING",
"||",
"token",
".",
"type",
"==",
"LazyNode",
".",... | Returns the boolean value stored in this object for the given key.
@param key the name of the field on this object
@return a boolean value
@throws LazyException if the value for the given key was not a boolean. | [
"Returns",
"the",
"boolean",
"value",
"stored",
"in",
"this",
"object",
"for",
"the",
"given",
"key",
"."
] | train | https://github.com/doubledutch/LazyJSON/blob/1a223f57fc0cb9941bc175739697ac95da5618cc/src/main/java/me/doubledutch/lazyjson/LazyObject.java#L514-L525 |
rhuss/jolokia | agent/core/src/main/java/org/jolokia/util/ClassUtil.java | ClassUtil.classForName | public static <T> Class<T> classForName(String pClassName, ClassLoader ... pClassLoaders) {
return classForName(pClassName, true, pClassLoaders);
} | java | public static <T> Class<T> classForName(String pClassName, ClassLoader ... pClassLoaders) {
return classForName(pClassName, true, pClassLoaders);
} | [
"public",
"static",
"<",
"T",
">",
"Class",
"<",
"T",
">",
"classForName",
"(",
"String",
"pClassName",
",",
"ClassLoader",
"...",
"pClassLoaders",
")",
"{",
"return",
"classForName",
"(",
"pClassName",
",",
"true",
",",
"pClassLoaders",
")",
";",
"}"
] | Lookup a class. See {@link ClassUtil#classForName(String, boolean,ClassLoader[])} for details. The class
gets initialized during lookup.
@param pClassName name to lookup.
@return the class found or null if no class could be found. | [
"Lookup",
"a",
"class",
".",
"See",
"{",
"@link",
"ClassUtil#classForName",
"(",
"String",
"boolean",
"ClassLoader",
"[]",
")",
"}",
"for",
"details",
".",
"The",
"class",
"gets",
"initialized",
"during",
"lookup",
"."
] | train | https://github.com/rhuss/jolokia/blob/dc95e7bef859b1829776c5a84c8f7738f5d7d9c3/agent/core/src/main/java/org/jolokia/util/ClassUtil.java#L41-L43 |
aalmiray/Json-lib | src/main/java/net/sf/json/JSONObject.java | JSONObject.toBean | public static Object toBean( JSONObject jsonObject, Class beanClass, Map classMap ) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setRootClass( beanClass );
jsonConfig.setClassMap( classMap );
return toBean( jsonObject, jsonConfig );
} | java | public static Object toBean( JSONObject jsonObject, Class beanClass, Map classMap ) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setRootClass( beanClass );
jsonConfig.setClassMap( classMap );
return toBean( jsonObject, jsonConfig );
} | [
"public",
"static",
"Object",
"toBean",
"(",
"JSONObject",
"jsonObject",
",",
"Class",
"beanClass",
",",
"Map",
"classMap",
")",
"{",
"JsonConfig",
"jsonConfig",
"=",
"new",
"JsonConfig",
"(",
")",
";",
"jsonConfig",
".",
"setRootClass",
"(",
"beanClass",
")",... | Creates a bean from a JSONObject, with a specific target class.<br>
If beanClass is null, this method will return a graph of DynaBeans. Any
attribute that is a JSONObject and matches a key in the classMap will be
converted to that target class.<br>
The classMap has the following conventions:
<ul>
<li>Every key must be an String.</li>
<li>Every value must be a Class.</li>
<li>A key may be a regular expression.</li>
</ul> | [
"Creates",
"a",
"bean",
"from",
"a",
"JSONObject",
"with",
"a",
"specific",
"target",
"class",
".",
"<br",
">",
"If",
"beanClass",
"is",
"null",
"this",
"method",
"will",
"return",
"a",
"graph",
"of",
"DynaBeans",
".",
"Any",
"attribute",
"that",
"is",
"... | train | https://github.com/aalmiray/Json-lib/blob/9e2b3376ee8f511a48aa7ac05f75a7414e02280f/src/main/java/net/sf/json/JSONObject.java#L237-L242 |
soi-toolkit/soi-toolkit-mule | commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/ftp/FtpUtil.java | FtpUtil.recursiveCreateDirectory | static public void recursiveCreateDirectory(FTPClient ftpClient, String path) throws IOException {
logger.info("Create Directory: {}", path);
int createDirectoryStatus = ftpClient.mkd(path); // makeDirectory...
logger.debug("Create Directory Status: {}", createDirectoryStatus);
if (createDirectoryStatus == FTP_FILE_NOT_FOUND) {
int sepIdx = path.lastIndexOf('/');
if (sepIdx > -1) {
String parentPath = path.substring(0, sepIdx);
recursiveCreateDirectory(ftpClient, parentPath);
logger.debug("2'nd CreateD irectory: {}", path);
createDirectoryStatus = ftpClient.mkd(path); // makeDirectory...
logger.debug("2'nd Create Directory Status: {}", createDirectoryStatus);
}
}
} | java | static public void recursiveCreateDirectory(FTPClient ftpClient, String path) throws IOException {
logger.info("Create Directory: {}", path);
int createDirectoryStatus = ftpClient.mkd(path); // makeDirectory...
logger.debug("Create Directory Status: {}", createDirectoryStatus);
if (createDirectoryStatus == FTP_FILE_NOT_FOUND) {
int sepIdx = path.lastIndexOf('/');
if (sepIdx > -1) {
String parentPath = path.substring(0, sepIdx);
recursiveCreateDirectory(ftpClient, parentPath);
logger.debug("2'nd CreateD irectory: {}", path);
createDirectoryStatus = ftpClient.mkd(path); // makeDirectory...
logger.debug("2'nd Create Directory Status: {}", createDirectoryStatus);
}
}
} | [
"static",
"public",
"void",
"recursiveCreateDirectory",
"(",
"FTPClient",
"ftpClient",
",",
"String",
"path",
")",
"throws",
"IOException",
"{",
"logger",
".",
"info",
"(",
"\"Create Directory: {}\"",
",",
"path",
")",
";",
"int",
"createDirectoryStatus",
"=",
"ft... | Create a directory and all missing parent-directories.
@param ftpClient
@param path
@throws IOException | [
"Create",
"a",
"directory",
"and",
"all",
"missing",
"parent",
"-",
"directories",
"."
] | train | https://github.com/soi-toolkit/soi-toolkit-mule/blob/e891350dbf55e6307be94d193d056bdb785b37d3/commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/ftp/FtpUtil.java#L172-L189 |
GoSimpleLLC/nbvcxz | src/main/java/me/gosimple/nbvcxz/resources/DictionaryBuilder.java | DictionaryBuilder.addWord | public DictionaryBuilder addWord(final String word, final int rank)
{
this.dictonary.put(word.toLowerCase(), rank);
return this;
} | java | public DictionaryBuilder addWord(final String word, final int rank)
{
this.dictonary.put(word.toLowerCase(), rank);
return this;
} | [
"public",
"DictionaryBuilder",
"addWord",
"(",
"final",
"String",
"word",
",",
"final",
"int",
"rank",
")",
"{",
"this",
".",
"dictonary",
".",
"put",
"(",
"word",
".",
"toLowerCase",
"(",
")",
",",
"rank",
")",
";",
"return",
"this",
";",
"}"
] | Add word to dictionary.
@param word key to add to the dictionary, will be lowercased.
@param rank the rank of the word in the dictionary.
Should increment from most common to least common if ranked.
If unranked, an example would be if there were 500 values in the dictionary, every word should have a rank of 250.
If exclusion dictionary, rank is unimportant (set to 0).
@return the builder | [
"Add",
"word",
"to",
"dictionary",
"."
] | train | https://github.com/GoSimpleLLC/nbvcxz/blob/a86fb24680e646efdf78d6fda9d68a5410145f56/src/main/java/me/gosimple/nbvcxz/resources/DictionaryBuilder.java#L49-L53 |
Azure/azure-sdk-for-java | batch/data-plane/src/main/java/com/microsoft/azure/batch/JobScheduleOperations.java | JobScheduleOperations.getJobSchedule | public CloudJobSchedule getJobSchedule(String jobScheduleId, DetailLevel detailLevel) throws BatchErrorException, IOException {
return getJobSchedule(jobScheduleId, detailLevel, null);
} | java | public CloudJobSchedule getJobSchedule(String jobScheduleId, DetailLevel detailLevel) throws BatchErrorException, IOException {
return getJobSchedule(jobScheduleId, detailLevel, null);
} | [
"public",
"CloudJobSchedule",
"getJobSchedule",
"(",
"String",
"jobScheduleId",
",",
"DetailLevel",
"detailLevel",
")",
"throws",
"BatchErrorException",
",",
"IOException",
"{",
"return",
"getJobSchedule",
"(",
"jobScheduleId",
",",
"detailLevel",
",",
"null",
")",
";... | Gets the specified {@link CloudJobSchedule}.
@param jobScheduleId The ID of the job schedule.
@param detailLevel A {@link DetailLevel} used for controlling which properties are retrieved from the service.
@return A {@link CloudJobSchedule} containing information about the specified Azure Batch job schedule.
@throws BatchErrorException Exception thrown when an error response is received from the Batch service.
@throws IOException Exception thrown when there is an error in serialization/deserialization of data sent to/received from the Batch service. | [
"Gets",
"the",
"specified",
"{",
"@link",
"CloudJobSchedule",
"}",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/batch/data-plane/src/main/java/com/microsoft/azure/batch/JobScheduleOperations.java#L145-L147 |
PomepuyN/discreet-app-rate | DiscreetAppRate/src/main/java/fr/nicolaspomepuy/discreetapprate/Utils.java | Utils.convertDPItoPixels | public static int convertDPItoPixels(Context context, int dpi) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpi * scale + 0.5f);
} | java | public static int convertDPItoPixels(Context context, int dpi) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpi * scale + 0.5f);
} | [
"public",
"static",
"int",
"convertDPItoPixels",
"(",
"Context",
"context",
",",
"int",
"dpi",
")",
"{",
"final",
"float",
"scale",
"=",
"context",
".",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
".",
"density",
";",
"return",
"(",
"int"... | Convert a size in dp to a size in pixels
@param context the {@link android.content.Context} to be used
@param dpi size in dp
@return the size in pixels | [
"Convert",
"a",
"size",
"in",
"dp",
"to",
"a",
"size",
"in",
"pixels"
] | train | https://github.com/PomepuyN/discreet-app-rate/blob/d9e007907d98191145f2b31057f0813e18bb320a/DiscreetAppRate/src/main/java/fr/nicolaspomepuy/discreetapprate/Utils.java#L36-L39 |
mygreen/super-csv-annotation | src/main/java/com/github/mygreen/supercsv/cellprocessor/conversion/RegexReplace.java | RegexReplace.checkPreconditions | private static void checkPreconditions(final Pattern pattern, final String replacement) {
if(pattern == null ) {
throw new NullPointerException("regex should not be null");
}
if(replacement == null) {
throw new NullPointerException("replacement should not be null");
}
} | java | private static void checkPreconditions(final Pattern pattern, final String replacement) {
if(pattern == null ) {
throw new NullPointerException("regex should not be null");
}
if(replacement == null) {
throw new NullPointerException("replacement should not be null");
}
} | [
"private",
"static",
"void",
"checkPreconditions",
"(",
"final",
"Pattern",
"pattern",
",",
"final",
"String",
"replacement",
")",
"{",
"if",
"(",
"pattern",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"regex should not be null\"",
")",
... | コンスタによるインスタンスを生成する際の前提条件となる引数のチェックを行う。
@param pattern コンパイル済みの正規表現
@param replacement 置換する文字。
@throws NullPointerException if pattern or replacement is null. | [
"コンスタによるインスタンスを生成する際の前提条件となる引数のチェックを行う。"
] | train | https://github.com/mygreen/super-csv-annotation/blob/9910320cb6dc143be972c7d10d9ab5ffb09c3b84/src/main/java/com/github/mygreen/supercsv/cellprocessor/conversion/RegexReplace.java#L68-L76 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_number_serviceName_convertToLine_POST | public OvhOfferTask billingAccount_number_serviceName_convertToLine_POST(String billingAccount, String serviceName, String offer) throws IOException {
String qPath = "/telephony/{billingAccount}/number/{serviceName}/convertToLine";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "offer", offer);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOfferTask.class);
} | java | public OvhOfferTask billingAccount_number_serviceName_convertToLine_POST(String billingAccount, String serviceName, String offer) throws IOException {
String qPath = "/telephony/{billingAccount}/number/{serviceName}/convertToLine";
StringBuilder sb = path(qPath, billingAccount, serviceName);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "offer", offer);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOfferTask.class);
} | [
"public",
"OvhOfferTask",
"billingAccount_number_serviceName_convertToLine_POST",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"String",
"offer",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/number/{serviceName... | Schedule a conversion to line
REST: POST /telephony/{billingAccount}/number/{serviceName}/convertToLine
@param offer [required] The future offer of the converted number
@param billingAccount [required] The name of your billingAccount
@param serviceName [required] Name of the service | [
"Schedule",
"a",
"conversion",
"to",
"line"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L5680-L5687 |
landawn/AbacusUtil | src/com/landawn/abacus/util/JdbcUtil.java | JdbcUtil.prepareCallableQuery | public static PreparedCallableQuery prepareCallableQuery(final Connection conn, final Try.Function<Connection, CallableStatement, SQLException> stmtCreator)
throws SQLException {
return new PreparedCallableQuery(stmtCreator.apply(conn));
} | java | public static PreparedCallableQuery prepareCallableQuery(final Connection conn, final Try.Function<Connection, CallableStatement, SQLException> stmtCreator)
throws SQLException {
return new PreparedCallableQuery(stmtCreator.apply(conn));
} | [
"public",
"static",
"PreparedCallableQuery",
"prepareCallableQuery",
"(",
"final",
"Connection",
"conn",
",",
"final",
"Try",
".",
"Function",
"<",
"Connection",
",",
"CallableStatement",
",",
"SQLException",
">",
"stmtCreator",
")",
"throws",
"SQLException",
"{",
"... | Never write below code because it will definitely cause {@code Connection} leak:
<pre>
<code>
JdbcUtil.prepareCallableQuery(dataSource.getConnection(), stmtCreator);
</code>
</pre>
@param conn the specified {@code conn} won't be close after this query is executed.
@param stmtCreator the created {@code CallableStatement} will be closed after any execution methods in {@code PreparedQuery/PreparedCallableQuery} is called.
An execution method is a method which will trigger the backed {@code PreparedStatement/CallableStatement} to be executed, for example: get/query/queryForInt/Long/../findFirst/list/execute/....
@return
@throws SQLException
@see {@link JdbcUtil#prepareCall(Connection, String, Object...)} | [
"Never",
"write",
"below",
"code",
"because",
"it",
"will",
"definitely",
"cause",
"{",
"@code",
"Connection",
"}",
"leak",
":",
"<pre",
">",
"<code",
">",
"JdbcUtil",
".",
"prepareCallableQuery",
"(",
"dataSource",
".",
"getConnection",
"()",
"stmtCreator",
"... | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/JdbcUtil.java#L1416-L1419 |
zeroturnaround/zt-zip | src/main/java/org/zeroturnaround/zip/Zips.java | Zips.addFile | public Zips addFile(File file, FileFilter filter) {
return this.addFile(file, false, filter);
} | java | public Zips addFile(File file, FileFilter filter) {
return this.addFile(file, false, filter);
} | [
"public",
"Zips",
"addFile",
"(",
"File",
"file",
",",
"FileFilter",
"filter",
")",
"{",
"return",
"this",
".",
"addFile",
"(",
"file",
",",
"false",
",",
"filter",
")",
";",
"}"
] | Adds a file entry. If given file is a dir, adds it and all subfiles recursively.
Adding takes precedence over removal of entries.
@param file file to add.
@param filter a filter to accept files for adding, null means all files are accepted
@return this Zips for fluent api | [
"Adds",
"a",
"file",
"entry",
".",
"If",
"given",
"file",
"is",
"a",
"dir",
"adds",
"it",
"and",
"all",
"subfiles",
"recursively",
".",
"Adding",
"takes",
"precedence",
"over",
"removal",
"of",
"entries",
"."
] | train | https://github.com/zeroturnaround/zt-zip/blob/abb4dc43583e4d19339c0c021035019798970a13/src/main/java/org/zeroturnaround/zip/Zips.java#L182-L184 |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/ObjectTypeAttributeDefinition.java | ObjectTypeAttributeDefinition.resolveValue | @Override
public ModelNode resolveValue(ExpressionResolver resolver, ModelNode value) throws OperationFailedException {
// Pass non-OBJECT values through the superclass so it can reject weird values and, in the odd chance
// that's how this object is set up, turn undefined into a default list value.
ModelNode superResult = value.getType() == ModelType.OBJECT ? value : super.resolveValue(resolver, value);
// If it's not an OBJECT (almost certainly UNDEFINED), then nothing more we can do
if (superResult.getType() != ModelType.OBJECT) {
return superResult;
}
// Resolve each field.
// Don't mess with the original value
ModelNode clone = superResult == value ? value.clone() : superResult;
ModelNode result = new ModelNode();
for (AttributeDefinition field : valueTypes) {
String fieldName = field.getName();
if (clone.has(fieldName)) {
result.get(fieldName).set(field.resolveValue(resolver, clone.get(fieldName)));
} else {
// Input doesn't have a child for this field.
// Don't create one in the output unless the AD produces a default value.
// TBH this doesn't make a ton of sense, since any object should have
// all of its fields, just some may be undefined. But doing it this
// way may avoid breaking some code that is incorrectly checking node.has("xxx")
// instead of node.hasDefined("xxx")
ModelNode val = field.resolveValue(resolver, new ModelNode());
if (val.isDefined()) {
result.get(fieldName).set(val);
}
}
}
// Validate the entire object
getValidator().validateParameter(getName(), result);
return result;
} | java | @Override
public ModelNode resolveValue(ExpressionResolver resolver, ModelNode value) throws OperationFailedException {
// Pass non-OBJECT values through the superclass so it can reject weird values and, in the odd chance
// that's how this object is set up, turn undefined into a default list value.
ModelNode superResult = value.getType() == ModelType.OBJECT ? value : super.resolveValue(resolver, value);
// If it's not an OBJECT (almost certainly UNDEFINED), then nothing more we can do
if (superResult.getType() != ModelType.OBJECT) {
return superResult;
}
// Resolve each field.
// Don't mess with the original value
ModelNode clone = superResult == value ? value.clone() : superResult;
ModelNode result = new ModelNode();
for (AttributeDefinition field : valueTypes) {
String fieldName = field.getName();
if (clone.has(fieldName)) {
result.get(fieldName).set(field.resolveValue(resolver, clone.get(fieldName)));
} else {
// Input doesn't have a child for this field.
// Don't create one in the output unless the AD produces a default value.
// TBH this doesn't make a ton of sense, since any object should have
// all of its fields, just some may be undefined. But doing it this
// way may avoid breaking some code that is incorrectly checking node.has("xxx")
// instead of node.hasDefined("xxx")
ModelNode val = field.resolveValue(resolver, new ModelNode());
if (val.isDefined()) {
result.get(fieldName).set(val);
}
}
}
// Validate the entire object
getValidator().validateParameter(getName(), result);
return result;
} | [
"@",
"Override",
"public",
"ModelNode",
"resolveValue",
"(",
"ExpressionResolver",
"resolver",
",",
"ModelNode",
"value",
")",
"throws",
"OperationFailedException",
"{",
"// Pass non-OBJECT values through the superclass so it can reject weird values and, in the odd chance",
"// that'... | Overrides the superclass implementation to allow the AttributeDefinition for each field in the
object to in turn resolve that field.
{@inheritDoc} | [
"Overrides",
"the",
"superclass",
"implementation",
"to",
"allow",
"the",
"AttributeDefinition",
"for",
"each",
"field",
"in",
"the",
"object",
"to",
"in",
"turn",
"resolve",
"that",
"field",
"."
] | train | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/ObjectTypeAttributeDefinition.java#L202-L238 |
aws/aws-sdk-java | aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java | AmazonS3Client.populateRequesterPaysHeader | protected static void populateRequesterPaysHeader(Request<?> request, boolean isRequesterPays) {
if (isRequesterPays) {
request.addHeader(Headers.REQUESTER_PAYS_HEADER, Constants.REQUESTER_PAYS);
}
} | java | protected static void populateRequesterPaysHeader(Request<?> request, boolean isRequesterPays) {
if (isRequesterPays) {
request.addHeader(Headers.REQUESTER_PAYS_HEADER, Constants.REQUESTER_PAYS);
}
} | [
"protected",
"static",
"void",
"populateRequesterPaysHeader",
"(",
"Request",
"<",
"?",
">",
"request",
",",
"boolean",
"isRequesterPays",
")",
"{",
"if",
"(",
"isRequesterPays",
")",
"{",
"request",
".",
"addHeader",
"(",
"Headers",
".",
"REQUESTER_PAYS_HEADER",
... | <p>
Populate the specified request with {@link Constants#REQUESTER_PAYS} to header {@link Headers#REQUESTER_PAYS_HEADER},
if isRequesterPays is true.
</p>
@param request
The specified request to populate.
@param isRequesterPays
The flag whether to populate the header or not. | [
"<p",
">",
"Populate",
"the",
"specified",
"request",
"with",
"{",
"@link",
"Constants#REQUESTER_PAYS",
"}",
"to",
"header",
"{",
"@link",
"Headers#REQUESTER_PAYS_HEADER",
"}",
"if",
"isRequesterPays",
"is",
"true",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java#L4197-L4201 |
JakeWharton/ActionBarSherlock | actionbarsherlock/src/com/actionbarsherlock/widget/SearchView.java | SearchView.createVoiceWebSearchIntent | private Intent createVoiceWebSearchIntent(Intent baseIntent, SearchableInfo searchable) {
Intent voiceIntent = new Intent(baseIntent);
ComponentName searchActivity = searchable.getSearchActivity();
voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
: searchActivity.flattenToShortString());
return voiceIntent;
} | java | private Intent createVoiceWebSearchIntent(Intent baseIntent, SearchableInfo searchable) {
Intent voiceIntent = new Intent(baseIntent);
ComponentName searchActivity = searchable.getSearchActivity();
voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null
: searchActivity.flattenToShortString());
return voiceIntent;
} | [
"private",
"Intent",
"createVoiceWebSearchIntent",
"(",
"Intent",
"baseIntent",
",",
"SearchableInfo",
"searchable",
")",
"{",
"Intent",
"voiceIntent",
"=",
"new",
"Intent",
"(",
"baseIntent",
")",
";",
"ComponentName",
"searchActivity",
"=",
"searchable",
".",
"get... | Create and return an Intent that can launch the voice search activity for web search. | [
"Create",
"and",
"return",
"an",
"Intent",
"that",
"can",
"launch",
"the",
"voice",
"search",
"activity",
"for",
"web",
"search",
"."
] | train | https://github.com/JakeWharton/ActionBarSherlock/blob/2c71339e756bcc0b1424c4525680549ba3a2dc97/actionbarsherlock/src/com/actionbarsherlock/widget/SearchView.java#L1498-L1504 |
pravega/pravega | common/src/main/java/io/pravega/common/concurrent/Futures.java | Futures.completeAfter | public static <T> void completeAfter(Supplier<CompletableFuture<? extends T>> futureSupplier, CompletableFuture<T> toComplete) {
Preconditions.checkArgument(!toComplete.isDone(), "toComplete is already completed.");
try {
CompletableFuture<? extends T> f = futureSupplier.get();
// Async termination.
f.thenAccept(toComplete::complete);
Futures.exceptionListener(f, toComplete::completeExceptionally);
} catch (Throwable ex) {
// Synchronous termination.
toComplete.completeExceptionally(ex);
throw ex;
}
} | java | public static <T> void completeAfter(Supplier<CompletableFuture<? extends T>> futureSupplier, CompletableFuture<T> toComplete) {
Preconditions.checkArgument(!toComplete.isDone(), "toComplete is already completed.");
try {
CompletableFuture<? extends T> f = futureSupplier.get();
// Async termination.
f.thenAccept(toComplete::complete);
Futures.exceptionListener(f, toComplete::completeExceptionally);
} catch (Throwable ex) {
// Synchronous termination.
toComplete.completeExceptionally(ex);
throw ex;
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"completeAfter",
"(",
"Supplier",
"<",
"CompletableFuture",
"<",
"?",
"extends",
"T",
">",
">",
"futureSupplier",
",",
"CompletableFuture",
"<",
"T",
">",
"toComplete",
")",
"{",
"Preconditions",
".",
"checkArgument",... | Given a Supplier returning a Future, completes another future either with the result of the first future, in case
of normal completion, or exceptionally with the exception of the first future.
@param futureSupplier A Supplier returning a Future to listen to.
@param toComplete A CompletableFuture that has not yet been completed, which will be completed with the result
of the Future from futureSupplier.
@param <T> Return type of Future. | [
"Given",
"a",
"Supplier",
"returning",
"a",
"Future",
"completes",
"another",
"future",
"either",
"with",
"the",
"result",
"of",
"the",
"first",
"future",
"in",
"case",
"of",
"normal",
"completion",
"or",
"exceptionally",
"with",
"the",
"exception",
"of",
"the... | train | https://github.com/pravega/pravega/blob/6e24df7470669b3956a07018f52b2c6b3c2a3503/common/src/main/java/io/pravega/common/concurrent/Futures.java#L85-L98 |
h2oai/h2o-3 | h2o-core/src/main/java/water/api/Route.java | Route.resolveMethod | private static Method resolveMethod(Class<? extends Handler> handler_class, String handler_method) {
for (Method method : handler_class.getMethods())
if (method.getName().equals(handler_method)) {
Class[] pt = method.getParameterTypes();
if (pt != null && pt.length == 2 && pt[0] == Integer.TYPE && Schema.class.isAssignableFrom(pt[1]))
return method;
}
throw H2O.fail("Failed to find handler method: " + handler_method + " in class: " + handler_class.getSimpleName());
} | java | private static Method resolveMethod(Class<? extends Handler> handler_class, String handler_method) {
for (Method method : handler_class.getMethods())
if (method.getName().equals(handler_method)) {
Class[] pt = method.getParameterTypes();
if (pt != null && pt.length == 2 && pt[0] == Integer.TYPE && Schema.class.isAssignableFrom(pt[1]))
return method;
}
throw H2O.fail("Failed to find handler method: " + handler_method + " in class: " + handler_class.getSimpleName());
} | [
"private",
"static",
"Method",
"resolveMethod",
"(",
"Class",
"<",
"?",
"extends",
"Handler",
">",
"handler_class",
",",
"String",
"handler_method",
")",
"{",
"for",
"(",
"Method",
"method",
":",
"handler_class",
".",
"getMethods",
"(",
")",
")",
"if",
"(",
... | Search the provided class (and all its superclasses) for the requested method.
@param handler_class Class to be searched
@param handler_method Name of the method to look for. The method must have signature (int, Schema).
@return The callable Method object. | [
"Search",
"the",
"provided",
"class",
"(",
"and",
"all",
"its",
"superclasses",
")",
"for",
"the",
"requested",
"method",
"."
] | train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-core/src/main/java/water/api/Route.java#L124-L132 |
CenturyLinkCloud/clc-java-sdk | sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/ip/Subnet.java | Subnet.getCidr | public String getCidr() {
if (cidr != null) {
return cidr;
}
if (ipAddress != null) {
if (mask != null) {
return new SubnetUtils(ipAddress, mask).getCidrSignature();
}
if (cidrMask != null) {
return new SubnetUtils(ipAddress+cidrMask).getCidrSignature();
}
}
return null;
} | java | public String getCidr() {
if (cidr != null) {
return cidr;
}
if (ipAddress != null) {
if (mask != null) {
return new SubnetUtils(ipAddress, mask).getCidrSignature();
}
if (cidrMask != null) {
return new SubnetUtils(ipAddress+cidrMask).getCidrSignature();
}
}
return null;
} | [
"public",
"String",
"getCidr",
"(",
")",
"{",
"if",
"(",
"cidr",
"!=",
"null",
")",
"{",
"return",
"cidr",
";",
"}",
"if",
"(",
"ipAddress",
"!=",
"null",
")",
"{",
"if",
"(",
"mask",
"!=",
"null",
")",
"{",
"return",
"new",
"SubnetUtils",
"(",
"... | Returns IP address in CIDR format.
If specified {@code cidr} - returns {@code cidr} value.
If specified {@code ipAddress} and {@code mask} - returns calculated IP address.
If specified {@code ipAddress} and {@code cidrMask} - returns calculated IP address.
Otherwise returns {@code null}
@return ip address string representation in CIDR format | [
"Returns",
"IP",
"address",
"in",
"CIDR",
"format",
"."
] | train | https://github.com/CenturyLinkCloud/clc-java-sdk/blob/c026322f077dea71b1acf9f2d665253d79d9bf85/sdk/src/main/java/com/centurylink/cloud/sdk/server/services/dsl/domain/ip/Subnet.java#L72-L85 |
OpenLiberty/open-liberty | dev/com.ibm.ws.microprofile.openapi/src/com/ibm/ws/microprofile/openapi/impl/core/jackson/JAXBAnnotationsHelper.java | JAXBAnnotationsHelper.apply | public static void apply(Annotated member, Schema property) {
if (member.hasAnnotation(XmlElementWrapper.class) || member.hasAnnotation(XmlElement.class)) {
applyElement(member, property);
} else if (member.hasAnnotation(XmlAttribute.class) && isAttributeAllowed(property)) {
applyAttribute(member, property);
}
} | java | public static void apply(Annotated member, Schema property) {
if (member.hasAnnotation(XmlElementWrapper.class) || member.hasAnnotation(XmlElement.class)) {
applyElement(member, property);
} else if (member.hasAnnotation(XmlAttribute.class) && isAttributeAllowed(property)) {
applyAttribute(member, property);
}
} | [
"public",
"static",
"void",
"apply",
"(",
"Annotated",
"member",
",",
"Schema",
"property",
")",
"{",
"if",
"(",
"member",
".",
"hasAnnotation",
"(",
"XmlElementWrapper",
".",
"class",
")",
"||",
"member",
".",
"hasAnnotation",
"(",
"XmlElement",
".",
"class... | Applies annotations to property's {@link XML} definition.
@param member annotations provider
@param property property instance to be updated | [
"Applies",
"annotations",
"to",
"property",
"s",
"{",
"@link",
"XML",
"}",
"definition",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.microprofile.openapi/src/com/ibm/ws/microprofile/openapi/impl/core/jackson/JAXBAnnotationsHelper.java#L41-L47 |
phax/ph-commons | ph-commons/src/main/java/com/helger/commons/string/StringHelper.java | StringHelper.getUntilLastExcl | @Nullable
public static String getUntilLastExcl (@Nullable final String sStr, final char cSearch)
{
return _getUntilLast (sStr, cSearch, false);
} | java | @Nullable
public static String getUntilLastExcl (@Nullable final String sStr, final char cSearch)
{
return _getUntilLast (sStr, cSearch, false);
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getUntilLastExcl",
"(",
"@",
"Nullable",
"final",
"String",
"sStr",
",",
"final",
"char",
"cSearch",
")",
"{",
"return",
"_getUntilLast",
"(",
"sStr",
",",
"cSearch",
",",
"false",
")",
";",
"}"
] | Get everything from the string up to and excluding first the passed char.
@param sStr
The source string. May be <code>null</code>.
@param cSearch
The character to search.
@return <code>null</code> if the passed string does not contain the search
character. | [
"Get",
"everything",
"from",
"the",
"string",
"up",
"to",
"and",
"excluding",
"first",
"the",
"passed",
"char",
"."
] | train | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/string/StringHelper.java#L4861-L4865 |
Azure/azure-sdk-for-java | cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java | ModelsImpl.updateClosedListEntityRole | public OperationStatus updateClosedListEntityRole(UUID appId, String versionId, UUID entityId, UUID roleId, UpdateClosedListEntityRoleOptionalParameter updateClosedListEntityRoleOptionalParameter) {
return updateClosedListEntityRoleWithServiceResponseAsync(appId, versionId, entityId, roleId, updateClosedListEntityRoleOptionalParameter).toBlocking().single().body();
} | java | public OperationStatus updateClosedListEntityRole(UUID appId, String versionId, UUID entityId, UUID roleId, UpdateClosedListEntityRoleOptionalParameter updateClosedListEntityRoleOptionalParameter) {
return updateClosedListEntityRoleWithServiceResponseAsync(appId, versionId, entityId, roleId, updateClosedListEntityRoleOptionalParameter).toBlocking().single().body();
} | [
"public",
"OperationStatus",
"updateClosedListEntityRole",
"(",
"UUID",
"appId",
",",
"String",
"versionId",
",",
"UUID",
"entityId",
",",
"UUID",
"roleId",
",",
"UpdateClosedListEntityRoleOptionalParameter",
"updateClosedListEntityRoleOptionalParameter",
")",
"{",
"return",
... | Update an entity role for a given entity.
@param appId The application ID.
@param versionId The version ID.
@param entityId The entity ID.
@param roleId The entity role ID.
@param updateClosedListEntityRoleOptionalParameter the object representing the optional parameters to be set before calling this API
@throws IllegalArgumentException thrown if parameters fail the validation
@throws ErrorResponseException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the OperationStatus object if successful. | [
"Update",
"an",
"entity",
"role",
"for",
"a",
"given",
"entity",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/cognitiveservices/data-plane/language/luis/authoring/src/main/java/com/microsoft/azure/cognitiveservices/language/luis/authoring/implementation/ModelsImpl.java#L11648-L11650 |
sarl/sarl | docs/io.sarl.docs.doclet/src/main/java/io/sarl/docs/doclet/utils/Reflect.java | Reflect.copyFields | public static <T> void copyFields(Class<T> type, T dest, T source) {
Class<?> clazz = type;
while (clazz != null && !Object.class.equals(clazz)) {
for (final Field field : clazz.getDeclaredFields()) {
if (!Modifier.isStatic(field.getModifiers())) {
field.setAccessible(true);
try {
field.set(dest, field.get(source));
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new Error(e);
}
}
}
clazz = clazz.getSuperclass();
}
} | java | public static <T> void copyFields(Class<T> type, T dest, T source) {
Class<?> clazz = type;
while (clazz != null && !Object.class.equals(clazz)) {
for (final Field field : clazz.getDeclaredFields()) {
if (!Modifier.isStatic(field.getModifiers())) {
field.setAccessible(true);
try {
field.set(dest, field.get(source));
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new Error(e);
}
}
}
clazz = clazz.getSuperclass();
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"copyFields",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"T",
"dest",
",",
"T",
"source",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"type",
";",
"while",
"(",
"clazz",
"!=",
"null",
"&&",
"!",
"Ob... | Clone the fields.
@param <T> the type of the objects.
@param type the type of the objects.
@param dest the destination.
@param source the source. | [
"Clone",
"the",
"fields",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/docs/io.sarl.docs.doclet/src/main/java/io/sarl/docs/doclet/utils/Reflect.java#L136-L151 |
structurizr/java | structurizr-core/src/com/structurizr/documentation/ViewpointsAndPerspectivesDocumentationTemplate.java | ViewpointsAndPerspectivesDocumentationTemplate.addSystemQualitiesSection | public Section addSystemQualitiesSection(SoftwareSystem softwareSystem, File... files) throws IOException {
return addSection(softwareSystem, "System Qualities", files);
} | java | public Section addSystemQualitiesSection(SoftwareSystem softwareSystem, File... files) throws IOException {
return addSection(softwareSystem, "System Qualities", files);
} | [
"public",
"Section",
"addSystemQualitiesSection",
"(",
"SoftwareSystem",
"softwareSystem",
",",
"File",
"...",
"files",
")",
"throws",
"IOException",
"{",
"return",
"addSection",
"(",
"softwareSystem",
",",
"\"System Qualities\"",
",",
"files",
")",
";",
"}"
] | Adds a "System Qualities" section relating to a {@link SoftwareSystem} from one or more files.
@param softwareSystem the {@link SoftwareSystem} the documentation content relates to
@param files one or more File objects that point to the documentation content
@return a documentation {@link Section}
@throws IOException if there is an error reading the files | [
"Adds",
"a",
"System",
"Qualities",
"section",
"relating",
"to",
"a",
"{",
"@link",
"SoftwareSystem",
"}",
"from",
"one",
"or",
"more",
"files",
"."
] | train | https://github.com/structurizr/java/blob/4b204f077877a24bcac363f5ecf0e129a0f9f4c5/structurizr-core/src/com/structurizr/documentation/ViewpointsAndPerspectivesDocumentationTemplate.java#L164-L166 |
threerings/gwt-utils | src/main/java/com/threerings/gwt/ui/InputUtil.java | InputUtil.requireNonEmpty | public static <T extends FocusWidget & HasText> String requireNonEmpty (T widget, String error)
{
String text = widget.getText().trim();
if (text.length() == 0) {
Popups.errorBelow(error, widget);
widget.setFocus(true);
throw new InputException();
}
return text;
} | java | public static <T extends FocusWidget & HasText> String requireNonEmpty (T widget, String error)
{
String text = widget.getText().trim();
if (text.length() == 0) {
Popups.errorBelow(error, widget);
widget.setFocus(true);
throw new InputException();
}
return text;
} | [
"public",
"static",
"<",
"T",
"extends",
"FocusWidget",
"&",
"HasText",
">",
"String",
"requireNonEmpty",
"(",
"T",
"widget",
",",
"String",
"error",
")",
"{",
"String",
"text",
"=",
"widget",
".",
"getText",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",... | Returns a text widget's value, making sure it is non-empty.
@throws InputException if the widget has no text | [
"Returns",
"a",
"text",
"widget",
"s",
"value",
"making",
"sure",
"it",
"is",
"non",
"-",
"empty",
"."
] | train | https://github.com/threerings/gwt-utils/blob/31b31a23b667f2a9c683160d77646db259f2aae5/src/main/java/com/threerings/gwt/ui/InputUtil.java#L23-L32 |
xvik/generics-resolver | src/main/java/ru/vyarus/java/generics/resolver/util/GenericsResolutionUtils.java | GenericsResolutionUtils.resolveDirectRawGenerics | public static LinkedHashMap<String, Type> resolveDirectRawGenerics(final Class<?> type) {
final TypeVariable[] declaredGenerics = type.getTypeParameters();
if (declaredGenerics.length == 0) {
return EmptyGenericsMap.getInstance();
}
final LinkedHashMap<String, Type> res = new LinkedHashMap<String, Type>();
final List<TypeVariable> failed = new ArrayList<TypeVariable>();
// variables in declaration could be dependant and in any direction (e.g. <A extends List<B>, B>)
// so assuming correct order at first, but if we face any error - order vars and resolve correctly
// (it's better to avoid ordering by default as its required quite rarely)
for (TypeVariable variable : declaredGenerics) {
try {
res.put(variable.getName(), resolveRawGeneric(variable, res));
} catch (UnknownGenericException ex) {
// preserve order without resolution
res.put(variable.getName(), null);
failed.add(variable);
}
}
if (!failed.isEmpty()) {
for (TypeVariable variable : GenericsUtils.orderVariablesForResolution(failed)) {
// replacing nulls in map
res.put(variable.getName(), resolveRawGeneric(variable, res));
}
}
return res;
} | java | public static LinkedHashMap<String, Type> resolveDirectRawGenerics(final Class<?> type) {
final TypeVariable[] declaredGenerics = type.getTypeParameters();
if (declaredGenerics.length == 0) {
return EmptyGenericsMap.getInstance();
}
final LinkedHashMap<String, Type> res = new LinkedHashMap<String, Type>();
final List<TypeVariable> failed = new ArrayList<TypeVariable>();
// variables in declaration could be dependant and in any direction (e.g. <A extends List<B>, B>)
// so assuming correct order at first, but if we face any error - order vars and resolve correctly
// (it's better to avoid ordering by default as its required quite rarely)
for (TypeVariable variable : declaredGenerics) {
try {
res.put(variable.getName(), resolveRawGeneric(variable, res));
} catch (UnknownGenericException ex) {
// preserve order without resolution
res.put(variable.getName(), null);
failed.add(variable);
}
}
if (!failed.isEmpty()) {
for (TypeVariable variable : GenericsUtils.orderVariablesForResolution(failed)) {
// replacing nulls in map
res.put(variable.getName(), resolveRawGeneric(variable, res));
}
}
return res;
} | [
"public",
"static",
"LinkedHashMap",
"<",
"String",
",",
"Type",
">",
"resolveDirectRawGenerics",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"final",
"TypeVariable",
"[",
"]",
"declaredGenerics",
"=",
"type",
".",
"getTypeParameters",
"(",
")",
... | Resolve type generics by declaration (as upper bound). Used for cases when actual generic definition is not
available (so actual generics are unknown). In most cases such generics resolved as Object
(for example, {@code Some<T>}).
<p>
IMPORTANT: this method does not count possible outer class generics! Use
{@link #resolveRawGeneric(TypeVariable, LinkedHashMap)} as universal resolution method
@param type class to analyze generics for
@return resolved generics or empty map if not generics used
@see #resolveRawGenerics(Class) to include outer type generics | [
"Resolve",
"type",
"generics",
"by",
"declaration",
"(",
"as",
"upper",
"bound",
")",
".",
"Used",
"for",
"cases",
"when",
"actual",
"generic",
"definition",
"is",
"not",
"available",
"(",
"so",
"actual",
"generics",
"are",
"unknown",
")",
".",
"In",
"most... | train | https://github.com/xvik/generics-resolver/blob/d7d9d2783265df1178230e8f0b7cb6d853b67a7b/src/main/java/ru/vyarus/java/generics/resolver/util/GenericsResolutionUtils.java#L196-L222 |
LAW-Unimi/BUbiNG | src/it/unimi/di/law/bubing/RuntimeConfiguration.java | RuntimeConfiguration.handleIPv4 | private int handleIPv4(final String s) throws ConfigurationException {
try {
if (!RuntimeConfiguration.DOTTED_ADDRESS.matcher(s).matches()) throw new ConfigurationException("Malformed IPv4 " + s + " for blacklisting");
// Note that since we're sure this is a dotted-notation address, we pass directly through InetAddress.
final byte[] address = InetAddress.getByName(s).getAddress();
if (address.length > 4) throw new UnknownHostException("Not IPv4");
return Ints.fromByteArray(address);
} catch (final UnknownHostException e) {
throw new ConfigurationException("Malformed IPv4 " + s + " for blacklisting", e);
}
} | java | private int handleIPv4(final String s) throws ConfigurationException {
try {
if (!RuntimeConfiguration.DOTTED_ADDRESS.matcher(s).matches()) throw new ConfigurationException("Malformed IPv4 " + s + " for blacklisting");
// Note that since we're sure this is a dotted-notation address, we pass directly through InetAddress.
final byte[] address = InetAddress.getByName(s).getAddress();
if (address.length > 4) throw new UnknownHostException("Not IPv4");
return Ints.fromByteArray(address);
} catch (final UnknownHostException e) {
throw new ConfigurationException("Malformed IPv4 " + s + " for blacklisting", e);
}
} | [
"private",
"int",
"handleIPv4",
"(",
"final",
"String",
"s",
")",
"throws",
"ConfigurationException",
"{",
"try",
"{",
"if",
"(",
"!",
"RuntimeConfiguration",
".",
"DOTTED_ADDRESS",
".",
"matcher",
"(",
"s",
")",
".",
"matches",
"(",
")",
")",
"throw",
"ne... | Converts a string specifying an IPv4 address into an integer. The string can be either a single integer (representing
the address) or a dot-separated 4-tuple of bytes.
@param s the string to be converted.
@return the integer representing the IP address specified by s.
@throws ConfigurationException | [
"Converts",
"a",
"string",
"specifying",
"an",
"IPv4",
"address",
"into",
"an",
"integer",
".",
"The",
"string",
"can",
"be",
"either",
"a",
"single",
"integer",
"(",
"representing",
"the",
"address",
")",
"or",
"a",
"dot",
"-",
"separated",
"4",
"-",
"t... | train | https://github.com/LAW-Unimi/BUbiNG/blob/e148acc90031a4f3967422705a9fb07ddaf155e4/src/it/unimi/di/law/bubing/RuntimeConfiguration.java#L302-L312 |
intendia-oss/rxjava-gwt | src/main/modified/io/reactivex/super/io/reactivex/Maybe.java | Maybe.flatMapPublisher | @BackpressureSupport(BackpressureKind.FULL)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Flowable<R> flatMapPublisher(Function<? super T, ? extends Publisher<? extends R>> mapper) {
ObjectHelper.requireNonNull(mapper, "mapper is null");
return RxJavaPlugins.onAssembly(new MaybeFlatMapPublisher<T, R>(this, mapper));
} | java | @BackpressureSupport(BackpressureKind.FULL)
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Flowable<R> flatMapPublisher(Function<? super T, ? extends Publisher<? extends R>> mapper) {
ObjectHelper.requireNonNull(mapper, "mapper is null");
return RxJavaPlugins.onAssembly(new MaybeFlatMapPublisher<T, R>(this, mapper));
} | [
"@",
"BackpressureSupport",
"(",
"BackpressureKind",
".",
"FULL",
")",
"@",
"CheckReturnValue",
"@",
"SchedulerSupport",
"(",
"SchedulerSupport",
".",
"NONE",
")",
"public",
"final",
"<",
"R",
">",
"Flowable",
"<",
"R",
">",
"flatMapPublisher",
"(",
"Function",
... | Returns a Flowable that emits items based on applying a specified function to the item emitted by the
source Maybe, where that function returns a Publisher.
<p>
<img width="640" height="260" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.flatMapPublisher.png" alt="">
<dl>
<dt><b>Backpressure:</b></dt>
<dd>The returned Flowable honors the downstream backpressure.</dd>
<dt><b>Scheduler:</b></dt>
<dd>{@code flatMapPublisher} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param <R> the result value type
@param mapper
a function that, when applied to the item emitted by the source Maybe, returns a
Flowable
@return the Flowable returned from {@code func} when applied to the item emitted by the source Maybe
@see <a href="http://reactivex.io/documentation/operators/flatmap.html">ReactiveX operators documentation: FlatMap</a> | [
"Returns",
"a",
"Flowable",
"that",
"emits",
"items",
"based",
"on",
"applying",
"a",
"specified",
"function",
"to",
"the",
"item",
"emitted",
"by",
"the",
"source",
"Maybe",
"where",
"that",
"function",
"returns",
"a",
"Publisher",
".",
"<p",
">",
"<img",
... | train | https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Maybe.java#L3065-L3071 |
exoplatform/jcr | exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/artifact/CRCGenerator.java | CRCGenerator.getChecksum | public static String getChecksum(InputStream in, String algo) throws NoSuchAlgorithmException,
IOException {
MessageDigest md = MessageDigest.getInstance(algo);
DigestInputStream digestInputStream = new DigestInputStream(in, md);
digestInputStream.on(true);
while (digestInputStream.read() > -1) {
digestInputStream.read();
}
byte[] bytes = digestInputStream.getMessageDigest().digest();
return generateString(bytes);
} | java | public static String getChecksum(InputStream in, String algo) throws NoSuchAlgorithmException,
IOException {
MessageDigest md = MessageDigest.getInstance(algo);
DigestInputStream digestInputStream = new DigestInputStream(in, md);
digestInputStream.on(true);
while (digestInputStream.read() > -1) {
digestInputStream.read();
}
byte[] bytes = digestInputStream.getMessageDigest().digest();
return generateString(bytes);
} | [
"public",
"static",
"String",
"getChecksum",
"(",
"InputStream",
"in",
",",
"String",
"algo",
")",
"throws",
"NoSuchAlgorithmException",
",",
"IOException",
"{",
"MessageDigest",
"md",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"algo",
")",
";",
"DigestInputSt... | Generates checksum for the InputStream.
@param in
stream to generate CheckSum
@param algo
algorithm name according to the
{@literal
<a href= "http://java.sun.com/j2se/1.4.2/docs/guide/security/CryptoSpec.html#AppA">
Java Cryptography Architecture API Specification & Reference
</a>
}
@return hexadecimal string checksun representation
@throws NoSuchAlgorithmException
@throws IOException | [
"Generates",
"checksum",
"for",
"the",
"InputStream",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/artifact/CRCGenerator.java#L52-L66 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/ReturnValueIgnored.java | ReturnValueIgnored.methodReceiverHasType | private static Matcher<ExpressionTree> methodReceiverHasType(final Set<String> typeSet) {
return new Matcher<ExpressionTree>() {
@Override
public boolean matches(ExpressionTree expressionTree, VisitorState state) {
Type receiverType = ASTHelpers.getReceiverType(expressionTree);
return typeSet.contains(receiverType.toString());
}
};
} | java | private static Matcher<ExpressionTree> methodReceiverHasType(final Set<String> typeSet) {
return new Matcher<ExpressionTree>() {
@Override
public boolean matches(ExpressionTree expressionTree, VisitorState state) {
Type receiverType = ASTHelpers.getReceiverType(expressionTree);
return typeSet.contains(receiverType.toString());
}
};
} | [
"private",
"static",
"Matcher",
"<",
"ExpressionTree",
">",
"methodReceiverHasType",
"(",
"final",
"Set",
"<",
"String",
">",
"typeSet",
")",
"{",
"return",
"new",
"Matcher",
"<",
"ExpressionTree",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"m... | Matches method calls whose receiver objects are of a type included in the set. | [
"Matches",
"method",
"calls",
"whose",
"receiver",
"objects",
"are",
"of",
"a",
"type",
"included",
"in",
"the",
"set",
"."
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/ReturnValueIgnored.java#L174-L182 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java | JBBPDslBuilder.BoolArray | public JBBPDslBuilder BoolArray(final String name, final String sizeExpression) {
final Item item = new Item(BinType.BOOL_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | java | public JBBPDslBuilder BoolArray(final String name, final String sizeExpression) {
final Item item = new Item(BinType.BOOL_ARRAY, name, this.byteOrder);
item.sizeExpression = assertExpressionChars(sizeExpression);
this.addItem(item);
return this;
} | [
"public",
"JBBPDslBuilder",
"BoolArray",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"sizeExpression",
")",
"{",
"final",
"Item",
"item",
"=",
"new",
"Item",
"(",
"BinType",
".",
"BOOL_ARRAY",
",",
"name",
",",
"this",
".",
"byteOrder",
")",
";... | Add named boolean array which length calculated through expression.
@param name name of the array, it can be null for anonymous one
@param sizeExpression expression to calculate number of elements, must not be null
@return the builder instance, must not be null | [
"Add",
"named",
"boolean",
"array",
"which",
"length",
"calculated",
"through",
"expression",
"."
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java#L784-L789 |
Bandwidth/java-bandwidth | src/main/java/com/bandwidth/sdk/model/Call.java | Call.getRecordings | public List<Recording> getRecordings() throws Exception {
final String recordingsPath = StringUtils.join(new String[]{
getUri(),
"recordings"
}, '/');
final JSONArray array = toJSONArray(client.get(recordingsPath, null));
final List<Recording> list = new ArrayList<Recording>();
for (final Object object : array) {
list.add(new Recording(client, recordingsPath, (JSONObject) object));
}
return list;
} | java | public List<Recording> getRecordings() throws Exception {
final String recordingsPath = StringUtils.join(new String[]{
getUri(),
"recordings"
}, '/');
final JSONArray array = toJSONArray(client.get(recordingsPath, null));
final List<Recording> list = new ArrayList<Recording>();
for (final Object object : array) {
list.add(new Recording(client, recordingsPath, (JSONObject) object));
}
return list;
} | [
"public",
"List",
"<",
"Recording",
">",
"getRecordings",
"(",
")",
"throws",
"Exception",
"{",
"final",
"String",
"recordingsPath",
"=",
"StringUtils",
".",
"join",
"(",
"new",
"String",
"[",
"]",
"{",
"getUri",
"(",
")",
",",
"\"recordings\"",
"}",
",",
... | Retrieve all recordings related to the call.
@return recordings the recordings
@throws IOException unexpected error. | [
"Retrieve",
"all",
"recordings",
"related",
"to",
"the",
"call",
"."
] | train | https://github.com/Bandwidth/java-bandwidth/blob/2124c85148ad6a54d2f2949cb952eb3985830e2a/src/main/java/com/bandwidth/sdk/model/Call.java#L304-L316 |
codegist/crest | core/src/main/java/org/codegist/crest/util/Pairs.java | Pairs.toPair | public static EncodedPair toPair(String nameToEncode, String valueToEncode, Charset charset) throws UnsupportedEncodingException {
return toPair(nameToEncode, valueToEncode, charset, false);
} | java | public static EncodedPair toPair(String nameToEncode, String valueToEncode, Charset charset) throws UnsupportedEncodingException {
return toPair(nameToEncode, valueToEncode, charset, false);
} | [
"public",
"static",
"EncodedPair",
"toPair",
"(",
"String",
"nameToEncode",
",",
"String",
"valueToEncode",
",",
"Charset",
"charset",
")",
"throws",
"UnsupportedEncodingException",
"{",
"return",
"toPair",
"(",
"nameToEncode",
",",
"valueToEncode",
",",
"charset",
... | Returns a EncodedPair with the given name/value considered as not encoded
@param nameToEncode name to encode
@param valueToEncode value to encode
@param charset charset to use while encoding the name/value
@return the encoded pair object
@throws UnsupportedEncodingException When the given charset is not supported | [
"Returns",
"a",
"EncodedPair",
"with",
"the",
"given",
"name",
"/",
"value",
"considered",
"as",
"not",
"encoded"
] | train | https://github.com/codegist/crest/blob/e99ba7728b27d2ddb2c247261350f1b6fa7a6698/core/src/main/java/org/codegist/crest/util/Pairs.java#L67-L69 |
ocelotds/ocelot | ocelot-processor/src/main/java/org/ocelotds/frameworks/angularjs/FunctionWriter.java | FunctionWriter.writeOpenFunctionWithDependencies | public void writeOpenFunctionWithDependencies(Writer writer, String object, String... dependencies) throws IOException {
writer.append(TAB).append("/* @ngInject */").append(CR);
writer.append(TAB).append(FUNCTION).append(SPACE).append(object).append(OPENPARENTHESIS);
writeDependencies(writer, "", dependencies);
writer.append(CLOSEPARENTHESIS).append(SPACEOPTIONAL).append(OPENBRACE).append(CR); //\tfunction config(dep1, dep2) {\n
} | java | public void writeOpenFunctionWithDependencies(Writer writer, String object, String... dependencies) throws IOException {
writer.append(TAB).append("/* @ngInject */").append(CR);
writer.append(TAB).append(FUNCTION).append(SPACE).append(object).append(OPENPARENTHESIS);
writeDependencies(writer, "", dependencies);
writer.append(CLOSEPARENTHESIS).append(SPACEOPTIONAL).append(OPENBRACE).append(CR); //\tfunction config(dep1, dep2) {\n
} | [
"public",
"void",
"writeOpenFunctionWithDependencies",
"(",
"Writer",
"writer",
",",
"String",
"object",
",",
"String",
"...",
"dependencies",
")",
"throws",
"IOException",
"{",
"writer",
".",
"append",
"(",
"TAB",
")",
".",
"append",
"(",
"\"/* @ngInject */\"",
... | \tfunction object(dep1, dep2) {\n
@param writer
@param object
@param dependencies
@throws IOException | [
"\\",
"tfunction",
"object",
"(",
"dep1",
"dep2",
")",
"{",
"\\",
"n"
] | train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-processor/src/main/java/org/ocelotds/frameworks/angularjs/FunctionWriter.java#L58-L64 |
micronaut-projects/micronaut-core | inject/src/main/java/io/micronaut/context/AbstractBeanDefinition.java | AbstractBeanDefinition.getBeansOfTypeForConstructorArgument | @SuppressWarnings("WeakerAccess")
@Internal
protected final Collection getBeansOfTypeForConstructorArgument(BeanResolutionContext resolutionContext, BeanContext context, @SuppressWarnings("unused") ConstructorInjectionPoint<T> constructorInjectionPoint, Argument argument) {
return resolveBeanWithGenericsFromConstructorArgument(resolutionContext, argument, (beanType, qualifier) -> {
boolean hasNoGenerics = !argument.getType().isArray() && argument.getTypeVariables().isEmpty();
if (hasNoGenerics) {
return ((DefaultBeanContext) context).getBean(resolutionContext, beanType, qualifier);
} else {
return ((DefaultBeanContext) context).getBeansOfType(resolutionContext, beanType, qualifier);
}
}
);
} | java | @SuppressWarnings("WeakerAccess")
@Internal
protected final Collection getBeansOfTypeForConstructorArgument(BeanResolutionContext resolutionContext, BeanContext context, @SuppressWarnings("unused") ConstructorInjectionPoint<T> constructorInjectionPoint, Argument argument) {
return resolveBeanWithGenericsFromConstructorArgument(resolutionContext, argument, (beanType, qualifier) -> {
boolean hasNoGenerics = !argument.getType().isArray() && argument.getTypeVariables().isEmpty();
if (hasNoGenerics) {
return ((DefaultBeanContext) context).getBean(resolutionContext, beanType, qualifier);
} else {
return ((DefaultBeanContext) context).getBeansOfType(resolutionContext, beanType, qualifier);
}
}
);
} | [
"@",
"SuppressWarnings",
"(",
"\"WeakerAccess\"",
")",
"@",
"Internal",
"protected",
"final",
"Collection",
"getBeansOfTypeForConstructorArgument",
"(",
"BeanResolutionContext",
"resolutionContext",
",",
"BeanContext",
"context",
",",
"@",
"SuppressWarnings",
"(",
"\"unused... | Obtains all bean definitions for a constructor argument at the given index
<p>
Warning: this method is used by internal generated code and should not be called by user code.
@param resolutionContext The resolution context
@param context The context
@param constructorInjectionPoint The constructor injection point
@param argument The argument
@return The resolved bean | [
"Obtains",
"all",
"bean",
"definitions",
"for",
"a",
"constructor",
"argument",
"at",
"the",
"given",
"index",
"<p",
">",
"Warning",
":",
"this",
"method",
"is",
"used",
"by",
"internal",
"generated",
"code",
"and",
"should",
"not",
"be",
"called",
"by",
"... | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/inject/src/main/java/io/micronaut/context/AbstractBeanDefinition.java#L1080-L1092 |
tvesalainen/util | util/src/main/java/org/vesalainen/nio/file/attribute/UserAttrs.java | UserAttrs.getLongAttribute | public static final long getLongAttribute(Path path, String attribute, LinkOption... options) throws IOException
{
return getLongAttribute(path, attribute, -1, options);
} | java | public static final long getLongAttribute(Path path, String attribute, LinkOption... options) throws IOException
{
return getLongAttribute(path, attribute, -1, options);
} | [
"public",
"static",
"final",
"long",
"getLongAttribute",
"(",
"Path",
"path",
",",
"String",
"attribute",
",",
"LinkOption",
"...",
"options",
")",
"throws",
"IOException",
"{",
"return",
"getLongAttribute",
"(",
"path",
",",
"attribute",
",",
"-",
"1",
",",
... | Returns user-defined-attribute -1 if not found.
@param path
@param attribute
@param options
@return
@throws IOException | [
"Returns",
"user",
"-",
"defined",
"-",
"attribute",
"-",
"1",
"if",
"not",
"found",
"."
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/nio/file/attribute/UserAttrs.java#L195-L198 |
amzn/ion-java | src/com/amazon/ion/impl/_Private_ScalarConversions.java | _Private_ScalarConversions.getConversionFnid | protected final static int getConversionFnid(int authoritative_type, int new_type) {
if (new_type == authoritative_type) return 0;
switch (new_type) {
case AS_TYPE.null_value:
assert( authoritative_type == AS_TYPE.string_value );
return from_string_conversion[AS_TYPE.null_value];
case AS_TYPE.boolean_value:
assert( authoritative_type == AS_TYPE.string_value );
return from_string_conversion[AS_TYPE.boolean_value];
case AS_TYPE.int_value:
return to_int_conversion[authoritative_type];
case AS_TYPE.long_value:
return to_long_conversion[authoritative_type];
case AS_TYPE.bigInteger_value:
return to_bigInteger_conversion[authoritative_type];
case AS_TYPE.decimal_value:
return to_decimal_conversion[authoritative_type];
case AS_TYPE.double_value:
return to_double_conversion[authoritative_type];
case AS_TYPE.string_value:
return to_string_conversions[authoritative_type];
case AS_TYPE.date_value:
assert( authoritative_type == AS_TYPE.timestamp_value );
return FNID_FROM_TIMESTAMP_TO_DATE;
case AS_TYPE.timestamp_value:
assert( authoritative_type == AS_TYPE.date_value );
return FNID_FROM_DATE_TO_TIMESTAMP;
}
String message = "can't convert from "
+ getValueTypeName(authoritative_type)
+ " to "
+ getValueTypeName(new_type);
throw new CantConvertException(message);
} | java | protected final static int getConversionFnid(int authoritative_type, int new_type) {
if (new_type == authoritative_type) return 0;
switch (new_type) {
case AS_TYPE.null_value:
assert( authoritative_type == AS_TYPE.string_value );
return from_string_conversion[AS_TYPE.null_value];
case AS_TYPE.boolean_value:
assert( authoritative_type == AS_TYPE.string_value );
return from_string_conversion[AS_TYPE.boolean_value];
case AS_TYPE.int_value:
return to_int_conversion[authoritative_type];
case AS_TYPE.long_value:
return to_long_conversion[authoritative_type];
case AS_TYPE.bigInteger_value:
return to_bigInteger_conversion[authoritative_type];
case AS_TYPE.decimal_value:
return to_decimal_conversion[authoritative_type];
case AS_TYPE.double_value:
return to_double_conversion[authoritative_type];
case AS_TYPE.string_value:
return to_string_conversions[authoritative_type];
case AS_TYPE.date_value:
assert( authoritative_type == AS_TYPE.timestamp_value );
return FNID_FROM_TIMESTAMP_TO_DATE;
case AS_TYPE.timestamp_value:
assert( authoritative_type == AS_TYPE.date_value );
return FNID_FROM_DATE_TO_TIMESTAMP;
}
String message = "can't convert from "
+ getValueTypeName(authoritative_type)
+ " to "
+ getValueTypeName(new_type);
throw new CantConvertException(message);
} | [
"protected",
"final",
"static",
"int",
"getConversionFnid",
"(",
"int",
"authoritative_type",
",",
"int",
"new_type",
")",
"{",
"if",
"(",
"new_type",
"==",
"authoritative_type",
")",
"return",
"0",
";",
"switch",
"(",
"new_type",
")",
"{",
"case",
"AS_TYPE",
... | from a values authoritative type (the type of the original data
for the value) and the desired type this returns the conversion
functions id, or throws a CantConvertException in the event the
authoritative type cannot be cast to the desired type.
@param authoritative_type
@param new_type
@return id of the conversion function required | [
"from",
"a",
"values",
"authoritative",
"type",
"(",
"the",
"type",
"of",
"the",
"original",
"data",
"for",
"the",
"value",
")",
"and",
"the",
"desired",
"type",
"this",
"returns",
"the",
"conversion",
"functions",
"id",
"or",
"throws",
"a",
"CantConvertExce... | train | https://github.com/amzn/ion-java/blob/4ce1f0f58c6a5a8e42d0425ccdb36e38be3e2270/src/com/amazon/ion/impl/_Private_ScalarConversions.java#L301-L334 |
trellis-ldp/trellis | components/webdav/src/main/java/org/trellisldp/webdav/impl/WebDAVUtils.java | WebDAVUtils.recursiveCopy | public static CompletionStage<Void> recursiveCopy(final ServiceBundler services, final Session session,
final Resource resource, final IRI destination, final String baseUrl) {
final List<IRI> resources = resource.stream(LDP.PreferContainment).map(Quad::getObject)
.filter(IRI.class::isInstance).map(IRI.class::cast).collect(toList());
resources.stream().parallel().map(id -> recursiveCopy(services, session, id,
mapDestination(id, resource.getIdentifier(), destination), baseUrl))
.map(CompletionStage::toCompletableFuture).forEach(CompletableFuture::join);
return copy(services, session, resource, destination, baseUrl);
} | java | public static CompletionStage<Void> recursiveCopy(final ServiceBundler services, final Session session,
final Resource resource, final IRI destination, final String baseUrl) {
final List<IRI> resources = resource.stream(LDP.PreferContainment).map(Quad::getObject)
.filter(IRI.class::isInstance).map(IRI.class::cast).collect(toList());
resources.stream().parallel().map(id -> recursiveCopy(services, session, id,
mapDestination(id, resource.getIdentifier(), destination), baseUrl))
.map(CompletionStage::toCompletableFuture).forEach(CompletableFuture::join);
return copy(services, session, resource, destination, baseUrl);
} | [
"public",
"static",
"CompletionStage",
"<",
"Void",
">",
"recursiveCopy",
"(",
"final",
"ServiceBundler",
"services",
",",
"final",
"Session",
"session",
",",
"final",
"Resource",
"resource",
",",
"final",
"IRI",
"destination",
",",
"final",
"String",
"baseUrl",
... | Recursively copy the resources under the provided identifier.
@param services the trellis service
@param session the session
@param resource the resource
@param destination the destination identifier
@param baseUrl the baseURL
@return the next stage of completion | [
"Recursively",
"copy",
"the",
"resources",
"under",
"the",
"provided",
"identifier",
"."
] | train | https://github.com/trellis-ldp/trellis/blob/789fd7a3df86cab7ebba63e72bf4e58397e5f42d/components/webdav/src/main/java/org/trellisldp/webdav/impl/WebDAVUtils.java#L110-L118 |
xwiki/xwiki-commons | xwiki-commons-core/xwiki-commons-crypto/xwiki-commons-crypto-pkix/src/main/java/org/xwiki/crypto/pkix/internal/BcUtils.java | BcUtils.getX509CertificateHolder | public static X509CertificateHolder getX509CertificateHolder(CertifiedPublicKey cert)
{
if (cert instanceof BcX509CertifiedPublicKey) {
return ((BcX509CertifiedPublicKey) cert).getX509CertificateHolder();
} else {
try {
return new X509CertificateHolder(cert.getEncoded());
} catch (IOException e) {
// Very unlikely
throw new IllegalArgumentException("Invalid certified public key, unable to encode.");
}
}
} | java | public static X509CertificateHolder getX509CertificateHolder(CertifiedPublicKey cert)
{
if (cert instanceof BcX509CertifiedPublicKey) {
return ((BcX509CertifiedPublicKey) cert).getX509CertificateHolder();
} else {
try {
return new X509CertificateHolder(cert.getEncoded());
} catch (IOException e) {
// Very unlikely
throw new IllegalArgumentException("Invalid certified public key, unable to encode.");
}
}
} | [
"public",
"static",
"X509CertificateHolder",
"getX509CertificateHolder",
"(",
"CertifiedPublicKey",
"cert",
")",
"{",
"if",
"(",
"cert",
"instanceof",
"BcX509CertifiedPublicKey",
")",
"{",
"return",
"(",
"(",
"BcX509CertifiedPublicKey",
")",
"cert",
")",
".",
"getX509... | Convert certified public key to certificate holder.
@param cert the certified public key.
@return a certificate holder. | [
"Convert",
"certified",
"public",
"key",
"to",
"certificate",
"holder",
"."
] | train | https://github.com/xwiki/xwiki-commons/blob/5374d8c6d966588c1eac7392c83da610dfb9f129/xwiki-commons-core/xwiki-commons-crypto/xwiki-commons-crypto-pkix/src/main/java/org/xwiki/crypto/pkix/internal/BcUtils.java#L68-L81 |
sarl/sarl | main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/appenders/SarlActionSourceAppender.java | SarlActionSourceAppender.eInit | public void eInit(XtendTypeDeclaration container, String name, String modifier, IJvmTypeProvider context) {
this.builder.eInit(container, name, modifier, context);
} | java | public void eInit(XtendTypeDeclaration container, String name, String modifier, IJvmTypeProvider context) {
this.builder.eInit(container, name, modifier, context);
} | [
"public",
"void",
"eInit",
"(",
"XtendTypeDeclaration",
"container",
",",
"String",
"name",
",",
"String",
"modifier",
",",
"IJvmTypeProvider",
"context",
")",
"{",
"this",
".",
"builder",
".",
"eInit",
"(",
"container",
",",
"name",
",",
"modifier",
",",
"c... | Initialize the Ecore element.
@param container the container of the SarlAction.
@param name the name of the SarlAction. | [
"Initialize",
"the",
"Ecore",
"element",
"."
] | train | https://github.com/sarl/sarl/blob/ca00ff994598c730339972def4e19a60e0b8cace/main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/codebuilder/appenders/SarlActionSourceAppender.java#L86-L88 |
wellner/jcarafe | jcarafe-core/src/main/java/cern/colt/map/AbstractLongObjectMap.java | AbstractLongObjectMap.pairsMatching | public void pairsMatching(final LongObjectProcedure condition, final LongArrayList keyList, final ObjectArrayList valueList) {
keyList.clear();
valueList.clear();
forEachPair(
new LongObjectProcedure() {
public boolean apply(long key, Object value) {
if (condition.apply(key,value)) {
keyList.add(key);
valueList.add(value);
}
return true;
}
}
);
} | java | public void pairsMatching(final LongObjectProcedure condition, final LongArrayList keyList, final ObjectArrayList valueList) {
keyList.clear();
valueList.clear();
forEachPair(
new LongObjectProcedure() {
public boolean apply(long key, Object value) {
if (condition.apply(key,value)) {
keyList.add(key);
valueList.add(value);
}
return true;
}
}
);
} | [
"public",
"void",
"pairsMatching",
"(",
"final",
"LongObjectProcedure",
"condition",
",",
"final",
"LongArrayList",
"keyList",
",",
"final",
"ObjectArrayList",
"valueList",
")",
"{",
"keyList",
".",
"clear",
"(",
")",
";",
"valueList",
".",
"clear",
"(",
")",
... | Fills all pairs satisfying a given condition into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists both have a new size, the number of pairs satisfying the condition.
Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(LongProcedure)}.
<p>
<b>Example:</b>
<br>
<pre>
LongObjectProcedure condition = new LongObjectProcedure() { // match even keys only
public boolean apply(long key, Object value) { return key%2==0; }
}
keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
</pre>
@param condition the condition to be matched. Takes the current key as first and the current value as second argument.
@param keyList the list to be filled with keys, can have any size.
@param valueList the list to be filled with values, can have any size. | [
"Fills",
"all",
"pairs",
"satisfying",
"a",
"given",
"condition",
"into",
"the",
"specified",
"lists",
".",
"Fills",
"into",
"the",
"lists",
"starting",
"at",
"index",
"0",
".",
"After",
"this",
"call",
"returns",
"the",
"specified",
"lists",
"both",
"have",... | train | https://github.com/wellner/jcarafe/blob/ab8b0a83dbf600fe80c27711815c90bd3055b217/jcarafe-core/src/main/java/cern/colt/map/AbstractLongObjectMap.java#L254-L269 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java | DatabasesInner.beginExport | public ImportExportResponseInner beginExport(String resourceGroupName, String serverName, String databaseName, ExportRequest parameters) {
return beginExportWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).toBlocking().single().body();
} | java | public ImportExportResponseInner beginExport(String resourceGroupName, String serverName, String databaseName, ExportRequest parameters) {
return beginExportWithServiceResponseAsync(resourceGroupName, serverName, databaseName, parameters).toBlocking().single().body();
} | [
"public",
"ImportExportResponseInner",
"beginExport",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"ExportRequest",
"parameters",
")",
"{",
"return",
"beginExportWithServiceResponseAsync",
"(",
"resourceGroupName",
","... | Exports a database to a bacpac.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@param databaseName The name of the database to be exported.
@param parameters The required parameters for exporting a database.
@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 ImportExportResponseInner object if successful. | [
"Exports",
"a",
"database",
"to",
"a",
"bacpac",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/DatabasesInner.java#L2182-L2184 |
OpenLiberty/open-liberty | dev/com.ibm.ws.config/src/com/ibm/ws/config/xml/internal/ConfigEvaluator.java | ConfigEvaluator.getUnconfiguredAttributeValue | private Object getUnconfiguredAttributeValue(EvaluationContext context, ExtendedAttributeDefinition attributeDef) throws ConfigEvaluatorException {
Object rawValue = null;
// no value in config then try ibm:variable if set
rawValue = variableEvaluator.lookupVariableExtension(context, attributeDef);
// no value in config, no ibm:variable, try defaults
if (rawValue == null) {
String[] defaultValues = attributeDef.getDefaultValue();
if (defaultValues != null) {
rawValue = Arrays.asList(defaultValues);
}
}
return rawValue;
} | java | private Object getUnconfiguredAttributeValue(EvaluationContext context, ExtendedAttributeDefinition attributeDef) throws ConfigEvaluatorException {
Object rawValue = null;
// no value in config then try ibm:variable if set
rawValue = variableEvaluator.lookupVariableExtension(context, attributeDef);
// no value in config, no ibm:variable, try defaults
if (rawValue == null) {
String[] defaultValues = attributeDef.getDefaultValue();
if (defaultValues != null) {
rawValue = Arrays.asList(defaultValues);
}
}
return rawValue;
} | [
"private",
"Object",
"getUnconfiguredAttributeValue",
"(",
"EvaluationContext",
"context",
",",
"ExtendedAttributeDefinition",
"attributeDef",
")",
"throws",
"ConfigEvaluatorException",
"{",
"Object",
"rawValue",
"=",
"null",
";",
"// no value in config then try ibm:variable if s... | Try to determine a value from variable or defaults for the AD.
@param attributeDef
@param context
@return
@throws ConfigEvaluatorException | [
"Try",
"to",
"determine",
"a",
"value",
"from",
"variable",
"or",
"defaults",
"for",
"the",
"AD",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.config/src/com/ibm/ws/config/xml/internal/ConfigEvaluator.java#L700-L717 |
sdl/odata | odata_renderer/src/main/java/com/sdl/odata/renderer/json/writer/JsonWriter.java | JsonWriter.writeEntry | public String writeEntry(Object entity, String contextUrl) throws ODataRenderException {
this.contextURL = checkNotNull(contextUrl);
try {
return writeJson(entity, null);
} catch (IOException | IllegalAccessException | NoSuchFieldException |
ODataEdmException | ODataRenderException e) {
LOG.error("Not possible to marshall single entity stream JSON");
throw new ODataRenderException("Not possible to marshall single entity stream JSON: ", e);
}
} | java | public String writeEntry(Object entity, String contextUrl) throws ODataRenderException {
this.contextURL = checkNotNull(contextUrl);
try {
return writeJson(entity, null);
} catch (IOException | IllegalAccessException | NoSuchFieldException |
ODataEdmException | ODataRenderException e) {
LOG.error("Not possible to marshall single entity stream JSON");
throw new ODataRenderException("Not possible to marshall single entity stream JSON: ", e);
}
} | [
"public",
"String",
"writeEntry",
"(",
"Object",
"entity",
",",
"String",
"contextUrl",
")",
"throws",
"ODataRenderException",
"{",
"this",
".",
"contextURL",
"=",
"checkNotNull",
"(",
"contextUrl",
")",
";",
"try",
"{",
"return",
"writeJson",
"(",
"entity",
"... | Write a single entity (entry) to the JSON stream.
@param entity The entity to fill in the JSON stream. It can not be {@code null}.
@param contextUrl The 'Context URL' to write. It can not be {@code null}.
@return the rendered entry
@throws ODataRenderException In case it is not possible to write to the JSON stream. | [
"Write",
"a",
"single",
"entity",
"(",
"entry",
")",
"to",
"the",
"JSON",
"stream",
"."
] | train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_renderer/src/main/java/com/sdl/odata/renderer/json/writer/JsonWriter.java#L125-L136 |
Whiley/WhileyCompiler | src/main/java/wyil/check/FlowTypeUtils.java | FlowTypeUtils.declareThisWithin | public static Environment declareThisWithin(Decl.FunctionOrMethod decl, Environment environment) {
if (decl instanceof Decl.Method) {
Decl.Method method = (Decl.Method) decl;
environment = environment.declareWithin("this", method.getLifetimes());
}
return environment;
} | java | public static Environment declareThisWithin(Decl.FunctionOrMethod decl, Environment environment) {
if (decl instanceof Decl.Method) {
Decl.Method method = (Decl.Method) decl;
environment = environment.declareWithin("this", method.getLifetimes());
}
return environment;
} | [
"public",
"static",
"Environment",
"declareThisWithin",
"(",
"Decl",
".",
"FunctionOrMethod",
"decl",
",",
"Environment",
"environment",
")",
"{",
"if",
"(",
"decl",
"instanceof",
"Decl",
".",
"Method",
")",
"{",
"Decl",
".",
"Method",
"method",
"=",
"(",
"D... | Update the environment to reflect the fact that the special "this" lifetime
is contained within all declared lifetime parameters. Observe that this only
makes sense if the enclosing declaration is for a method.
@param decl
@param environment
@return | [
"Update",
"the",
"environment",
"to",
"reflect",
"the",
"fact",
"that",
"the",
"special",
"this",
"lifetime",
"is",
"contained",
"within",
"all",
"declared",
"lifetime",
"parameters",
".",
"Observe",
"that",
"this",
"only",
"makes",
"sense",
"if",
"the",
"encl... | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyil/check/FlowTypeUtils.java#L70-L76 |
exoplatform/jcr | exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java | ValueConstraintsMatcher.parsePathMatcher | protected JCRPathMatcher parsePathMatcher(LocationFactory locFactory, String path) throws RepositoryException
{
JCRPath knownPath = null;
boolean forDescendants = false;
boolean forAncestors = false;
if (path.equals("*") || path.equals(".*"))
{
// any
forDescendants = true;
forAncestors = true;
}
else if (path.endsWith("*") && path.startsWith("*"))
{
forDescendants = true;
forAncestors = true;
knownPath = parsePath(path.substring(1, path.length() - 1), locFactory);
}
else if (path.endsWith("*"))
{
forDescendants = true;
knownPath = parsePath(path.substring(0, path.length() - 1), locFactory);
}
else if (path.startsWith("*"))
{
forAncestors = true;
knownPath = parsePath(path.substring(1), locFactory);
}
else
{
knownPath = parsePath(path, locFactory);
}
return new JCRPathMatcher(knownPath == null ? null : knownPath.getInternalPath(), forDescendants, forAncestors);
} | java | protected JCRPathMatcher parsePathMatcher(LocationFactory locFactory, String path) throws RepositoryException
{
JCRPath knownPath = null;
boolean forDescendants = false;
boolean forAncestors = false;
if (path.equals("*") || path.equals(".*"))
{
// any
forDescendants = true;
forAncestors = true;
}
else if (path.endsWith("*") && path.startsWith("*"))
{
forDescendants = true;
forAncestors = true;
knownPath = parsePath(path.substring(1, path.length() - 1), locFactory);
}
else if (path.endsWith("*"))
{
forDescendants = true;
knownPath = parsePath(path.substring(0, path.length() - 1), locFactory);
}
else if (path.startsWith("*"))
{
forAncestors = true;
knownPath = parsePath(path.substring(1), locFactory);
}
else
{
knownPath = parsePath(path, locFactory);
}
return new JCRPathMatcher(knownPath == null ? null : knownPath.getInternalPath(), forDescendants, forAncestors);
} | [
"protected",
"JCRPathMatcher",
"parsePathMatcher",
"(",
"LocationFactory",
"locFactory",
",",
"String",
"path",
")",
"throws",
"RepositoryException",
"{",
"JCRPath",
"knownPath",
"=",
"null",
";",
"boolean",
"forDescendants",
"=",
"false",
";",
"boolean",
"forAncestor... | Parses JCR path matcher from string.
@param path
@return
@throws RepositoryException | [
"Parses",
"JCR",
"path",
"matcher",
"from",
"string",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java#L405-L440 |
JavaMoney/jsr354-ri-bp | src/main/java/org/javamoney/moneta/spi/base/BaseExchangeRateProvider.java | BaseExchangeRateProvider.getExchangeRate | public ExchangeRate getExchangeRate(String baseCode, String termCode){
return getExchangeRate(Monetary.getCurrency(baseCode), Monetary.getCurrency(termCode));
} | java | public ExchangeRate getExchangeRate(String baseCode, String termCode){
return getExchangeRate(Monetary.getCurrency(baseCode), Monetary.getCurrency(termCode));
} | [
"public",
"ExchangeRate",
"getExchangeRate",
"(",
"String",
"baseCode",
",",
"String",
"termCode",
")",
"{",
"return",
"getExchangeRate",
"(",
"Monetary",
".",
"getCurrency",
"(",
"baseCode",
")",
",",
"Monetary",
".",
"getCurrency",
"(",
"termCode",
")",
")",
... | Access a {@link javax.money.convert.ExchangeRate} using the given currencies. The
{@link javax.money.convert.ExchangeRate} may be, depending on the data provider, eal-time or
deferred. This method should return the rate that is <i>currently</i>
valid.
@param baseCode base currency code, not {@code null}
@param termCode term/target currency code, not {@code null}
@return the matching {@link javax.money.convert.ExchangeRate}.
@throws javax.money.convert.CurrencyConversionException If no such rate is available.
@throws javax.money.MonetaryException if one of the currency codes passed is not valid. | [
"Access",
"a",
"{",
"@link",
"javax",
".",
"money",
".",
"convert",
".",
"ExchangeRate",
"}",
"using",
"the",
"given",
"currencies",
".",
"The",
"{",
"@link",
"javax",
".",
"money",
".",
"convert",
".",
"ExchangeRate",
"}",
"may",
"be",
"depending",
"on"... | train | https://github.com/JavaMoney/jsr354-ri-bp/blob/9c147ef5623d8032a6dc4c0e5eefdfb41641a9a2/src/main/java/org/javamoney/moneta/spi/base/BaseExchangeRateProvider.java#L139-L141 |
ist-dresden/composum | sling/core/commons/src/main/java/com/composum/sling/core/util/LinkUtil.java | LinkUtil.getAbsoluteUrl | public static String getAbsoluteUrl(SlingHttpServletRequest request, String url) {
if (!isExternalUrl(url) && url.startsWith("/")) {
String scheme = request.getScheme().toLowerCase();
url = scheme + "://" + getAuthority(request) + url;
}
return url;
} | java | public static String getAbsoluteUrl(SlingHttpServletRequest request, String url) {
if (!isExternalUrl(url) && url.startsWith("/")) {
String scheme = request.getScheme().toLowerCase();
url = scheme + "://" + getAuthority(request) + url;
}
return url;
} | [
"public",
"static",
"String",
"getAbsoluteUrl",
"(",
"SlingHttpServletRequest",
"request",
",",
"String",
"url",
")",
"{",
"if",
"(",
"!",
"isExternalUrl",
"(",
"url",
")",
"&&",
"url",
".",
"startsWith",
"(",
"\"/\"",
")",
")",
"{",
"String",
"scheme",
"=... | Makes a URL already built external; the url should be built by the 'getUrl' method.
@param request the request as the externalization context
@param url the url value (the local URL)
@return | [
"Makes",
"a",
"URL",
"already",
"built",
"external",
";",
"the",
"url",
"should",
"be",
"built",
"by",
"the",
"getUrl",
"method",
"."
] | train | https://github.com/ist-dresden/composum/blob/ebc79f559f6022c935240c19102539bdfb1bd1e2/sling/core/commons/src/main/java/com/composum/sling/core/util/LinkUtil.java#L182-L188 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/field/BaseField.java | BaseField.getFieldName | public String getFieldName(boolean bAddQuotes, boolean bIncludeFileName)
{
if (!bAddQuotes) if (!bIncludeFileName)
return super.getFieldName(bAddQuotes, bIncludeFileName); // Return m_sFieldName
String strFieldName = Constants.BLANK;
if (bIncludeFileName)
if (this.getRecord() != null)
{
strFieldName = this.getRecord().getTableNames(bAddQuotes);
if (strFieldName.length() != 0)
strFieldName += ".";
}
strFieldName += Record.formatTableNames(m_strFieldName, bAddQuotes);
return strFieldName;
} | java | public String getFieldName(boolean bAddQuotes, boolean bIncludeFileName)
{
if (!bAddQuotes) if (!bIncludeFileName)
return super.getFieldName(bAddQuotes, bIncludeFileName); // Return m_sFieldName
String strFieldName = Constants.BLANK;
if (bIncludeFileName)
if (this.getRecord() != null)
{
strFieldName = this.getRecord().getTableNames(bAddQuotes);
if (strFieldName.length() != 0)
strFieldName += ".";
}
strFieldName += Record.formatTableNames(m_strFieldName, bAddQuotes);
return strFieldName;
} | [
"public",
"String",
"getFieldName",
"(",
"boolean",
"bAddQuotes",
",",
"boolean",
"bIncludeFileName",
")",
"{",
"if",
"(",
"!",
"bAddQuotes",
")",
"if",
"(",
"!",
"bIncludeFileName",
")",
"return",
"super",
".",
"getFieldName",
"(",
"bAddQuotes",
",",
"bInclud... | Get this field's name.
@param bAddQuotes Add quotes if this field contains a space.
@param bIncludeFileName include the file name as file.field.
@return The field name. | [
"Get",
"this",
"field",
"s",
"name",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/BaseField.java#L658-L672 |
Azure/azure-sdk-for-java | labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GalleryImagesInner.java | GalleryImagesInner.createOrUpdateAsync | public Observable<GalleryImageInner> createOrUpdateAsync(String resourceGroupName, String labAccountName, String galleryImageName, GalleryImageInner galleryImage) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, labAccountName, galleryImageName, galleryImage).map(new Func1<ServiceResponse<GalleryImageInner>, GalleryImageInner>() {
@Override
public GalleryImageInner call(ServiceResponse<GalleryImageInner> response) {
return response.body();
}
});
} | java | public Observable<GalleryImageInner> createOrUpdateAsync(String resourceGroupName, String labAccountName, String galleryImageName, GalleryImageInner galleryImage) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, labAccountName, galleryImageName, galleryImage).map(new Func1<ServiceResponse<GalleryImageInner>, GalleryImageInner>() {
@Override
public GalleryImageInner call(ServiceResponse<GalleryImageInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"GalleryImageInner",
">",
"createOrUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"labAccountName",
",",
"String",
"galleryImageName",
",",
"GalleryImageInner",
"galleryImage",
")",
"{",
"return",
"createOrUpdateWithServiceResp... | Create or replace an existing Gallery Image.
@param resourceGroupName The name of the resource group.
@param labAccountName The name of the lab Account.
@param galleryImageName The name of the gallery Image.
@param galleryImage Represents an image from the Azure Marketplace
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the GalleryImageInner object | [
"Create",
"or",
"replace",
"an",
"existing",
"Gallery",
"Image",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/labservices/resource-manager/v2018_10_15/src/main/java/com/microsoft/azure/management/labservices/v2018_10_15/implementation/GalleryImagesInner.java#L580-L587 |
alamkanak/Android-Week-View | sample/src/main/java/com/alamkanak/weekview/sample/AsynchronousActivity.java | AsynchronousActivity.eventMatches | private boolean eventMatches(WeekViewEvent event, int year, int month) {
return (event.getStartTime().get(Calendar.YEAR) == year && event.getStartTime().get(Calendar.MONTH) == month - 1) || (event.getEndTime().get(Calendar.YEAR) == year && event.getEndTime().get(Calendar.MONTH) == month - 1);
} | java | private boolean eventMatches(WeekViewEvent event, int year, int month) {
return (event.getStartTime().get(Calendar.YEAR) == year && event.getStartTime().get(Calendar.MONTH) == month - 1) || (event.getEndTime().get(Calendar.YEAR) == year && event.getEndTime().get(Calendar.MONTH) == month - 1);
} | [
"private",
"boolean",
"eventMatches",
"(",
"WeekViewEvent",
"event",
",",
"int",
"year",
",",
"int",
"month",
")",
"{",
"return",
"(",
"event",
".",
"getStartTime",
"(",
")",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
"==",
"year",
"&&",
"event",
"... | Checks if an event falls into a specific year and month.
@param event The event to check for.
@param year The year.
@param month The month.
@return True if the event matches the year and month. | [
"Checks",
"if",
"an",
"event",
"falls",
"into",
"a",
"specific",
"year",
"and",
"month",
"."
] | train | https://github.com/alamkanak/Android-Week-View/blob/dc3f97d65d44785d1a761b52b58527c86c4eee1b/sample/src/main/java/com/alamkanak/weekview/sample/AsynchronousActivity.java#L59-L61 |
classgraph/classgraph | src/main/java/nonapi/io/github/classgraph/classpath/CallStackReader.java | CallStackReader.getCallStackViaStackWalker | private static Class<?>[] getCallStackViaStackWalker() {
try {
// // Implement the following via reflection, for JDK7 compatibility:
// List<Class<?>> stackFrameClasses = new ArrayList<>();
// StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE)
// .forEach(sf -> stackFrameClasses.add(sf.getDeclaringClass()));
final Class<?> consumerClass = Class.forName("java.util.function.Consumer");
final List<Class<?>> stackFrameClasses = new ArrayList<>();
final Class<?> stackWalkerOptionClass = Class.forName("java.lang.StackWalker$Option");
final Object retainClassReference = Class.forName("java.lang.Enum")
.getMethod("valueOf", Class.class, String.class)
.invoke(null, stackWalkerOptionClass, "RETAIN_CLASS_REFERENCE");
final Class<?> stackWalkerClass = Class.forName("java.lang.StackWalker");
final Object stackWalkerInstance = stackWalkerClass.getMethod("getInstance", stackWalkerOptionClass)
.invoke(null, retainClassReference);
final Method stackFrameGetDeclaringClassMethod = Class.forName("java.lang.StackWalker$StackFrame")
.getMethod("getDeclaringClass");
stackWalkerClass.getMethod("forEach", consumerClass).invoke(stackWalkerInstance, //
// InvocationHandler proxy for Consumer<StackFrame>
Proxy.newProxyInstance(consumerClass.getClassLoader(), new Class[] { consumerClass },
new InvocationHandler() {
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args)
throws Throwable {
// Consumer<StackFrame> has only one method: void accept(StackFrame)
final Class<?> declaringClass = (Class<?>) stackFrameGetDeclaringClassMethod
.invoke(args[0]);
stackFrameClasses.add(declaringClass);
return null;
}
}));
return stackFrameClasses.toArray(new Class<?>[0]);
} catch (Exception | LinkageError e) {
return null;
}
} | java | private static Class<?>[] getCallStackViaStackWalker() {
try {
// // Implement the following via reflection, for JDK7 compatibility:
// List<Class<?>> stackFrameClasses = new ArrayList<>();
// StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE)
// .forEach(sf -> stackFrameClasses.add(sf.getDeclaringClass()));
final Class<?> consumerClass = Class.forName("java.util.function.Consumer");
final List<Class<?>> stackFrameClasses = new ArrayList<>();
final Class<?> stackWalkerOptionClass = Class.forName("java.lang.StackWalker$Option");
final Object retainClassReference = Class.forName("java.lang.Enum")
.getMethod("valueOf", Class.class, String.class)
.invoke(null, stackWalkerOptionClass, "RETAIN_CLASS_REFERENCE");
final Class<?> stackWalkerClass = Class.forName("java.lang.StackWalker");
final Object stackWalkerInstance = stackWalkerClass.getMethod("getInstance", stackWalkerOptionClass)
.invoke(null, retainClassReference);
final Method stackFrameGetDeclaringClassMethod = Class.forName("java.lang.StackWalker$StackFrame")
.getMethod("getDeclaringClass");
stackWalkerClass.getMethod("forEach", consumerClass).invoke(stackWalkerInstance, //
// InvocationHandler proxy for Consumer<StackFrame>
Proxy.newProxyInstance(consumerClass.getClassLoader(), new Class[] { consumerClass },
new InvocationHandler() {
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args)
throws Throwable {
// Consumer<StackFrame> has only one method: void accept(StackFrame)
final Class<?> declaringClass = (Class<?>) stackFrameGetDeclaringClassMethod
.invoke(args[0]);
stackFrameClasses.add(declaringClass);
return null;
}
}));
return stackFrameClasses.toArray(new Class<?>[0]);
} catch (Exception | LinkageError e) {
return null;
}
} | [
"private",
"static",
"Class",
"<",
"?",
">",
"[",
"]",
"getCallStackViaStackWalker",
"(",
")",
"{",
"try",
"{",
"// // Implement the following via reflection, for JDK7 compatibility:",
"// List<Class<?>> stackFrameClasses = new ArrayList<>();",
"// StackWalker.getInstance(Op... | Get the call stack via the StackWalker API (JRE 9+).
@return the call stack, or null if it could not be obtained. | [
"Get",
"the",
"call",
"stack",
"via",
"the",
"StackWalker",
"API",
"(",
"JRE",
"9",
"+",
")",
"."
] | train | https://github.com/classgraph/classgraph/blob/c8c8b2ca1eb76339f69193fdac33d735c864215c/src/main/java/nonapi/io/github/classgraph/classpath/CallStackReader.java#L57-L93 |
google/jimfs | jimfs/src/main/java/com/google/common/jimfs/FileSystemView.java | FileSystemView.getFileAttributeView | @Nullable
public <V extends FileAttributeView> V getFileAttributeView(
final JimfsPath path, Class<V> type, final Set<? super LinkOption> options) {
return store.getFileAttributeView(
new FileLookup() {
@Override
public File lookup() throws IOException {
return lookUpWithLock(path, options).requireExists(path).file();
}
},
type);
} | java | @Nullable
public <V extends FileAttributeView> V getFileAttributeView(
final JimfsPath path, Class<V> type, final Set<? super LinkOption> options) {
return store.getFileAttributeView(
new FileLookup() {
@Override
public File lookup() throws IOException {
return lookUpWithLock(path, options).requireExists(path).file();
}
},
type);
} | [
"@",
"Nullable",
"public",
"<",
"V",
"extends",
"FileAttributeView",
">",
"V",
"getFileAttributeView",
"(",
"final",
"JimfsPath",
"path",
",",
"Class",
"<",
"V",
">",
"type",
",",
"final",
"Set",
"<",
"?",
"super",
"LinkOption",
">",
"options",
")",
"{",
... | Returns a file attribute view for the given path in this view. | [
"Returns",
"a",
"file",
"attribute",
"view",
"for",
"the",
"given",
"path",
"in",
"this",
"view",
"."
] | train | https://github.com/google/jimfs/blob/3eadff747a3afa7b498030f420d2d04ce700534a/jimfs/src/main/java/com/google/common/jimfs/FileSystemView.java#L701-L712 |
kirgor/enklib | sql/src/main/java/com/kirgor/enklib/sql/Session.java | Session.createConnection | private static Connection createConnection(String driver, String url, String user, String password)
throws SQLException, ClassNotFoundException {
Class.forName(driver);
return DriverManager.getConnection(url, user, password);
} | java | private static Connection createConnection(String driver, String url, String user, String password)
throws SQLException, ClassNotFoundException {
Class.forName(driver);
return DriverManager.getConnection(url, user, password);
} | [
"private",
"static",
"Connection",
"createConnection",
"(",
"String",
"driver",
",",
"String",
"url",
",",
"String",
"user",
",",
"String",
"password",
")",
"throws",
"SQLException",
",",
"ClassNotFoundException",
"{",
"Class",
".",
"forName",
"(",
"driver",
")"... | Creates {@link Connection} instance from supplied driver, JDBC URL and user credentials. | [
"Creates",
"{"
] | train | https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/sql/src/main/java/com/kirgor/enklib/sql/Session.java#L213-L217 |
trustathsh/ironcommon | src/main/java/de/hshannover/f4/trust/ironcommon/properties/Properties.java | Properties.addToRootMap | @SuppressWarnings("unchecked")
private void addToRootMap(String propertyPath, Object propertyValue)
throws PropertyException {
// split propertyPath
String[] propertyKeyArray = propertyPath.split("\\.");
// load configMap from disk
Map<String, Object> configMap = load();
// if simple token add too root map
if (propertyKeyArray.length == 1) {
configMap.put(propertyPath, propertyValue);
}
// add to root map
Map<String, Object> deeperNestedMap = configMap;
Object foundedValue = null;
// search the subMap with the key[i] without the last key
for (int i = 0; i < propertyKeyArray.length - 1; i++) {
foundedValue = deeperNestedMap.get(propertyKeyArray[i]);
if (foundedValue instanceof Map) {
// go deeper if something was found
deeperNestedMap = (Map<String, Object>) foundedValue;
} else {
// if foundedValue == null or not a Map
// then build from the i position new nested map(s)
String[] subArray = getCopyFrom(i + 1, propertyKeyArray);
Map<String, Object> newNestedMap = buildNewNestedMap(subArray,
propertyValue);
// add the newNestedMap map to the deeperNestedMap
deeperNestedMap.put(propertyKeyArray[i], newNestedMap);
break;
}
if (i == propertyKeyArray.length - 2) {
deeperNestedMap.put(
propertyKeyArray[propertyKeyArray.length - 1],
propertyValue);
}
}
// save all
save(configMap);
} | java | @SuppressWarnings("unchecked")
private void addToRootMap(String propertyPath, Object propertyValue)
throws PropertyException {
// split propertyPath
String[] propertyKeyArray = propertyPath.split("\\.");
// load configMap from disk
Map<String, Object> configMap = load();
// if simple token add too root map
if (propertyKeyArray.length == 1) {
configMap.put(propertyPath, propertyValue);
}
// add to root map
Map<String, Object> deeperNestedMap = configMap;
Object foundedValue = null;
// search the subMap with the key[i] without the last key
for (int i = 0; i < propertyKeyArray.length - 1; i++) {
foundedValue = deeperNestedMap.get(propertyKeyArray[i]);
if (foundedValue instanceof Map) {
// go deeper if something was found
deeperNestedMap = (Map<String, Object>) foundedValue;
} else {
// if foundedValue == null or not a Map
// then build from the i position new nested map(s)
String[] subArray = getCopyFrom(i + 1, propertyKeyArray);
Map<String, Object> newNestedMap = buildNewNestedMap(subArray,
propertyValue);
// add the newNestedMap map to the deeperNestedMap
deeperNestedMap.put(propertyKeyArray[i], newNestedMap);
break;
}
if (i == propertyKeyArray.length - 2) {
deeperNestedMap.put(
propertyKeyArray[propertyKeyArray.length - 1],
propertyValue);
}
}
// save all
save(configMap);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"void",
"addToRootMap",
"(",
"String",
"propertyPath",
",",
"Object",
"propertyValue",
")",
"throws",
"PropertyException",
"{",
"// split propertyPath",
"String",
"[",
"]",
"propertyKeyArray",
"=",
"proper... | Adds a given value object to the properties {@link Map} corresponding to
the configuration file, creates deeper nested maps if necessary.
@param propertyPath
a property path where the value will be stored at
@param propertyValue
the value to be added to the root map
@throws PropertyException
If the propertyKey-Path is not a property key or is a not
part of a property path | [
"Adds",
"a",
"given",
"value",
"object",
"to",
"the",
"properties",
"{",
"@link",
"Map",
"}",
"corresponding",
"to",
"the",
"configuration",
"file",
"creates",
"deeper",
"nested",
"maps",
"if",
"necessary",
"."
] | train | https://github.com/trustathsh/ironcommon/blob/fee589a9300ab16744ca12fafae4357dd18c9fcb/src/main/java/de/hshannover/f4/trust/ironcommon/properties/Properties.java#L412-L457 |
OpenTSDB/opentsdb | src/tsd/HttpSerializer.java | HttpSerializer.formatVersionV1 | public ChannelBuffer formatVersionV1(final Map<String, String> version) {
throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED,
"The requested API endpoint has not been implemented",
this.getClass().getCanonicalName() +
" has not implemented formatVersionV1");
} | java | public ChannelBuffer formatVersionV1(final Map<String, String> version) {
throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED,
"The requested API endpoint has not been implemented",
this.getClass().getCanonicalName() +
" has not implemented formatVersionV1");
} | [
"public",
"ChannelBuffer",
"formatVersionV1",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"version",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"NOT_IMPLEMENTED",
",",
"\"The requested API endpoint has not been implemented... | Format a hash map of information about the OpenTSDB version
@param version A hash map with version information
@return A ChannelBuffer object to pass on to the caller
@throws BadRequestException if the plugin has not implemented this method | [
"Format",
"a",
"hash",
"map",
"of",
"information",
"about",
"the",
"OpenTSDB",
"version"
] | train | https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpSerializer.java#L443-L448 |
lightblueseas/swing-components | src/main/java/de/alpharogroup/swing/base/ApplicationFrame.java | ApplicationFrame.replaceInternalFrame | public void replaceInternalFrame(final String title, final Component component)
{
if (getCurrentVisibleInternalFrame() != null)
{
getCurrentVisibleInternalFrame().dispose();
}
// create internal frame
final JInternalFrame internalFrame = JComponentFactory.newInternalFrame(title, true, true,
true, true);
JInternalFrameExtensions.addComponentToFrame(internalFrame, component);
JInternalFrameExtensions.addJInternalFrame(getMainComponent(), internalFrame);
setCurrentVisibleInternalFrame(internalFrame);
} | java | public void replaceInternalFrame(final String title, final Component component)
{
if (getCurrentVisibleInternalFrame() != null)
{
getCurrentVisibleInternalFrame().dispose();
}
// create internal frame
final JInternalFrame internalFrame = JComponentFactory.newInternalFrame(title, true, true,
true, true);
JInternalFrameExtensions.addComponentToFrame(internalFrame, component);
JInternalFrameExtensions.addJInternalFrame(getMainComponent(), internalFrame);
setCurrentVisibleInternalFrame(internalFrame);
} | [
"public",
"void",
"replaceInternalFrame",
"(",
"final",
"String",
"title",
",",
"final",
"Component",
"component",
")",
"{",
"if",
"(",
"getCurrentVisibleInternalFrame",
"(",
")",
"!=",
"null",
")",
"{",
"getCurrentVisibleInternalFrame",
"(",
")",
".",
"dispose",
... | Replace the current internal frame with a new internal frame with the given {@link Component}
as content.
@param title
the title
@param component
the component | [
"Replace",
"the",
"current",
"internal",
"frame",
"with",
"a",
"new",
"internal",
"frame",
"with",
"the",
"given",
"{",
"@link",
"Component",
"}",
"as",
"content",
"."
] | train | https://github.com/lightblueseas/swing-components/blob/4045e85cabd8f0ce985cbfff134c3c9873930c79/src/main/java/de/alpharogroup/swing/base/ApplicationFrame.java#L97-L109 |
EMCECS/nfs-client-java | src/main/java/com/emc/ecs/nfsclient/rpc/RpcWrapper.java | RpcWrapper.callRpcWrapped | public void callRpcWrapped(S request, RpcResponseHandler<? extends T> responseHandler) throws IOException {
for (int i = 0; i < _maximumRetries; ++i) {
try {
callRpcChecked(request, responseHandler);
return;
} catch (RpcException e) {
handleRpcException(e, i);
}
}
} | java | public void callRpcWrapped(S request, RpcResponseHandler<? extends T> responseHandler) throws IOException {
for (int i = 0; i < _maximumRetries; ++i) {
try {
callRpcChecked(request, responseHandler);
return;
} catch (RpcException e) {
handleRpcException(e, i);
}
}
} | [
"public",
"void",
"callRpcWrapped",
"(",
"S",
"request",
",",
"RpcResponseHandler",
"<",
"?",
"extends",
"T",
">",
"responseHandler",
")",
"throws",
"IOException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"_maximumRetries",
";",
"++",
"i",
"... | Make the wrapped call and unmarshall the returned Xdr to a response,
getting the IP key from the request. If an RPC Exception is being thrown,
and retries remain, then log the exception and retry.
@param request
The request to send.
@param responseHandler
A response handler.
@throws IOException | [
"Make",
"the",
"wrapped",
"call",
"and",
"unmarshall",
"the",
"returned",
"Xdr",
"to",
"a",
"response",
"getting",
"the",
"IP",
"key",
"from",
"the",
"request",
".",
"If",
"an",
"RPC",
"Exception",
"is",
"being",
"thrown",
"and",
"retries",
"remain",
"then... | train | https://github.com/EMCECS/nfs-client-java/blob/7ba25bad5052b95cd286052745327729288b2843/src/main/java/com/emc/ecs/nfsclient/rpc/RpcWrapper.java#L128-L137 |
RobotiumTech/robotium | robotium-solo/src/main/java/com/robotium/solo/Solo.java | Solo.waitForCondition | public boolean waitForCondition(Condition condition, final int timeout){
if(config.commandLogging){
Log.d(config.commandLoggingTag, "waitForCondition("+condition+","+timeout+")");
}
return waiter.waitForCondition(condition, timeout);
} | java | public boolean waitForCondition(Condition condition, final int timeout){
if(config.commandLogging){
Log.d(config.commandLoggingTag, "waitForCondition("+condition+","+timeout+")");
}
return waiter.waitForCondition(condition, timeout);
} | [
"public",
"boolean",
"waitForCondition",
"(",
"Condition",
"condition",
",",
"final",
"int",
"timeout",
")",
"{",
"if",
"(",
"config",
".",
"commandLogging",
")",
"{",
"Log",
".",
"d",
"(",
"config",
".",
"commandLoggingTag",
",",
"\"waitForCondition(\"",
"+",... | Waits for a condition to be satisfied.
@param condition the condition to wait for
@param timeout the amount of time in milliseconds to wait
@return {@code true} if condition is satisfied and {@code false} if it is not satisfied before the timeout | [
"Waits",
"for",
"a",
"condition",
"to",
"be",
"satisfied",
"."
] | train | https://github.com/RobotiumTech/robotium/blob/75e567c38f26a6a87dc8bef90b3886a20e28d291/robotium-solo/src/main/java/com/robotium/solo/Solo.java#L716-L722 |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGUtil.java | SVGUtil.svgText | public static Element svgText(Document document, double x, double y, String text) {
Element elem = SVGUtil.svgElement(document, SVGConstants.SVG_TEXT_TAG);
SVGUtil.setAtt(elem, SVGConstants.SVG_X_ATTRIBUTE, x);
SVGUtil.setAtt(elem, SVGConstants.SVG_Y_ATTRIBUTE, y);
elem.setTextContent(text);
return elem;
} | java | public static Element svgText(Document document, double x, double y, String text) {
Element elem = SVGUtil.svgElement(document, SVGConstants.SVG_TEXT_TAG);
SVGUtil.setAtt(elem, SVGConstants.SVG_X_ATTRIBUTE, x);
SVGUtil.setAtt(elem, SVGConstants.SVG_Y_ATTRIBUTE, y);
elem.setTextContent(text);
return elem;
} | [
"public",
"static",
"Element",
"svgText",
"(",
"Document",
"document",
",",
"double",
"x",
",",
"double",
"y",
",",
"String",
"text",
")",
"{",
"Element",
"elem",
"=",
"SVGUtil",
".",
"svgElement",
"(",
"document",
",",
"SVGConstants",
".",
"SVG_TEXT_TAG",
... | Create a SVG text element.
@param document document to create in (factory)
@param x first point x
@param y first point y
@param text Content of text element.
@return New text element. | [
"Create",
"a",
"SVG",
"text",
"element",
"."
] | train | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGUtil.java#L482-L488 |
neo4j/neo4j-java-driver | driver/src/main/java/org/neo4j/driver/internal/DriverFactory.java | DriverFactory.createRetryLogic | protected RetryLogic createRetryLogic( RetrySettings settings, EventExecutorGroup eventExecutorGroup,
Logging logging )
{
return new ExponentialBackoffRetryLogic( settings, eventExecutorGroup, createClock(), logging );
} | java | protected RetryLogic createRetryLogic( RetrySettings settings, EventExecutorGroup eventExecutorGroup,
Logging logging )
{
return new ExponentialBackoffRetryLogic( settings, eventExecutorGroup, createClock(), logging );
} | [
"protected",
"RetryLogic",
"createRetryLogic",
"(",
"RetrySettings",
"settings",
",",
"EventExecutorGroup",
"eventExecutorGroup",
",",
"Logging",
"logging",
")",
"{",
"return",
"new",
"ExponentialBackoffRetryLogic",
"(",
"settings",
",",
"eventExecutorGroup",
",",
"create... | Creates new {@link RetryLogic}.
<p>
<b>This method is protected only for testing</b> | [
"Creates",
"new",
"{"
] | train | https://github.com/neo4j/neo4j-java-driver/blob/8dad6c48251fa1ab7017e72d9998a24fa2337a22/driver/src/main/java/org/neo4j/driver/internal/DriverFactory.java#L258-L262 |
tvesalainen/util | util/src/main/java/org/vesalainen/util/navi/RateOfTurn.java | RateOfTurn.getMotionAfter | public Motion getMotionAfter(Motion motion, TimeSpan span)
{
return new Motion(motion.getSpeed(), getBearingAfter(motion.getAngle(), span));
} | java | public Motion getMotionAfter(Motion motion, TimeSpan span)
{
return new Motion(motion.getSpeed(), getBearingAfter(motion.getAngle(), span));
} | [
"public",
"Motion",
"getMotionAfter",
"(",
"Motion",
"motion",
",",
"TimeSpan",
"span",
")",
"{",
"return",
"new",
"Motion",
"(",
"motion",
".",
"getSpeed",
"(",
")",
",",
"getBearingAfter",
"(",
"motion",
".",
"getAngle",
"(",
")",
",",
"span",
")",
")"... | Return's motion after timespan
@param motion Motion at the beginning
@param span TimeSpan of turning
@return | [
"Return",
"s",
"motion",
"after",
"timespan"
] | train | https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/navi/RateOfTurn.java#L104-L107 |
legsem/legstar-core2 | legstar-base-generator/src/main/java/com/legstar/base/generator/AbstractCob2JavaGeneratorMain.java | AbstractCob2JavaGeneratorMain.collectOptions | protected boolean collectOptions(final Options options, final String[] args) {
try {
if (args != null && args.length > 0) {
CommandLineParser parser = new PosixParser();
CommandLine line = parser.parse(options, args);
return processLine(line, options);
}
return true;
} catch (ParseException e) {
log.error("Invalid option", e);
return false;
} catch (IllegalArgumentException e) {
log.error("Invalid option value", e);
return false;
}
} | java | protected boolean collectOptions(final Options options, final String[] args) {
try {
if (args != null && args.length > 0) {
CommandLineParser parser = new PosixParser();
CommandLine line = parser.parse(options, args);
return processLine(line, options);
}
return true;
} catch (ParseException e) {
log.error("Invalid option", e);
return false;
} catch (IllegalArgumentException e) {
log.error("Invalid option value", e);
return false;
}
} | [
"protected",
"boolean",
"collectOptions",
"(",
"final",
"Options",
"options",
",",
"final",
"String",
"[",
"]",
"args",
")",
"{",
"try",
"{",
"if",
"(",
"args",
"!=",
"null",
"&&",
"args",
".",
"length",
">",
"0",
")",
"{",
"CommandLineParser",
"parser",... | Take arguments received on the command line and setup corresponding
options.
<p/>
No arguments is valid. It means use the defaults.
@param options the expected options
@param args the actual arguments received on the command line
@return true if arguments were valid | [
"Take",
"arguments",
"received",
"on",
"the",
"command",
"line",
"and",
"setup",
"corresponding",
"options",
".",
"<p",
"/",
">",
"No",
"arguments",
"is",
"valid",
".",
"It",
"means",
"use",
"the",
"defaults",
"."
] | train | https://github.com/legsem/legstar-core2/blob/f74d25d5b2b21a2ebaaaf2162b3fb7138dca40c6/legstar-base-generator/src/main/java/com/legstar/base/generator/AbstractCob2JavaGeneratorMain.java#L177-L192 |
andriusvelykis/reflow-maven-skin | reflow-velocity-tools/src/main/java/lt/velykis/maven/skins/reflow/HtmlTool.java | HtmlTool.replaceAll | public String replaceAll(String content, Map<String, String> replacements) {
Element body = parseContent(content);
boolean modified = false;
for (Entry<String, String> replacementEntry : replacements.entrySet()) {
String selector = replacementEntry.getKey();
String replacement = replacementEntry.getValue();
List<Element> elements = body.select(selector);
if (elements.size() > 0) {
// take the first child
Element replacementElem = parseContent(replacement).child(0);
if (replacementElem != null) {
for (Element element : elements) {
element.replaceWith(replacementElem.clone());
}
modified = true;
}
}
}
if (modified) {
return body.html();
} else {
// nothing changed
return content;
}
} | java | public String replaceAll(String content, Map<String, String> replacements) {
Element body = parseContent(content);
boolean modified = false;
for (Entry<String, String> replacementEntry : replacements.entrySet()) {
String selector = replacementEntry.getKey();
String replacement = replacementEntry.getValue();
List<Element> elements = body.select(selector);
if (elements.size() > 0) {
// take the first child
Element replacementElem = parseContent(replacement).child(0);
if (replacementElem != null) {
for (Element element : elements) {
element.replaceWith(replacementElem.clone());
}
modified = true;
}
}
}
if (modified) {
return body.html();
} else {
// nothing changed
return content;
}
} | [
"public",
"String",
"replaceAll",
"(",
"String",
"content",
",",
"Map",
"<",
"String",
",",
"String",
">",
"replacements",
")",
"{",
"Element",
"body",
"=",
"parseContent",
"(",
"content",
")",
";",
"boolean",
"modified",
"=",
"false",
";",
"for",
"(",
"... | Replaces elements in HTML.
@param content
HTML content to modify
@param replacements
Map of CSS selectors to their replacement HTML texts. CSS selectors find elements
to be replaced with the HTML in the mapping. The HTML must parse to a single
element.
@return HTML content with replaced elements. If no elements are found, the original content
is returned.
@since 1.0 | [
"Replaces",
"elements",
"in",
"HTML",
"."
] | train | https://github.com/andriusvelykis/reflow-maven-skin/blob/01170ae1426a1adfe7cc9c199e77aaa2ecb37ef2/reflow-velocity-tools/src/main/java/lt/velykis/maven/skins/reflow/HtmlTool.java#L813-L844 |
phax/ph-schedule | ph-mini-quartz/src/main/java/com/helger/quartz/TriggerBuilder.java | TriggerBuilder.forJob | @Nonnull
public TriggerBuilder <T> forJob (final String jobName)
{
m_aJobKey = new JobKey (jobName, null);
return this;
} | java | @Nonnull
public TriggerBuilder <T> forJob (final String jobName)
{
m_aJobKey = new JobKey (jobName, null);
return this;
} | [
"@",
"Nonnull",
"public",
"TriggerBuilder",
"<",
"T",
">",
"forJob",
"(",
"final",
"String",
"jobName",
")",
"{",
"m_aJobKey",
"=",
"new",
"JobKey",
"(",
"jobName",
",",
"null",
")",
";",
"return",
"this",
";",
"}"
] | Set the identity of the Job which should be fired by the produced Trigger -
a <code>JobKey</code> will be produced with the given name and default
group.
@param jobName
the name of the job (in default group) to fire.
@return the updated TriggerBuilder
@see ITrigger#getJobKey() | [
"Set",
"the",
"identity",
"of",
"the",
"Job",
"which",
"should",
"be",
"fired",
"by",
"the",
"produced",
"Trigger",
"-",
"a",
"<code",
">",
"JobKey<",
"/",
"code",
">",
"will",
"be",
"produced",
"with",
"the",
"given",
"name",
"and",
"default",
"group",
... | train | https://github.com/phax/ph-schedule/blob/b000790b46a9f8d23ad44cc20591f753d07c0229/ph-mini-quartz/src/main/java/com/helger/quartz/TriggerBuilder.java#L329-L334 |
jbundle/jbundle | base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBasePanel.java | HBasePanel.addHiddenParam | public void addHiddenParam(PrintWriter out, String strParam, String strValue)
{
out.println("<input type=\"hidden\" name=\"" + strParam + "\" value=\"" + strValue + "\">");
} | java | public void addHiddenParam(PrintWriter out, String strParam, String strValue)
{
out.println("<input type=\"hidden\" name=\"" + strParam + "\" value=\"" + strValue + "\">");
} | [
"public",
"void",
"addHiddenParam",
"(",
"PrintWriter",
"out",
",",
"String",
"strParam",
",",
"String",
"strValue",
")",
"{",
"out",
".",
"println",
"(",
"\"<input type=\\\"hidden\\\" name=\\\"\"",
"+",
"strParam",
"+",
"\"\\\" value=\\\"\"",
"+",
"strValue",
"+",
... | Add this hidden param to the output stream.
@param out The html output stream.
@param strParam The parameter.
@param strValue The param's value. | [
"Add",
"this",
"hidden",
"param",
"to",
"the",
"output",
"stream",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/html/src/main/java/org/jbundle/base/screen/view/html/HBasePanel.java#L601-L604 |
ButterFaces/ButterFaces | components/src/main/java/org/butterfaces/component/partrenderer/CheckBoxReadonlyPartRenderer.java | CheckBoxReadonlyPartRenderer.getReadonlyDisplayValue | private String getReadonlyDisplayValue(final Object value, final HtmlCheckBox checkBox) {
final StringBuilder sb = new StringBuilder();
if (StringUtils.isNotEmpty(checkBox.getDescription())) {
sb.append(checkBox.getDescription()).append(": ");
}
sb.append((Boolean) value ? "ja" : "nein");
return sb.toString();
} | java | private String getReadonlyDisplayValue(final Object value, final HtmlCheckBox checkBox) {
final StringBuilder sb = new StringBuilder();
if (StringUtils.isNotEmpty(checkBox.getDescription())) {
sb.append(checkBox.getDescription()).append(": ");
}
sb.append((Boolean) value ? "ja" : "nein");
return sb.toString();
} | [
"private",
"String",
"getReadonlyDisplayValue",
"(",
"final",
"Object",
"value",
",",
"final",
"HtmlCheckBox",
"checkBox",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"... | Should return value string for the readonly view mode. Can be overridden
for custom components. | [
"Should",
"return",
"value",
"string",
"for",
"the",
"readonly",
"view",
"mode",
".",
"Can",
"be",
"overridden",
"for",
"custom",
"components",
"."
] | train | https://github.com/ButterFaces/ButterFaces/blob/e8c2bb340c89dcdbac409fcfc7a2a0e07f2462fc/components/src/main/java/org/butterfaces/component/partrenderer/CheckBoxReadonlyPartRenderer.java#L52-L59 |
ggrandes/packer | src/main/java/org/javastack/packer/Packer.java | Packer.crc8 | static final int crc8(final byte[] input, final int offset, final int len) {
final int poly = 0x0D5;
int crc = 0;
for (int i = 0; i < len; i++) {
final byte c = input[offset + i];
crc ^= c;
for (int j = 0; j < 8; j++) {
if ((crc & 0x80) != 0) {
crc = ((crc << 1) ^ poly);
} else {
crc <<= 1;
}
}
crc &= 0xFF;
}
return crc;
} | java | static final int crc8(final byte[] input, final int offset, final int len) {
final int poly = 0x0D5;
int crc = 0;
for (int i = 0; i < len; i++) {
final byte c = input[offset + i];
crc ^= c;
for (int j = 0; j < 8; j++) {
if ((crc & 0x80) != 0) {
crc = ((crc << 1) ^ poly);
} else {
crc <<= 1;
}
}
crc &= 0xFF;
}
return crc;
} | [
"static",
"final",
"int",
"crc8",
"(",
"final",
"byte",
"[",
"]",
"input",
",",
"final",
"int",
"offset",
",",
"final",
"int",
"len",
")",
"{",
"final",
"int",
"poly",
"=",
"0x0D5",
";",
"int",
"crc",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
... | Calculate CRC-8 of input
<p>
<a href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check">CRC-8</a>
@param input
@param offset
@param len
@return | [
"Calculate",
"CRC",
"-",
"8",
"of",
"input",
"<p",
">",
"<a",
"href",
"=",
"http",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Cyclic_redundancy_check",
">",
"CRC",
"-",
"8<",
"/",
"a",
">"
] | train | https://github.com/ggrandes/packer/blob/0b37b286a3d0555050eb2e65419dd74f8d8d3e78/src/main/java/org/javastack/packer/Packer.java#L1415-L1431 |
jenkinsci/jenkins | core/src/main/java/jenkins/mvn/GlobalSettingsProvider.java | GlobalSettingsProvider.getSettingsRemotePath | public static String getSettingsRemotePath(GlobalSettingsProvider provider, AbstractBuild<?, ?> build, TaskListener listener) {
FilePath fp = getSettingsFilePath(provider, build, listener);
return fp == null ? null : fp.getRemote();
} | java | public static String getSettingsRemotePath(GlobalSettingsProvider provider, AbstractBuild<?, ?> build, TaskListener listener) {
FilePath fp = getSettingsFilePath(provider, build, listener);
return fp == null ? null : fp.getRemote();
} | [
"public",
"static",
"String",
"getSettingsRemotePath",
"(",
"GlobalSettingsProvider",
"provider",
",",
"AbstractBuild",
"<",
"?",
",",
"?",
">",
"build",
",",
"TaskListener",
"listener",
")",
"{",
"FilePath",
"fp",
"=",
"getSettingsFilePath",
"(",
"provider",
",",... | Convenience method handling all <code>null</code> checks. Provides the path on the (possible) remote settings file.
@param provider
the provider to be used
@param build
the active build
@param listener
the listener of the current build
@return the path to the global settings.xml | [
"Convenience",
"method",
"handling",
"all",
"<code",
">",
"null<",
"/",
"code",
">",
"checks",
".",
"Provides",
"the",
"path",
"on",
"the",
"(",
"possible",
")",
"remote",
"settings",
"file",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/jenkins/mvn/GlobalSettingsProvider.java#L70-L73 |
avianey/facebook-api-android-maven | facebook/src/main/java/com/facebook/NativeAppCallAttachmentStore.java | NativeAppCallAttachmentStore.addAttachmentFilesForCall | public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
Validate.notNull(context, "context");
Validate.notNull(callId, "callId");
Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");
addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
@Override
public void processAttachment(File attachment, File outputFile) throws IOException {
FileOutputStream outputStream = new FileOutputStream(outputFile);
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(attachment);
byte[] buffer = new byte[1024];
int len;
while ((len = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, len);
}
} finally {
Utility.closeQuietly(outputStream);
Utility.closeQuietly(inputStream);
}
}
});
} | java | public void addAttachmentFilesForCall(Context context, UUID callId, Map<String, File> imageAttachmentFiles) {
Validate.notNull(context, "context");
Validate.notNull(callId, "callId");
Validate.containsNoNulls(imageAttachmentFiles.values(), "imageAttachmentFiles");
Validate.containsNoNullOrEmpty(imageAttachmentFiles.keySet(), "imageAttachmentFiles");
addAttachments(context, callId, imageAttachmentFiles, new ProcessAttachment<File>() {
@Override
public void processAttachment(File attachment, File outputFile) throws IOException {
FileOutputStream outputStream = new FileOutputStream(outputFile);
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(attachment);
byte[] buffer = new byte[1024];
int len;
while ((len = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, len);
}
} finally {
Utility.closeQuietly(outputStream);
Utility.closeQuietly(inputStream);
}
}
});
} | [
"public",
"void",
"addAttachmentFilesForCall",
"(",
"Context",
"context",
",",
"UUID",
"callId",
",",
"Map",
"<",
"String",
",",
"File",
">",
"imageAttachmentFiles",
")",
"{",
"Validate",
".",
"notNull",
"(",
"context",
",",
"\"context\"",
")",
";",
"Validate"... | Adds a number of bitmap attachment files associated with a native app call. The attachments will be
served via {@link NativeAppCallContentProvider#openFile(android.net.Uri, String) openFile}.
@param context the Context the call is being made from
@param callId the unique ID of the call
@param imageAttachments a Map of attachment names to Files containing the bitmaps; the attachment names will be
part of the URI processed by openFile
@throws java.io.IOException | [
"Adds",
"a",
"number",
"of",
"bitmap",
"attachment",
"files",
"associated",
"with",
"a",
"native",
"app",
"call",
".",
"The",
"attachments",
"will",
"be",
"served",
"via",
"{",
"@link",
"NativeAppCallContentProvider#openFile",
"(",
"android",
".",
"net",
".",
... | train | https://github.com/avianey/facebook-api-android-maven/blob/ae6c7aa7ae45739ee19f18c1983e05f7e35b9ede/facebook/src/main/java/com/facebook/NativeAppCallAttachmentStore.java#L88-L113 |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/subsys/picketlink/FederationPresenter.java | FederationPresenter.modifyIdentityProvider | public void modifyIdentityProvider(final Map<String, Object> changedValues) {
AddressTemplate template = IDENTITY_PROVIDER_TEMPLATE.replaceWildcards(federation, identityProvider);
modify(template, identityProvider, changedValues);
} | java | public void modifyIdentityProvider(final Map<String, Object> changedValues) {
AddressTemplate template = IDENTITY_PROVIDER_TEMPLATE.replaceWildcards(federation, identityProvider);
modify(template, identityProvider, changedValues);
} | [
"public",
"void",
"modifyIdentityProvider",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"changedValues",
")",
"{",
"AddressTemplate",
"template",
"=",
"IDENTITY_PROVIDER_TEMPLATE",
".",
"replaceWildcards",
"(",
"federation",
",",
"identityProvider",
")",
... | ------------------------------------------------------ identity provider, handlers & trust domain | [
"------------------------------------------------------",
"identity",
"provider",
"handlers",
"&",
"trust",
"domain"
] | train | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/subsys/picketlink/FederationPresenter.java#L182-L185 |
square/wire | wire-java-generator/src/main/java/com/squareup/wire/java/ProfileLoader.java | ProfileLoader.loadProfileFile | private ProfileFileElement loadProfileFile(Path base, String path) throws IOException {
Source source = source(base, path);
if (source == null) return null;
try {
Location location = Location.get(base.toString(), path);
String data = Okio.buffer(source).readUtf8();
return new ProfileParser(location, data).read();
} catch (IOException e) {
throw new IOException("Failed to load " + source + " from " + base, e);
} finally {
source.close();
}
} | java | private ProfileFileElement loadProfileFile(Path base, String path) throws IOException {
Source source = source(base, path);
if (source == null) return null;
try {
Location location = Location.get(base.toString(), path);
String data = Okio.buffer(source).readUtf8();
return new ProfileParser(location, data).read();
} catch (IOException e) {
throw new IOException("Failed to load " + source + " from " + base, e);
} finally {
source.close();
}
} | [
"private",
"ProfileFileElement",
"loadProfileFile",
"(",
"Path",
"base",
",",
"String",
"path",
")",
"throws",
"IOException",
"{",
"Source",
"source",
"=",
"source",
"(",
"base",
",",
"path",
")",
";",
"if",
"(",
"source",
"==",
"null",
")",
"return",
"nul... | Parses the {@code .wire} file at {@code base/path} and returns it. Returns null if no such
file exists. | [
"Parses",
"the",
"{"
] | train | https://github.com/square/wire/blob/4a9a00dfadfc14d6a0780b85810418f9cbc78a49/wire-java-generator/src/main/java/com/squareup/wire/java/ProfileLoader.java#L138-L150 |
windup/windup | rules-base/api/src/main/java/org/jboss/windup/rules/files/FileMapping.java | FileMapping.addMapping | public static void addMapping(GraphRewrite event, String pattern, Class<? extends WindupVertexFrame> type)
{
getMappings(event, pattern).add(type);
} | java | public static void addMapping(GraphRewrite event, String pattern, Class<? extends WindupVertexFrame> type)
{
getMappings(event, pattern).add(type);
} | [
"public",
"static",
"void",
"addMapping",
"(",
"GraphRewrite",
"event",
",",
"String",
"pattern",
",",
"Class",
"<",
"?",
"extends",
"WindupVertexFrame",
">",
"type",
")",
"{",
"getMappings",
"(",
"event",
",",
"pattern",
")",
".",
"add",
"(",
"type",
")",... | Add a {@link WindupVertexFrame} type to the list of mappings for the given pattern and {@link GraphRewrite}
event. | [
"Add",
"a",
"{"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-base/api/src/main/java/org/jboss/windup/rules/files/FileMapping.java#L176-L179 |
landawn/AbacusUtil | src/com/landawn/abacus/util/DateUtil.java | DateUtil.addHours | public static <T extends java.util.Date> T addHours(final T date, final int amount) {
return roll(date, amount, CalendarUnit.HOUR);
} | java | public static <T extends java.util.Date> T addHours(final T date, final int amount) {
return roll(date, amount, CalendarUnit.HOUR);
} | [
"public",
"static",
"<",
"T",
"extends",
"java",
".",
"util",
".",
"Date",
">",
"T",
"addHours",
"(",
"final",
"T",
"date",
",",
"final",
"int",
"amount",
")",
"{",
"return",
"roll",
"(",
"date",
",",
"amount",
",",
"CalendarUnit",
".",
"HOUR",
")",
... | Adds a number of hours to a date returning a new object.
The original {@code Date} is unchanged.
@param date the date, not null
@param amount the amount to add, may be negative
@return the new {@code Date} with the amount added
@throws IllegalArgumentException if the date is null | [
"Adds",
"a",
"number",
"of",
"hours",
"to",
"a",
"date",
"returning",
"a",
"new",
"object",
".",
"The",
"original",
"{",
"@code",
"Date",
"}",
"is",
"unchanged",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/DateUtil.java#L1007-L1009 |
Ordinastie/MalisisCore | src/main/java/net/malisis/core/inventory/message/UpdateInventorySlotsMessage.java | UpdateInventorySlotsMessage.updateSlots | public static void updateSlots(int inventoryId, List<MalisisSlot> slots, EntityPlayerMP player, int windowId)
{
Packet packet = new Packet(inventoryId, windowId);
for (MalisisSlot slot : slots)
packet.addSlot(slot);
MalisisCore.network.sendTo(packet, player);
} | java | public static void updateSlots(int inventoryId, List<MalisisSlot> slots, EntityPlayerMP player, int windowId)
{
Packet packet = new Packet(inventoryId, windowId);
for (MalisisSlot slot : slots)
packet.addSlot(slot);
MalisisCore.network.sendTo(packet, player);
} | [
"public",
"static",
"void",
"updateSlots",
"(",
"int",
"inventoryId",
",",
"List",
"<",
"MalisisSlot",
">",
"slots",
",",
"EntityPlayerMP",
"player",
",",
"int",
"windowId",
")",
"{",
"Packet",
"packet",
"=",
"new",
"Packet",
"(",
"inventoryId",
",",
"window... | Sends a {@link Packet} to player to update the inventory slots.
@param inventoryId the inventory id
@param slots the slots
@param player the player
@param windowId the window id | [
"Sends",
"a",
"{",
"@link",
"Packet",
"}",
"to",
"player",
"to",
"update",
"the",
"inventory",
"slots",
"."
] | train | https://github.com/Ordinastie/MalisisCore/blob/4f8e1fa462d5c372fc23414482ba9f429881cc54/src/main/java/net/malisis/core/inventory/message/UpdateInventorySlotsMessage.java#L121-L127 |
exoplatform/jcr | exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/common/SessionProvider.java | SessionProvider.createAnonimProvider | public static SessionProvider createAnonimProvider()
{
Identity id = new Identity(IdentityConstants.ANONIM, new HashSet<MembershipEntry>());
return new SessionProvider(new ConversationState(id));
} | java | public static SessionProvider createAnonimProvider()
{
Identity id = new Identity(IdentityConstants.ANONIM, new HashSet<MembershipEntry>());
return new SessionProvider(new ConversationState(id));
} | [
"public",
"static",
"SessionProvider",
"createAnonimProvider",
"(",
")",
"{",
"Identity",
"id",
"=",
"new",
"Identity",
"(",
"IdentityConstants",
".",
"ANONIM",
",",
"new",
"HashSet",
"<",
"MembershipEntry",
">",
"(",
")",
")",
";",
"return",
"new",
"SessionPr... | Helper for creating Anonymous session provider.
@return an anonymous session provider | [
"Helper",
"for",
"creating",
"Anonymous",
"session",
"provider",
"."
] | train | https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/common/SessionProvider.java#L128-L132 |
belaban/jgroups-raft | src/org/jgroups/raft/blocks/ReplicatedStateMachine.java | ReplicatedStateMachine.put | public V put(K key, V val) throws Exception {
return invoke(PUT, key, val, false);
} | java | public V put(K key, V val) throws Exception {
return invoke(PUT, key, val, false);
} | [
"public",
"V",
"put",
"(",
"K",
"key",
",",
"V",
"val",
")",
"throws",
"Exception",
"{",
"return",
"invoke",
"(",
"PUT",
",",
"key",
",",
"val",
",",
"false",
")",
";",
"}"
] | Adds a key value pair to the state machine. The data is not added directly, but sent to the RAFT leader and only
added to the hashmap after the change has been committed (by majority decision). The actual change will be
applied with callback {@link #apply(byte[],int,int)}.
@param key The key to be added.
@param val The value to be added
@return Null, or the previous value associated with key (if present) | [
"Adds",
"a",
"key",
"value",
"pair",
"to",
"the",
"state",
"machine",
".",
"The",
"data",
"is",
"not",
"added",
"directly",
"but",
"sent",
"to",
"the",
"RAFT",
"leader",
"and",
"only",
"added",
"to",
"the",
"hashmap",
"after",
"the",
"change",
"has",
"... | train | https://github.com/belaban/jgroups-raft/blob/5923a4761df50bfd203cc82cefc138694b4d7fc3/src/org/jgroups/raft/blocks/ReplicatedStateMachine.java#L130-L132 |
zxing/zxing | core/src/main/java/com/google/zxing/aztec/detector/Detector.java | Detector.getColor | private int getColor(Point p1, Point p2) {
float d = distance(p1, p2);
float dx = (p2.getX() - p1.getX()) / d;
float dy = (p2.getY() - p1.getY()) / d;
int error = 0;
float px = p1.getX();
float py = p1.getY();
boolean colorModel = image.get(p1.getX(), p1.getY());
int iMax = (int) Math.ceil(d);
for (int i = 0; i < iMax; i++) {
px += dx;
py += dy;
if (image.get(MathUtils.round(px), MathUtils.round(py)) != colorModel) {
error++;
}
}
float errRatio = error / d;
if (errRatio > 0.1f && errRatio < 0.9f) {
return 0;
}
return (errRatio <= 0.1f) == colorModel ? 1 : -1;
} | java | private int getColor(Point p1, Point p2) {
float d = distance(p1, p2);
float dx = (p2.getX() - p1.getX()) / d;
float dy = (p2.getY() - p1.getY()) / d;
int error = 0;
float px = p1.getX();
float py = p1.getY();
boolean colorModel = image.get(p1.getX(), p1.getY());
int iMax = (int) Math.ceil(d);
for (int i = 0; i < iMax; i++) {
px += dx;
py += dy;
if (image.get(MathUtils.round(px), MathUtils.round(py)) != colorModel) {
error++;
}
}
float errRatio = error / d;
if (errRatio > 0.1f && errRatio < 0.9f) {
return 0;
}
return (errRatio <= 0.1f) == colorModel ? 1 : -1;
} | [
"private",
"int",
"getColor",
"(",
"Point",
"p1",
",",
"Point",
"p2",
")",
"{",
"float",
"d",
"=",
"distance",
"(",
"p1",
",",
"p2",
")",
";",
"float",
"dx",
"=",
"(",
"p2",
".",
"getX",
"(",
")",
"-",
"p1",
".",
"getX",
"(",
")",
")",
"/",
... | Gets the color of a segment
@return 1 if segment more than 90% black, -1 if segment is more than 90% white, 0 else | [
"Gets",
"the",
"color",
"of",
"a",
"segment"
] | train | https://github.com/zxing/zxing/blob/653ac2a3beb11481eff82e7d5f2bab8a745f7fac/core/src/main/java/com/google/zxing/aztec/detector/Detector.java#L462-L489 |
czyzby/gdx-lml | kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/collection/lazy/LazyObjectMap.java | LazyObjectMap.get | @Override
@Deprecated
public Value get(final Key key, final Value defaultValue) {
return super.get(key, defaultValue);
} | java | @Override
@Deprecated
public Value get(final Key key, final Value defaultValue) {
return super.get(key, defaultValue);
} | [
"@",
"Override",
"@",
"Deprecated",
"public",
"Value",
"get",
"(",
"final",
"Key",
"key",
",",
"final",
"Value",
"defaultValue",
")",
"{",
"return",
"super",
".",
"get",
"(",
"key",
",",
"defaultValue",
")",
";",
"}"
] | LazyObjectMap initiates values on access. No need for default values, as nulls are impossible as long as the
provided is correctly implemented and nulls are not put into the map.
@param key selected key.
@param defaultValue returned if no value is set for the key. | [
"LazyObjectMap",
"initiates",
"values",
"on",
"access",
".",
"No",
"need",
"for",
"default",
"values",
"as",
"nulls",
"are",
"impossible",
"as",
"long",
"as",
"the",
"provided",
"is",
"correctly",
"implemented",
"and",
"nulls",
"are",
"not",
"put",
"into",
"... | train | https://github.com/czyzby/gdx-lml/blob/7623b322e6afe49ad4dd636c80c230150a1cfa4e/kiwi/src/main/java/com/github/czyzby/kiwi/util/gdx/collection/lazy/LazyObjectMap.java#L165-L169 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToStream.java | ToStream.internalEntityDecl | public void internalEntityDecl(String name, String value)
throws SAXException
{
// Do not inline external DTD
if (m_inExternalDTD)
return;
try
{
DTDprolog();
outputEntityDecl(name, value);
}
catch (IOException e)
{
throw new SAXException(e);
}
} | java | public void internalEntityDecl(String name, String value)
throws SAXException
{
// Do not inline external DTD
if (m_inExternalDTD)
return;
try
{
DTDprolog();
outputEntityDecl(name, value);
}
catch (IOException e)
{
throw new SAXException(e);
}
} | [
"public",
"void",
"internalEntityDecl",
"(",
"String",
"name",
",",
"String",
"value",
")",
"throws",
"SAXException",
"{",
"// Do not inline external DTD",
"if",
"(",
"m_inExternalDTD",
")",
"return",
";",
"try",
"{",
"DTDprolog",
"(",
")",
";",
"outputEntityDecl"... | Report an internal entity declaration.
<p>Only the effective (first) declaration for each entity
will be reported.</p>
@param name The name of the entity. If it is a parameter
entity, the name will begin with '%'.
@param value The replacement text of the entity.
@exception SAXException The application may raise an exception.
@see #externalEntityDecl
@see org.xml.sax.DTDHandler#unparsedEntityDecl | [
"Report",
"an",
"internal",
"entity",
"declaration",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/serializer/ToStream.java#L337-L353 |
52inc/android-52Kit | library/src/main/java/com/ftinc/kit/util/MediaUtils.java | MediaUtils.grantPermissions | private static void grantPermissions(Context ctx, Uri uri){
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
List<ResolveInfo> resolvedIntentActivities = ctx.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolvedIntentInfo : resolvedIntentActivities) {
String packageName = resolvedIntentInfo.activityInfo.packageName;
// Grant Permissions
ctx.grantUriPermission(packageName, uri,
Intent.FLAG_GRANT_WRITE_URI_PERMISSION |
Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
} | java | private static void grantPermissions(Context ctx, Uri uri){
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
List<ResolveInfo> resolvedIntentActivities = ctx.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolvedIntentInfo : resolvedIntentActivities) {
String packageName = resolvedIntentInfo.activityInfo.packageName;
// Grant Permissions
ctx.grantUriPermission(packageName, uri,
Intent.FLAG_GRANT_WRITE_URI_PERMISSION |
Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
} | [
"private",
"static",
"void",
"grantPermissions",
"(",
"Context",
"ctx",
",",
"Uri",
"uri",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"MediaStore",
".",
"ACTION_IMAGE_CAPTURE",
")",
";",
"List",
"<",
"ResolveInfo",
">",
"resolvedIntentActivities",
... | Grant URI permissions for all potential camera applications that can handle the capture
intent. | [
"Grant",
"URI",
"permissions",
"for",
"all",
"potential",
"camera",
"applications",
"that",
"can",
"handle",
"the",
"capture",
"intent",
"."
] | train | https://github.com/52inc/android-52Kit/blob/8644fab0f633477b1bb1dddd8147a9ef8bc03516/library/src/main/java/com/ftinc/kit/util/MediaUtils.java#L255-L266 |
liferay/com-liferay-commerce | commerce-price-list-service/src/main/java/com/liferay/commerce/price/list/service/persistence/impl/CommercePriceEntryPersistenceImpl.java | CommercePriceEntryPersistenceImpl.findAll | @Override
public List<CommercePriceEntry> findAll(int start, int end) {
return findAll(start, end, null);
} | java | @Override
public List<CommercePriceEntry> findAll(int start, int end) {
return findAll(start, end, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommercePriceEntry",
">",
"findAll",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"findAll",
"(",
"start",
",",
"end",
",",
"null",
")",
";",
"}"
] | Returns a range of all the commerce price entries.
<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 CommercePriceEntryModelImpl}. 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 price entries
@param end the upper bound of the range of commerce price entries (not inclusive)
@return the range of commerce price entries | [
"Returns",
"a",
"range",
"of",
"all",
"the",
"commerce",
"price",
"entries",
"."
] | 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#L4915-L4918 |
google/closure-compiler | src/com/google/javascript/jscomp/NodeTraversal.java | NodeTraversal.pushScope | private void pushScope(AbstractScope<?, ?> s, boolean quietly) {
checkNotNull(curNode);
scopes.push(s);
recordScopeRoot(s.getRootNode());
if (!quietly && scopeCallback != null) {
scopeCallback.enterScope(this);
}
} | java | private void pushScope(AbstractScope<?, ?> s, boolean quietly) {
checkNotNull(curNode);
scopes.push(s);
recordScopeRoot(s.getRootNode());
if (!quietly && scopeCallback != null) {
scopeCallback.enterScope(this);
}
} | [
"private",
"void",
"pushScope",
"(",
"AbstractScope",
"<",
"?",
",",
"?",
">",
"s",
",",
"boolean",
"quietly",
")",
"{",
"checkNotNull",
"(",
"curNode",
")",
";",
"scopes",
".",
"push",
"(",
"s",
")",
";",
"recordScopeRoot",
"(",
"s",
".",
"getRootNode... | Creates a new scope (e.g. when entering a function).
@param quietly Don't fire an enterScope callback. | [
"Creates",
"a",
"new",
"scope",
"(",
"e",
".",
"g",
".",
"when",
"entering",
"a",
"function",
")",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/NodeTraversal.java#L1026-L1033 |
Wadpam/guja | guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java | GeneratedDContactDaoImpl.queryByLinkedIn | public Iterable<DContact> queryByLinkedIn(Object parent, java.lang.String linkedIn) {
return queryByField(parent, DContactMapper.Field.LINKEDIN.getFieldName(), linkedIn);
} | java | public Iterable<DContact> queryByLinkedIn(Object parent, java.lang.String linkedIn) {
return queryByField(parent, DContactMapper.Field.LINKEDIN.getFieldName(), linkedIn);
} | [
"public",
"Iterable",
"<",
"DContact",
">",
"queryByLinkedIn",
"(",
"Object",
"parent",
",",
"java",
".",
"lang",
".",
"String",
"linkedIn",
")",
"{",
"return",
"queryByField",
"(",
"parent",
",",
"DContactMapper",
".",
"Field",
".",
"LINKEDIN",
".",
"getFie... | query-by method for field linkedIn
@param linkedIn the specified attribute
@return an Iterable of DContacts for the specified linkedIn | [
"query",
"-",
"by",
"method",
"for",
"field",
"linkedIn"
] | train | https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java#L205-L207 |
couchbase/couchbase-lite-java | src/main/java/com/couchbase/lite/AbstractDatabase.java | AbstractDatabase.addDocumentChangeListener | @NonNull
public ListenerToken addDocumentChangeListener(
@NonNull String id,
Executor executor,
@NonNull DocumentChangeListener listener) {
if (id == null) { throw new IllegalArgumentException("id cannot be null."); }
if (listener == null) { throw new IllegalArgumentException("listener cannot be null."); }
synchronized (lock) {
mustBeOpen();
return addDocumentChangeListener(executor, listener, id);
}
} | java | @NonNull
public ListenerToken addDocumentChangeListener(
@NonNull String id,
Executor executor,
@NonNull DocumentChangeListener listener) {
if (id == null) { throw new IllegalArgumentException("id cannot be null."); }
if (listener == null) { throw new IllegalArgumentException("listener cannot be null."); }
synchronized (lock) {
mustBeOpen();
return addDocumentChangeListener(executor, listener, id);
}
} | [
"@",
"NonNull",
"public",
"ListenerToken",
"addDocumentChangeListener",
"(",
"@",
"NonNull",
"String",
"id",
",",
"Executor",
"executor",
",",
"@",
"NonNull",
"DocumentChangeListener",
"listener",
")",
"{",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"throw",
"ne... | Add the given DocumentChangeListener to the specified document with an executor on which
the changes will be posted to the listener. | [
"Add",
"the",
"given",
"DocumentChangeListener",
"to",
"the",
"specified",
"document",
"with",
"an",
"executor",
"on",
"which",
"the",
"changes",
"will",
"be",
"posted",
"to",
"the",
"listener",
"."
] | train | https://github.com/couchbase/couchbase-lite-java/blob/cb72c44186456e6191a9ad0a7feb310011d0b081/src/main/java/com/couchbase/lite/AbstractDatabase.java#L665-L677 |
windup/windup | rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/JmsDestinationService.java | JmsDestinationService.createUnique | public JmsDestinationModel createUnique(Set<ProjectModel> applications, String jndiName, String destinationTypeClass)
{
JmsDestinationType destinationType = JmsDestinationService.getTypeFromClass(destinationTypeClass);
return this.createUnique(applications, jndiName, destinationType);
} | java | public JmsDestinationModel createUnique(Set<ProjectModel> applications, String jndiName, String destinationTypeClass)
{
JmsDestinationType destinationType = JmsDestinationService.getTypeFromClass(destinationTypeClass);
return this.createUnique(applications, jndiName, destinationType);
} | [
"public",
"JmsDestinationModel",
"createUnique",
"(",
"Set",
"<",
"ProjectModel",
">",
"applications",
",",
"String",
"jndiName",
",",
"String",
"destinationTypeClass",
")",
"{",
"JmsDestinationType",
"destinationType",
"=",
"JmsDestinationService",
".",
"getTypeFromClass... | Creates a new instance with the given name, or converts an existing instance at this location if one already exists | [
"Creates",
"a",
"new",
"instance",
"with",
"the",
"given",
"name",
"or",
"converts",
"an",
"existing",
"instance",
"at",
"this",
"location",
"if",
"one",
"already",
"exists"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/JmsDestinationService.java#L35-L40 |
HanSolo/SteelSeries-Swing | src/main/java/eu/hansolo/steelseries/tools/GradientWrapper.java | GradientWrapper.getColorAt | public Color getColorAt(final float FRACTION) {
float fraction = FRACTION < 0f ? 0f : (FRACTION > 1f ? 1f : FRACTION);
float lowerLimit = 0f;
int lowerIndex = 0;
float upperLimit = 1f;
int upperIndex = 1;
int index = 0;
for (float currentFraction : fractions) {
if (Float.compare(currentFraction, fraction) < 0) {
lowerLimit = currentFraction;
lowerIndex = index;
}
if (Float.compare(currentFraction, fraction) == 0) {
return colors[index];
}
if (Float.compare(currentFraction, fraction) > 0) {
upperLimit = currentFraction;
upperIndex = index;
break;
}
index++;
}
float interpolationFraction = (fraction - lowerLimit) / (upperLimit - lowerLimit);
return interpolateColor(colors[lowerIndex], colors[upperIndex], interpolationFraction);
} | java | public Color getColorAt(final float FRACTION) {
float fraction = FRACTION < 0f ? 0f : (FRACTION > 1f ? 1f : FRACTION);
float lowerLimit = 0f;
int lowerIndex = 0;
float upperLimit = 1f;
int upperIndex = 1;
int index = 0;
for (float currentFraction : fractions) {
if (Float.compare(currentFraction, fraction) < 0) {
lowerLimit = currentFraction;
lowerIndex = index;
}
if (Float.compare(currentFraction, fraction) == 0) {
return colors[index];
}
if (Float.compare(currentFraction, fraction) > 0) {
upperLimit = currentFraction;
upperIndex = index;
break;
}
index++;
}
float interpolationFraction = (fraction - lowerLimit) / (upperLimit - lowerLimit);
return interpolateColor(colors[lowerIndex], colors[upperIndex], interpolationFraction);
} | [
"public",
"Color",
"getColorAt",
"(",
"final",
"float",
"FRACTION",
")",
"{",
"float",
"fraction",
"=",
"FRACTION",
"<",
"0f",
"?",
"0f",
":",
"(",
"FRACTION",
">",
"1f",
"?",
"1f",
":",
"FRACTION",
")",
";",
"float",
"lowerLimit",
"=",
"0f",
";",
"i... | Returns the color that is defined by the given fraction in the linear gradient paint
@param FRACTION
@return the color that is defined by the given fraction in the linear gradient paint | [
"Returns",
"the",
"color",
"that",
"is",
"defined",
"by",
"the",
"given",
"fraction",
"in",
"the",
"linear",
"gradient",
"paint"
] | train | https://github.com/HanSolo/SteelSeries-Swing/blob/c2f7b45a477757ef21bbb6a1174ddedb2250ae57/src/main/java/eu/hansolo/steelseries/tools/GradientWrapper.java#L109-L136 |
OpenLiberty/open-liberty | dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/admin/internal/JsLocalizer.java | JsLocalizer.deleteLocalizationPoint | public void deleteLocalizationPoint(JsBus bus, LWMConfig dest) throws SIBExceptionBase, SIException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.entry(tc, "deleteLocalizationPoint", ((BaseDestination)dest).getName());
}
DestinationDefinition destDef = (DestinationDefinition) _me.getSIBDestination(bus.getName(), ((SIBDestination) dest).getName());
if (destDef == null) {
missingDestinations.add(destDef.getName());
}
if (!isInZOSServentRegion() && _mpAdmin != null) {
alterDestinations.add(destDef.getName());
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
SibTr.debug(tc, "unlocalize: Dest unlocalized on existing destination deferring alter until end, Destination Name=" + destDef.getName());
}
// Now add code to call administrator to delete destination localization
deleteDestLocalizations(bus);
alterDestinations.remove(destDef.getName());
unlocalize(destDef);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "deleteLocalizationPoint");
} | java | public void deleteLocalizationPoint(JsBus bus, LWMConfig dest) throws SIBExceptionBase, SIException {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
SibTr.entry(tc, "deleteLocalizationPoint", ((BaseDestination)dest).getName());
}
DestinationDefinition destDef = (DestinationDefinition) _me.getSIBDestination(bus.getName(), ((SIBDestination) dest).getName());
if (destDef == null) {
missingDestinations.add(destDef.getName());
}
if (!isInZOSServentRegion() && _mpAdmin != null) {
alterDestinations.add(destDef.getName());
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
SibTr.debug(tc, "unlocalize: Dest unlocalized on existing destination deferring alter until end, Destination Name=" + destDef.getName());
}
// Now add code to call administrator to delete destination localization
deleteDestLocalizations(bus);
alterDestinations.remove(destDef.getName());
unlocalize(destDef);
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "deleteLocalizationPoint");
} | [
"public",
"void",
"deleteLocalizationPoint",
"(",
"JsBus",
"bus",
",",
"LWMConfig",
"dest",
")",
"throws",
"SIBExceptionBase",
",",
"SIException",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")"... | Delete a given localization point, this will normally involve altering the
destination localization held by mp, unless the associated
DestinationDefinition has gone, in which case the DestinationDefinition
will be flagged for deletion. The deletetion will occure in the endUpdate()
method which will be called after all create/alter/delete operations have
occured. This method is used by dynamic config.
@param lp
@throws SIException
@throws SIBExceptionBase | [
"Delete",
"a",
"given",
"localization",
"point",
"this",
"will",
"normally",
"involve",
"altering",
"the",
"destination",
"localization",
"held",
"by",
"mp",
"unless",
"the",
"associated",
"DestinationDefinition",
"has",
"gone",
"in",
"which",
"case",
"the",
"Dest... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.runtime/src/com/ibm/ws/sib/admin/internal/JsLocalizer.java#L432-L454 |
moparisthebest/beehive | beehive-netui-tags/src/main/java/org/apache/beehive/netui/databinding/datagrid/api/DataGridStateFactory.java | DataGridStateFactory.getDataGridState | public final DataGridState getDataGridState(String name, DataGridConfig config) {
if(config == null)
throw new IllegalArgumentException(Bundle.getErrorString("DataGridStateFactory_nullDataGridConfig"));
DataGridStateCodec codec = lookupCodec(name, config);
DataGridState state = codec.getDataGridState();
return state;
} | java | public final DataGridState getDataGridState(String name, DataGridConfig config) {
if(config == null)
throw new IllegalArgumentException(Bundle.getErrorString("DataGridStateFactory_nullDataGridConfig"));
DataGridStateCodec codec = lookupCodec(name, config);
DataGridState state = codec.getDataGridState();
return state;
} | [
"public",
"final",
"DataGridState",
"getDataGridState",
"(",
"String",
"name",
",",
"DataGridConfig",
"config",
")",
"{",
"if",
"(",
"config",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"Bundle",
".",
"getErrorString",
"(",
"\"DataGridStat... | <p>
Lookup a {@link DataGridState} object given a data grid identifier and a specific
{@link DataGridConfig} object.
</p>
@param name the name of the data grid
@param config the {@link DataGridConfig} object to use when creating the
grid's {@link DataGridState} object.
@return the data grid state object | [
"<p",
">",
"Lookup",
"a",
"{",
"@link",
"DataGridState",
"}",
"object",
"given",
"a",
"data",
"grid",
"identifier",
"and",
"a",
"specific",
"{",
"@link",
"DataGridConfig",
"}",
"object",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/moparisthebest/beehive/blob/4246a0cc40ce3c05f1a02c2da2653ac622703d77/beehive-netui-tags/src/main/java/org/apache/beehive/netui/databinding/datagrid/api/DataGridStateFactory.java#L115-L122 |
sdl/odata | odata_renderer/src/main/java/com/sdl/odata/unmarshaller/json/ODataJsonParser.java | ODataJsonParser.setEntityNavigationProperties | protected void setEntityNavigationProperties(Object entity, StructuredType entityType) throws ODataException {
for (Map.Entry<String, Object> entry : links.entrySet()) {
String propertyName = entry.getKey();
Object entryLinks = entry.getValue();
LOG.debug("Found link for navigation property: {}", propertyName);
StructuralProperty property = entityType.getStructuralProperty(propertyName);
if (!(property instanceof NavigationProperty)) {
throw new ODataUnmarshallingException("The request contains a navigation link '" + propertyName +
"' but the entity type '" + entityType + "' does not contain a navigation property " +
"with this name.");
}
// Note: The links are processed a bit differently depending on whether we are parsing in the context
// of a 'write operation' or 'read operation'. Only in the case of a 'write operation' it is necessary
// to resolve the referenced entity.
if (isWriteOperation()) {
// Get the referenced entity(es), but only with the key fields filled in
if (entryLinks instanceof List) {
List<String> linksList = (List<String>) entryLinks;
for (String link : linksList) {
Object referencedEntity = getReferencedEntity(link, propertyName);
LOG.debug("Referenced entity: {}", referencedEntity);
saveReferencedEntity(entity, propertyName, property, referencedEntity);
}
} else {
Object referencedEntity = getReferencedEntity((String) entryLinks, propertyName);
LOG.debug("Referenced entity: {}", referencedEntity);
saveReferencedEntity(entity, propertyName, property, referencedEntity);
}
}
}
} | java | protected void setEntityNavigationProperties(Object entity, StructuredType entityType) throws ODataException {
for (Map.Entry<String, Object> entry : links.entrySet()) {
String propertyName = entry.getKey();
Object entryLinks = entry.getValue();
LOG.debug("Found link for navigation property: {}", propertyName);
StructuralProperty property = entityType.getStructuralProperty(propertyName);
if (!(property instanceof NavigationProperty)) {
throw new ODataUnmarshallingException("The request contains a navigation link '" + propertyName +
"' but the entity type '" + entityType + "' does not contain a navigation property " +
"with this name.");
}
// Note: The links are processed a bit differently depending on whether we are parsing in the context
// of a 'write operation' or 'read operation'. Only in the case of a 'write operation' it is necessary
// to resolve the referenced entity.
if (isWriteOperation()) {
// Get the referenced entity(es), but only with the key fields filled in
if (entryLinks instanceof List) {
List<String> linksList = (List<String>) entryLinks;
for (String link : linksList) {
Object referencedEntity = getReferencedEntity(link, propertyName);
LOG.debug("Referenced entity: {}", referencedEntity);
saveReferencedEntity(entity, propertyName, property, referencedEntity);
}
} else {
Object referencedEntity = getReferencedEntity((String) entryLinks, propertyName);
LOG.debug("Referenced entity: {}", referencedEntity);
saveReferencedEntity(entity, propertyName, property, referencedEntity);
}
}
}
} | [
"protected",
"void",
"setEntityNavigationProperties",
"(",
"Object",
"entity",
",",
"StructuredType",
"entityType",
")",
"throws",
"ODataException",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"links",
".",
"entrySet",
... | Sets the given entity with navigation links.
@param entity entity
@param entityType the entity type
@throws ODataException If unable to set navigation properties | [
"Sets",
"the",
"given",
"entity",
"with",
"navigation",
"links",
"."
] | train | https://github.com/sdl/odata/blob/eb747d73e9af0f4e59a25b82ed656e526a7e2189/odata_renderer/src/main/java/com/sdl/odata/unmarshaller/json/ODataJsonParser.java#L136-L168 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java | WalletProtobufSerializer.readWallet | public Wallet readWallet(InputStream input, boolean forceReset, @Nullable WalletExtension[] extensions) throws UnreadableWalletException {
try {
Protos.Wallet walletProto = parseToProto(input);
final String paramsID = walletProto.getNetworkIdentifier();
NetworkParameters params = NetworkParameters.fromID(paramsID);
if (params == null)
throw new UnreadableWalletException("Unknown network parameters ID " + paramsID);
return readWallet(params, extensions, walletProto, forceReset);
} catch (IOException e) {
throw new UnreadableWalletException("Could not parse input stream to protobuf", e);
} catch (IllegalStateException e) {
throw new UnreadableWalletException("Could not parse input stream to protobuf", e);
} catch (IllegalArgumentException e) {
throw new UnreadableWalletException("Could not parse input stream to protobuf", e);
}
} | java | public Wallet readWallet(InputStream input, boolean forceReset, @Nullable WalletExtension[] extensions) throws UnreadableWalletException {
try {
Protos.Wallet walletProto = parseToProto(input);
final String paramsID = walletProto.getNetworkIdentifier();
NetworkParameters params = NetworkParameters.fromID(paramsID);
if (params == null)
throw new UnreadableWalletException("Unknown network parameters ID " + paramsID);
return readWallet(params, extensions, walletProto, forceReset);
} catch (IOException e) {
throw new UnreadableWalletException("Could not parse input stream to protobuf", e);
} catch (IllegalStateException e) {
throw new UnreadableWalletException("Could not parse input stream to protobuf", e);
} catch (IllegalArgumentException e) {
throw new UnreadableWalletException("Could not parse input stream to protobuf", e);
}
} | [
"public",
"Wallet",
"readWallet",
"(",
"InputStream",
"input",
",",
"boolean",
"forceReset",
",",
"@",
"Nullable",
"WalletExtension",
"[",
"]",
"extensions",
")",
"throws",
"UnreadableWalletException",
"{",
"try",
"{",
"Protos",
".",
"Wallet",
"walletProto",
"=",
... | <p>Loads wallet data from the given protocol buffer and inserts it into the given Wallet object. This is primarily
useful when you wish to pre-register extension objects. Note that if loading fails the provided Wallet object
may be in an indeterminate state and should be thrown away. Do not simply call this method again on the same
Wallet object with {@code forceReset} set {@code true}. It won't work.</p>
<p>If {@code forceReset} is {@code true}, then no transactions are loaded from the wallet, and it is configured
to replay transactions from the blockchain (as if the wallet had been loaded and {@link Wallet#reset()}
had been called immediately thereafter).
<p>A wallet can be unreadable for various reasons, such as inability to open the file, corrupt data, internally
inconsistent data, a wallet extension marked as mandatory that cannot be handled and so on. You should always
handle {@link UnreadableWalletException} and communicate failure to the user in an appropriate manner.</p>
@throws UnreadableWalletException thrown in various error conditions (see description). | [
"<p",
">",
"Loads",
"wallet",
"data",
"from",
"the",
"given",
"protocol",
"buffer",
"and",
"inserts",
"it",
"into",
"the",
"given",
"Wallet",
"object",
".",
"This",
"is",
"primarily",
"useful",
"when",
"you",
"wish",
"to",
"pre",
"-",
"register",
"extensio... | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/wallet/WalletProtobufSerializer.java#L439-L454 |
line/centraldogma | server-auth/shiro/src/main/java/com/linecorp/centraldogma/server/auth/shiro/LoginService.java | LoginService.usernamePassword | private UsernamePasswordToken usernamePassword(ServiceRequestContext ctx, AggregatedHttpMessage req) {
// check the Basic HTTP authentication first (https://tools.ietf.org/html/rfc7617)
final BasicToken basicToken = AuthTokenExtractors.BASIC.apply(req.headers());
if (basicToken != null) {
return new UsernamePasswordToken(basicToken.username(), basicToken.password());
}
final MediaType mediaType = req.headers().contentType();
if (mediaType != MediaType.FORM_DATA) {
return throwResponse(ctx, HttpStatus.BAD_REQUEST,
"The content type of a login request must be '%s'.", MediaType.FORM_DATA);
}
final Map<String, List<String>> parameters = new QueryStringDecoder(req.contentUtf8(),
false).parameters();
// assume that the grant_type is "password"
final List<String> usernames = parameters.get("username");
final List<String> passwords = parameters.get("password");
if (usernames != null && passwords != null) {
final String username = usernames.get(0);
final String password = passwords.get(0);
return new UsernamePasswordToken(loginNameNormalizer.apply(username), password);
}
return throwResponse(ctx, HttpStatus.BAD_REQUEST,
"A login request must contain username and password.");
} | java | private UsernamePasswordToken usernamePassword(ServiceRequestContext ctx, AggregatedHttpMessage req) {
// check the Basic HTTP authentication first (https://tools.ietf.org/html/rfc7617)
final BasicToken basicToken = AuthTokenExtractors.BASIC.apply(req.headers());
if (basicToken != null) {
return new UsernamePasswordToken(basicToken.username(), basicToken.password());
}
final MediaType mediaType = req.headers().contentType();
if (mediaType != MediaType.FORM_DATA) {
return throwResponse(ctx, HttpStatus.BAD_REQUEST,
"The content type of a login request must be '%s'.", MediaType.FORM_DATA);
}
final Map<String, List<String>> parameters = new QueryStringDecoder(req.contentUtf8(),
false).parameters();
// assume that the grant_type is "password"
final List<String> usernames = parameters.get("username");
final List<String> passwords = parameters.get("password");
if (usernames != null && passwords != null) {
final String username = usernames.get(0);
final String password = passwords.get(0);
return new UsernamePasswordToken(loginNameNormalizer.apply(username), password);
}
return throwResponse(ctx, HttpStatus.BAD_REQUEST,
"A login request must contain username and password.");
} | [
"private",
"UsernamePasswordToken",
"usernamePassword",
"(",
"ServiceRequestContext",
"ctx",
",",
"AggregatedHttpMessage",
"req",
")",
"{",
"// check the Basic HTTP authentication first (https://tools.ietf.org/html/rfc7617)",
"final",
"BasicToken",
"basicToken",
"=",
"AuthTokenExtrac... | Returns {@link UsernamePasswordToken} which holds a username and a password. | [
"Returns",
"{"
] | train | https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server-auth/shiro/src/main/java/com/linecorp/centraldogma/server/auth/shiro/LoginService.java#L155-L181 |
shrinkwrap/descriptors | metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/Metadata.java | Metadata.addGroupReference | public void addGroupReference(final String groupName, final MetadataElement groupReference) {
groupReference.setRef(getNamespaceValue(groupReference.getRef()));
for (MetadataItem item : groupList) {
if (item.getName().equals(groupName) && item.getNamespace().equals(getCurrentNamespace())) {
item.getReferences().add(groupReference);
return;
}
}
final MetadataItem newItem = new MetadataItem(groupName);
newItem.getReferences().add(groupReference);
newItem.setNamespace(getCurrentNamespace());
newItem.setSchemaName(getCurrentSchmema());
newItem.setPackageApi(getCurrentPackageApi());
newItem.setPackageImpl(getCurrentPackageImpl());
groupList.add(newItem);
} | java | public void addGroupReference(final String groupName, final MetadataElement groupReference) {
groupReference.setRef(getNamespaceValue(groupReference.getRef()));
for (MetadataItem item : groupList) {
if (item.getName().equals(groupName) && item.getNamespace().equals(getCurrentNamespace())) {
item.getReferences().add(groupReference);
return;
}
}
final MetadataItem newItem = new MetadataItem(groupName);
newItem.getReferences().add(groupReference);
newItem.setNamespace(getCurrentNamespace());
newItem.setSchemaName(getCurrentSchmema());
newItem.setPackageApi(getCurrentPackageApi());
newItem.setPackageImpl(getCurrentPackageImpl());
groupList.add(newItem);
} | [
"public",
"void",
"addGroupReference",
"(",
"final",
"String",
"groupName",
",",
"final",
"MetadataElement",
"groupReference",
")",
"{",
"groupReference",
".",
"setRef",
"(",
"getNamespaceValue",
"(",
"groupReference",
".",
"getRef",
"(",
")",
")",
")",
";",
"fo... | Adds a new reference to the specific group element class. If no group element class is found, then a new group
element class. will be created.
@param groupName
the group class name of
@param groupReference
the new reference to be added. | [
"Adds",
"a",
"new",
"reference",
"to",
"the",
"specific",
"group",
"element",
"class",
".",
"If",
"no",
"group",
"element",
"class",
"is",
"found",
"then",
"a",
"new",
"group",
"element",
"class",
".",
"will",
"be",
"created",
"."
] | train | https://github.com/shrinkwrap/descriptors/blob/023ba080e6396b9f4dd8275dc4e5c0ebb6b5e6ba/metadata-parser/src/main/java/org/jboss/shrinkwrap/descriptor/metadata/Metadata.java#L169-L185 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/vod/VodClient.java | VodClient.listMediaResources | public ListMediaResourceResponse listMediaResources(ListMediaResourceRequest request) {
checkIsTrue(request.getPageNo() > 0, "pageNo should greater than 0!");
InternalRequest internalRequest =
createRequest(HttpMethodName.GET, request, PATH_MEDIA);
internalRequest.addParameter(PARA_PAGENO, String.valueOf(request.getPageNo()));
internalRequest.addParameter(PARA_PAGESIZE, String.valueOf(request.getPageSize()));
if (request.getStatus() != null) {
internalRequest.addParameter(PARA_STATUS, request.getStatus());
}
if (request.getBegin() != null) {
internalRequest.addParameter(PARA_BEGIN, DateUtils.formatAlternateIso8601Date(request.getBegin()));
}
if (request.getEnd() != null) {
internalRequest.addParameter(PARA_END, DateUtils.formatAlternateIso8601Date(request.getEnd()));
}
if (request.getTitle() != null) {
internalRequest.addParameter(PARA_TITLE, request.getTitle());
}
return invokeHttpClient(internalRequest, ListMediaResourceResponse.class);
} | java | public ListMediaResourceResponse listMediaResources(ListMediaResourceRequest request) {
checkIsTrue(request.getPageNo() > 0, "pageNo should greater than 0!");
InternalRequest internalRequest =
createRequest(HttpMethodName.GET, request, PATH_MEDIA);
internalRequest.addParameter(PARA_PAGENO, String.valueOf(request.getPageNo()));
internalRequest.addParameter(PARA_PAGESIZE, String.valueOf(request.getPageSize()));
if (request.getStatus() != null) {
internalRequest.addParameter(PARA_STATUS, request.getStatus());
}
if (request.getBegin() != null) {
internalRequest.addParameter(PARA_BEGIN, DateUtils.formatAlternateIso8601Date(request.getBegin()));
}
if (request.getEnd() != null) {
internalRequest.addParameter(PARA_END, DateUtils.formatAlternateIso8601Date(request.getEnd()));
}
if (request.getTitle() != null) {
internalRequest.addParameter(PARA_TITLE, request.getTitle());
}
return invokeHttpClient(internalRequest, ListMediaResourceResponse.class);
} | [
"public",
"ListMediaResourceResponse",
"listMediaResources",
"(",
"ListMediaResourceRequest",
"request",
")",
"{",
"checkIsTrue",
"(",
"request",
".",
"getPageNo",
"(",
")",
">",
"0",
",",
"\"pageNo should greater than 0!\"",
")",
";",
"InternalRequest",
"internalRequest"... | List the properties of all media resource managed by VOD service.
<p>
The caller <i>must</i> authenticate with a valid BCE Access Key / Private Key pair.
@param request The request wrapper object containing all options.
@return The properties of all specific media resources | [
"List",
"the",
"properties",
"of",
"all",
"media",
"resource",
"managed",
"by",
"VOD",
"service",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/vod/VodClient.java#L537-L558 |
wdullaer/SwipeActionAdapter | library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java | SwipeViewGroup.showBackground | public void showBackground(SwipeDirection direction, boolean dimBackground){
if(SwipeDirection.DIRECTION_NEUTRAL != direction && mBackgroundMap.get(direction) == null) return;
if(SwipeDirection.DIRECTION_NEUTRAL != visibleView)
mBackgroundMap.get(visibleView).setVisibility(View.INVISIBLE);
if(SwipeDirection.DIRECTION_NEUTRAL != direction) {
mBackgroundMap.get(direction).setVisibility(View.VISIBLE);
mBackgroundMap.get(direction).setAlpha(dimBackground ? 0.4f : 1);
}
visibleView = direction;
} | java | public void showBackground(SwipeDirection direction, boolean dimBackground){
if(SwipeDirection.DIRECTION_NEUTRAL != direction && mBackgroundMap.get(direction) == null) return;
if(SwipeDirection.DIRECTION_NEUTRAL != visibleView)
mBackgroundMap.get(visibleView).setVisibility(View.INVISIBLE);
if(SwipeDirection.DIRECTION_NEUTRAL != direction) {
mBackgroundMap.get(direction).setVisibility(View.VISIBLE);
mBackgroundMap.get(direction).setAlpha(dimBackground ? 0.4f : 1);
}
visibleView = direction;
} | [
"public",
"void",
"showBackground",
"(",
"SwipeDirection",
"direction",
",",
"boolean",
"dimBackground",
")",
"{",
"if",
"(",
"SwipeDirection",
".",
"DIRECTION_NEUTRAL",
"!=",
"direction",
"&&",
"mBackgroundMap",
".",
"get",
"(",
"direction",
")",
"==",
"null",
... | Show the View linked to a key. Don't do anything if the key is not found
@param direction The key of the View to be shown
@param dimBackground Indicates whether the background should be dimmed | [
"Show",
"the",
"View",
"linked",
"to",
"a",
"key",
".",
"Don",
"t",
"do",
"anything",
"if",
"the",
"key",
"is",
"not",
"found"
] | train | https://github.com/wdullaer/SwipeActionAdapter/blob/24a7e2ed953ac11ea0d8875d375bba571ffeba55/library/src/main/java/com/wdullaer/swipeactionadapter/SwipeViewGroup.java#L91-L102 |
buschmais/jqa-rdbms-plugin | src/main/java/com/buschmais/jqassistant/plugin/rdbms/impl/scanner/AbstractSchemaScannerPlugin.java | AbstractSchemaScannerPlugin.getOptions | private SchemaCrawlerOptions getOptions(String bundledDriverName, InfoLevel level) throws IOException {
for (BundledDriver bundledDriver : BundledDriver.values()) {
if (bundledDriver.name().toLowerCase().equals(bundledDriverName.toLowerCase())) {
return bundledDriver.getOptions(level);
}
}
throw new IOException("Unknown bundled driver name '" + bundledDriverName + "', supported values are " + Arrays.asList(BundledDriver.values()));
} | java | private SchemaCrawlerOptions getOptions(String bundledDriverName, InfoLevel level) throws IOException {
for (BundledDriver bundledDriver : BundledDriver.values()) {
if (bundledDriver.name().toLowerCase().equals(bundledDriverName.toLowerCase())) {
return bundledDriver.getOptions(level);
}
}
throw new IOException("Unknown bundled driver name '" + bundledDriverName + "', supported values are " + Arrays.asList(BundledDriver.values()));
} | [
"private",
"SchemaCrawlerOptions",
"getOptions",
"(",
"String",
"bundledDriverName",
",",
"InfoLevel",
"level",
")",
"throws",
"IOException",
"{",
"for",
"(",
"BundledDriver",
"bundledDriver",
":",
"BundledDriver",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"... | Loads the bundled driver options
@param bundledDriverName The driver name.
@param level The info level.
@return The options or <code>null</code>.
@throws java.io.IOException If loading fails. | [
"Loads",
"the",
"bundled",
"driver",
"options"
] | train | https://github.com/buschmais/jqa-rdbms-plugin/blob/96c3919907deee00175cf5ab005867d76e01ba62/src/main/java/com/buschmais/jqassistant/plugin/rdbms/impl/scanner/AbstractSchemaScannerPlugin.java#L110-L117 |
dadoonet/fscrawler | framework/src/main/java/fr/pilato/elasticsearch/crawler/fs/framework/MetaFileHandler.java | MetaFileHandler.readFile | protected String readFile(String subdir, String filename) throws IOException {
Path dir = root;
if (subdir != null) {
dir = dir.resolve(subdir);
}
return new String(Files.readAllBytes(dir.resolve(filename)), StandardCharsets.UTF_8);
} | java | protected String readFile(String subdir, String filename) throws IOException {
Path dir = root;
if (subdir != null) {
dir = dir.resolve(subdir);
}
return new String(Files.readAllBytes(dir.resolve(filename)), StandardCharsets.UTF_8);
} | [
"protected",
"String",
"readFile",
"(",
"String",
"subdir",
",",
"String",
"filename",
")",
"throws",
"IOException",
"{",
"Path",
"dir",
"=",
"root",
";",
"if",
"(",
"subdir",
"!=",
"null",
")",
"{",
"dir",
"=",
"dir",
".",
"resolve",
"(",
"subdir",
")... | Read a file in ~/.fscrawler/{subdir} dir
@param subdir subdir where we can read the file (null if we read in the root dir)
@param filename filename
@return The String UTF-8 content
@throws IOException in case of error while reading | [
"Read",
"a",
"file",
"in",
"~",
"/",
".",
"fscrawler",
"/",
"{",
"subdir",
"}",
"dir"
] | train | https://github.com/dadoonet/fscrawler/blob/cca00a14e21ef9986aa30e19b160463aed6bf921/framework/src/main/java/fr/pilato/elasticsearch/crawler/fs/framework/MetaFileHandler.java#L49-L55 |
gosu-lang/gosu-lang | gosu-core-api/src/main/java/gw/util/GosuStringUtil.java | GosuStringUtil.replaceEach | public static String replaceEach(String text, String[] searchList, String[] replacementList) {
return replaceEach(text, searchList, replacementList, false, 0);
} | java | public static String replaceEach(String text, String[] searchList, String[] replacementList) {
return replaceEach(text, searchList, replacementList, false, 0);
} | [
"public",
"static",
"String",
"replaceEach",
"(",
"String",
"text",
",",
"String",
"[",
"]",
"searchList",
",",
"String",
"[",
"]",
"replacementList",
")",
"{",
"return",
"replaceEach",
"(",
"text",
",",
"searchList",
",",
"replacementList",
",",
"false",
",... | <p>
Replaces all occurrences of Strings within another String.
</p>
<p>
A <code>null</code> reference passed to this method is a no-op, or if
any "search string" or "string to replace" is null, that replace will be
ignored. This will not repeat. For repeating replaces, call the
overloaded method.
</p>
<pre>
GosuStringUtil.replaceEach(null, *, *) = null
GosuStringUtil.replaceEach("", *, *) = ""
GosuStringUtil.replaceEach("aba", null, null) = "aba"
GosuStringUtil.replaceEach("aba", new String[0], null) = "aba"
GosuStringUtil.replaceEach("aba", null, new String[0]) = "aba"
GosuStringUtil.replaceEach("aba", new String[]{"a"}, null) = "aba"
GosuStringUtil.replaceEach("aba", new String[]{"a"}, new String[]{""}) = "b"
GosuStringUtil.replaceEach("aba", new String[]{null}, new String[]{"a"}) = "aba"
GosuStringUtil.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"w", "t"}) = "wcte"
(example of how it does not repeat)
GosuStringUtil.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}) = "dcte"
</pre>
@param text
text to search and replace in, no-op if null
@param searchList
the Strings to search for, no-op if null
@param replacementList
the Strings to replace them with, no-op if null
@return the text with any replacements processed, <code>null</code> if
null String input
@throws IndexOutOfBoundsException
if the lengths of the arrays are not the same (null is ok,
and/or size 0)
@since 2.4 | [
"<p",
">",
"Replaces",
"all",
"occurrences",
"of",
"Strings",
"within",
"another",
"String",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/gosu-lang/gosu-lang/blob/d6e9261b137ce66fef3726cabe7826d4a1f946b7/gosu-core-api/src/main/java/gw/util/GosuStringUtil.java#L3490-L3492 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.