repository_name
stringlengths 7
54
| func_path_in_repository
stringlengths 18
196
| func_name
stringlengths 7
107
| whole_func_string
stringlengths 76
3.82k
| language
stringclasses 1
value | func_code_string
stringlengths 76
3.82k
| func_code_tokens
listlengths 22
717
| func_documentation_string
stringlengths 61
1.98k
| func_documentation_tokens
listlengths 1
508
| split_name
stringclasses 1
value | func_code_url
stringlengths 111
310
|
---|---|---|---|---|---|---|---|---|---|---|
milaboratory/milib
|
src/main/java/com/milaboratory/core/alignment/BandedLinearAligner.java
|
BandedLinearAligner.alignLeftAdded
|
public static Alignment<NucleotideSequence> alignLeftAdded(LinearGapAlignmentScoring scoring, NucleotideSequence seq1, NucleotideSequence seq2,
int offset1, int length1, int addedNucleotides1, int offset2, int length2, int addedNucleotides2,
int width) {
try {
MutationsBuilder<NucleotideSequence> mutations = new MutationsBuilder<>(NucleotideSequence.ALPHABET);
BandedSemiLocalResult result = alignLeftAdded0(scoring, seq1, seq2,
offset1, length1, addedNucleotides1, offset2, length2, addedNucleotides2,
width, mutations, AlignmentCache.get());
return new Alignment<>(seq1, mutations.createAndDestroy(),
new Range(result.sequence1Stop, offset1 + length1), new Range(result.sequence2Stop, offset2 + length2),
result.score);
} finally {
AlignmentCache.release();
}
}
|
java
|
public static Alignment<NucleotideSequence> alignLeftAdded(LinearGapAlignmentScoring scoring, NucleotideSequence seq1, NucleotideSequence seq2,
int offset1, int length1, int addedNucleotides1, int offset2, int length2, int addedNucleotides2,
int width) {
try {
MutationsBuilder<NucleotideSequence> mutations = new MutationsBuilder<>(NucleotideSequence.ALPHABET);
BandedSemiLocalResult result = alignLeftAdded0(scoring, seq1, seq2,
offset1, length1, addedNucleotides1, offset2, length2, addedNucleotides2,
width, mutations, AlignmentCache.get());
return new Alignment<>(seq1, mutations.createAndDestroy(),
new Range(result.sequence1Stop, offset1 + length1), new Range(result.sequence2Stop, offset2 + length2),
result.score);
} finally {
AlignmentCache.release();
}
}
|
[
"public",
"static",
"Alignment",
"<",
"NucleotideSequence",
">",
"alignLeftAdded",
"(",
"LinearGapAlignmentScoring",
"scoring",
",",
"NucleotideSequence",
"seq1",
",",
"NucleotideSequence",
"seq2",
",",
"int",
"offset1",
",",
"int",
"length1",
",",
"int",
"addedNucleotides1",
",",
"int",
"offset2",
",",
"int",
"length2",
",",
"int",
"addedNucleotides2",
",",
"int",
"width",
")",
"{",
"try",
"{",
"MutationsBuilder",
"<",
"NucleotideSequence",
">",
"mutations",
"=",
"new",
"MutationsBuilder",
"<>",
"(",
"NucleotideSequence",
".",
"ALPHABET",
")",
";",
"BandedSemiLocalResult",
"result",
"=",
"alignLeftAdded0",
"(",
"scoring",
",",
"seq1",
",",
"seq2",
",",
"offset1",
",",
"length1",
",",
"addedNucleotides1",
",",
"offset2",
",",
"length2",
",",
"addedNucleotides2",
",",
"width",
",",
"mutations",
",",
"AlignmentCache",
".",
"get",
"(",
")",
")",
";",
"return",
"new",
"Alignment",
"<>",
"(",
"seq1",
",",
"mutations",
".",
"createAndDestroy",
"(",
")",
",",
"new",
"Range",
"(",
"result",
".",
"sequence1Stop",
",",
"offset1",
"+",
"length1",
")",
",",
"new",
"Range",
"(",
"result",
".",
"sequence2Stop",
",",
"offset2",
"+",
"length2",
")",
",",
"result",
".",
"score",
")",
";",
"}",
"finally",
"{",
"AlignmentCache",
".",
"release",
"(",
")",
";",
"}",
"}"
] |
Semi-semi-global alignment with artificially added letters.
<p>Alignment where second sequence is aligned to the left part of first sequence.</p>
<p>Whole second sequence must be highly similar to the first sequence, except last {@code width} letters, which
are to be checked whether they can improve alignment or not.</p>
@param scoring scoring system
@param seq1 first sequence
@param seq2 second sequence
@param offset1 offset in first sequence
@param length1 length of first sequence's part to be aligned
@param addedNucleotides1 number of artificially added letters to the first sequence
@param offset2 offset in second sequence
@param length2 length of second sequence's part to be aligned
@param addedNucleotides2 number of artificially added letters to the second sequence
@param width width of banded alignment matrix. In other terms max allowed number of indels
|
[
"Semi",
"-",
"semi",
"-",
"global",
"alignment",
"with",
"artificially",
"added",
"letters",
"."
] |
train
|
https://github.com/milaboratory/milib/blob/2349b3dccdd3c7948643760e570238d6e30d5a34/src/main/java/com/milaboratory/core/alignment/BandedLinearAligner.java#L596-L610
|
operasoftware/operaprestodriver
|
src/com/opera/core/systems/OperaWebElement.java
|
OperaWebElement.saveScreenshot
|
public String saveScreenshot(String filename, long timeout) {
return saveScreenshot(filename, timeout, true, new ArrayList<String>());
}
|
java
|
public String saveScreenshot(String filename, long timeout) {
return saveScreenshot(filename, timeout, true, new ArrayList<String>());
}
|
[
"public",
"String",
"saveScreenshot",
"(",
"String",
"filename",
",",
"long",
"timeout",
")",
"{",
"return",
"saveScreenshot",
"(",
"filename",
",",
"timeout",
",",
"true",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
")",
";",
"}"
] |
Take a screenshot of the area this element covers. Saves a copy of the image to the given
filename.
@param filename the location to save the screenshot
@param timeout the number of milliseconds to wait before taking the screenshot
@return the MD5 hash of the screenshot
|
[
"Take",
"a",
"screenshot",
"of",
"the",
"area",
"this",
"element",
"covers",
".",
"Saves",
"a",
"copy",
"of",
"the",
"image",
"to",
"the",
"given",
"filename",
"."
] |
train
|
https://github.com/operasoftware/operaprestodriver/blob/1ccceda80f1c1a0489171d17dcaa6e7b18fb4c01/src/com/opera/core/systems/OperaWebElement.java#L345-L347
|
Wadpam/guja
|
guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java
|
GeneratedDContactDaoImpl.queryByCreatedDate
|
public Iterable<DContact> queryByCreatedDate(Object parent, java.util.Date createdDate) {
return queryByField(parent, DContactMapper.Field.CREATEDDATE.getFieldName(), createdDate);
}
|
java
|
public Iterable<DContact> queryByCreatedDate(Object parent, java.util.Date createdDate) {
return queryByField(parent, DContactMapper.Field.CREATEDDATE.getFieldName(), createdDate);
}
|
[
"public",
"Iterable",
"<",
"DContact",
">",
"queryByCreatedDate",
"(",
"Object",
"parent",
",",
"java",
".",
"util",
".",
"Date",
"createdDate",
")",
"{",
"return",
"queryByField",
"(",
"parent",
",",
"DContactMapper",
".",
"Field",
".",
"CREATEDDATE",
".",
"getFieldName",
"(",
")",
",",
"createdDate",
")",
";",
"}"
] |
query-by method for field createdDate
@param createdDate the specified attribute
@return an Iterable of DContacts for the specified createdDate
|
[
"query",
"-",
"by",
"method",
"for",
"field",
"createdDate"
] |
train
|
https://github.com/Wadpam/guja/blob/eb8ba8e6794a96ea0dd9744cada4f9ad9618f114/guja-contact/src/main/java/com/wadpam/guja/dao/GeneratedDContactDaoImpl.java#L142-L144
|
spotbugs/spotbugs
|
spotbugs/src/main/java/edu/umd/cs/findbugs/BugInstance.java
|
BugInstance.setProperty
|
@Nonnull
public BugInstance setProperty(String name, String value) {
BugProperty prop = lookupProperty(name);
if (prop != null) {
prop.setValue(value);
} else {
prop = new BugProperty(name, value);
addProperty(prop);
}
return this;
}
|
java
|
@Nonnull
public BugInstance setProperty(String name, String value) {
BugProperty prop = lookupProperty(name);
if (prop != null) {
prop.setValue(value);
} else {
prop = new BugProperty(name, value);
addProperty(prop);
}
return this;
}
|
[
"@",
"Nonnull",
"public",
"BugInstance",
"setProperty",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"BugProperty",
"prop",
"=",
"lookupProperty",
"(",
"name",
")",
";",
"if",
"(",
"prop",
"!=",
"null",
")",
"{",
"prop",
".",
"setValue",
"(",
"value",
")",
";",
"}",
"else",
"{",
"prop",
"=",
"new",
"BugProperty",
"(",
"name",
",",
"value",
")",
";",
"addProperty",
"(",
"prop",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Set value of given property.
@param name
name of the property to set
@param value
the value of the property
@return this object, so calls can be chained
|
[
"Set",
"value",
"of",
"given",
"property",
"."
] |
train
|
https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/BugInstance.java#L711-L721
|
aws/aws-sdk-java
|
aws-java-sdk-cognitoidp/src/main/java/com/amazonaws/services/cognitoidp/model/InitiateAuthRequest.java
|
InitiateAuthRequest.withClientMetadata
|
public InitiateAuthRequest withClientMetadata(java.util.Map<String, String> clientMetadata) {
setClientMetadata(clientMetadata);
return this;
}
|
java
|
public InitiateAuthRequest withClientMetadata(java.util.Map<String, String> clientMetadata) {
setClientMetadata(clientMetadata);
return this;
}
|
[
"public",
"InitiateAuthRequest",
"withClientMetadata",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"clientMetadata",
")",
"{",
"setClientMetadata",
"(",
"clientMetadata",
")",
";",
"return",
"this",
";",
"}"
] |
<p>
This is a random key-value pair map which can contain any key and will be passed to your PreAuthentication Lambda
trigger as-is. It can be used to implement additional validations around authentication.
</p>
@param clientMetadata
This is a random key-value pair map which can contain any key and will be passed to your PreAuthentication
Lambda trigger as-is. It can be used to implement additional validations around authentication.
@return Returns a reference to this object so that method calls can be chained together.
|
[
"<p",
">",
"This",
"is",
"a",
"random",
"key",
"-",
"value",
"pair",
"map",
"which",
"can",
"contain",
"any",
"key",
"and",
"will",
"be",
"passed",
"to",
"your",
"PreAuthentication",
"Lambda",
"trigger",
"as",
"-",
"is",
".",
"It",
"can",
"be",
"used",
"to",
"implement",
"additional",
"validations",
"around",
"authentication",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cognitoidp/src/main/java/com/amazonaws/services/cognitoidp/model/InitiateAuthRequest.java#L946-L949
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java
|
ApiOvhOrder.vps_serviceName_ip_GET
|
public ArrayList<String> vps_serviceName_ip_GET(String serviceName, OvhGeolocationEnum country, Long number) throws IOException {
String qPath = "/order/vps/{serviceName}/ip";
StringBuilder sb = path(qPath, serviceName);
query(sb, "country", country);
query(sb, "number", number);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
}
|
java
|
public ArrayList<String> vps_serviceName_ip_GET(String serviceName, OvhGeolocationEnum country, Long number) throws IOException {
String qPath = "/order/vps/{serviceName}/ip";
StringBuilder sb = path(qPath, serviceName);
query(sb, "country", country);
query(sb, "number", number);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, t1);
}
|
[
"public",
"ArrayList",
"<",
"String",
">",
"vps_serviceName_ip_GET",
"(",
"String",
"serviceName",
",",
"OvhGeolocationEnum",
"country",
",",
"Long",
"number",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/vps/{serviceName}/ip\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qPath",
",",
"serviceName",
")",
";",
"query",
"(",
"sb",
",",
"\"country\"",
",",
"country",
")",
";",
"query",
"(",
"sb",
",",
"\"number\"",
",",
"number",
")",
";",
"String",
"resp",
"=",
"exec",
"(",
"qPath",
",",
"\"GET\"",
",",
"sb",
".",
"toString",
"(",
")",
",",
"null",
")",
";",
"return",
"convertTo",
"(",
"resp",
",",
"t1",
")",
";",
"}"
] |
Get allowed durations for 'ip' option
REST: GET /order/vps/{serviceName}/ip
@param number [required] Number of IPs to order
@param country [required] Choose a geolocation for your IP Address
@param serviceName [required] The internal name of your VPS offer
|
[
"Get",
"allowed",
"durations",
"for",
"ip",
"option"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L3400-L3407
|
j-a-w-r/jawr-main-repo
|
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/ResourceBundleMessagesGenerator.java
|
ResourceBundleMessagesGenerator.addLinkedResources
|
protected void addLinkedResources(String path, GeneratorContext context) {
List<Locale> locales = new ArrayList<>();
Locale currentLocale = context.getLocale();
if (currentLocale != null) {
locales.add(currentLocale);
if (StringUtils.isNotEmpty(currentLocale.getVariant())) {
locales.add(new Locale(currentLocale.getCountry(), currentLocale.getLanguage()));
}
if (StringUtils.isNotEmpty(currentLocale.getLanguage())) {
locales.add(new Locale(currentLocale.getCountry()));
}
}
// Adds fallback locale
locales.add(control.getFallbackLocale());
Locale baseLocale = new Locale("", "");
if (!locales.contains(baseLocale)) {
locales.add(baseLocale);
}
List<FilePathMapping> fMappings = getFileMappings(path, context, locales);
addLinkedResources(path, context, fMappings);
}
|
java
|
protected void addLinkedResources(String path, GeneratorContext context) {
List<Locale> locales = new ArrayList<>();
Locale currentLocale = context.getLocale();
if (currentLocale != null) {
locales.add(currentLocale);
if (StringUtils.isNotEmpty(currentLocale.getVariant())) {
locales.add(new Locale(currentLocale.getCountry(), currentLocale.getLanguage()));
}
if (StringUtils.isNotEmpty(currentLocale.getLanguage())) {
locales.add(new Locale(currentLocale.getCountry()));
}
}
// Adds fallback locale
locales.add(control.getFallbackLocale());
Locale baseLocale = new Locale("", "");
if (!locales.contains(baseLocale)) {
locales.add(baseLocale);
}
List<FilePathMapping> fMappings = getFileMappings(path, context, locales);
addLinkedResources(path, context, fMappings);
}
|
[
"protected",
"void",
"addLinkedResources",
"(",
"String",
"path",
",",
"GeneratorContext",
"context",
")",
"{",
"List",
"<",
"Locale",
">",
"locales",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Locale",
"currentLocale",
"=",
"context",
".",
"getLocale",
"(",
")",
";",
"if",
"(",
"currentLocale",
"!=",
"null",
")",
"{",
"locales",
".",
"add",
"(",
"currentLocale",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"currentLocale",
".",
"getVariant",
"(",
")",
")",
")",
"{",
"locales",
".",
"add",
"(",
"new",
"Locale",
"(",
"currentLocale",
".",
"getCountry",
"(",
")",
",",
"currentLocale",
".",
"getLanguage",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isNotEmpty",
"(",
"currentLocale",
".",
"getLanguage",
"(",
")",
")",
")",
"{",
"locales",
".",
"add",
"(",
"new",
"Locale",
"(",
"currentLocale",
".",
"getCountry",
"(",
")",
")",
")",
";",
"}",
"}",
"// Adds fallback locale",
"locales",
".",
"add",
"(",
"control",
".",
"getFallbackLocale",
"(",
")",
")",
";",
"Locale",
"baseLocale",
"=",
"new",
"Locale",
"(",
"\"\"",
",",
"\"\"",
")",
";",
"if",
"(",
"!",
"locales",
".",
"contains",
"(",
"baseLocale",
")",
")",
"{",
"locales",
".",
"add",
"(",
"baseLocale",
")",
";",
"}",
"List",
"<",
"FilePathMapping",
">",
"fMappings",
"=",
"getFileMappings",
"(",
"path",
",",
"context",
",",
"locales",
")",
";",
"addLinkedResources",
"(",
"path",
",",
"context",
",",
"fMappings",
")",
";",
"}"
] |
Adds the linked resources
@param path
the resource path
@param context
the generator context
|
[
"Adds",
"the",
"linked",
"resources"
] |
train
|
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/ResourceBundleMessagesGenerator.java#L172-L195
|
goldmansachs/gs-collections
|
collections/src/main/java/com/gs/collections/impl/utility/MapIterate.java
|
MapIterate.getIfAbsent
|
public static <K, V> V getIfAbsent(Map<K, V> map, K key, Function0<? extends V> instanceBlock)
{
if (map instanceof UnsortedMapIterable)
{
return ((MapIterable<K, V>) map).getIfAbsent(key, instanceBlock);
}
V result = map.get(key);
if (MapIterate.isAbsent(result, map, key))
{
result = instanceBlock.value();
}
return result;
}
|
java
|
public static <K, V> V getIfAbsent(Map<K, V> map, K key, Function0<? extends V> instanceBlock)
{
if (map instanceof UnsortedMapIterable)
{
return ((MapIterable<K, V>) map).getIfAbsent(key, instanceBlock);
}
V result = map.get(key);
if (MapIterate.isAbsent(result, map, key))
{
result = instanceBlock.value();
}
return result;
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"V",
"getIfAbsent",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"K",
"key",
",",
"Function0",
"<",
"?",
"extends",
"V",
">",
"instanceBlock",
")",
"{",
"if",
"(",
"map",
"instanceof",
"UnsortedMapIterable",
")",
"{",
"return",
"(",
"(",
"MapIterable",
"<",
"K",
",",
"V",
">",
")",
"map",
")",
".",
"getIfAbsent",
"(",
"key",
",",
"instanceBlock",
")",
";",
"}",
"V",
"result",
"=",
"map",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"MapIterate",
".",
"isAbsent",
"(",
"result",
",",
"map",
",",
"key",
")",
")",
"{",
"result",
"=",
"instanceBlock",
".",
"value",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Get and return the value in the Map that corresponds to the specified key, or if there is no value
at the key, return the result of evaluating the specified {@link Function0}.
|
[
"Get",
"and",
"return",
"the",
"value",
"in",
"the",
"Map",
"that",
"corresponds",
"to",
"the",
"specified",
"key",
"or",
"if",
"there",
"is",
"no",
"value",
"at",
"the",
"key",
"return",
"the",
"result",
"of",
"evaluating",
"the",
"specified",
"{"
] |
train
|
https://github.com/goldmansachs/gs-collections/blob/fa8bf3e103689efa18bca2ab70203e71cde34b52/collections/src/main/java/com/gs/collections/impl/utility/MapIterate.java#L176-L188
|
xiancloud/xian
|
xian-core/src/main/java/info/xiancloud/core/LocalUnitsManager.java
|
LocalUnitsManager.replaceUnit
|
public static void replaceUnit(/*String group, String unitName, */ Unit newUnit) {
String group = newUnit.getGroup().getName(), unitName = newUnit.getName();
readWriteLock.writeLock().lock();
try {
//unitMap
List<Unit> unitList = unitMap.get(group);
unitList.removeIf(unitToRemove -> Objects.equals(unitToRemove.getName(), unitName));
unitList.add(newUnit);
//searchUnitByClassMap
Map<Class<? extends Unit>, Unit> tmp = new HashMap<>();
for (Map.Entry<Class<? extends Unit>, Unit> classUnitEntry : searchUnitByClass.entrySet()) {
Unit unit = classUnitEntry.getValue();
if (unit.getGroup().getName().equals(group) && unit.getName().equals(unitName)) {
tmp.put(classUnitEntry.getKey(), newUnit);
break;
}
}
searchUnitByClass.putAll(tmp);
//searchUnitMap
searchUnitMap.put(Unit.fullName(group, unitName), newUnit);
} finally {
readWriteLock.writeLock().unlock();
}
}
|
java
|
public static void replaceUnit(/*String group, String unitName, */ Unit newUnit) {
String group = newUnit.getGroup().getName(), unitName = newUnit.getName();
readWriteLock.writeLock().lock();
try {
//unitMap
List<Unit> unitList = unitMap.get(group);
unitList.removeIf(unitToRemove -> Objects.equals(unitToRemove.getName(), unitName));
unitList.add(newUnit);
//searchUnitByClassMap
Map<Class<? extends Unit>, Unit> tmp = new HashMap<>();
for (Map.Entry<Class<? extends Unit>, Unit> classUnitEntry : searchUnitByClass.entrySet()) {
Unit unit = classUnitEntry.getValue();
if (unit.getGroup().getName().equals(group) && unit.getName().equals(unitName)) {
tmp.put(classUnitEntry.getKey(), newUnit);
break;
}
}
searchUnitByClass.putAll(tmp);
//searchUnitMap
searchUnitMap.put(Unit.fullName(group, unitName), newUnit);
} finally {
readWriteLock.writeLock().unlock();
}
}
|
[
"public",
"static",
"void",
"replaceUnit",
"(",
"/*String group, String unitName, */",
"Unit",
"newUnit",
")",
"{",
"String",
"group",
"=",
"newUnit",
".",
"getGroup",
"(",
")",
".",
"getName",
"(",
")",
",",
"unitName",
"=",
"newUnit",
".",
"getName",
"(",
")",
";",
"readWriteLock",
".",
"writeLock",
"(",
")",
".",
"lock",
"(",
")",
";",
"try",
"{",
"//unitMap",
"List",
"<",
"Unit",
">",
"unitList",
"=",
"unitMap",
".",
"get",
"(",
"group",
")",
";",
"unitList",
".",
"removeIf",
"(",
"unitToRemove",
"->",
"Objects",
".",
"equals",
"(",
"unitToRemove",
".",
"getName",
"(",
")",
",",
"unitName",
")",
")",
";",
"unitList",
".",
"add",
"(",
"newUnit",
")",
";",
"//searchUnitByClassMap",
"Map",
"<",
"Class",
"<",
"?",
"extends",
"Unit",
">",
",",
"Unit",
">",
"tmp",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Class",
"<",
"?",
"extends",
"Unit",
">",
",",
"Unit",
">",
"classUnitEntry",
":",
"searchUnitByClass",
".",
"entrySet",
"(",
")",
")",
"{",
"Unit",
"unit",
"=",
"classUnitEntry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"unit",
".",
"getGroup",
"(",
")",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"group",
")",
"&&",
"unit",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"unitName",
")",
")",
"{",
"tmp",
".",
"put",
"(",
"classUnitEntry",
".",
"getKey",
"(",
")",
",",
"newUnit",
")",
";",
"break",
";",
"}",
"}",
"searchUnitByClass",
".",
"putAll",
"(",
"tmp",
")",
";",
"//searchUnitMap",
"searchUnitMap",
".",
"put",
"(",
"Unit",
".",
"fullName",
"(",
"group",
",",
"unitName",
")",
",",
"newUnit",
")",
";",
"}",
"finally",
"{",
"readWriteLock",
".",
"writeLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Dynamically change the unit collections. Currently we use this for aop.
|
[
"Dynamically",
"change",
"the",
"unit",
"collections",
".",
"Currently",
"we",
"use",
"this",
"for",
"aop",
"."
] |
train
|
https://github.com/xiancloud/xian/blob/1948e088545553d2745b2c86d8b5a64988bb850e/xian-core/src/main/java/info/xiancloud/core/LocalUnitsManager.java#L129-L154
|
xhsun/gw2wrapper
|
src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java
|
AsynchronousRequest.getPetInfo
|
public void getPetInfo(int[] ids, Callback<List<Pet>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getPetInfo(processIds(ids), GuildWars2.lang.getValue()).enqueue(callback);
}
|
java
|
public void getPetInfo(int[] ids, Callback<List<Pet>> callback) throws GuildWars2Exception, NullPointerException {
isParamValid(new ParamChecker(ids));
gw2API.getPetInfo(processIds(ids), GuildWars2.lang.getValue()).enqueue(callback);
}
|
[
"public",
"void",
"getPetInfo",
"(",
"int",
"[",
"]",
"ids",
",",
"Callback",
"<",
"List",
"<",
"Pet",
">",
">",
"callback",
")",
"throws",
"GuildWars2Exception",
",",
"NullPointerException",
"{",
"isParamValid",
"(",
"new",
"ParamChecker",
"(",
"ids",
")",
")",
";",
"gw2API",
".",
"getPetInfo",
"(",
"processIds",
"(",
"ids",
")",
",",
"GuildWars2",
".",
"lang",
".",
"getValue",
"(",
")",
")",
".",
"enqueue",
"(",
"callback",
")",
";",
"}"
] |
For more info on pets API go <a href="https://wiki.guildwars2.com/wiki/API:2/pets">here</a><br/>
Give user the access to {@link Callback#onResponse(Call, Response)} and {@link Callback#onFailure(Call, Throwable)} methods for custom interactions
@param ids list of pet id
@param callback callback that is going to be used for {@link Call#enqueue(Callback)}
@throws GuildWars2Exception empty ID list
@throws NullPointerException if given {@link Callback} is empty
@see Pet pet info
|
[
"For",
"more",
"info",
"on",
"pets",
"API",
"go",
"<a",
"href",
"=",
"https",
":",
"//",
"wiki",
".",
"guildwars2",
".",
"com",
"/",
"wiki",
"/",
"API",
":",
"2",
"/",
"pets",
">",
"here<",
"/",
"a",
">",
"<br",
"/",
">",
"Give",
"user",
"the",
"access",
"to",
"{",
"@link",
"Callback#onResponse",
"(",
"Call",
"Response",
")",
"}",
"and",
"{",
"@link",
"Callback#onFailure",
"(",
"Call",
"Throwable",
")",
"}",
"methods",
"for",
"custom",
"interactions"
] |
train
|
https://github.com/xhsun/gw2wrapper/blob/c8a43b51f363b032074fb152ee6efe657e33e525/src/main/java/me/xhsun/guildwars2wrapper/AsynchronousRequest.java#L1963-L1966
|
BorderTech/wcomponents
|
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WContentRenderer.java
|
WContentRenderer.doRender
|
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WContent content = (WContent) component;
XmlStringBuilder xml = renderContext.getWriter();
if (!content.isDisplayRequested()) {
// This is the normal situation.
return;
}
Object contentAccess = content.getContentAccess();
if (contentAccess == null) {
LOG.warn("No content specified");
return;
}
// Ok, the content is available and should be shown
switch (content.getDisplayMode()) {
case DISPLAY_INLINE:
case PROMPT_TO_SAVE:
xml.appendTagOpen("ui:redirect");
xml.appendUrlAttribute("url", content.getUrl());
xml.appendEnd();
break;
case OPEN_NEW_WINDOW:
xml.appendTagOpen("ui:popup");
xml.appendUrlAttribute("url", content.getUrl());
xml.appendAttribute("width", content.getWidth().replaceAll("px", ""));
xml.appendAttribute("height", content.getHeight().replaceAll("px", ""));
xml.appendOptionalAttribute("resizable", content.isResizable(), "true");
xml.appendEnd();
break;
default:
throw new IllegalStateException("Invalid display mode: " + content.getDisplayMode());
}
}
|
java
|
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WContent content = (WContent) component;
XmlStringBuilder xml = renderContext.getWriter();
if (!content.isDisplayRequested()) {
// This is the normal situation.
return;
}
Object contentAccess = content.getContentAccess();
if (contentAccess == null) {
LOG.warn("No content specified");
return;
}
// Ok, the content is available and should be shown
switch (content.getDisplayMode()) {
case DISPLAY_INLINE:
case PROMPT_TO_SAVE:
xml.appendTagOpen("ui:redirect");
xml.appendUrlAttribute("url", content.getUrl());
xml.appendEnd();
break;
case OPEN_NEW_WINDOW:
xml.appendTagOpen("ui:popup");
xml.appendUrlAttribute("url", content.getUrl());
xml.appendAttribute("width", content.getWidth().replaceAll("px", ""));
xml.appendAttribute("height", content.getHeight().replaceAll("px", ""));
xml.appendOptionalAttribute("resizable", content.isResizable(), "true");
xml.appendEnd();
break;
default:
throw new IllegalStateException("Invalid display mode: " + content.getDisplayMode());
}
}
|
[
"@",
"Override",
"public",
"void",
"doRender",
"(",
"final",
"WComponent",
"component",
",",
"final",
"WebXmlRenderContext",
"renderContext",
")",
"{",
"WContent",
"content",
"=",
"(",
"WContent",
")",
"component",
";",
"XmlStringBuilder",
"xml",
"=",
"renderContext",
".",
"getWriter",
"(",
")",
";",
"if",
"(",
"!",
"content",
".",
"isDisplayRequested",
"(",
")",
")",
"{",
"// This is the normal situation.",
"return",
";",
"}",
"Object",
"contentAccess",
"=",
"content",
".",
"getContentAccess",
"(",
")",
";",
"if",
"(",
"contentAccess",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"No content specified\"",
")",
";",
"return",
";",
"}",
"// Ok, the content is available and should be shown",
"switch",
"(",
"content",
".",
"getDisplayMode",
"(",
")",
")",
"{",
"case",
"DISPLAY_INLINE",
":",
"case",
"PROMPT_TO_SAVE",
":",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:redirect\"",
")",
";",
"xml",
".",
"appendUrlAttribute",
"(",
"\"url\"",
",",
"content",
".",
"getUrl",
"(",
")",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"break",
";",
"case",
"OPEN_NEW_WINDOW",
":",
"xml",
".",
"appendTagOpen",
"(",
"\"ui:popup\"",
")",
";",
"xml",
".",
"appendUrlAttribute",
"(",
"\"url\"",
",",
"content",
".",
"getUrl",
"(",
")",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"width\"",
",",
"content",
".",
"getWidth",
"(",
")",
".",
"replaceAll",
"(",
"\"px\"",
",",
"\"\"",
")",
")",
";",
"xml",
".",
"appendAttribute",
"(",
"\"height\"",
",",
"content",
".",
"getHeight",
"(",
")",
".",
"replaceAll",
"(",
"\"px\"",
",",
"\"\"",
")",
")",
";",
"xml",
".",
"appendOptionalAttribute",
"(",
"\"resizable\"",
",",
"content",
".",
"isResizable",
"(",
")",
",",
"\"true\"",
")",
";",
"xml",
".",
"appendEnd",
"(",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"Invalid display mode: \"",
"+",
"content",
".",
"getDisplayMode",
"(",
")",
")",
";",
"}",
"}"
] |
<p>
Paints the given WContent.</p>
<p>
This paint method outputs a popup that opens browser window in which the content document will be displayed. The
component is only rendered for requests in which the display() method of the content component has just been
called.</p>
<p>
WContent's handleRequest() method will return the actual PDF document content via the use of an Escape.</p>
@param component the WContent to paint.
@param renderContext the RenderContext to paint to.
|
[
"<p",
">",
"Paints",
"the",
"given",
"WContent",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WContentRenderer.java#L39-L77
|
jpush/jmessage-api-java-client
|
src/main/java/cn/jmessage/api/JMessageClient.java
|
JMessageClient.getMessageList
|
public MessageListResult getMessageList(int count, String begin_time, String end_time)
throws APIConnectionException, APIRequestException {
return _messageClient.getMessageList(count, begin_time, end_time);
}
|
java
|
public MessageListResult getMessageList(int count, String begin_time, String end_time)
throws APIConnectionException, APIRequestException {
return _messageClient.getMessageList(count, begin_time, end_time);
}
|
[
"public",
"MessageListResult",
"getMessageList",
"(",
"int",
"count",
",",
"String",
"begin_time",
",",
"String",
"end_time",
")",
"throws",
"APIConnectionException",
",",
"APIRequestException",
"{",
"return",
"_messageClient",
".",
"getMessageList",
"(",
"count",
",",
"begin_time",
",",
"end_time",
")",
";",
"}"
] |
Get message list from history, messages will store 60 days.
@param count Necessary parameter. The count of the message list.
@param begin_time Necessary parameter. The format must follow by 'yyyy-MM-dd HH:mm:ss'
@param end_time Necessary parameter. The format must follow by 'yyyy-MM-dd HH:mm:ss'
@return MessageListResult
@throws APIConnectionException connect exception
@throws APIRequestException request exception
|
[
"Get",
"message",
"list",
"from",
"history",
"messages",
"will",
"store",
"60",
"days",
"."
] |
train
|
https://github.com/jpush/jmessage-api-java-client/blob/767f5fb15e9fe5a546c00f6e68b64f6dd53c617c/src/main/java/cn/jmessage/api/JMessageClient.java#L500-L503
|
infinispan/infinispan
|
commons/src/main/java/org/infinispan/commons/util/TypedProperties.java
|
TypedProperties.putIfAbsent
|
public synchronized TypedProperties putIfAbsent(String key, String value) {
if (getProperty(key) == null) {
put(key, value);
}
return this;
}
|
java
|
public synchronized TypedProperties putIfAbsent(String key, String value) {
if (getProperty(key) == null) {
put(key, value);
}
return this;
}
|
[
"public",
"synchronized",
"TypedProperties",
"putIfAbsent",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"getProperty",
"(",
"key",
")",
"==",
"null",
")",
"{",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Put a value if the associated key is not present
@param key new key
@param value new value
@return this TypedProperties instance for method chaining
|
[
"Put",
"a",
"value",
"if",
"the",
"associated",
"key",
"is",
"not",
"present",
"@param",
"key",
"new",
"key",
"@param",
"value",
"new",
"value",
"@return",
"this",
"TypedProperties",
"instance",
"for",
"method",
"chaining"
] |
train
|
https://github.com/infinispan/infinispan/blob/7c62b94886c3febb4774ae8376acf2baa0265ab5/commons/src/main/java/org/infinispan/commons/util/TypedProperties.java#L162-L167
|
hazelcast/hazelcast
|
hazelcast/src/main/java/com/hazelcast/internal/config/ConfigValidator.java
|
ConfigValidator.checkCacheConfig
|
public static void checkCacheConfig(CacheSimpleConfig cacheSimpleConfig, CacheMergePolicyProvider mergePolicyProvider) {
checkCacheConfig(cacheSimpleConfig.getInMemoryFormat(), cacheSimpleConfig.getEvictionConfig(),
cacheSimpleConfig.getMergePolicy(), cacheSimpleConfig, mergePolicyProvider);
}
|
java
|
public static void checkCacheConfig(CacheSimpleConfig cacheSimpleConfig, CacheMergePolicyProvider mergePolicyProvider) {
checkCacheConfig(cacheSimpleConfig.getInMemoryFormat(), cacheSimpleConfig.getEvictionConfig(),
cacheSimpleConfig.getMergePolicy(), cacheSimpleConfig, mergePolicyProvider);
}
|
[
"public",
"static",
"void",
"checkCacheConfig",
"(",
"CacheSimpleConfig",
"cacheSimpleConfig",
",",
"CacheMergePolicyProvider",
"mergePolicyProvider",
")",
"{",
"checkCacheConfig",
"(",
"cacheSimpleConfig",
".",
"getInMemoryFormat",
"(",
")",
",",
"cacheSimpleConfig",
".",
"getEvictionConfig",
"(",
")",
",",
"cacheSimpleConfig",
".",
"getMergePolicy",
"(",
")",
",",
"cacheSimpleConfig",
",",
"mergePolicyProvider",
")",
";",
"}"
] |
Validates the given {@link CacheSimpleConfig}.
@param cacheSimpleConfig the {@link CacheSimpleConfig} to check
@param mergePolicyProvider the {@link CacheMergePolicyProvider} to resolve merge policy classes
|
[
"Validates",
"the",
"given",
"{",
"@link",
"CacheSimpleConfig",
"}",
"."
] |
train
|
https://github.com/hazelcast/hazelcast/blob/8c4bc10515dbbfb41a33e0302c0caedf3cda1baf/hazelcast/src/main/java/com/hazelcast/internal/config/ConfigValidator.java#L319-L322
|
CenturyLinkCloud/mdw
|
mdw-common/src/com/centurylink/mdw/common/service/SystemMessages.java
|
SystemMessages.bulletinOff
|
public static void bulletinOff(Bulletin bulletin, Level level, String message) {
if (bulletin == null)
return;
synchronized (bulletins) {
bulletins.remove(bulletin.getId(), bulletin);
}
try {
WebSocketMessenger.getInstance().send("SystemMessage", bulletin.off(message).getJson().toString());
}
catch (IOException ex) {
logger.warnException("Unable to publish to websocket", ex);
}
}
|
java
|
public static void bulletinOff(Bulletin bulletin, Level level, String message) {
if (bulletin == null)
return;
synchronized (bulletins) {
bulletins.remove(bulletin.getId(), bulletin);
}
try {
WebSocketMessenger.getInstance().send("SystemMessage", bulletin.off(message).getJson().toString());
}
catch (IOException ex) {
logger.warnException("Unable to publish to websocket", ex);
}
}
|
[
"public",
"static",
"void",
"bulletinOff",
"(",
"Bulletin",
"bulletin",
",",
"Level",
"level",
",",
"String",
"message",
")",
"{",
"if",
"(",
"bulletin",
"==",
"null",
")",
"return",
";",
"synchronized",
"(",
"bulletins",
")",
"{",
"bulletins",
".",
"remove",
"(",
"bulletin",
".",
"getId",
"(",
")",
",",
"bulletin",
")",
";",
"}",
"try",
"{",
"WebSocketMessenger",
".",
"getInstance",
"(",
")",
".",
"send",
"(",
"\"SystemMessage\"",
",",
"bulletin",
".",
"off",
"(",
"message",
")",
".",
"getJson",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"logger",
".",
"warnException",
"(",
"\"Unable to publish to websocket\"",
",",
"ex",
")",
";",
"}",
"}"
] |
Should be the same instance or have the same id as the bulletinOn message.
|
[
"Should",
"be",
"the",
"same",
"instance",
"or",
"have",
"the",
"same",
"id",
"as",
"the",
"bulletinOn",
"message",
"."
] |
train
|
https://github.com/CenturyLinkCloud/mdw/blob/91167fe65a25a5d7022cdcf8b0fae8506f5b87ce/mdw-common/src/com/centurylink/mdw/common/service/SystemMessages.java#L76-L88
|
uber/NullAway
|
nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java
|
ErrorBuilder.createErrorDescriptionForNullAssignment
|
Description createErrorDescriptionForNullAssignment(
ErrorMessage errorMessage,
@Nullable Tree suggestTreeIfCastToNonNull,
@Nullable TreePath suggestTreePathIfSuppression,
Description.Builder descriptionBuilder) {
final Tree enclosingSuppressTree = suppressibleNode(suggestTreePathIfSuppression);
if (config.getCastToNonNullMethod() != null) {
return createErrorDescription(errorMessage, suggestTreeIfCastToNonNull, descriptionBuilder);
} else {
return createErrorDescription(errorMessage, enclosingSuppressTree, descriptionBuilder);
}
}
|
java
|
Description createErrorDescriptionForNullAssignment(
ErrorMessage errorMessage,
@Nullable Tree suggestTreeIfCastToNonNull,
@Nullable TreePath suggestTreePathIfSuppression,
Description.Builder descriptionBuilder) {
final Tree enclosingSuppressTree = suppressibleNode(suggestTreePathIfSuppression);
if (config.getCastToNonNullMethod() != null) {
return createErrorDescription(errorMessage, suggestTreeIfCastToNonNull, descriptionBuilder);
} else {
return createErrorDescription(errorMessage, enclosingSuppressTree, descriptionBuilder);
}
}
|
[
"Description",
"createErrorDescriptionForNullAssignment",
"(",
"ErrorMessage",
"errorMessage",
",",
"@",
"Nullable",
"Tree",
"suggestTreeIfCastToNonNull",
",",
"@",
"Nullable",
"TreePath",
"suggestTreePathIfSuppression",
",",
"Description",
".",
"Builder",
"descriptionBuilder",
")",
"{",
"final",
"Tree",
"enclosingSuppressTree",
"=",
"suppressibleNode",
"(",
"suggestTreePathIfSuppression",
")",
";",
"if",
"(",
"config",
".",
"getCastToNonNullMethod",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"createErrorDescription",
"(",
"errorMessage",
",",
"suggestTreeIfCastToNonNull",
",",
"descriptionBuilder",
")",
";",
"}",
"else",
"{",
"return",
"createErrorDescription",
"(",
"errorMessage",
",",
"enclosingSuppressTree",
",",
"descriptionBuilder",
")",
";",
"}",
"}"
] |
create an error description for a generalized @Nullable value to @NonNull location assignment.
<p>This includes: field assignments, method arguments and method returns
@param errorMessage the error message object.
@param suggestTreeIfCastToNonNull the location at which a fix suggestion should be made if a
castToNonNull method is available (usually the expression to cast)
@param suggestTreePathIfSuppression the location at which a fix suggestion should be made if a
castToNonNull method is not available (usually the enclosing method, or any place
where @SuppressWarnings can be added).
@param descriptionBuilder the description builder for the error.
@return the error description.
|
[
"create",
"an",
"error",
"description",
"for",
"a",
"generalized",
"@Nullable",
"value",
"to",
"@NonNull",
"location",
"assignment",
"."
] |
train
|
https://github.com/uber/NullAway/blob/c3979b4241f80411dbba6aac3ff653acbb88d00b/nullaway/src/main/java/com/uber/nullaway/ErrorBuilder.java#L147-L158
|
bingoohuang/westcache
|
src/main/java/com/github/bingoohuang/westcache/utils/Methods.java
|
Methods.getAllMethodsInHierarchy
|
public static Set<Method> getAllMethodsInHierarchy(Method method) {
LinkedHashSet<Method> allMethods = new LinkedHashSet<>();
val declaringClass = method.getDeclaringClass();
return getAllMethodsInHierarchy(allMethods, declaringClass, method);
}
|
java
|
public static Set<Method> getAllMethodsInHierarchy(Method method) {
LinkedHashSet<Method> allMethods = new LinkedHashSet<>();
val declaringClass = method.getDeclaringClass();
return getAllMethodsInHierarchy(allMethods, declaringClass, method);
}
|
[
"public",
"static",
"Set",
"<",
"Method",
">",
"getAllMethodsInHierarchy",
"(",
"Method",
"method",
")",
"{",
"LinkedHashSet",
"<",
"Method",
">",
"allMethods",
"=",
"new",
"LinkedHashSet",
"<>",
"(",
")",
";",
"val",
"declaringClass",
"=",
"method",
".",
"getDeclaringClass",
"(",
")",
";",
"return",
"getAllMethodsInHierarchy",
"(",
"allMethods",
",",
"declaringClass",
",",
"method",
")",
";",
"}"
] |
/*
Gets an array of all methods in a class hierarchy walking up to parent classes
|
[
"/",
"*",
"Gets",
"an",
"array",
"of",
"all",
"methods",
"in",
"a",
"class",
"hierarchy",
"walking",
"up",
"to",
"parent",
"classes"
] |
train
|
https://github.com/bingoohuang/westcache/blob/09842bf0b9299abe75551c4b51d326fcc96da42d/src/main/java/com/github/bingoohuang/westcache/utils/Methods.java#L28-L32
|
openengsb/openengsb
|
connector/userprojectsfile/src/main/java/org/openengsb/connector/userprojects/file/internal/file/AssignmentFileAccessObject.java
|
AssignmentFileAccessObject.findAllAssignments
|
public List<Assignment> findAllAssignments() {
List<Assignment> list = new ArrayList<>();
List<String> assignmentStrings;
try {
assignmentStrings = readLines(assignmentsFile);
} catch (IOException e) {
throw new FileBasedRuntimeException(e);
}
for (String assignmentString : assignmentStrings) {
if (StringUtils.isNotBlank(assignmentString)) {
String[] substrings =
StringUtils
.splitByWholeSeparator(assignmentString, Configuration.get().getAssociationSeparator());
if (substrings.length < 2 || StringUtils.isBlank(substrings[1])) {
continue;
}
Assignment assignment = new Assignment(substrings[0], substrings[1]);
if (substrings.length > 2) {
assignment.setRoles(Arrays.asList(StringUtils.splitByWholeSeparator(substrings[2], Configuration
.get().getValueSeparator())));
}
list.add(assignment);
}
}
return list;
}
|
java
|
public List<Assignment> findAllAssignments() {
List<Assignment> list = new ArrayList<>();
List<String> assignmentStrings;
try {
assignmentStrings = readLines(assignmentsFile);
} catch (IOException e) {
throw new FileBasedRuntimeException(e);
}
for (String assignmentString : assignmentStrings) {
if (StringUtils.isNotBlank(assignmentString)) {
String[] substrings =
StringUtils
.splitByWholeSeparator(assignmentString, Configuration.get().getAssociationSeparator());
if (substrings.length < 2 || StringUtils.isBlank(substrings[1])) {
continue;
}
Assignment assignment = new Assignment(substrings[0], substrings[1]);
if (substrings.length > 2) {
assignment.setRoles(Arrays.asList(StringUtils.splitByWholeSeparator(substrings[2], Configuration
.get().getValueSeparator())));
}
list.add(assignment);
}
}
return list;
}
|
[
"public",
"List",
"<",
"Assignment",
">",
"findAllAssignments",
"(",
")",
"{",
"List",
"<",
"Assignment",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"String",
">",
"assignmentStrings",
";",
"try",
"{",
"assignmentStrings",
"=",
"readLines",
"(",
"assignmentsFile",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"FileBasedRuntimeException",
"(",
"e",
")",
";",
"}",
"for",
"(",
"String",
"assignmentString",
":",
"assignmentStrings",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"assignmentString",
")",
")",
"{",
"String",
"[",
"]",
"substrings",
"=",
"StringUtils",
".",
"splitByWholeSeparator",
"(",
"assignmentString",
",",
"Configuration",
".",
"get",
"(",
")",
".",
"getAssociationSeparator",
"(",
")",
")",
";",
"if",
"(",
"substrings",
".",
"length",
"<",
"2",
"||",
"StringUtils",
".",
"isBlank",
"(",
"substrings",
"[",
"1",
"]",
")",
")",
"{",
"continue",
";",
"}",
"Assignment",
"assignment",
"=",
"new",
"Assignment",
"(",
"substrings",
"[",
"0",
"]",
",",
"substrings",
"[",
"1",
"]",
")",
";",
"if",
"(",
"substrings",
".",
"length",
">",
"2",
")",
"{",
"assignment",
".",
"setRoles",
"(",
"Arrays",
".",
"asList",
"(",
"StringUtils",
".",
"splitByWholeSeparator",
"(",
"substrings",
"[",
"2",
"]",
",",
"Configuration",
".",
"get",
"(",
")",
".",
"getValueSeparator",
"(",
")",
")",
")",
")",
";",
"}",
"list",
".",
"add",
"(",
"assignment",
")",
";",
"}",
"}",
"return",
"list",
";",
"}"
] |
Finds all the available assignments.
@return the list of available assignments
|
[
"Finds",
"all",
"the",
"available",
"assignments",
"."
] |
train
|
https://github.com/openengsb/openengsb/blob/d39058000707f617cd405629f9bc7f17da7b414a/connector/userprojectsfile/src/main/java/org/openengsb/connector/userprojects/file/internal/file/AssignmentFileAccessObject.java#L45-L71
|
GwtMaterialDesign/gwt-material-addins
|
src/main/java/gwt/material/design/addins/client/combobox/MaterialComboBox.java
|
MaterialComboBox.setSingleValue
|
public void setSingleValue(T value, boolean fireEvents) {
int index = this.values.indexOf(value);
if (index < 0 && value instanceof String) {
index = getIndexByString((String) value);
}
if (index > -1) {
List<T> before = getValue();
setSelectedIndex(index);
if (fireEvents) {
ValueChangeEvent.fireIfNotEqual(this, before, Collections.singletonList(value));
}
}
}
|
java
|
public void setSingleValue(T value, boolean fireEvents) {
int index = this.values.indexOf(value);
if (index < 0 && value instanceof String) {
index = getIndexByString((String) value);
}
if (index > -1) {
List<T> before = getValue();
setSelectedIndex(index);
if (fireEvents) {
ValueChangeEvent.fireIfNotEqual(this, before, Collections.singletonList(value));
}
}
}
|
[
"public",
"void",
"setSingleValue",
"(",
"T",
"value",
",",
"boolean",
"fireEvents",
")",
"{",
"int",
"index",
"=",
"this",
".",
"values",
".",
"indexOf",
"(",
"value",
")",
";",
"if",
"(",
"index",
"<",
"0",
"&&",
"value",
"instanceof",
"String",
")",
"{",
"index",
"=",
"getIndexByString",
"(",
"(",
"String",
")",
"value",
")",
";",
"}",
"if",
"(",
"index",
">",
"-",
"1",
")",
"{",
"List",
"<",
"T",
">",
"before",
"=",
"getValue",
"(",
")",
";",
"setSelectedIndex",
"(",
"index",
")",
";",
"if",
"(",
"fireEvents",
")",
"{",
"ValueChangeEvent",
".",
"fireIfNotEqual",
"(",
"this",
",",
"before",
",",
"Collections",
".",
"singletonList",
"(",
"value",
")",
")",
";",
"}",
"}",
"}"
] |
Set the selected value using a single item, generally used
in single selection mode.
|
[
"Set",
"the",
"selected",
"value",
"using",
"a",
"single",
"item",
"generally",
"used",
"in",
"single",
"selection",
"mode",
"."
] |
train
|
https://github.com/GwtMaterialDesign/gwt-material-addins/blob/11aec9d92918225f70f936285d0ae94f2178c36e/src/main/java/gwt/material/design/addins/client/combobox/MaterialComboBox.java#L533-L547
|
Steveice10/OpenNBT
|
src/main/java/com/github/steveice10/opennbt/NBTIO.java
|
NBTIO.writeTag
|
public static void writeTag(DataOutput out, Tag tag) throws IOException {
out.writeByte(TagRegistry.getIdFor(tag.getClass()));
out.writeUTF(tag.getName());
tag.write(out);
}
|
java
|
public static void writeTag(DataOutput out, Tag tag) throws IOException {
out.writeByte(TagRegistry.getIdFor(tag.getClass()));
out.writeUTF(tag.getName());
tag.write(out);
}
|
[
"public",
"static",
"void",
"writeTag",
"(",
"DataOutput",
"out",
",",
"Tag",
"tag",
")",
"throws",
"IOException",
"{",
"out",
".",
"writeByte",
"(",
"TagRegistry",
".",
"getIdFor",
"(",
"tag",
".",
"getClass",
"(",
")",
")",
")",
";",
"out",
".",
"writeUTF",
"(",
"tag",
".",
"getName",
"(",
")",
")",
";",
"tag",
".",
"write",
"(",
"out",
")",
";",
"}"
] |
Writes an NBT tag.
@param out Data output to write to.
@param tag Tag to write.
@throws java.io.IOException If an I/O error occurs.
|
[
"Writes",
"an",
"NBT",
"tag",
"."
] |
train
|
https://github.com/Steveice10/OpenNBT/blob/9bf4adb2afd206a21bc4309c85d642494d1fb536/src/main/java/com/github/steveice10/opennbt/NBTIO.java#L227-L231
|
jenkinsci/pipeline-maven-plugin
|
jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/InvokerRunsPublisher.java
|
InvokerRunsPublisher.process
|
@Override
public void process(@Nonnull StepContext context, @Nonnull Element mavenSpyLogsElt) throws IOException, InterruptedException {
TaskListener listener = context.get(TaskListener.class);
if (listener == null) {
LOGGER.warning("TaskListener is NULL, default to stderr");
listener = new StreamBuildListener((OutputStream) System.err);
}
List<Element> invokerRunRunEvents = XmlUtils.getExecutionEventsByPlugin(mavenSpyLogsElt, GROUP_ID, ARTIFACT_ID, RUN_GOAL, "MojoSucceeded", "MojoFailed");
List<Element> invokerRunIntegrationTestEvents = XmlUtils.getExecutionEventsByPlugin(mavenSpyLogsElt, GROUP_ID, ARTIFACT_ID, INTEGRATION_TEST_GOAL, "MojoSucceeded", "MojoFailed");
if (invokerRunRunEvents.isEmpty() && invokerRunIntegrationTestEvents.isEmpty()) {
if (LOGGER.isLoggable(Level.FINE)) {
listener.getLogger().println("[withMaven] invokerPublisher - " +
"No " + GROUP_ID + ":" + ARTIFACT_ID + ":" + RUN_GOAL +
" or " + GROUP_ID + ":" + ARTIFACT_ID + ":" + INTEGRATION_TEST_GOAL + " execution found");
}
return;
}
try {
Class.forName("org.jenkinsci.plugins.maveninvoker.MavenInvokerRecorder");
} catch (ClassNotFoundException e) {
listener.getLogger().print("[withMaven] invokerPublisher - Jenkins ");
listener.hyperlink("https://wiki.jenkins.io/display/JENKINS/Maven+Invoker+Plugin", "Maven Invoker Plugin");
listener.getLogger().println(" not found, don't display " + GROUP_ID + ":" + ARTIFACT_ID + ":" + RUN_GOAL + " results in pipeline screen.");
return;
}
executeReporter(context, listener, invokerRunRunEvents);
executeReporter(context, listener, invokerRunIntegrationTestEvents);
}
|
java
|
@Override
public void process(@Nonnull StepContext context, @Nonnull Element mavenSpyLogsElt) throws IOException, InterruptedException {
TaskListener listener = context.get(TaskListener.class);
if (listener == null) {
LOGGER.warning("TaskListener is NULL, default to stderr");
listener = new StreamBuildListener((OutputStream) System.err);
}
List<Element> invokerRunRunEvents = XmlUtils.getExecutionEventsByPlugin(mavenSpyLogsElt, GROUP_ID, ARTIFACT_ID, RUN_GOAL, "MojoSucceeded", "MojoFailed");
List<Element> invokerRunIntegrationTestEvents = XmlUtils.getExecutionEventsByPlugin(mavenSpyLogsElt, GROUP_ID, ARTIFACT_ID, INTEGRATION_TEST_GOAL, "MojoSucceeded", "MojoFailed");
if (invokerRunRunEvents.isEmpty() && invokerRunIntegrationTestEvents.isEmpty()) {
if (LOGGER.isLoggable(Level.FINE)) {
listener.getLogger().println("[withMaven] invokerPublisher - " +
"No " + GROUP_ID + ":" + ARTIFACT_ID + ":" + RUN_GOAL +
" or " + GROUP_ID + ":" + ARTIFACT_ID + ":" + INTEGRATION_TEST_GOAL + " execution found");
}
return;
}
try {
Class.forName("org.jenkinsci.plugins.maveninvoker.MavenInvokerRecorder");
} catch (ClassNotFoundException e) {
listener.getLogger().print("[withMaven] invokerPublisher - Jenkins ");
listener.hyperlink("https://wiki.jenkins.io/display/JENKINS/Maven+Invoker+Plugin", "Maven Invoker Plugin");
listener.getLogger().println(" not found, don't display " + GROUP_ID + ":" + ARTIFACT_ID + ":" + RUN_GOAL + " results in pipeline screen.");
return;
}
executeReporter(context, listener, invokerRunRunEvents);
executeReporter(context, listener, invokerRunIntegrationTestEvents);
}
|
[
"@",
"Override",
"public",
"void",
"process",
"(",
"@",
"Nonnull",
"StepContext",
"context",
",",
"@",
"Nonnull",
"Element",
"mavenSpyLogsElt",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"TaskListener",
"listener",
"=",
"context",
".",
"get",
"(",
"TaskListener",
".",
"class",
")",
";",
"if",
"(",
"listener",
"==",
"null",
")",
"{",
"LOGGER",
".",
"warning",
"(",
"\"TaskListener is NULL, default to stderr\"",
")",
";",
"listener",
"=",
"new",
"StreamBuildListener",
"(",
"(",
"OutputStream",
")",
"System",
".",
"err",
")",
";",
"}",
"List",
"<",
"Element",
">",
"invokerRunRunEvents",
"=",
"XmlUtils",
".",
"getExecutionEventsByPlugin",
"(",
"mavenSpyLogsElt",
",",
"GROUP_ID",
",",
"ARTIFACT_ID",
",",
"RUN_GOAL",
",",
"\"MojoSucceeded\"",
",",
"\"MojoFailed\"",
")",
";",
"List",
"<",
"Element",
">",
"invokerRunIntegrationTestEvents",
"=",
"XmlUtils",
".",
"getExecutionEventsByPlugin",
"(",
"mavenSpyLogsElt",
",",
"GROUP_ID",
",",
"ARTIFACT_ID",
",",
"INTEGRATION_TEST_GOAL",
",",
"\"MojoSucceeded\"",
",",
"\"MojoFailed\"",
")",
";",
"if",
"(",
"invokerRunRunEvents",
".",
"isEmpty",
"(",
")",
"&&",
"invokerRunIntegrationTestEvents",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isLoggable",
"(",
"Level",
".",
"FINE",
")",
")",
"{",
"listener",
".",
"getLogger",
"(",
")",
".",
"println",
"(",
"\"[withMaven] invokerPublisher - \"",
"+",
"\"No \"",
"+",
"GROUP_ID",
"+",
"\":\"",
"+",
"ARTIFACT_ID",
"+",
"\":\"",
"+",
"RUN_GOAL",
"+",
"\" or \"",
"+",
"GROUP_ID",
"+",
"\":\"",
"+",
"ARTIFACT_ID",
"+",
"\":\"",
"+",
"INTEGRATION_TEST_GOAL",
"+",
"\" execution found\"",
")",
";",
"}",
"return",
";",
"}",
"try",
"{",
"Class",
".",
"forName",
"(",
"\"org.jenkinsci.plugins.maveninvoker.MavenInvokerRecorder\"",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"listener",
".",
"getLogger",
"(",
")",
".",
"print",
"(",
"\"[withMaven] invokerPublisher - Jenkins \"",
")",
";",
"listener",
".",
"hyperlink",
"(",
"\"https://wiki.jenkins.io/display/JENKINS/Maven+Invoker+Plugin\"",
",",
"\"Maven Invoker Plugin\"",
")",
";",
"listener",
".",
"getLogger",
"(",
")",
".",
"println",
"(",
"\" not found, don't display \"",
"+",
"GROUP_ID",
"+",
"\":\"",
"+",
"ARTIFACT_ID",
"+",
"\":\"",
"+",
"RUN_GOAL",
"+",
"\" results in pipeline screen.\"",
")",
";",
"return",
";",
"}",
"executeReporter",
"(",
"context",
",",
"listener",
",",
"invokerRunRunEvents",
")",
";",
"executeReporter",
"(",
"context",
",",
"listener",
",",
"invokerRunIntegrationTestEvents",
")",
";",
"}"
] |
/*
<ExecutionEvent type="MojoSucceeded" class="org.apache.maven.lifecycle.internal.DefaultExecutionEvent" _time="2017-06-25 20:47:25.741">
<project baseDir="/home/jenkins/workspace/aProject" file="/home/jenkins/workspace/aProject/pom.xml" groupId="org.myorg" name="My Project" artifactId="my-maven-plugin" version="1.0.0-SNAPSHOT">
<build sourceDirectory="/home/jenkins/workspace/aProject/src/main/java" directory="/home/jenkins/workspace/aProject/target"/>
</project>
<plugin executionId="integration-test" goal="run" groupId="org.apache.maven.plugins" artifactId="maven-invoker-plugin" version="2.0.0">
<projectsDirectory>${invoker.projectsDirectory}</projectsDirectory>
<cloneProjectsTo>/var/lib/jenkins/workspace/ncjira-maven-plugin-pipeline/target/it</cloneProjectsTo>
<reportsDirectory>${invoker.reportsDirectory}</reportsDirectory>
</plugin>
</ExecutionEvent>
|
[
"/",
"*",
"<ExecutionEvent",
"type",
"=",
"MojoSucceeded",
"class",
"=",
"org",
".",
"apache",
".",
"maven",
".",
"lifecycle",
".",
"internal",
".",
"DefaultExecutionEvent",
"_time",
"=",
"2017",
"-",
"06",
"-",
"25",
"20",
":",
"47",
":",
"25",
".",
"741",
">",
"<project",
"baseDir",
"=",
"/",
"home",
"/",
"jenkins",
"/",
"workspace",
"/",
"aProject",
"file",
"=",
"/",
"home",
"/",
"jenkins",
"/",
"workspace",
"/",
"aProject",
"/",
"pom",
".",
"xml",
"groupId",
"=",
"org",
".",
"myorg",
"name",
"=",
"My",
"Project",
"artifactId",
"=",
"my",
"-",
"maven",
"-",
"plugin",
"version",
"=",
"1",
".",
"0",
".",
"0",
"-",
"SNAPSHOT",
">",
"<build",
"sourceDirectory",
"=",
"/",
"home",
"/",
"jenkins",
"/",
"workspace",
"/",
"aProject",
"/",
"src",
"/",
"main",
"/",
"java",
"directory",
"=",
"/",
"home",
"/",
"jenkins",
"/",
"workspace",
"/",
"aProject",
"/",
"target",
"/",
">",
"<",
"/",
"project",
">",
"<plugin",
"executionId",
"=",
"integration",
"-",
"test",
"goal",
"=",
"run",
"groupId",
"=",
"org",
".",
"apache",
".",
"maven",
".",
"plugins",
"artifactId",
"=",
"maven",
"-",
"invoker",
"-",
"plugin",
"version",
"=",
"2",
".",
"0",
".",
"0",
">",
"<projectsDirectory",
">",
"$",
"{",
"invoker",
".",
"projectsDirectory",
"}",
"<",
"/",
"projectsDirectory",
">",
"<cloneProjectsTo",
">",
"/",
"var",
"/",
"lib",
"/",
"jenkins",
"/",
"workspace",
"/",
"ncjira",
"-",
"maven",
"-",
"plugin",
"-",
"pipeline",
"/",
"target",
"/",
"it<",
"/",
"cloneProjectsTo",
">",
"<reportsDirectory",
">",
"$",
"{",
"invoker",
".",
"reportsDirectory",
"}",
"<",
"/",
"reportsDirectory",
">",
"<",
"/",
"plugin",
">",
"<",
"/",
"ExecutionEvent",
">"
] |
train
|
https://github.com/jenkinsci/pipeline-maven-plugin/blob/685d7dbb894fb4c976dbfa922e3caba8e8d5bed8/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/InvokerRunsPublisher.java#L79-L112
|
mcxiaoke/Android-Next
|
recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java
|
HeaderFooterRecyclerAdapter.notifyFooterItemRangeChanged
|
public final void notifyFooterItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart + headerItemCount + contentItemCount, itemCount);
}
|
java
|
public final void notifyFooterItemRangeChanged(int positionStart, int itemCount) {
if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount) {
throw new IndexOutOfBoundsException("The given range [" + positionStart + " - "
+ (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - "
+ (footerItemCount - 1) + "].");
}
notifyItemRangeChanged(positionStart + headerItemCount + contentItemCount, itemCount);
}
|
[
"public",
"final",
"void",
"notifyFooterItemRangeChanged",
"(",
"int",
"positionStart",
",",
"int",
"itemCount",
")",
"{",
"if",
"(",
"positionStart",
"<",
"0",
"||",
"itemCount",
"<",
"0",
"||",
"positionStart",
"+",
"itemCount",
">",
"footerItemCount",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The given range [\"",
"+",
"positionStart",
"+",
"\" - \"",
"+",
"(",
"positionStart",
"+",
"itemCount",
"-",
"1",
")",
"+",
"\"] is not within the position bounds for footer items [0 - \"",
"+",
"(",
"footerItemCount",
"-",
"1",
")",
"+",
"\"].\"",
")",
";",
"}",
"notifyItemRangeChanged",
"(",
"positionStart",
"+",
"headerItemCount",
"+",
"contentItemCount",
",",
"itemCount",
")",
";",
"}"
] |
Notifies that multiple footer items are changed.
@param positionStart the position.
@param itemCount the item count.
|
[
"Notifies",
"that",
"multiple",
"footer",
"items",
"are",
"changed",
"."
] |
train
|
https://github.com/mcxiaoke/Android-Next/blob/1bfdf99d0b81a849aa0fa6697c53ed673151ca39/recycler/src/main/java/com/mcxiaoke/next/recycler/HeaderFooterRecyclerAdapter.java#L361-L368
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mspdi/DatatypeConverter.java
|
DatatypeConverter.parseDurationInThousanthsOfMinutes
|
public static final Duration parseDurationInThousanthsOfMinutes(ProjectProperties properties, Number value, TimeUnit targetTimeUnit)
{
return parseDurationInFractionsOfMinutes(properties, value, targetTimeUnit, 1000);
}
|
java
|
public static final Duration parseDurationInThousanthsOfMinutes(ProjectProperties properties, Number value, TimeUnit targetTimeUnit)
{
return parseDurationInFractionsOfMinutes(properties, value, targetTimeUnit, 1000);
}
|
[
"public",
"static",
"final",
"Duration",
"parseDurationInThousanthsOfMinutes",
"(",
"ProjectProperties",
"properties",
",",
"Number",
"value",
",",
"TimeUnit",
"targetTimeUnit",
")",
"{",
"return",
"parseDurationInFractionsOfMinutes",
"(",
"properties",
",",
"value",
",",
"targetTimeUnit",
",",
"1000",
")",
";",
"}"
] |
Parse duration represented in thousandths of minutes.
@param properties project properties
@param value duration value
@param targetTimeUnit required output time units
@return Duration instance
|
[
"Parse",
"duration",
"represented",
"in",
"thousandths",
"of",
"minutes",
"."
] |
train
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mspdi/DatatypeConverter.java#L1309-L1312
|
aol/micro-server
|
micro-s3/src/main/java/com/oath/micro/server/s3/data/ReadUtils.java
|
ReadUtils.getInputStream
|
public InputStream getInputStream(String bucketName, String key)
throws AmazonServiceException, AmazonClientException, InterruptedException, IOException {
Supplier<File> tempFileSupplier = ExceptionSoftener.softenSupplier(() -> Files.createTempFile(FileSystems.getDefault()
.getPath(tmpDirectory),
"micro-s3",
"file")
.toFile());
return getInputStream(bucketName, key, tempFileSupplier);
}
|
java
|
public InputStream getInputStream(String bucketName, String key)
throws AmazonServiceException, AmazonClientException, InterruptedException, IOException {
Supplier<File> tempFileSupplier = ExceptionSoftener.softenSupplier(() -> Files.createTempFile(FileSystems.getDefault()
.getPath(tmpDirectory),
"micro-s3",
"file")
.toFile());
return getInputStream(bucketName, key, tempFileSupplier);
}
|
[
"public",
"InputStream",
"getInputStream",
"(",
"String",
"bucketName",
",",
"String",
"key",
")",
"throws",
"AmazonServiceException",
",",
"AmazonClientException",
",",
"InterruptedException",
",",
"IOException",
"{",
"Supplier",
"<",
"File",
">",
"tempFileSupplier",
"=",
"ExceptionSoftener",
".",
"softenSupplier",
"(",
"(",
")",
"->",
"Files",
".",
"createTempFile",
"(",
"FileSystems",
".",
"getDefault",
"(",
")",
".",
"getPath",
"(",
"tmpDirectory",
")",
",",
"\"micro-s3\"",
",",
"\"file\"",
")",
".",
"toFile",
"(",
")",
")",
";",
"return",
"getInputStream",
"(",
"bucketName",
",",
"key",
",",
"tempFileSupplier",
")",
";",
"}"
] |
Method returns InputStream from S3Object. Multi-part download is used to
get file. s3.tmp.dir property used to store temporary files.
@param bucketName
@param key
@return
@throws AmazonServiceException
@throws AmazonClientException
@throws InterruptedException
@throws IOException
|
[
"Method",
"returns",
"InputStream",
"from",
"S3Object",
".",
"Multi",
"-",
"part",
"download",
"is",
"used",
"to",
"get",
"file",
".",
"s3",
".",
"tmp",
".",
"dir",
"property",
"used",
"to",
"store",
"temporary",
"files",
"."
] |
train
|
https://github.com/aol/micro-server/blob/5c7103c5b43d2f4d16350dbd2f9802af307c63f7/micro-s3/src/main/java/com/oath/micro/server/s3/data/ReadUtils.java#L68-L76
|
ysc/HtmlExtractor
|
html-extractor/src/main/java/org/apdplat/extractor/html/impl/ExtractFunctionExecutor.java
|
ExtractFunctionExecutor.executeSubstring
|
public static String executeSubstring(String text, String parseExpression) {
LOGGER.debug("substring抽取函数之前:" + text);
String parameter = parseExpression.replace("substring(", "");
parameter = parameter.substring(0, parameter.length() - 1);
String[] attr = parameter.split(",");
if (attr != null && attr.length == 2) {
int beginIndex = Integer.parseInt(attr[0]);
int endIndex = Integer.parseInt(attr[1]);
text = text.substring(beginIndex, endIndex);
}
LOGGER.debug("substring抽取函数之后:" + text);
return text;
}
|
java
|
public static String executeSubstring(String text, String parseExpression) {
LOGGER.debug("substring抽取函数之前:" + text);
String parameter = parseExpression.replace("substring(", "");
parameter = parameter.substring(0, parameter.length() - 1);
String[] attr = parameter.split(",");
if (attr != null && attr.length == 2) {
int beginIndex = Integer.parseInt(attr[0]);
int endIndex = Integer.parseInt(attr[1]);
text = text.substring(beginIndex, endIndex);
}
LOGGER.debug("substring抽取函数之后:" + text);
return text;
}
|
[
"public",
"static",
"String",
"executeSubstring",
"(",
"String",
"text",
",",
"String",
"parseExpression",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"substring抽取函数之前:\" + text);",
"",
"",
"",
"",
"String",
"parameter",
"=",
"parseExpression",
".",
"replace",
"(",
"\"substring(\"",
",",
"\"\"",
")",
";",
"parameter",
"=",
"parameter",
".",
"substring",
"(",
"0",
",",
"parameter",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"String",
"[",
"]",
"attr",
"=",
"parameter",
".",
"split",
"(",
"\",\"",
")",
";",
"if",
"(",
"attr",
"!=",
"null",
"&&",
"attr",
".",
"length",
"==",
"2",
")",
"{",
"int",
"beginIndex",
"=",
"Integer",
".",
"parseInt",
"(",
"attr",
"[",
"0",
"]",
")",
";",
"int",
"endIndex",
"=",
"Integer",
".",
"parseInt",
"(",
"attr",
"[",
"1",
"]",
")",
";",
"text",
"=",
"text",
".",
"substring",
"(",
"beginIndex",
",",
"endIndex",
")",
";",
"}",
"LOGGER",
".",
"debug",
"(",
"\"substring抽取函数之后:\" + text);",
"",
"",
"",
"",
"return",
"text",
";",
"}"
] |
截取指定范围的文本 使用方法:substring(0,19)
括号内的参数为2个,分别是字符索引下标,截取从0开始到19的字符串,索引包括0,不包括19,即[0 - 19)
@param text CSS路径抽取出来的文本
@param parseExpression 抽取函数
@return 抽取函数处理之后的文本
|
[
"截取指定范围的文本",
"使用方法:substring",
"(",
"0",
"19",
")",
"括号内的参数为2个,分别是字符索引下标,截取从0开始到19的字符串,索引包括0,不包括19",
"即",
"[",
"0",
"-",
"19",
")"
] |
train
|
https://github.com/ysc/HtmlExtractor/blob/5378bc5f94138562c55506cf81de1ffe72ab701e/html-extractor/src/main/java/org/apdplat/extractor/html/impl/ExtractFunctionExecutor.java#L74-L86
|
Azure/azure-sdk-for-java
|
iotcentral/resource-manager/v2017_07_01_privatepreview/src/main/java/com/microsoft/azure/management/iotcentral/v2017_07_01_privatepreview/implementation/AppsInner.java
|
AppsInner.beginUpdateAsync
|
public Observable<AppInner> beginUpdateAsync(String resourceGroupName, String resourceName, AppPatch appPatch) {
return beginUpdateWithServiceResponseAsync(resourceGroupName, resourceName, appPatch).map(new Func1<ServiceResponse<AppInner>, AppInner>() {
@Override
public AppInner call(ServiceResponse<AppInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<AppInner> beginUpdateAsync(String resourceGroupName, String resourceName, AppPatch appPatch) {
return beginUpdateWithServiceResponseAsync(resourceGroupName, resourceName, appPatch).map(new Func1<ServiceResponse<AppInner>, AppInner>() {
@Override
public AppInner call(ServiceResponse<AppInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"AppInner",
">",
"beginUpdateAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"resourceName",
",",
"AppPatch",
"appPatch",
")",
"{",
"return",
"beginUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"resourceName",
",",
"appPatch",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"AppInner",
">",
",",
"AppInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"AppInner",
"call",
"(",
"ServiceResponse",
"<",
"AppInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Update the metadata of an IoT Central application.
@param resourceGroupName The name of the resource group that contains the IoT Central application.
@param resourceName The ARM resource name of the IoT Central application.
@param appPatch The IoT Central application metadata and security metadata.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the AppInner object
|
[
"Update",
"the",
"metadata",
"of",
"an",
"IoT",
"Central",
"application",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/iotcentral/resource-manager/v2017_07_01_privatepreview/src/main/java/com/microsoft/azure/management/iotcentral/v2017_07_01_privatepreview/implementation/AppsInner.java#L495-L502
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.app.manager/src/com/ibm/ws/app/manager/ApplicationManager.java
|
ApplicationManager.modified
|
@Modified
protected void modified(ComponentContext compcontext, Map<String, Object> properties) {
Boolean autoExpandValue = (Boolean) properties.get("autoExpand");
setExpandApps(autoExpandValue == null ? false : autoExpandValue);
Boolean useJandexValue = getProperty(properties, "useJandex", false);
setUseJandex(useJandexValue == null ? false : useJandexValue);
//System.setProperty("com.ibm.ws.jandex.enable", useJandexValue.toString()); // Temporary -- REMOVE THIS LATER ////
long startTimeoutValue = getProperty(properties, "startTimeout", 30L);
setStartTimeout(startTimeoutValue);
long stopTimeoutValue = getProperty(properties, "stopTimeout", 30L);
setStopTimeout(stopTimeoutValue);
ApplicationStateCoordinator.setApplicationStartTimeout(startTimeoutValue);
ApplicationStateCoordinator.setApplicationStopTimeout(stopTimeoutValue);
}
|
java
|
@Modified
protected void modified(ComponentContext compcontext, Map<String, Object> properties) {
Boolean autoExpandValue = (Boolean) properties.get("autoExpand");
setExpandApps(autoExpandValue == null ? false : autoExpandValue);
Boolean useJandexValue = getProperty(properties, "useJandex", false);
setUseJandex(useJandexValue == null ? false : useJandexValue);
//System.setProperty("com.ibm.ws.jandex.enable", useJandexValue.toString()); // Temporary -- REMOVE THIS LATER ////
long startTimeoutValue = getProperty(properties, "startTimeout", 30L);
setStartTimeout(startTimeoutValue);
long stopTimeoutValue = getProperty(properties, "stopTimeout", 30L);
setStopTimeout(stopTimeoutValue);
ApplicationStateCoordinator.setApplicationStartTimeout(startTimeoutValue);
ApplicationStateCoordinator.setApplicationStopTimeout(stopTimeoutValue);
}
|
[
"@",
"Modified",
"protected",
"void",
"modified",
"(",
"ComponentContext",
"compcontext",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
")",
"{",
"Boolean",
"autoExpandValue",
"=",
"(",
"Boolean",
")",
"properties",
".",
"get",
"(",
"\"autoExpand\"",
")",
";",
"setExpandApps",
"(",
"autoExpandValue",
"==",
"null",
"?",
"false",
":",
"autoExpandValue",
")",
";",
"Boolean",
"useJandexValue",
"=",
"getProperty",
"(",
"properties",
",",
"\"useJandex\"",
",",
"false",
")",
";",
"setUseJandex",
"(",
"useJandexValue",
"==",
"null",
"?",
"false",
":",
"useJandexValue",
")",
";",
"//System.setProperty(\"com.ibm.ws.jandex.enable\", useJandexValue.toString()); // Temporary -- REMOVE THIS LATER ////",
"long",
"startTimeoutValue",
"=",
"getProperty",
"(",
"properties",
",",
"\"startTimeout\"",
",",
"30L",
")",
";",
"setStartTimeout",
"(",
"startTimeoutValue",
")",
";",
"long",
"stopTimeoutValue",
"=",
"getProperty",
"(",
"properties",
",",
"\"stopTimeout\"",
",",
"30L",
")",
";",
"setStopTimeout",
"(",
"stopTimeoutValue",
")",
";",
"ApplicationStateCoordinator",
".",
"setApplicationStartTimeout",
"(",
"startTimeoutValue",
")",
";",
"ApplicationStateCoordinator",
".",
"setApplicationStopTimeout",
"(",
"stopTimeoutValue",
")",
";",
"}"
] |
DS method to modify the configuration of this component
@param compcontext the context of this component
@param properties the updated configuration properties
|
[
"DS",
"method",
"to",
"modify",
"the",
"configuration",
"of",
"this",
"component"
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.app.manager/src/com/ibm/ws/app/manager/ApplicationManager.java#L53-L68
|
Mozu/mozu-java
|
mozu-javaasync-core/src/main/java/com/mozu/api/urls/platform/appdev/AppPackageUrl.java
|
AppPackageUrl.clonePackageUrl
|
public static MozuUrl clonePackageUrl(String applicationKey, String packageName, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/platform/appdev/apppackages/{applicationKey}/clone/{packageName}?responseFields={responseFields}");
formatter.formatUrl("applicationKey", applicationKey);
formatter.formatUrl("packageName", packageName);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
java
|
public static MozuUrl clonePackageUrl(String applicationKey, String packageName, String responseFields)
{
UrlFormatter formatter = new UrlFormatter("/api/platform/appdev/apppackages/{applicationKey}/clone/{packageName}?responseFields={responseFields}");
formatter.formatUrl("applicationKey", applicationKey);
formatter.formatUrl("packageName", packageName);
formatter.formatUrl("responseFields", responseFields);
return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
}
|
[
"public",
"static",
"MozuUrl",
"clonePackageUrl",
"(",
"String",
"applicationKey",
",",
"String",
"packageName",
",",
"String",
"responseFields",
")",
"{",
"UrlFormatter",
"formatter",
"=",
"new",
"UrlFormatter",
"(",
"\"/api/platform/appdev/apppackages/{applicationKey}/clone/{packageName}?responseFields={responseFields}\"",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"applicationKey\"",
",",
"applicationKey",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"packageName\"",
",",
"packageName",
")",
";",
"formatter",
".",
"formatUrl",
"(",
"\"responseFields\"",
",",
"responseFields",
")",
";",
"return",
"new",
"MozuUrl",
"(",
"formatter",
".",
"getResourceUrl",
"(",
")",
",",
"MozuUrl",
".",
"UrlLocation",
".",
"TENANT_POD",
")",
";",
"}"
] |
Get Resource Url for ClonePackage
@param applicationKey The application key uniquely identifies the developer namespace, application ID, version, and package in Dev Center. The format is {Dev Account namespace}.{Application ID}.{Application Version}.{Package name}.
@param packageName
@param responseFields Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.
@return String Resource Url
|
[
"Get",
"Resource",
"Url",
"for",
"ClonePackage"
] |
train
|
https://github.com/Mozu/mozu-java/blob/5beadde73601a859f845e3e2fc1077b39c8bea83/mozu-javaasync-core/src/main/java/com/mozu/api/urls/platform/appdev/AppPackageUrl.java#L115-L122
|
looly/hutool
|
hutool-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java
|
SecureUtil.getCertificate
|
public static Certificate getCertificate(KeyStore keyStore, String alias) {
return KeyUtil.getCertificate(keyStore, alias);
}
|
java
|
public static Certificate getCertificate(KeyStore keyStore, String alias) {
return KeyUtil.getCertificate(keyStore, alias);
}
|
[
"public",
"static",
"Certificate",
"getCertificate",
"(",
"KeyStore",
"keyStore",
",",
"String",
"alias",
")",
"{",
"return",
"KeyUtil",
".",
"getCertificate",
"(",
"keyStore",
",",
"alias",
")",
";",
"}"
] |
获得 Certification
@param keyStore {@link KeyStore}
@param alias 别名
@return {@link Certificate}
|
[
"获得",
"Certification"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-crypto/src/main/java/cn/hutool/crypto/SecureUtil.java#L388-L390
|
Azure/azure-sdk-for-java
|
policy/resource-manager/v2016_12_01/src/main/java/com/microsoft/azure/management/policy/v2016_12_01/implementation/PolicyAssignmentsInner.java
|
PolicyAssignmentsInner.createAsync
|
public Observable<PolicyAssignmentInner> createAsync(String scope, String policyAssignmentName, PolicyAssignmentInner parameters) {
return createWithServiceResponseAsync(scope, policyAssignmentName, parameters).map(new Func1<ServiceResponse<PolicyAssignmentInner>, PolicyAssignmentInner>() {
@Override
public PolicyAssignmentInner call(ServiceResponse<PolicyAssignmentInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<PolicyAssignmentInner> createAsync(String scope, String policyAssignmentName, PolicyAssignmentInner parameters) {
return createWithServiceResponseAsync(scope, policyAssignmentName, parameters).map(new Func1<ServiceResponse<PolicyAssignmentInner>, PolicyAssignmentInner>() {
@Override
public PolicyAssignmentInner call(ServiceResponse<PolicyAssignmentInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"PolicyAssignmentInner",
">",
"createAsync",
"(",
"String",
"scope",
",",
"String",
"policyAssignmentName",
",",
"PolicyAssignmentInner",
"parameters",
")",
"{",
"return",
"createWithServiceResponseAsync",
"(",
"scope",
",",
"policyAssignmentName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"PolicyAssignmentInner",
">",
",",
"PolicyAssignmentInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"PolicyAssignmentInner",
"call",
"(",
"ServiceResponse",
"<",
"PolicyAssignmentInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates a policy assignment.
Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group.
@param scope The scope of the policy assignment.
@param policyAssignmentName The name of the policy assignment.
@param parameters Parameters for the policy assignment.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the PolicyAssignmentInner object
|
[
"Creates",
"a",
"policy",
"assignment",
".",
"Policy",
"assignments",
"are",
"inherited",
"by",
"child",
"resources",
".",
"For",
"example",
"when",
"you",
"apply",
"a",
"policy",
"to",
"a",
"resource",
"group",
"that",
"policy",
"is",
"assigned",
"to",
"all",
"resources",
"in",
"the",
"group",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/policy/resource-manager/v2016_12_01/src/main/java/com/microsoft/azure/management/policy/v2016_12_01/implementation/PolicyAssignmentsInner.java#L241-L248
|
GoogleCloudPlatform/google-cloud-datastore
|
java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java
|
DatastoreHelper.getServiceAccountCredential
|
public static Credential getServiceAccountCredential(String serviceAccountId,
PrivateKey privateKey, Collection<String> serviceAccountScopes)
throws GeneralSecurityException, IOException {
return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes)
.setServiceAccountPrivateKey(privateKey)
.build();
}
|
java
|
public static Credential getServiceAccountCredential(String serviceAccountId,
PrivateKey privateKey, Collection<String> serviceAccountScopes)
throws GeneralSecurityException, IOException {
return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes)
.setServiceAccountPrivateKey(privateKey)
.build();
}
|
[
"public",
"static",
"Credential",
"getServiceAccountCredential",
"(",
"String",
"serviceAccountId",
",",
"PrivateKey",
"privateKey",
",",
"Collection",
"<",
"String",
">",
"serviceAccountScopes",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"return",
"getCredentialBuilderWithoutPrivateKey",
"(",
"serviceAccountId",
",",
"serviceAccountScopes",
")",
".",
"setServiceAccountPrivateKey",
"(",
"privateKey",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Constructs credentials for the given account and key.
@param serviceAccountId service account ID (typically an e-mail address).
@param privateKey the private key for the given account.
@param serviceAccountScopes Collection of OAuth scopes to use with the the service
account flow or {@code null} if not.
@return valid credentials or {@code null}
|
[
"Constructs",
"credentials",
"for",
"the",
"given",
"account",
"and",
"key",
"."
] |
train
|
https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java#L194-L200
|
jferard/fastods
|
fastods/src/main/java/com/github/jferard/fastods/TextBuilder.java
|
TextBuilder.styledLink
|
public TextBuilder styledLink(final String text, final TextStyle ts, final String ref) {
this.curParagraphBuilder.styledLink(text, ts, ref);
return this;
}
|
java
|
public TextBuilder styledLink(final String text, final TextStyle ts, final String ref) {
this.curParagraphBuilder.styledLink(text, ts, ref);
return this;
}
|
[
"public",
"TextBuilder",
"styledLink",
"(",
"final",
"String",
"text",
",",
"final",
"TextStyle",
"ts",
",",
"final",
"String",
"ref",
")",
"{",
"this",
".",
"curParagraphBuilder",
".",
"styledLink",
"(",
"text",
",",
"ts",
",",
"ref",
")",
";",
"return",
"this",
";",
"}"
] |
Create a styled link in the current paragraph.
@param text the text
@param ts the style
@param ref the destination
@return this for fluent style
|
[
"Create",
"a",
"styled",
"link",
"in",
"the",
"current",
"paragraph",
"."
] |
train
|
https://github.com/jferard/fastods/blob/a034d173083ffa602dc525699b97f753082eaef9/fastods/src/main/java/com/github/jferard/fastods/TextBuilder.java#L199-L202
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java
|
MapUtil.of
|
public static <K, V> HashMap<K, V> of(K key, V value) {
return of(key, value, false);
}
|
java
|
public static <K, V> HashMap<K, V> of(K key, V value) {
return of(key, value, false);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"HashMap",
"<",
"K",
",",
"V",
">",
"of",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"return",
"of",
"(",
"key",
",",
"value",
",",
"false",
")",
";",
"}"
] |
将单一键值对转换为Map
@param <K> 键类型
@param <V> 值类型
@param key 键
@param value 值
@return {@link HashMap}
|
[
"将单一键值对转换为Map"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/map/MapUtil.java#L175-L177
|
apache/incubator-atlas
|
repository/src/main/java/org/apache/atlas/gremlin/GremlinExpressionFactory.java
|
GremlinExpressionFactory.generateUnaryHasExpression
|
public GroovyExpression generateUnaryHasExpression(GroovyExpression parent, String fieldName) {
return new FunctionCallExpression(TraversalStepType.FILTER, parent, HAS_METHOD, new LiteralExpression(fieldName));
}
|
java
|
public GroovyExpression generateUnaryHasExpression(GroovyExpression parent, String fieldName) {
return new FunctionCallExpression(TraversalStepType.FILTER, parent, HAS_METHOD, new LiteralExpression(fieldName));
}
|
[
"public",
"GroovyExpression",
"generateUnaryHasExpression",
"(",
"GroovyExpression",
"parent",
",",
"String",
"fieldName",
")",
"{",
"return",
"new",
"FunctionCallExpression",
"(",
"TraversalStepType",
".",
"FILTER",
",",
"parent",
",",
"HAS_METHOD",
",",
"new",
"LiteralExpression",
"(",
"fieldName",
")",
")",
";",
"}"
] |
Generates an expression which checks whether the vertices in the query have
a field with the given name.
@param parent
@param fieldName
@return
|
[
"Generates",
"an",
"expression",
"which",
"checks",
"whether",
"the",
"vertices",
"in",
"the",
"query",
"have",
"a",
"field",
"with",
"the",
"given",
"name",
"."
] |
train
|
https://github.com/apache/incubator-atlas/blob/e0d2cdc27c32742ebecd24db4cca62dc04dcdf4b/repository/src/main/java/org/apache/atlas/gremlin/GremlinExpressionFactory.java#L421-L423
|
google/closure-compiler
|
src/com/google/javascript/jscomp/DotFormatter.java
|
DotFormatter.toDot
|
static String toDot(Node n, ControlFlowGraph<Node> inCFG)
throws IOException {
StringBuilder builder = new StringBuilder();
new DotFormatter(n, inCFG, builder, false);
return builder.toString();
}
|
java
|
static String toDot(Node n, ControlFlowGraph<Node> inCFG)
throws IOException {
StringBuilder builder = new StringBuilder();
new DotFormatter(n, inCFG, builder, false);
return builder.toString();
}
|
[
"static",
"String",
"toDot",
"(",
"Node",
"n",
",",
"ControlFlowGraph",
"<",
"Node",
">",
"inCFG",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"new",
"DotFormatter",
"(",
"n",
",",
"inCFG",
",",
"builder",
",",
"false",
")",
";",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
Converts an AST to dot representation.
@param n the root of the AST described in the dot formatted string
@param inCFG Control Flow Graph.
@return the dot representation of the AST
|
[
"Converts",
"an",
"AST",
"to",
"dot",
"representation",
"."
] |
train
|
https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DotFormatter.java#L93-L98
|
Impetus/Kundera
|
src/jpa-engine/core/src/main/java/com/impetus/kundera/utils/ReflectUtils.java
|
ReflectUtils.hasSuperClass
|
public static boolean hasSuperClass(Class<?> has, Class<?> in)
{
if (in.equals(has))
{
return true;
}
boolean match = false;
// stop if the superclass is Object
if (in.getSuperclass() != null && in.getSuperclass().equals(Object.class))
{
return match;
}
match = in.getSuperclass() != null ? hasSuperClass(has, in.getSuperclass()): false;
return match;
}
|
java
|
public static boolean hasSuperClass(Class<?> has, Class<?> in)
{
if (in.equals(has))
{
return true;
}
boolean match = false;
// stop if the superclass is Object
if (in.getSuperclass() != null && in.getSuperclass().equals(Object.class))
{
return match;
}
match = in.getSuperclass() != null ? hasSuperClass(has, in.getSuperclass()): false;
return match;
}
|
[
"public",
"static",
"boolean",
"hasSuperClass",
"(",
"Class",
"<",
"?",
">",
"has",
",",
"Class",
"<",
"?",
">",
"in",
")",
"{",
"if",
"(",
"in",
".",
"equals",
"(",
"has",
")",
")",
"{",
"return",
"true",
";",
"}",
"boolean",
"match",
"=",
"false",
";",
"// stop if the superclass is Object\r",
"if",
"(",
"in",
".",
"getSuperclass",
"(",
")",
"!=",
"null",
"&&",
"in",
".",
"getSuperclass",
"(",
")",
".",
"equals",
"(",
"Object",
".",
"class",
")",
")",
"{",
"return",
"match",
";",
"}",
"match",
"=",
"in",
".",
"getSuperclass",
"(",
")",
"!=",
"null",
"?",
"hasSuperClass",
"(",
"has",
",",
"in",
".",
"getSuperclass",
"(",
")",
")",
":",
"false",
";",
"return",
"match",
";",
"}"
] |
Checks for super "has" in class "in".
@param has
the has
@param in
the in
@return true, if exists?
|
[
"Checks",
"for",
"super",
"has",
"in",
"class",
"in",
"."
] |
train
|
https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/utils/ReflectUtils.java#L108-L122
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.security.token.ltpa/src/com/ibm/ws/security/token/ltpa/internal/LTPAToken2.java
|
LTPAToken2.toUTF8String
|
private static final String toUTF8String(byte[] b) {
String ns = null;
try {
ns = new String(b, "UTF8");
} catch (UnsupportedEncodingException e) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Error converting to string; " + e);
}
}
return ns;
}
|
java
|
private static final String toUTF8String(byte[] b) {
String ns = null;
try {
ns = new String(b, "UTF8");
} catch (UnsupportedEncodingException e) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Error converting to string; " + e);
}
}
return ns;
}
|
[
"private",
"static",
"final",
"String",
"toUTF8String",
"(",
"byte",
"[",
"]",
"b",
")",
"{",
"String",
"ns",
"=",
"null",
";",
"try",
"{",
"ns",
"=",
"new",
"String",
"(",
"b",
",",
"\"UTF8\"",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEventEnabled",
"(",
")",
")",
"{",
"Tr",
".",
"event",
"(",
"tc",
",",
"\"Error converting to string; \"",
"+",
"e",
")",
";",
"}",
"}",
"return",
"ns",
";",
"}"
] |
Convert the byte representation to the UTF-8 String form.
@param b The byte representation
@return The UTF-8 String form
|
[
"Convert",
"the",
"byte",
"representation",
"to",
"the",
"UTF",
"-",
"8",
"String",
"form",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.security.token.ltpa/src/com/ibm/ws/security/token/ltpa/internal/LTPAToken2.java#L431-L441
|
zaproxy/zaproxy
|
src/org/zaproxy/zap/view/StandardFieldsDialog.java
|
StandardFieldsDialog.addNodeSelectField
|
public void addNodeSelectField(final String fieldLabel, final SiteNode value,
final boolean editable, final boolean allowRoot) {
validateNotTabbed();
final ZapTextField text = new ZapTextField();
text.setEditable(editable);
if (value != null) {
text.setText(getNodeText(value));
}
JButton selectButton = new JButton(Constant.messages.getString("all.button.select"));
selectButton.setIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png"))); // Globe icon
selectButton.addActionListener(new java.awt.event.ActionListener() {
// Keep a local copy so that we can always select the last node chosen
SiteNode node = value;
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
NodeSelectDialog nsd = new NodeSelectDialog(StandardFieldsDialog.this);
nsd.setAllowRoot(allowRoot);
SiteNode node = nsd.showDialog(this.node);
if (node != null) {
text.setText(getNodeText(node));
this.node = node;
siteNodeSelected(fieldLabel, node);
}
}
});
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.add(text, LayoutHelper.getGBC(0, 0, 1, 1.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4,4,4,4)));
panel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4,4,4,4)));
this.addField(fieldLabel, text, panel, 0.0D);
}
|
java
|
public void addNodeSelectField(final String fieldLabel, final SiteNode value,
final boolean editable, final boolean allowRoot) {
validateNotTabbed();
final ZapTextField text = new ZapTextField();
text.setEditable(editable);
if (value != null) {
text.setText(getNodeText(value));
}
JButton selectButton = new JButton(Constant.messages.getString("all.button.select"));
selectButton.setIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png"))); // Globe icon
selectButton.addActionListener(new java.awt.event.ActionListener() {
// Keep a local copy so that we can always select the last node chosen
SiteNode node = value;
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
NodeSelectDialog nsd = new NodeSelectDialog(StandardFieldsDialog.this);
nsd.setAllowRoot(allowRoot);
SiteNode node = nsd.showDialog(this.node);
if (node != null) {
text.setText(getNodeText(node));
this.node = node;
siteNodeSelected(fieldLabel, node);
}
}
});
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.add(text, LayoutHelper.getGBC(0, 0, 1, 1.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4,4,4,4)));
panel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4,4,4,4)));
this.addField(fieldLabel, text, panel, 0.0D);
}
|
[
"public",
"void",
"addNodeSelectField",
"(",
"final",
"String",
"fieldLabel",
",",
"final",
"SiteNode",
"value",
",",
"final",
"boolean",
"editable",
",",
"final",
"boolean",
"allowRoot",
")",
"{",
"validateNotTabbed",
"(",
")",
";",
"final",
"ZapTextField",
"text",
"=",
"new",
"ZapTextField",
"(",
")",
";",
"text",
".",
"setEditable",
"(",
"editable",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"text",
".",
"setText",
"(",
"getNodeText",
"(",
"value",
")",
")",
";",
"}",
"JButton",
"selectButton",
"=",
"new",
"JButton",
"(",
"Constant",
".",
"messages",
".",
"getString",
"(",
"\"all.button.select\"",
")",
")",
";",
"selectButton",
".",
"setIcon",
"(",
"new",
"ImageIcon",
"(",
"View",
".",
"class",
".",
"getResource",
"(",
"\"/resource/icon/16/094.png\"",
")",
")",
")",
";",
"// Globe icon",
"selectButton",
".",
"addActionListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"ActionListener",
"(",
")",
"{",
"// Keep a local copy so that we can always select the last node chosen",
"SiteNode",
"node",
"=",
"value",
";",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"e",
")",
"{",
"NodeSelectDialog",
"nsd",
"=",
"new",
"NodeSelectDialog",
"(",
"StandardFieldsDialog",
".",
"this",
")",
";",
"nsd",
".",
"setAllowRoot",
"(",
"allowRoot",
")",
";",
"SiteNode",
"node",
"=",
"nsd",
".",
"showDialog",
"(",
"this",
".",
"node",
")",
";",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"text",
".",
"setText",
"(",
"getNodeText",
"(",
"node",
")",
")",
";",
"this",
".",
"node",
"=",
"node",
";",
"siteNodeSelected",
"(",
"fieldLabel",
",",
"node",
")",
";",
"}",
"}",
"}",
")",
";",
"JPanel",
"panel",
"=",
"new",
"JPanel",
"(",
")",
";",
"panel",
".",
"setLayout",
"(",
"new",
"GridBagLayout",
"(",
")",
")",
";",
"panel",
".",
"add",
"(",
"text",
",",
"LayoutHelper",
".",
"getGBC",
"(",
"0",
",",
"0",
",",
"1",
",",
"1.0D",
",",
"0.0D",
",",
"GridBagConstraints",
".",
"BOTH",
",",
"new",
"Insets",
"(",
"4",
",",
"4",
",",
"4",
",",
"4",
")",
")",
")",
";",
"panel",
".",
"add",
"(",
"selectButton",
",",
"LayoutHelper",
".",
"getGBC",
"(",
"1",
",",
"0",
",",
"1",
",",
"0.0D",
",",
"0.0D",
",",
"GridBagConstraints",
".",
"BOTH",
",",
"new",
"Insets",
"(",
"4",
",",
"4",
",",
"4",
",",
"4",
")",
")",
")",
";",
"this",
".",
"addField",
"(",
"fieldLabel",
",",
"text",
",",
"panel",
",",
"0.0D",
")",
";",
"}"
] |
/*
Add a 'node select' field which provides a button for showing a Node Select Dialog and a
non editable field for showing the node selected
|
[
"/",
"*",
"Add",
"a",
"node",
"select",
"field",
"which",
"provides",
"a",
"button",
"for",
"showing",
"a",
"Node",
"Select",
"Dialog",
"and",
"a",
"non",
"editable",
"field",
"for",
"showing",
"the",
"node",
"selected"
] |
train
|
https://github.com/zaproxy/zaproxy/blob/0cbe5121f2ae1ecca222513d182759210c569bec/src/org/zaproxy/zap/view/StandardFieldsDialog.java#L1101-L1132
|
spotify/styx
|
styx-common/src/main/java/com/spotify/styx/util/TimeUtil.java
|
TimeUtil.addOffset
|
public static ZonedDateTime addOffset(ZonedDateTime time, String offset) {
final Matcher matcher = OFFSET_PATTERN.matcher(offset);
if (!matcher.matches()) {
throw new DateTimeParseException("Unable to parse offset period", offset, 0);
}
final String sign = matcher.group(1);
final String periodOffset = sign + "P" + Optional.ofNullable(matcher.group(2)).orElse("0D");
final String durationOffset = sign + "PT" + Optional.ofNullable(matcher.group(4)).orElse("0S");
final TemporalAmount dateAmount = Period.parse(periodOffset);
final TemporalAmount timeAmount = Duration.parse(durationOffset);
return time.plus(dateAmount).plus(timeAmount);
}
|
java
|
public static ZonedDateTime addOffset(ZonedDateTime time, String offset) {
final Matcher matcher = OFFSET_PATTERN.matcher(offset);
if (!matcher.matches()) {
throw new DateTimeParseException("Unable to parse offset period", offset, 0);
}
final String sign = matcher.group(1);
final String periodOffset = sign + "P" + Optional.ofNullable(matcher.group(2)).orElse("0D");
final String durationOffset = sign + "PT" + Optional.ofNullable(matcher.group(4)).orElse("0S");
final TemporalAmount dateAmount = Period.parse(periodOffset);
final TemporalAmount timeAmount = Duration.parse(durationOffset);
return time.plus(dateAmount).plus(timeAmount);
}
|
[
"public",
"static",
"ZonedDateTime",
"addOffset",
"(",
"ZonedDateTime",
"time",
",",
"String",
"offset",
")",
"{",
"final",
"Matcher",
"matcher",
"=",
"OFFSET_PATTERN",
".",
"matcher",
"(",
"offset",
")",
";",
"if",
"(",
"!",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"throw",
"new",
"DateTimeParseException",
"(",
"\"Unable to parse offset period\"",
",",
"offset",
",",
"0",
")",
";",
"}",
"final",
"String",
"sign",
"=",
"matcher",
".",
"group",
"(",
"1",
")",
";",
"final",
"String",
"periodOffset",
"=",
"sign",
"+",
"\"P\"",
"+",
"Optional",
".",
"ofNullable",
"(",
"matcher",
".",
"group",
"(",
"2",
")",
")",
".",
"orElse",
"(",
"\"0D\"",
")",
";",
"final",
"String",
"durationOffset",
"=",
"sign",
"+",
"\"PT\"",
"+",
"Optional",
".",
"ofNullable",
"(",
"matcher",
".",
"group",
"(",
"4",
")",
")",
".",
"orElse",
"(",
"\"0S\"",
")",
";",
"final",
"TemporalAmount",
"dateAmount",
"=",
"Period",
".",
"parse",
"(",
"periodOffset",
")",
";",
"final",
"TemporalAmount",
"timeAmount",
"=",
"Duration",
".",
"parse",
"(",
"durationOffset",
")",
";",
"return",
"time",
".",
"plus",
"(",
"dateAmount",
")",
".",
"plus",
"(",
"timeAmount",
")",
";",
"}"
] |
Applies an ISO 8601 Duration to a {@link ZonedDateTime}.
<p>Since the JDK defined different types for the different parts of a Duration
specification, this utility method is needed when a full Duration is to be applied to a
{@link ZonedDateTime}. See {@link Period} and {@link Duration}.
<p>All date-based parts of a Duration specification (Year, Month, Day or Week) are parsed
using {@link Period#parse(CharSequence)} and added to the time. The remaining parts (Hour,
Minute, Second) are parsed using {@link Duration#parse(CharSequence)} and added to the time.
@param time A zoned date time to apply the offset to
@param offset The offset in ISO 8601 Duration format
@return A zoned date time with the offset applied
|
[
"Applies",
"an",
"ISO",
"8601",
"Duration",
"to",
"a",
"{",
"@link",
"ZonedDateTime",
"}",
"."
] |
train
|
https://github.com/spotify/styx/blob/0d63999beeb93a17447e3bbccaa62175b74cf6e4/styx-common/src/main/java/com/spotify/styx/util/TimeUtil.java#L217-L232
|
WiQuery/wiquery
|
wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/button/ButtonBehavior.java
|
ButtonBehavior.setIcons
|
public ButtonBehavior setIcons(UiIcon primary, UiIcon secondary)
{
options.put("icons", new ButtonIcon(primary, secondary));
return this;
}
|
java
|
public ButtonBehavior setIcons(UiIcon primary, UiIcon secondary)
{
options.put("icons", new ButtonIcon(primary, secondary));
return this;
}
|
[
"public",
"ButtonBehavior",
"setIcons",
"(",
"UiIcon",
"primary",
",",
"UiIcon",
"secondary",
")",
"{",
"options",
".",
"put",
"(",
"\"icons\"",
",",
"new",
"ButtonIcon",
"(",
"primary",
",",
"secondary",
")",
")",
";",
"return",
"this",
";",
"}"
] |
* Icons to display, with or without text (see text option). The primary icon is
displayed on the left of the label text, the secondary on the right. Value for the
primary and secondary properties must be a classname (String), eg. "ui-icon-gear".
For using only a primary icon: icons: {primary:'ui-icon-locked'}. For using both
primary and secondary icon: icons:
{primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'}
@param primary
The primary icon (should be non-null)
@param secondary
The secondary icon (might be null).
@return
|
[
"*",
"Icons",
"to",
"display",
"with",
"or",
"without",
"text",
"(",
"see",
"text",
"option",
")",
".",
"The",
"primary",
"icon",
"is",
"displayed",
"on",
"the",
"left",
"of",
"the",
"label",
"text",
"the",
"secondary",
"on",
"the",
"right",
".",
"Value",
"for",
"the",
"primary",
"and",
"secondary",
"properties",
"must",
"be",
"a",
"classname",
"(",
"String",
")",
"eg",
".",
"ui",
"-",
"icon",
"-",
"gear",
".",
"For",
"using",
"only",
"a",
"primary",
"icon",
":",
"icons",
":",
"{",
"primary",
":",
"ui",
"-",
"icon",
"-",
"locked",
"}",
".",
"For",
"using",
"both",
"primary",
"and",
"secondary",
"icon",
":",
"icons",
":",
"{",
"primary",
":",
"ui",
"-",
"icon",
"-",
"gear",
"secondary",
":",
"ui",
"-",
"icon",
"-",
"triangle",
"-",
"1",
"-",
"s",
"}"
] |
train
|
https://github.com/WiQuery/wiquery/blob/1b8d60c7a3c37b90fd68c9cd0ff97178fcbcbb08/wiquery-jquery-ui/src/main/java/org/odlabs/wiquery/ui/button/ButtonBehavior.java#L189-L193
|
maguro/aunit
|
junit/src/main/java/com/toolazydogs/aunit/Assert.java
|
Assert.refuteParse
|
public static void refuteParse(SelectedRule rule, LexerResults lexerResults)
{
try
{
lexerResults.parseAs(rule);
fail("parsed as " + rule);
}
catch (AssertionError e)
{
if (checkMessage(e.getMessage()))
{
// things are good
}
else
{
throw e;
}
}
}
|
java
|
public static void refuteParse(SelectedRule rule, LexerResults lexerResults)
{
try
{
lexerResults.parseAs(rule);
fail("parsed as " + rule);
}
catch (AssertionError e)
{
if (checkMessage(e.getMessage()))
{
// things are good
}
else
{
throw e;
}
}
}
|
[
"public",
"static",
"void",
"refuteParse",
"(",
"SelectedRule",
"rule",
",",
"LexerResults",
"lexerResults",
")",
"{",
"try",
"{",
"lexerResults",
".",
"parseAs",
"(",
"rule",
")",
";",
"fail",
"(",
"\"parsed as \"",
"+",
"rule",
")",
";",
"}",
"catch",
"(",
"AssertionError",
"e",
")",
"{",
"if",
"(",
"checkMessage",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
")",
"{",
"// things are good",
"}",
"else",
"{",
"throw",
"e",
";",
"}",
"}",
"}"
] |
To "refute" a parse means that the scan cannot be parsed with the
specified rule.
<p/>
<pre>
refuteParse("program", myTester.scanInput("5 / * 8"));
</pre>
@param rule the rule to apply from the parser.
@param lexerResults the result of scanning input with the tester.
|
[
"To",
"refute",
"a",
"parse",
"means",
"that",
"the",
"scan",
"cannot",
"be",
"parsed",
"with",
"the",
"specified",
"rule",
".",
"<p",
"/",
">",
"<pre",
">",
"refuteParse",
"(",
""",
";",
"program"",
";",
"myTester",
".",
"scanInput",
"(",
""",
";",
"5",
"/",
"*",
"8"",
";",
"))",
";",
"<",
"/",
"pre",
">"
] |
train
|
https://github.com/maguro/aunit/blob/1f972e35b28327e5e2e7881befc928df0546d74c/junit/src/main/java/com/toolazydogs/aunit/Assert.java#L196-L214
|
Ekryd/sortpom
|
sorter/src/main/java/sortpom/XmlOutputGenerator.java
|
XmlOutputGenerator.getSortedXml
|
public String getSortedXml(Document newDocument) {
try (ByteArrayOutputStream sortedXml = new ByteArrayOutputStream()) {
BufferedLineSeparatorOutputStream bufferedLineOutputStream =
new BufferedLineSeparatorOutputStream(lineSeparatorUtil.toString(), sortedXml);
XMLOutputter xmlOutputter = new PatchedXMLOutputter(bufferedLineOutputStream, indentBlankLines);
xmlOutputter.setFormat(createPrettyFormat());
xmlOutputter.output(newDocument, bufferedLineOutputStream);
bufferedLineOutputStream.close();
return sortedXml.toString(encoding);
} catch (IOException ioex) {
throw new FailureException("Could not format pom files content", ioex);
}
}
|
java
|
public String getSortedXml(Document newDocument) {
try (ByteArrayOutputStream sortedXml = new ByteArrayOutputStream()) {
BufferedLineSeparatorOutputStream bufferedLineOutputStream =
new BufferedLineSeparatorOutputStream(lineSeparatorUtil.toString(), sortedXml);
XMLOutputter xmlOutputter = new PatchedXMLOutputter(bufferedLineOutputStream, indentBlankLines);
xmlOutputter.setFormat(createPrettyFormat());
xmlOutputter.output(newDocument, bufferedLineOutputStream);
bufferedLineOutputStream.close();
return sortedXml.toString(encoding);
} catch (IOException ioex) {
throw new FailureException("Could not format pom files content", ioex);
}
}
|
[
"public",
"String",
"getSortedXml",
"(",
"Document",
"newDocument",
")",
"{",
"try",
"(",
"ByteArrayOutputStream",
"sortedXml",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
")",
"{",
"BufferedLineSeparatorOutputStream",
"bufferedLineOutputStream",
"=",
"new",
"BufferedLineSeparatorOutputStream",
"(",
"lineSeparatorUtil",
".",
"toString",
"(",
")",
",",
"sortedXml",
")",
";",
"XMLOutputter",
"xmlOutputter",
"=",
"new",
"PatchedXMLOutputter",
"(",
"bufferedLineOutputStream",
",",
"indentBlankLines",
")",
";",
"xmlOutputter",
".",
"setFormat",
"(",
"createPrettyFormat",
"(",
")",
")",
";",
"xmlOutputter",
".",
"output",
"(",
"newDocument",
",",
"bufferedLineOutputStream",
")",
";",
"bufferedLineOutputStream",
".",
"close",
"(",
")",
";",
"return",
"sortedXml",
".",
"toString",
"(",
"encoding",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioex",
")",
"{",
"throw",
"new",
"FailureException",
"(",
"\"Could not format pom files content\"",
",",
"ioex",
")",
";",
"}",
"}"
] |
Returns the sorted xml as an OutputStream.
@return the sorted xml
|
[
"Returns",
"the",
"sorted",
"xml",
"as",
"an",
"OutputStream",
"."
] |
train
|
https://github.com/Ekryd/sortpom/blob/27056420803ed04001e4149b04a719fbac774c5d/sorter/src/main/java/sortpom/XmlOutputGenerator.java#L41-L55
|
Netflix/ndbench
|
ndbench-dyno-plugins/src/main/java/com/netflix/ndbench/plugin/dyno/DynoJedisUtils.java
|
DynoJedisUtils.pipelineWriteHMSET
|
public String pipelineWriteHMSET(String key, DataGenerator dataGenerator, String hm_key_prefix) {
Map<String, String> map = new HashMap<>();
String hmKey = hm_key_prefix + key;
map.put((hmKey + "__1"), (key + "__" + dataGenerator.getRandomValue() + "__" + key));
map.put((hmKey + "__2"), (key + "__" + dataGenerator.getRandomValue() + "__" + key));
DynoJedisPipeline pipeline = jedisClient.get().pipelined();
pipeline.hmset(hmKey, map);
pipeline.expire(hmKey, 3600);
pipeline.sync();
return "HMSET:" + hmKey;
}
|
java
|
public String pipelineWriteHMSET(String key, DataGenerator dataGenerator, String hm_key_prefix) {
Map<String, String> map = new HashMap<>();
String hmKey = hm_key_prefix + key;
map.put((hmKey + "__1"), (key + "__" + dataGenerator.getRandomValue() + "__" + key));
map.put((hmKey + "__2"), (key + "__" + dataGenerator.getRandomValue() + "__" + key));
DynoJedisPipeline pipeline = jedisClient.get().pipelined();
pipeline.hmset(hmKey, map);
pipeline.expire(hmKey, 3600);
pipeline.sync();
return "HMSET:" + hmKey;
}
|
[
"public",
"String",
"pipelineWriteHMSET",
"(",
"String",
"key",
",",
"DataGenerator",
"dataGenerator",
",",
"String",
"hm_key_prefix",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"String",
"hmKey",
"=",
"hm_key_prefix",
"+",
"key",
";",
"map",
".",
"put",
"(",
"(",
"hmKey",
"+",
"\"__1\"",
")",
",",
"(",
"key",
"+",
"\"__\"",
"+",
"dataGenerator",
".",
"getRandomValue",
"(",
")",
"+",
"\"__\"",
"+",
"key",
")",
")",
";",
"map",
".",
"put",
"(",
"(",
"hmKey",
"+",
"\"__2\"",
")",
",",
"(",
"key",
"+",
"\"__\"",
"+",
"dataGenerator",
".",
"getRandomValue",
"(",
")",
"+",
"\"__\"",
"+",
"key",
")",
")",
";",
"DynoJedisPipeline",
"pipeline",
"=",
"jedisClient",
".",
"get",
"(",
")",
".",
"pipelined",
"(",
")",
";",
"pipeline",
".",
"hmset",
"(",
"hmKey",
",",
"map",
")",
";",
"pipeline",
".",
"expire",
"(",
"hmKey",
",",
"3600",
")",
";",
"pipeline",
".",
"sync",
"(",
")",
";",
"return",
"\"HMSET:\"",
"+",
"hmKey",
";",
"}"
] |
writes with an pipelined HMSET
@param key
@return the keys of the hash that was stored.
|
[
"writes",
"with",
"an",
"pipelined",
"HMSET"
] |
train
|
https://github.com/Netflix/ndbench/blob/8d664244b5f9d01395248a296b86a3c822e6d764/ndbench-dyno-plugins/src/main/java/com/netflix/ndbench/plugin/dyno/DynoJedisUtils.java#L217-L229
|
EdwardRaff/JSAT
|
JSAT/src/jsat/datatransform/NumericalToHistogram.java
|
NumericalToHistogram.guessNumberOfBins
|
public static Distribution guessNumberOfBins(DataSet data)
{
if(data.size() < 20)
return new UniformDiscrete(2, data.size()-1);
else if(data.size() >= 1000000)
return new LogUniform(50, 1000);
int sqrt = (int) Math.sqrt(data.size());
return new UniformDiscrete(Math.max(sqrt/3, 2), Math.min(sqrt*3, data.size()-1));
}
|
java
|
public static Distribution guessNumberOfBins(DataSet data)
{
if(data.size() < 20)
return new UniformDiscrete(2, data.size()-1);
else if(data.size() >= 1000000)
return new LogUniform(50, 1000);
int sqrt = (int) Math.sqrt(data.size());
return new UniformDiscrete(Math.max(sqrt/3, 2), Math.min(sqrt*3, data.size()-1));
}
|
[
"public",
"static",
"Distribution",
"guessNumberOfBins",
"(",
"DataSet",
"data",
")",
"{",
"if",
"(",
"data",
".",
"size",
"(",
")",
"<",
"20",
")",
"return",
"new",
"UniformDiscrete",
"(",
"2",
",",
"data",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"else",
"if",
"(",
"data",
".",
"size",
"(",
")",
">=",
"1000000",
")",
"return",
"new",
"LogUniform",
"(",
"50",
",",
"1000",
")",
";",
"int",
"sqrt",
"=",
"(",
"int",
")",
"Math",
".",
"sqrt",
"(",
"data",
".",
"size",
"(",
")",
")",
";",
"return",
"new",
"UniformDiscrete",
"(",
"Math",
".",
"max",
"(",
"sqrt",
"/",
"3",
",",
"2",
")",
",",
"Math",
".",
"min",
"(",
"sqrt",
"*",
"3",
",",
"data",
".",
"size",
"(",
")",
"-",
"1",
")",
")",
";",
"}"
] |
Attempts to guess the number of bins to use
@param data the dataset to be transforms
@return a distribution of the guess
|
[
"Attempts",
"to",
"guess",
"the",
"number",
"of",
"bins",
"to",
"use"
] |
train
|
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/datatransform/NumericalToHistogram.java#L138-L146
|
indeedeng/util
|
io/src/main/java/com/indeed/util/io/Files.java
|
Files.writeObjectIfChanged
|
@Deprecated
public static boolean writeObjectIfChanged(Object obj, String filepath) {
try {
return writeObjectIfChangedOrDie(obj, filepath, LOGGER);
} catch (Exception e) {
LOGGER.error(e.getClass() + ": writeObjectIfChanged(" + filepath + ") encountered exception: " + e.getMessage(), e);
return false;
}
}
|
java
|
@Deprecated
public static boolean writeObjectIfChanged(Object obj, String filepath) {
try {
return writeObjectIfChangedOrDie(obj, filepath, LOGGER);
} catch (Exception e) {
LOGGER.error(e.getClass() + ": writeObjectIfChanged(" + filepath + ") encountered exception: " + e.getMessage(), e);
return false;
}
}
|
[
"@",
"Deprecated",
"public",
"static",
"boolean",
"writeObjectIfChanged",
"(",
"Object",
"obj",
",",
"String",
"filepath",
")",
"{",
"try",
"{",
"return",
"writeObjectIfChangedOrDie",
"(",
"obj",
",",
"filepath",
",",
"LOGGER",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"e",
".",
"getClass",
"(",
")",
"+",
"\": writeObjectIfChanged(\"",
"+",
"filepath",
"+",
"\") encountered exception: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Writes an object to a file only if it is different from the current
contents of the file, or if the file does not exist. Note that you must
have enough heap to contain the entire contents of the object graph.
@return true if the file was actually written, false otherwise
@deprecated use {@link #writeObjectIfChangedOrDie(Object, String, org.apache.log4j.Logger)} instead
|
[
"Writes",
"an",
"object",
"to",
"a",
"file",
"only",
"if",
"it",
"is",
"different",
"from",
"the",
"current",
"contents",
"of",
"the",
"file",
"or",
"if",
"the",
"file",
"does",
"not",
"exist",
".",
"Note",
"that",
"you",
"must",
"have",
"enough",
"heap",
"to",
"contain",
"the",
"entire",
"contents",
"of",
"the",
"object",
"graph",
"."
] |
train
|
https://github.com/indeedeng/util/blob/332008426cf14b57e7fc3e817d9423e3f84fb922/io/src/main/java/com/indeed/util/io/Files.java#L354-L362
|
datumbox/datumbox-framework
|
datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/nonparametrics/onesample/SignOneSample.java
|
SignOneSample.getPvalue
|
public static double getPvalue(FlatDataCollection flatDataCollection, double median) {
int n=flatDataCollection.size();
if(n<=0) {
throw new IllegalArgumentException("The provided collection can't be empty.");
}
int Tplus=0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
double v = it.next();
if(Math.abs(v-median) < 0.0000001) {
continue; //don't count it at all
}
if(v>median) {
++Tplus;
}
}
double pvalue= scoreToPvalue(Tplus, n);
return pvalue;
}
|
java
|
public static double getPvalue(FlatDataCollection flatDataCollection, double median) {
int n=flatDataCollection.size();
if(n<=0) {
throw new IllegalArgumentException("The provided collection can't be empty.");
}
int Tplus=0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
double v = it.next();
if(Math.abs(v-median) < 0.0000001) {
continue; //don't count it at all
}
if(v>median) {
++Tplus;
}
}
double pvalue= scoreToPvalue(Tplus, n);
return pvalue;
}
|
[
"public",
"static",
"double",
"getPvalue",
"(",
"FlatDataCollection",
"flatDataCollection",
",",
"double",
"median",
")",
"{",
"int",
"n",
"=",
"flatDataCollection",
".",
"size",
"(",
")",
";",
"if",
"(",
"n",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The provided collection can't be empty.\"",
")",
";",
"}",
"int",
"Tplus",
"=",
"0",
";",
"Iterator",
"<",
"Double",
">",
"it",
"=",
"flatDataCollection",
".",
"iteratorDouble",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"double",
"v",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"v",
"-",
"median",
")",
"<",
"0.0000001",
")",
"{",
"continue",
";",
"//don't count it at all",
"}",
"if",
"(",
"v",
">",
"median",
")",
"{",
"++",
"Tplus",
";",
"}",
"}",
"double",
"pvalue",
"=",
"scoreToPvalue",
"(",
"Tplus",
",",
"n",
")",
";",
"return",
"pvalue",
";",
"}"
] |
Calculates the p-value of null Hypothesis.
@param flatDataCollection
@param median
@return
|
[
"Calculates",
"the",
"p",
"-",
"value",
"of",
"null",
"Hypothesis",
"."
] |
train
|
https://github.com/datumbox/datumbox-framework/blob/909dff0476e80834f05ecdde0624dd2390e9b0ca/datumbox-framework-core/src/main/java/com/datumbox/framework/core/statistics/nonparametrics/onesample/SignOneSample.java#L37-L59
|
OpenBEL/openbel-framework
|
org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/beldata/annotation/AnnotationHeaderParser.java
|
AnnotationHeaderParser.parseAnnotation
|
public AnnotationHeader parseAnnotation(String resourceLocation,
File annotationFile) throws IOException,
BELDataMissingPropertyException,
BELDataConversionException, BELDataInvalidPropertyException {
if (annotationFile == null) {
throw new InvalidArgument("annotationFile", annotationFile);
}
if (!annotationFile.exists()) {
throw new InvalidArgument("annotationFile does not exist");
}
if (!annotationFile.canRead()) {
throw new InvalidArgument("annotationFile cannot be read");
}
Map<String, Properties> blockProperties = parse(annotationFile);
AnnotationBlock annotationBlock =
AnnotationBlock.create(resourceLocation,
blockProperties.get(AnnotationBlock.BLOCK_NAME));
AuthorBlock authorblock = AuthorBlock.create(resourceLocation,
blockProperties.get(AuthorBlock.BLOCK_NAME));
CitationBlock citationBlock = CitationBlock.create(resourceLocation,
blockProperties.get(CitationBlock.BLOCK_NAME));
ProcessingBlock processingBlock = ProcessingBlock.create(
resourceLocation,
blockProperties.get(ProcessingBlock.BLOCK_NAME));
return new AnnotationHeader(annotationBlock, authorblock,
citationBlock,
processingBlock);
}
|
java
|
public AnnotationHeader parseAnnotation(String resourceLocation,
File annotationFile) throws IOException,
BELDataMissingPropertyException,
BELDataConversionException, BELDataInvalidPropertyException {
if (annotationFile == null) {
throw new InvalidArgument("annotationFile", annotationFile);
}
if (!annotationFile.exists()) {
throw new InvalidArgument("annotationFile does not exist");
}
if (!annotationFile.canRead()) {
throw new InvalidArgument("annotationFile cannot be read");
}
Map<String, Properties> blockProperties = parse(annotationFile);
AnnotationBlock annotationBlock =
AnnotationBlock.create(resourceLocation,
blockProperties.get(AnnotationBlock.BLOCK_NAME));
AuthorBlock authorblock = AuthorBlock.create(resourceLocation,
blockProperties.get(AuthorBlock.BLOCK_NAME));
CitationBlock citationBlock = CitationBlock.create(resourceLocation,
blockProperties.get(CitationBlock.BLOCK_NAME));
ProcessingBlock processingBlock = ProcessingBlock.create(
resourceLocation,
blockProperties.get(ProcessingBlock.BLOCK_NAME));
return new AnnotationHeader(annotationBlock, authorblock,
citationBlock,
processingBlock);
}
|
[
"public",
"AnnotationHeader",
"parseAnnotation",
"(",
"String",
"resourceLocation",
",",
"File",
"annotationFile",
")",
"throws",
"IOException",
",",
"BELDataMissingPropertyException",
",",
"BELDataConversionException",
",",
"BELDataInvalidPropertyException",
"{",
"if",
"(",
"annotationFile",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"annotationFile\"",
",",
"annotationFile",
")",
";",
"}",
"if",
"(",
"!",
"annotationFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"annotationFile does not exist\"",
")",
";",
"}",
"if",
"(",
"!",
"annotationFile",
".",
"canRead",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgument",
"(",
"\"annotationFile cannot be read\"",
")",
";",
"}",
"Map",
"<",
"String",
",",
"Properties",
">",
"blockProperties",
"=",
"parse",
"(",
"annotationFile",
")",
";",
"AnnotationBlock",
"annotationBlock",
"=",
"AnnotationBlock",
".",
"create",
"(",
"resourceLocation",
",",
"blockProperties",
".",
"get",
"(",
"AnnotationBlock",
".",
"BLOCK_NAME",
")",
")",
";",
"AuthorBlock",
"authorblock",
"=",
"AuthorBlock",
".",
"create",
"(",
"resourceLocation",
",",
"blockProperties",
".",
"get",
"(",
"AuthorBlock",
".",
"BLOCK_NAME",
")",
")",
";",
"CitationBlock",
"citationBlock",
"=",
"CitationBlock",
".",
"create",
"(",
"resourceLocation",
",",
"blockProperties",
".",
"get",
"(",
"CitationBlock",
".",
"BLOCK_NAME",
")",
")",
";",
"ProcessingBlock",
"processingBlock",
"=",
"ProcessingBlock",
".",
"create",
"(",
"resourceLocation",
",",
"blockProperties",
".",
"get",
"(",
"ProcessingBlock",
".",
"BLOCK_NAME",
")",
")",
";",
"return",
"new",
"AnnotationHeader",
"(",
"annotationBlock",
",",
"authorblock",
",",
"citationBlock",
",",
"processingBlock",
")",
";",
"}"
] |
Parses the annotation {@link File} into a {@link AnnotationHeader} object.
@param annotationFile {@link File}, the annotation file, which cannot be
null, must exist, and must be readable
@return {@link annotationHeader}, the parsed annotation header
@throws IOException Thrown if an IO error occurred reading the
<tt>annotationFile</tt>
@throws BELDataHeaderParseException Thrown if a parsing error occurred
when processing the <tt>annotationFile</tt>
@throws BELDataConversionException
@throws BELDataMissingPropertyException
@throws BELDataInvalidPropertyException
@throws InvalidArgument Thrown if the <tt>annotationFile</tt> is null,
does not exist, or cannot be read
|
[
"Parses",
"the",
"annotation",
"{",
"@link",
"File",
"}",
"into",
"a",
"{",
"@link",
"AnnotationHeader",
"}",
"object",
"."
] |
train
|
https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/beldata/annotation/AnnotationHeaderParser.java#L70-L105
|
code4everything/util
|
src/main/java/com/zhazhapan/util/NetUtils.java
|
NetUtils.getLocationByIp
|
public static String getLocationByIp(String ip) throws IOException, XPathExpressionException,
ParserConfigurationException {
return evaluate(ValueConsts.IP_REGION_XPATH, getHtmlFromUrl("http://ip.chinaz.com/" + ip));
}
|
java
|
public static String getLocationByIp(String ip) throws IOException, XPathExpressionException,
ParserConfigurationException {
return evaluate(ValueConsts.IP_REGION_XPATH, getHtmlFromUrl("http://ip.chinaz.com/" + ip));
}
|
[
"public",
"static",
"String",
"getLocationByIp",
"(",
"String",
"ip",
")",
"throws",
"IOException",
",",
"XPathExpressionException",
",",
"ParserConfigurationException",
"{",
"return",
"evaluate",
"(",
"ValueConsts",
".",
"IP_REGION_XPATH",
",",
"getHtmlFromUrl",
"(",
"\"http://ip.chinaz.com/\"",
"+",
"ip",
")",
")",
";",
"}"
] |
获取ip归属地
@param ip ip地址
@return 归属地
@throws IOException 异常
@throws XPathExpressionException 异常
@throws ParserConfigurationException 异常
|
[
"获取ip归属地"
] |
train
|
https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/NetUtils.java#L680-L683
|
apache/flink
|
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraph.java
|
StreamGraph.addVirtualSelectNode
|
public void addVirtualSelectNode(Integer originalId, Integer virtualId, List<String> selectedNames) {
if (virtualSelectNodes.containsKey(virtualId)) {
throw new IllegalStateException("Already has virtual select node with id " + virtualId);
}
virtualSelectNodes.put(virtualId,
new Tuple2<Integer, List<String>>(originalId, selectedNames));
}
|
java
|
public void addVirtualSelectNode(Integer originalId, Integer virtualId, List<String> selectedNames) {
if (virtualSelectNodes.containsKey(virtualId)) {
throw new IllegalStateException("Already has virtual select node with id " + virtualId);
}
virtualSelectNodes.put(virtualId,
new Tuple2<Integer, List<String>>(originalId, selectedNames));
}
|
[
"public",
"void",
"addVirtualSelectNode",
"(",
"Integer",
"originalId",
",",
"Integer",
"virtualId",
",",
"List",
"<",
"String",
">",
"selectedNames",
")",
"{",
"if",
"(",
"virtualSelectNodes",
".",
"containsKey",
"(",
"virtualId",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Already has virtual select node with id \"",
"+",
"virtualId",
")",
";",
"}",
"virtualSelectNodes",
".",
"put",
"(",
"virtualId",
",",
"new",
"Tuple2",
"<",
"Integer",
",",
"List",
"<",
"String",
">",
">",
"(",
"originalId",
",",
"selectedNames",
")",
")",
";",
"}"
] |
Adds a new virtual node that is used to connect a downstream vertex to only the outputs
with the selected names.
<p>When adding an edge from the virtual node to a downstream node the connection will be made
to the original node, only with the selected names given here.
@param originalId ID of the node that should be connected to.
@param virtualId ID of the virtual node.
@param selectedNames The selected names.
|
[
"Adds",
"a",
"new",
"virtual",
"node",
"that",
"is",
"used",
"to",
"connect",
"a",
"downstream",
"vertex",
"to",
"only",
"the",
"outputs",
"with",
"the",
"selected",
"names",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/graph/StreamGraph.java#L290-L298
|
bitcoinj/bitcoinj
|
core/src/main/java/org/bitcoinj/core/PeerGroup.java
|
PeerGroup.waitForPeersWithServiceMask
|
public ListenableFuture<List<Peer>> waitForPeersWithServiceMask(final int numPeers, final int mask) {
lock.lock();
try {
List<Peer> foundPeers = findPeersWithServiceMask(mask);
if (foundPeers.size() >= numPeers)
return Futures.immediateFuture(foundPeers);
final SettableFuture<List<Peer>> future = SettableFuture.create();
addConnectedEventListener(new PeerConnectedEventListener() {
@Override
public void onPeerConnected(Peer peer, int peerCount) {
final List<Peer> peers = findPeersWithServiceMask(mask);
if (peers.size() >= numPeers) {
future.set(peers);
removeConnectedEventListener(this);
}
}
});
return future;
} finally {
lock.unlock();
}
}
|
java
|
public ListenableFuture<List<Peer>> waitForPeersWithServiceMask(final int numPeers, final int mask) {
lock.lock();
try {
List<Peer> foundPeers = findPeersWithServiceMask(mask);
if (foundPeers.size() >= numPeers)
return Futures.immediateFuture(foundPeers);
final SettableFuture<List<Peer>> future = SettableFuture.create();
addConnectedEventListener(new PeerConnectedEventListener() {
@Override
public void onPeerConnected(Peer peer, int peerCount) {
final List<Peer> peers = findPeersWithServiceMask(mask);
if (peers.size() >= numPeers) {
future.set(peers);
removeConnectedEventListener(this);
}
}
});
return future;
} finally {
lock.unlock();
}
}
|
[
"public",
"ListenableFuture",
"<",
"List",
"<",
"Peer",
">",
">",
"waitForPeersWithServiceMask",
"(",
"final",
"int",
"numPeers",
",",
"final",
"int",
"mask",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"List",
"<",
"Peer",
">",
"foundPeers",
"=",
"findPeersWithServiceMask",
"(",
"mask",
")",
";",
"if",
"(",
"foundPeers",
".",
"size",
"(",
")",
">=",
"numPeers",
")",
"return",
"Futures",
".",
"immediateFuture",
"(",
"foundPeers",
")",
";",
"final",
"SettableFuture",
"<",
"List",
"<",
"Peer",
">",
">",
"future",
"=",
"SettableFuture",
".",
"create",
"(",
")",
";",
"addConnectedEventListener",
"(",
"new",
"PeerConnectedEventListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onPeerConnected",
"(",
"Peer",
"peer",
",",
"int",
"peerCount",
")",
"{",
"final",
"List",
"<",
"Peer",
">",
"peers",
"=",
"findPeersWithServiceMask",
"(",
"mask",
")",
";",
"if",
"(",
"peers",
".",
"size",
"(",
")",
">=",
"numPeers",
")",
"{",
"future",
".",
"set",
"(",
"peers",
")",
";",
"removeConnectedEventListener",
"(",
"this",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"future",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Returns a future that is triggered when there are at least the requested number of connected peers that support
the given protocol version or higher. To block immediately, just call get() on the result.
@param numPeers How many peers to wait for.
@param mask An integer representing a bit mask that will be ANDed with the peers advertised service masks.
@return a future that will be triggered when the number of connected peers implementing protocolVersion or higher is greater than or equals numPeers
|
[
"Returns",
"a",
"future",
"that",
"is",
"triggered",
"when",
"there",
"are",
"at",
"least",
"the",
"requested",
"number",
"of",
"connected",
"peers",
"that",
"support",
"the",
"given",
"protocol",
"version",
"or",
"higher",
".",
"To",
"block",
"immediately",
"just",
"call",
"get",
"()",
"on",
"the",
"result",
"."
] |
train
|
https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/core/PeerGroup.java#L1941-L1962
|
revelytix/spark
|
spark-http-client/src/main/java/spark/protocol/parser/ResultFactory.java
|
ResultFactory.findParser
|
private static final ResultParser findParser(String mediaType, ResultType expectedType) {
ResponseFormat format = null;
// Prefer MIME type when choosing result format.
if (mediaType != null) {
mediaType = stripParams(mediaType);
format = mimeFormats.get(mediaType);
if (format == null) {
logger.warn("Unrecognized media type ({}) in SPARQL server response", mediaType);
} else {
logger.debug("Using result format {} for media type {}", format, mediaType);
}
}
// If MIME type was absent or unrecognized, choose default based on expected result type.
if (format == null) {
logger.debug("Unable to determine result format from media type");
if (expectedType != null) {
format = defaultTypeFormats.get(expectedType);
logger.debug("Using default format {} for expected result type {}", format, expectedType);
} else {
format = DEFAULT_FORMAT;
logger.debug("No expected type provided; using default format {}", format);
}
}
assert format != null:"Could not determine result format";
// Validate that the chosen format can produce the expected result type.
if (expectedType != null && !format.resultTypes.contains(expectedType)) {
throw new SparqlException("Result format " + format + " does not support expected result type " + expectedType);
}
return format.parser;
}
|
java
|
private static final ResultParser findParser(String mediaType, ResultType expectedType) {
ResponseFormat format = null;
// Prefer MIME type when choosing result format.
if (mediaType != null) {
mediaType = stripParams(mediaType);
format = mimeFormats.get(mediaType);
if (format == null) {
logger.warn("Unrecognized media type ({}) in SPARQL server response", mediaType);
} else {
logger.debug("Using result format {} for media type {}", format, mediaType);
}
}
// If MIME type was absent or unrecognized, choose default based on expected result type.
if (format == null) {
logger.debug("Unable to determine result format from media type");
if (expectedType != null) {
format = defaultTypeFormats.get(expectedType);
logger.debug("Using default format {} for expected result type {}", format, expectedType);
} else {
format = DEFAULT_FORMAT;
logger.debug("No expected type provided; using default format {}", format);
}
}
assert format != null:"Could not determine result format";
// Validate that the chosen format can produce the expected result type.
if (expectedType != null && !format.resultTypes.contains(expectedType)) {
throw new SparqlException("Result format " + format + " does not support expected result type " + expectedType);
}
return format.parser;
}
|
[
"private",
"static",
"final",
"ResultParser",
"findParser",
"(",
"String",
"mediaType",
",",
"ResultType",
"expectedType",
")",
"{",
"ResponseFormat",
"format",
"=",
"null",
";",
"// Prefer MIME type when choosing result format.",
"if",
"(",
"mediaType",
"!=",
"null",
")",
"{",
"mediaType",
"=",
"stripParams",
"(",
"mediaType",
")",
";",
"format",
"=",
"mimeFormats",
".",
"get",
"(",
"mediaType",
")",
";",
"if",
"(",
"format",
"==",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Unrecognized media type ({}) in SPARQL server response\"",
",",
"mediaType",
")",
";",
"}",
"else",
"{",
"logger",
".",
"debug",
"(",
"\"Using result format {} for media type {}\"",
",",
"format",
",",
"mediaType",
")",
";",
"}",
"}",
"// If MIME type was absent or unrecognized, choose default based on expected result type.",
"if",
"(",
"format",
"==",
"null",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Unable to determine result format from media type\"",
")",
";",
"if",
"(",
"expectedType",
"!=",
"null",
")",
"{",
"format",
"=",
"defaultTypeFormats",
".",
"get",
"(",
"expectedType",
")",
";",
"logger",
".",
"debug",
"(",
"\"Using default format {} for expected result type {}\"",
",",
"format",
",",
"expectedType",
")",
";",
"}",
"else",
"{",
"format",
"=",
"DEFAULT_FORMAT",
";",
"logger",
".",
"debug",
"(",
"\"No expected type provided; using default format {}\"",
",",
"format",
")",
";",
"}",
"}",
"assert",
"format",
"!=",
"null",
":",
"\"Could not determine result format\"",
";",
"// Validate that the chosen format can produce the expected result type.",
"if",
"(",
"expectedType",
"!=",
"null",
"&&",
"!",
"format",
".",
"resultTypes",
".",
"contains",
"(",
"expectedType",
")",
")",
"{",
"throw",
"new",
"SparqlException",
"(",
"\"Result format \"",
"+",
"format",
"+",
"\" does not support expected result type \"",
"+",
"expectedType",
")",
";",
"}",
"return",
"format",
".",
"parser",
";",
"}"
] |
Find a parser to handle the protocol response body based on the content type found in the response
and the expected result type specified by the user; if one or both fields is missing then
attempts to choose a sensible default.
@param mediaType The content type in the response, or null if none was given.
@param expectedType The expected response type indicated by the user, or
@return
|
[
"Find",
"a",
"parser",
"to",
"handle",
"the",
"protocol",
"response",
"body",
"based",
"on",
"the",
"content",
"type",
"found",
"in",
"the",
"response",
"and",
"the",
"expected",
"result",
"type",
"specified",
"by",
"the",
"user",
";",
"if",
"one",
"or",
"both",
"fields",
"is",
"missing",
"then",
"attempts",
"to",
"choose",
"a",
"sensible",
"default",
"."
] |
train
|
https://github.com/revelytix/spark/blob/d777d40c962bc66fdc04b7c3a66d20b777ff6fb4/spark-http-client/src/main/java/spark/protocol/parser/ResultFactory.java#L153-L187
|
powermock/powermock
|
powermock-api/powermock-api-easymock/src/main/java/org/powermock/api/easymock/PowerMock.java
|
PowerMock.createStrictPartialMockAndInvokeDefaultConstructor
|
public static <T> T createStrictPartialMockAndInvokeDefaultConstructor(Class<T> type, String... methodNames)
throws Exception {
return createStrictMock(type, new ConstructorArgs(Whitebox.getConstructor(type)),
Whitebox.getMethods(type, methodNames));
}
|
java
|
public static <T> T createStrictPartialMockAndInvokeDefaultConstructor(Class<T> type, String... methodNames)
throws Exception {
return createStrictMock(type, new ConstructorArgs(Whitebox.getConstructor(type)),
Whitebox.getMethods(type, methodNames));
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"createStrictPartialMockAndInvokeDefaultConstructor",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"...",
"methodNames",
")",
"throws",
"Exception",
"{",
"return",
"createStrictMock",
"(",
"type",
",",
"new",
"ConstructorArgs",
"(",
"Whitebox",
".",
"getConstructor",
"(",
"type",
")",
")",
",",
"Whitebox",
".",
"getMethods",
"(",
"type",
",",
"methodNames",
")",
")",
";",
"}"
] |
A utility method that may be used to strictly mock several methods in an
easy way (by just passing in the method names of the method you wish to
mock). The mock object created will support mocking of final methods and
invokes the default constructor (even if it's private).
@param <T> the type of the mock object
@param type the type of the mock object
@param methodNames The names of the methods that should be mocked. If
{@code null}, then this method will have the same effect
as just calling {@link #createMock(Class, Method...)} with the
second parameter as {@code new Method[0]} (i.e. all
methods in that class will be mocked).
@return the mock object.
|
[
"A",
"utility",
"method",
"that",
"may",
"be",
"used",
"to",
"strictly",
"mock",
"several",
"methods",
"in",
"an",
"easy",
"way",
"(",
"by",
"just",
"passing",
"in",
"the",
"method",
"names",
"of",
"the",
"method",
"you",
"wish",
"to",
"mock",
")",
".",
"The",
"mock",
"object",
"created",
"will",
"support",
"mocking",
"of",
"final",
"methods",
"and",
"invokes",
"the",
"default",
"constructor",
"(",
"even",
"if",
"it",
"s",
"private",
")",
"."
] |
train
|
https://github.com/powermock/powermock/blob/e8cd68026c284c6a7efe66959809eeebd8d1f9ad/powermock-api/powermock-api-easymock/src/main/java/org/powermock/api/easymock/PowerMock.java#L880-L884
|
enasequence/sequencetools
|
src/main/java/uk/ac/ebi/embl/api/validation/check/feature/FeatureValidationCheck.java
|
FeatureValidationCheck.reportError
|
protected ValidationMessage<Origin> reportError(Origin origin, String messageKey,
Object... params) {
return reportMessage(Severity.ERROR, origin, messageKey, params);
}
|
java
|
protected ValidationMessage<Origin> reportError(Origin origin, String messageKey,
Object... params) {
return reportMessage(Severity.ERROR, origin, messageKey, params);
}
|
[
"protected",
"ValidationMessage",
"<",
"Origin",
">",
"reportError",
"(",
"Origin",
"origin",
",",
"String",
"messageKey",
",",
"Object",
"...",
"params",
")",
"{",
"return",
"reportMessage",
"(",
"Severity",
".",
"ERROR",
",",
"origin",
",",
"messageKey",
",",
"params",
")",
";",
"}"
] |
Creates an error validation message for the feature and adds it to
the validation result.
@param origin the origin
@param messageKey a message key
@param params message parameters
|
[
"Creates",
"an",
"error",
"validation",
"message",
"for",
"the",
"feature",
"and",
"adds",
"it",
"to",
"the",
"validation",
"result",
"."
] |
train
|
https://github.com/enasequence/sequencetools/blob/4127f5e1a17540239f5810136153fbd6737fa262/src/main/java/uk/ac/ebi/embl/api/validation/check/feature/FeatureValidationCheck.java#L67-L70
|
thinkaurelius/faunus
|
src/main/java/com/thinkaurelius/faunus/FaunusPipeline.java
|
FaunusPipeline.interval
|
public FaunusPipeline interval(final String key, final Object startValue, final Object endValue) {
this.state.assertNotLocked();
this.state.assertNoProperty();
this.compiler.addMap(IntervalFilterMap.Map.class,
NullWritable.class,
FaunusVertex.class,
IntervalFilterMap.createConfiguration(this.state.getElementType(), key, startValue, endValue));
makeMapReduceString(IntervalFilterMap.class, key, startValue, endValue);
return this;
}
|
java
|
public FaunusPipeline interval(final String key, final Object startValue, final Object endValue) {
this.state.assertNotLocked();
this.state.assertNoProperty();
this.compiler.addMap(IntervalFilterMap.Map.class,
NullWritable.class,
FaunusVertex.class,
IntervalFilterMap.createConfiguration(this.state.getElementType(), key, startValue, endValue));
makeMapReduceString(IntervalFilterMap.class, key, startValue, endValue);
return this;
}
|
[
"public",
"FaunusPipeline",
"interval",
"(",
"final",
"String",
"key",
",",
"final",
"Object",
"startValue",
",",
"final",
"Object",
"endValue",
")",
"{",
"this",
".",
"state",
".",
"assertNotLocked",
"(",
")",
";",
"this",
".",
"state",
".",
"assertNoProperty",
"(",
")",
";",
"this",
".",
"compiler",
".",
"addMap",
"(",
"IntervalFilterMap",
".",
"Map",
".",
"class",
",",
"NullWritable",
".",
"class",
",",
"FaunusVertex",
".",
"class",
",",
"IntervalFilterMap",
".",
"createConfiguration",
"(",
"this",
".",
"state",
".",
"getElementType",
"(",
")",
",",
"key",
",",
"startValue",
",",
"endValue",
")",
")",
";",
"makeMapReduceString",
"(",
"IntervalFilterMap",
".",
"class",
",",
"key",
",",
"startValue",
",",
"endValue",
")",
";",
"return",
"this",
";",
"}"
] |
Emit the current element it has a property value equal within the provided range.
@param key the property key of the element
@param startValue the start of the range (inclusive)
@param endValue the end of the range (exclusive)
@return the extended FaunusPipeline
|
[
"Emit",
"the",
"current",
"element",
"it",
"has",
"a",
"property",
"value",
"equal",
"within",
"the",
"provided",
"range",
"."
] |
train
|
https://github.com/thinkaurelius/faunus/blob/1eb8494eeb3fe3b84a98d810d304ba01d55b0d6e/src/main/java/com/thinkaurelius/faunus/FaunusPipeline.java#L705-L715
|
looly/hutool
|
hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java
|
FileUtil.isSub
|
public static boolean isSub(File parent, File sub) {
Assert.notNull(parent);
Assert.notNull(sub);
return sub.toPath().startsWith(parent.toPath());
}
|
java
|
public static boolean isSub(File parent, File sub) {
Assert.notNull(parent);
Assert.notNull(sub);
return sub.toPath().startsWith(parent.toPath());
}
|
[
"public",
"static",
"boolean",
"isSub",
"(",
"File",
"parent",
",",
"File",
"sub",
")",
"{",
"Assert",
".",
"notNull",
"(",
"parent",
")",
";",
"Assert",
".",
"notNull",
"(",
"sub",
")",
";",
"return",
"sub",
".",
"toPath",
"(",
")",
".",
"startsWith",
"(",
"parent",
".",
"toPath",
"(",
")",
")",
";",
"}"
] |
判断给定的目录是否为给定文件或文件夹的父目录
@param parent 父目录
@param sub 子目录
@return 子目录是否为父目录的子目录
@since 4.5.4
|
[
"判断给定的目录是否为给定文件或文件夹的父目录"
] |
train
|
https://github.com/looly/hutool/blob/bbd74eda4c7e8a81fe7a991fa6c2276eec062e6a/hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java#L3431-L3435
|
js-lib-com/template.xhtml
|
src/main/java/js/template/xhtml/XhtmlTemplate.java
|
XhtmlTemplate.setProperty
|
@Override
public void setProperty(String name, Object value)
{
switch(name) {
case "js.template.serialize.prolog":
serializeProlog = (Boolean)value;
break;
case "js.template.serialize.operator":
serializeOperators = (Boolean)value;
break;
}
}
|
java
|
@Override
public void setProperty(String name, Object value)
{
switch(name) {
case "js.template.serialize.prolog":
serializeProlog = (Boolean)value;
break;
case "js.template.serialize.operator":
serializeOperators = (Boolean)value;
break;
}
}
|
[
"@",
"Override",
"public",
"void",
"setProperty",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"switch",
"(",
"name",
")",
"{",
"case",
"\"js.template.serialize.prolog\"",
":",
"serializeProlog",
"=",
"(",
"Boolean",
")",
"value",
";",
"break",
";",
"case",
"\"js.template.serialize.operator\"",
":",
"serializeOperators",
"=",
"(",
"Boolean",
")",
"value",
";",
"break",
";",
"}",
"}"
] |
Set template instance properties overriding the template engine ones. Current implementation deals with
<code>js.template.serialize.prolog</code> and <code>js.template.serialize.operator</code> flags.
<p>
First is used to disable prolog serialization. By default prolog serialization is enabled, see
{@link #serializeProlog}. Use this property to disable it, that to not include XML prolog, respective X(H)MTL
DOCTYPE, into serialization output.
<p>
The second property is used to control operators serialization. By default, templates operators are not included
into resulting document. If one may want to include operators, perhaps in order to enable data extraction, uses
this method. But be warned that if document is validated operators syntax may collide with document grammar and
render document invalid.
@param name property name,
@param value property value.
|
[
"Set",
"template",
"instance",
"properties",
"overriding",
"the",
"template",
"engine",
"ones",
".",
"Current",
"implementation",
"deals",
"with",
"<code",
">",
"js",
".",
"template",
".",
"serialize",
".",
"prolog<",
"/",
"code",
">",
"and",
"<code",
">",
"js",
".",
"template",
".",
"serialize",
".",
"operator<",
"/",
"code",
">",
"flags",
".",
"<p",
">",
"First",
"is",
"used",
"to",
"disable",
"prolog",
"serialization",
".",
"By",
"default",
"prolog",
"serialization",
"is",
"enabled",
"see",
"{",
"@link",
"#serializeProlog",
"}",
".",
"Use",
"this",
"property",
"to",
"disable",
"it",
"that",
"to",
"not",
"include",
"XML",
"prolog",
"respective",
"X",
"(",
"H",
")",
"MTL",
"DOCTYPE",
"into",
"serialization",
"output",
".",
"<p",
">",
"The",
"second",
"property",
"is",
"used",
"to",
"control",
"operators",
"serialization",
".",
"By",
"default",
"templates",
"operators",
"are",
"not",
"included",
"into",
"resulting",
"document",
".",
"If",
"one",
"may",
"want",
"to",
"include",
"operators",
"perhaps",
"in",
"order",
"to",
"enable",
"data",
"extraction",
"uses",
"this",
"method",
".",
"But",
"be",
"warned",
"that",
"if",
"document",
"is",
"validated",
"operators",
"syntax",
"may",
"collide",
"with",
"document",
"grammar",
"and",
"render",
"document",
"invalid",
"."
] |
train
|
https://github.com/js-lib-com/template.xhtml/blob/d50cec08aca9ab9680baebe2a26a341c096564fb/src/main/java/js/template/xhtml/XhtmlTemplate.java#L85-L97
|
BlueBrain/bluima
|
modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/tools/sentdetect/SDContextGenerator.java
|
SDContextGenerator.previousSpaceIndex
|
private static final int previousSpaceIndex(StringBuffer sb, int seek) {
seek--;
while (seek > 0) {
if (sb.charAt(seek) == ' ') {
while (seek > 0 && sb.charAt(seek - 1) == ' ')
seek--;
return seek;
}
seek--;
}
return 0;
}
|
java
|
private static final int previousSpaceIndex(StringBuffer sb, int seek) {
seek--;
while (seek > 0) {
if (sb.charAt(seek) == ' ') {
while (seek > 0 && sb.charAt(seek - 1) == ' ')
seek--;
return seek;
}
seek--;
}
return 0;
}
|
[
"private",
"static",
"final",
"int",
"previousSpaceIndex",
"(",
"StringBuffer",
"sb",
",",
"int",
"seek",
")",
"{",
"seek",
"--",
";",
"while",
"(",
"seek",
">",
"0",
")",
"{",
"if",
"(",
"sb",
".",
"charAt",
"(",
"seek",
")",
"==",
"'",
"'",
")",
"{",
"while",
"(",
"seek",
">",
"0",
"&&",
"sb",
".",
"charAt",
"(",
"seek",
"-",
"1",
")",
"==",
"'",
"'",
")",
"seek",
"--",
";",
"return",
"seek",
";",
"}",
"seek",
"--",
";",
"}",
"return",
"0",
";",
"}"
] |
Finds the index of the nearest space before a specified index.
@param sb The string buffer which contains the text being examined.
@param seek The index to begin searching from.
@return The index which contains the nearest space.
|
[
"Finds",
"the",
"index",
"of",
"the",
"nearest",
"space",
"before",
"a",
"specified",
"index",
"."
] |
train
|
https://github.com/BlueBrain/bluima/blob/793ea3f46761dce72094e057a56cddfa677156ae/modules/bluima_opennlp/src/main/java/ch/epfl/bbp/shaded/opennlp/tools/sentdetect/SDContextGenerator.java#L219-L230
|
hageldave/ImagingKit
|
ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/Fourier.java
|
Fourier.horizontalTransform
|
public static ComplexImg horizontalTransform(ColorImg img, int channel) {
// sanity checks
sanityCheckForward(img, channel);
// make transforms
ComplexImg transformed = new ComplexImg(img.getDimension());
try(
NativeRealArray row = new NativeRealArray(img.getWidth());
NativeRealArray fft_r = new NativeRealArray(row.length);
NativeRealArray fft_i = new NativeRealArray(row.length);
) {
for(int y = 0; y < img.getHeight(); y++){
row.set(0, img.getWidth(), y*img.getWidth(), img.getData()[channel]);
FFTW_Guru.execute_split_r2c(row, fft_r, fft_i, img.getWidth());
fft_r.get(0, img.getWidth(), y*img.getWidth(), transformed.getDataReal());
fft_i.get(0, img.getWidth(), y*img.getWidth(), transformed.getDataImag());
}
}
return transformed;
}
|
java
|
public static ComplexImg horizontalTransform(ColorImg img, int channel) {
// sanity checks
sanityCheckForward(img, channel);
// make transforms
ComplexImg transformed = new ComplexImg(img.getDimension());
try(
NativeRealArray row = new NativeRealArray(img.getWidth());
NativeRealArray fft_r = new NativeRealArray(row.length);
NativeRealArray fft_i = new NativeRealArray(row.length);
) {
for(int y = 0; y < img.getHeight(); y++){
row.set(0, img.getWidth(), y*img.getWidth(), img.getData()[channel]);
FFTW_Guru.execute_split_r2c(row, fft_r, fft_i, img.getWidth());
fft_r.get(0, img.getWidth(), y*img.getWidth(), transformed.getDataReal());
fft_i.get(0, img.getWidth(), y*img.getWidth(), transformed.getDataImag());
}
}
return transformed;
}
|
[
"public",
"static",
"ComplexImg",
"horizontalTransform",
"(",
"ColorImg",
"img",
",",
"int",
"channel",
")",
"{",
"// sanity checks",
"sanityCheckForward",
"(",
"img",
",",
"channel",
")",
";",
"// make transforms",
"ComplexImg",
"transformed",
"=",
"new",
"ComplexImg",
"(",
"img",
".",
"getDimension",
"(",
")",
")",
";",
"try",
"(",
"NativeRealArray",
"row",
"=",
"new",
"NativeRealArray",
"(",
"img",
".",
"getWidth",
"(",
")",
")",
";",
"NativeRealArray",
"fft_r",
"=",
"new",
"NativeRealArray",
"(",
"row",
".",
"length",
")",
";",
"NativeRealArray",
"fft_i",
"=",
"new",
"NativeRealArray",
"(",
"row",
".",
"length",
")",
";",
")",
"{",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"img",
".",
"getHeight",
"(",
")",
";",
"y",
"++",
")",
"{",
"row",
".",
"set",
"(",
"0",
",",
"img",
".",
"getWidth",
"(",
")",
",",
"y",
"*",
"img",
".",
"getWidth",
"(",
")",
",",
"img",
".",
"getData",
"(",
")",
"[",
"channel",
"]",
")",
";",
"FFTW_Guru",
".",
"execute_split_r2c",
"(",
"row",
",",
"fft_r",
",",
"fft_i",
",",
"img",
".",
"getWidth",
"(",
")",
")",
";",
"fft_r",
".",
"get",
"(",
"0",
",",
"img",
".",
"getWidth",
"(",
")",
",",
"y",
"*",
"img",
".",
"getWidth",
"(",
")",
",",
"transformed",
".",
"getDataReal",
"(",
")",
")",
";",
"fft_i",
".",
"get",
"(",
"0",
",",
"img",
".",
"getWidth",
"(",
")",
",",
"y",
"*",
"img",
".",
"getWidth",
"(",
")",
",",
"transformed",
".",
"getDataImag",
"(",
")",
")",
";",
"}",
"}",
"return",
"transformed",
";",
"}"
] |
Executes row wise Fourier transforms of the specified channel of the specified {@link ColorImg}.
A 1-dimensional Fourier transform is done for each row of the image's channel.
@param img of which one channel is to be transformed
@param channel the channel which will be transformed
@return transform as ComplexImg
@throws IllegalArgumentException if the specified channel is out of range ([0..3]) or is alpha (3)
but the specified image does not have an alpha channel
|
[
"Executes",
"row",
"wise",
"Fourier",
"transforms",
"of",
"the",
"specified",
"channel",
"of",
"the",
"specified",
"{",
"@link",
"ColorImg",
"}",
".",
"A",
"1",
"-",
"dimensional",
"Fourier",
"transform",
"is",
"done",
"for",
"each",
"row",
"of",
"the",
"image",
"s",
"channel",
".",
"@param",
"img",
"of",
"which",
"one",
"channel",
"is",
"to",
"be",
"transformed",
"@param",
"channel",
"the",
"channel",
"which",
"will",
"be",
"transformed",
"@return",
"transform",
"as",
"ComplexImg"
] |
train
|
https://github.com/hageldave/ImagingKit/blob/3837c7d550a12cf4dc5718b644ced94b97f52668/ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/Fourier.java#L173-L191
|
korpling/ANNIS
|
annis-libgui/src/main/java/annis/libgui/Helper.java
|
Helper.getAnnisWebResource
|
public static WebResource getAnnisWebResource()
{
VaadinSession vSession = VaadinSession.getCurrent();
// get URI used by the application
String uri = null;
if (vSession != null)
{
uri = (String) VaadinSession.getCurrent().getAttribute(
KEY_WEB_SERVICE_URL);
}
// if already authentificated the REST client is set as the "user" property
AnnisUser user = getUser();
return getAnnisWebResource(uri, user);
}
|
java
|
public static WebResource getAnnisWebResource()
{
VaadinSession vSession = VaadinSession.getCurrent();
// get URI used by the application
String uri = null;
if (vSession != null)
{
uri = (String) VaadinSession.getCurrent().getAttribute(
KEY_WEB_SERVICE_URL);
}
// if already authentificated the REST client is set as the "user" property
AnnisUser user = getUser();
return getAnnisWebResource(uri, user);
}
|
[
"public",
"static",
"WebResource",
"getAnnisWebResource",
"(",
")",
"{",
"VaadinSession",
"vSession",
"=",
"VaadinSession",
".",
"getCurrent",
"(",
")",
";",
"// get URI used by the application",
"String",
"uri",
"=",
"null",
";",
"if",
"(",
"vSession",
"!=",
"null",
")",
"{",
"uri",
"=",
"(",
"String",
")",
"VaadinSession",
".",
"getCurrent",
"(",
")",
".",
"getAttribute",
"(",
"KEY_WEB_SERVICE_URL",
")",
";",
"}",
"// if already authentificated the REST client is set as the \"user\" property",
"AnnisUser",
"user",
"=",
"getUser",
"(",
")",
";",
"return",
"getAnnisWebResource",
"(",
"uri",
",",
"user",
")",
";",
"}"
] |
Gets or creates a web resource to the ANNIS service.
This is a convenience wrapper to {@link #getAnnisWebResource(java.lang.String, annis.security.AnnisUser)
}
that does not need any arguments
@return A reference to the ANNIS service root resource.
|
[
"Gets",
"or",
"creates",
"a",
"web",
"resource",
"to",
"the",
"ANNIS",
"service",
"."
] |
train
|
https://github.com/korpling/ANNIS/blob/152a2e34832e015f73ac8ce8a7d4c32641641324/annis-libgui/src/main/java/annis/libgui/Helper.java#L322-L340
|
dlemmermann/CalendarFX
|
CalendarFXRecurrence/src/main/java/com/google/ical/compat/jodatime/LocalDateIteratorFactory.java
|
LocalDateIteratorFactory.createLocalDateIterable
|
public static LocalDateIterable createLocalDateIterable(
String rdata, LocalDate start, boolean strict)
throws ParseException {
return createLocalDateIterable(rdata, start, DateTimeZone.UTC, strict);
}
|
java
|
public static LocalDateIterable createLocalDateIterable(
String rdata, LocalDate start, boolean strict)
throws ParseException {
return createLocalDateIterable(rdata, start, DateTimeZone.UTC, strict);
}
|
[
"public",
"static",
"LocalDateIterable",
"createLocalDateIterable",
"(",
"String",
"rdata",
",",
"LocalDate",
"start",
",",
"boolean",
"strict",
")",
"throws",
"ParseException",
"{",
"return",
"createLocalDateIterable",
"(",
"rdata",
",",
"start",
",",
"DateTimeZone",
".",
"UTC",
",",
"strict",
")",
";",
"}"
] |
given a block of RRULE, EXRULE, RDATE, and EXDATE content lines, parse
them into a single local date iterable.
@param rdata RRULE, EXRULE, RDATE, and EXDATE lines.
@param start the first occurrence of the series.
@param strict true if any failure to parse should result in a
ParseException. false causes bad content lines to be logged and ignored.
|
[
"given",
"a",
"block",
"of",
"RRULE",
"EXRULE",
"RDATE",
"and",
"EXDATE",
"content",
"lines",
"parse",
"them",
"into",
"a",
"single",
"local",
"date",
"iterable",
"."
] |
train
|
https://github.com/dlemmermann/CalendarFX/blob/f2b91c2622c3f29d004485b6426b23b86c331f96/CalendarFXRecurrence/src/main/java/com/google/ical/compat/jodatime/LocalDateIteratorFactory.java#L104-L108
|
phax/ph-commons
|
ph-xml/src/main/java/com/helger/xml/transform/XMLTransformerFactory.java
|
XMLTransformerFactory.newTransformer
|
@Nullable
public static Transformer newTransformer (@Nonnull final TransformerFactory aTransformerFactory,
@Nonnull final IReadableResource aResource)
{
ValueEnforcer.notNull (aResource, "Resource");
return newTransformer (aTransformerFactory, TransformSourceFactory.create (aResource));
}
|
java
|
@Nullable
public static Transformer newTransformer (@Nonnull final TransformerFactory aTransformerFactory,
@Nonnull final IReadableResource aResource)
{
ValueEnforcer.notNull (aResource, "Resource");
return newTransformer (aTransformerFactory, TransformSourceFactory.create (aResource));
}
|
[
"@",
"Nullable",
"public",
"static",
"Transformer",
"newTransformer",
"(",
"@",
"Nonnull",
"final",
"TransformerFactory",
"aTransformerFactory",
",",
"@",
"Nonnull",
"final",
"IReadableResource",
"aResource",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aResource",
",",
"\"Resource\"",
")",
";",
"return",
"newTransformer",
"(",
"aTransformerFactory",
",",
"TransformSourceFactory",
".",
"create",
"(",
"aResource",
")",
")",
";",
"}"
] |
Create a new XSLT transformer for the passed resource.
@param aTransformerFactory
The transformer factory to be used. May not be <code>null</code>.
@param aResource
The resource to be transformed. May not be <code>null</code>.
@return <code>null</code> if something goes wrong
|
[
"Create",
"a",
"new",
"XSLT",
"transformer",
"for",
"the",
"passed",
"resource",
"."
] |
train
|
https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/transform/XMLTransformerFactory.java#L186-L193
|
xm-online/xm-commons
|
xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/ConfigSignatureVerifierClient.java
|
ConfigSignatureVerifierClient.getSignatureVerifier
|
@Override
public SignatureVerifier getSignatureVerifier() throws Exception {
try {
HttpEntity<Void> request = new HttpEntity<>(new HttpHeaders());
String content = restTemplate.exchange(getPublicKeyEndpoint(),
HttpMethod.GET, request, String.class).getBody();
if (StringUtils.isEmpty(content)) {
log.info("Public key not fetched");
return null;
}
InputStream fin = new ByteArrayInputStream(content.getBytes());
CertificateFactory f = CertificateFactory.getInstance("X.509");
X509Certificate certificate = (X509Certificate) f.generateCertificate(fin);
PublicKey pk = certificate.getPublicKey();
return new RsaVerifier(String.format(PUBLIC_KEY, new String(Base64.getEncoder().encode(pk.getEncoded()))));
} catch (IllegalStateException ex) {
log.warn("could not contact Config to get public key");
return null;
}
}
|
java
|
@Override
public SignatureVerifier getSignatureVerifier() throws Exception {
try {
HttpEntity<Void> request = new HttpEntity<>(new HttpHeaders());
String content = restTemplate.exchange(getPublicKeyEndpoint(),
HttpMethod.GET, request, String.class).getBody();
if (StringUtils.isEmpty(content)) {
log.info("Public key not fetched");
return null;
}
InputStream fin = new ByteArrayInputStream(content.getBytes());
CertificateFactory f = CertificateFactory.getInstance("X.509");
X509Certificate certificate = (X509Certificate) f.generateCertificate(fin);
PublicKey pk = certificate.getPublicKey();
return new RsaVerifier(String.format(PUBLIC_KEY, new String(Base64.getEncoder().encode(pk.getEncoded()))));
} catch (IllegalStateException ex) {
log.warn("could not contact Config to get public key");
return null;
}
}
|
[
"@",
"Override",
"public",
"SignatureVerifier",
"getSignatureVerifier",
"(",
")",
"throws",
"Exception",
"{",
"try",
"{",
"HttpEntity",
"<",
"Void",
">",
"request",
"=",
"new",
"HttpEntity",
"<>",
"(",
"new",
"HttpHeaders",
"(",
")",
")",
";",
"String",
"content",
"=",
"restTemplate",
".",
"exchange",
"(",
"getPublicKeyEndpoint",
"(",
")",
",",
"HttpMethod",
".",
"GET",
",",
"request",
",",
"String",
".",
"class",
")",
".",
"getBody",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"content",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Public key not fetched\"",
")",
";",
"return",
"null",
";",
"}",
"InputStream",
"fin",
"=",
"new",
"ByteArrayInputStream",
"(",
"content",
".",
"getBytes",
"(",
")",
")",
";",
"CertificateFactory",
"f",
"=",
"CertificateFactory",
".",
"getInstance",
"(",
"\"X.509\"",
")",
";",
"X509Certificate",
"certificate",
"=",
"(",
"X509Certificate",
")",
"f",
".",
"generateCertificate",
"(",
"fin",
")",
";",
"PublicKey",
"pk",
"=",
"certificate",
".",
"getPublicKey",
"(",
")",
";",
"return",
"new",
"RsaVerifier",
"(",
"String",
".",
"format",
"(",
"PUBLIC_KEY",
",",
"new",
"String",
"(",
"Base64",
".",
"getEncoder",
"(",
")",
".",
"encode",
"(",
"pk",
".",
"getEncoded",
"(",
")",
")",
")",
")",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"ex",
")",
"{",
"log",
".",
"warn",
"(",
"\"could not contact Config to get public key\"",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Fetches the public key from the MS Config.
@return the public key used to verify JWT tokens; or null.
|
[
"Fetches",
"the",
"public",
"key",
"from",
"the",
"MS",
"Config",
"."
] |
train
|
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/ConfigSignatureVerifierClient.java#L44-L67
|
albfernandez/itext2
|
src/main/java/com/lowagie/text/rtf/document/output/RtfByteArrayBuffer.java
|
RtfByteArrayBuffer.write
|
public void write(final byte[] src, int off, int len)
{
if(src == null) throw new NullPointerException();
if((off < 0) || (off > src.length) || (len < 0) || ((off + len) > src.length) || ((off + len) < 0)) throw new IndexOutOfBoundsException();
writeLoop(src, off, len);
}
|
java
|
public void write(final byte[] src, int off, int len)
{
if(src == null) throw new NullPointerException();
if((off < 0) || (off > src.length) || (len < 0) || ((off + len) > src.length) || ((off + len) < 0)) throw new IndexOutOfBoundsException();
writeLoop(src, off, len);
}
|
[
"public",
"void",
"write",
"(",
"final",
"byte",
"[",
"]",
"src",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"if",
"(",
"src",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"if",
"(",
"(",
"off",
"<",
"0",
")",
"||",
"(",
"off",
">",
"src",
".",
"length",
")",
"||",
"(",
"len",
"<",
"0",
")",
"||",
"(",
"(",
"off",
"+",
"len",
")",
">",
"src",
".",
"length",
")",
"||",
"(",
"(",
"off",
"+",
"len",
")",
"<",
"0",
")",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"writeLoop",
"(",
"src",
",",
"off",
",",
"len",
")",
";",
"}"
] |
Copies len bytes starting at position off from the array src to the internal buffer.
@param src
@param off
@param len
|
[
"Copies",
"len",
"bytes",
"starting",
"at",
"position",
"off",
"from",
"the",
"array",
"src",
"to",
"the",
"internal",
"buffer",
"."
] |
train
|
https://github.com/albfernandez/itext2/blob/438fc1899367fd13dfdfa8dfdca9a3c1a7783b84/src/main/java/com/lowagie/text/rtf/document/output/RtfByteArrayBuffer.java#L182-L188
|
Azure/azure-sdk-for-java
|
compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java
|
VirtualMachinesInner.captureAsync
|
public Observable<VirtualMachineCaptureResultInner> captureAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParameters parameters) {
return captureWithServiceResponseAsync(resourceGroupName, vmName, parameters).map(new Func1<ServiceResponse<VirtualMachineCaptureResultInner>, VirtualMachineCaptureResultInner>() {
@Override
public VirtualMachineCaptureResultInner call(ServiceResponse<VirtualMachineCaptureResultInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<VirtualMachineCaptureResultInner> captureAsync(String resourceGroupName, String vmName, VirtualMachineCaptureParameters parameters) {
return captureWithServiceResponseAsync(resourceGroupName, vmName, parameters).map(new Func1<ServiceResponse<VirtualMachineCaptureResultInner>, VirtualMachineCaptureResultInner>() {
@Override
public VirtualMachineCaptureResultInner call(ServiceResponse<VirtualMachineCaptureResultInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"VirtualMachineCaptureResultInner",
">",
"captureAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"vmName",
",",
"VirtualMachineCaptureParameters",
"parameters",
")",
"{",
"return",
"captureWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"vmName",
",",
"parameters",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"VirtualMachineCaptureResultInner",
">",
",",
"VirtualMachineCaptureResultInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"VirtualMachineCaptureResultInner",
"call",
"(",
"ServiceResponse",
"<",
"VirtualMachineCaptureResultInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs.
@param resourceGroupName The name of the resource group.
@param vmName The name of the virtual machine.
@param parameters Parameters supplied to the Capture Virtual Machine operation.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable for the request
|
[
"Captures",
"the",
"VM",
"by",
"copying",
"virtual",
"hard",
"disks",
"of",
"the",
"VM",
"and",
"outputs",
"a",
"template",
"that",
"can",
"be",
"used",
"to",
"create",
"similar",
"VMs",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/compute/resource-manager/v2017_03_30/src/main/java/com/microsoft/azure/management/compute/v2017_03_30/implementation/VirtualMachinesInner.java#L405-L412
|
cdk/cdk
|
storage/smiles/src/main/java/org/openscience/cdk/smiles/CxSmilesParser.java
|
CxSmilesParser.processIntList
|
private static boolean processIntList(CharIter iter, char sep, List<Integer> dest) {
while (iter.hasNext()) {
char c = iter.curr();
if (isDigit(c)) {
int r = processUnsignedInt(iter);
if (r < 0) return false;
iter.nextIf(sep);
dest.add(r);
} else {
return true;
}
}
// ran off end
return false;
}
|
java
|
private static boolean processIntList(CharIter iter, char sep, List<Integer> dest) {
while (iter.hasNext()) {
char c = iter.curr();
if (isDigit(c)) {
int r = processUnsignedInt(iter);
if (r < 0) return false;
iter.nextIf(sep);
dest.add(r);
} else {
return true;
}
}
// ran off end
return false;
}
|
[
"private",
"static",
"boolean",
"processIntList",
"(",
"CharIter",
"iter",
",",
"char",
"sep",
",",
"List",
"<",
"Integer",
">",
"dest",
")",
"{",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"char",
"c",
"=",
"iter",
".",
"curr",
"(",
")",
";",
"if",
"(",
"isDigit",
"(",
"c",
")",
")",
"{",
"int",
"r",
"=",
"processUnsignedInt",
"(",
"iter",
")",
";",
"if",
"(",
"r",
"<",
"0",
")",
"return",
"false",
";",
"iter",
".",
"nextIf",
"(",
"sep",
")",
";",
"dest",
".",
"add",
"(",
"r",
")",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"// ran off end",
"return",
"false",
";",
"}"
] |
Process a list of unsigned integers.
@param iter char iter
@param sep the separator
@param dest output
@return int-list was successfully processed
|
[
"Process",
"a",
"list",
"of",
"unsigned",
"integers",
"."
] |
train
|
https://github.com/cdk/cdk/blob/c3d0f16502bf08df50365fee392e11d7c9856657/storage/smiles/src/main/java/org/openscience/cdk/smiles/CxSmilesParser.java#L567-L581
|
jlinn/quartz-redis-jobstore
|
src/main/java/net/joelinn/quartz/jobstore/RedisJobStore.java
|
RedisJobStore.doWithLock
|
private <T> T doWithLock(LockCallback<T> callback, String errorMessage) throws JobPersistenceException {
JedisCommands jedis = null;
try {
jedis = getResource();
try {
storage.waitForLock(jedis);
return callback.doWithLock(jedis);
} catch (ObjectAlreadyExistsException e) {
throw e;
} catch (Exception e) {
if (errorMessage == null || errorMessage.isEmpty()) {
errorMessage = "Job storage error.";
}
throw new JobPersistenceException(errorMessage, e);
} finally {
storage.unlock(jedis);
}
} finally {
if (jedis != null && jedis instanceof Jedis) {
// only close if we're not using a JedisCluster instance
((Jedis) jedis).close();
}
}
}
|
java
|
private <T> T doWithLock(LockCallback<T> callback, String errorMessage) throws JobPersistenceException {
JedisCommands jedis = null;
try {
jedis = getResource();
try {
storage.waitForLock(jedis);
return callback.doWithLock(jedis);
} catch (ObjectAlreadyExistsException e) {
throw e;
} catch (Exception e) {
if (errorMessage == null || errorMessage.isEmpty()) {
errorMessage = "Job storage error.";
}
throw new JobPersistenceException(errorMessage, e);
} finally {
storage.unlock(jedis);
}
} finally {
if (jedis != null && jedis instanceof Jedis) {
// only close if we're not using a JedisCluster instance
((Jedis) jedis).close();
}
}
}
|
[
"private",
"<",
"T",
">",
"T",
"doWithLock",
"(",
"LockCallback",
"<",
"T",
">",
"callback",
",",
"String",
"errorMessage",
")",
"throws",
"JobPersistenceException",
"{",
"JedisCommands",
"jedis",
"=",
"null",
";",
"try",
"{",
"jedis",
"=",
"getResource",
"(",
")",
";",
"try",
"{",
"storage",
".",
"waitForLock",
"(",
"jedis",
")",
";",
"return",
"callback",
".",
"doWithLock",
"(",
"jedis",
")",
";",
"}",
"catch",
"(",
"ObjectAlreadyExistsException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"errorMessage",
"==",
"null",
"||",
"errorMessage",
".",
"isEmpty",
"(",
")",
")",
"{",
"errorMessage",
"=",
"\"Job storage error.\"",
";",
"}",
"throw",
"new",
"JobPersistenceException",
"(",
"errorMessage",
",",
"e",
")",
";",
"}",
"finally",
"{",
"storage",
".",
"unlock",
"(",
"jedis",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"jedis",
"!=",
"null",
"&&",
"jedis",
"instanceof",
"Jedis",
")",
"{",
"// only close if we're not using a JedisCluster instance",
"(",
"(",
"Jedis",
")",
"jedis",
")",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] |
Perform a redis operation while lock is acquired
@param callback a callback containing the actions to perform during lock
@param errorMessage optional error message to include in exception should an error arise
@param <T> return class
@return the result of the actions performed while locked, if any
@throws JobPersistenceException
|
[
"Perform",
"a",
"redis",
"operation",
"while",
"lock",
"is",
"acquired"
] |
train
|
https://github.com/jlinn/quartz-redis-jobstore/blob/be9a52ee776d8a09866fe99fd9718bc13a0cb992/src/main/java/net/joelinn/quartz/jobstore/RedisJobStore.java#L1148-L1171
|
OpenLiberty/open-liberty
|
dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jms/impl/URIDestinationCreator.java
|
URIDestinationCreator.charIsEscaped
|
private static boolean charIsEscaped(String str, int index) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "charIsEscaped", new Object[]{str, index});
// precondition, null str or out of range index returns false.
if (str == null || index < 0 || index >= str.length()) return false;
// A character is escaped if it is preceded by an odd number of '\'s.
int nEscape = 0;
int i = index-1;
while(i>=0 && str.charAt(i) == '\\') {
nEscape++;
i--;
}
boolean result = nEscape % 2 == 1 ;
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "charIsEscaped", result);
return result;
}
|
java
|
private static boolean charIsEscaped(String str, int index) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "charIsEscaped", new Object[]{str, index});
// precondition, null str or out of range index returns false.
if (str == null || index < 0 || index >= str.length()) return false;
// A character is escaped if it is preceded by an odd number of '\'s.
int nEscape = 0;
int i = index-1;
while(i>=0 && str.charAt(i) == '\\') {
nEscape++;
i--;
}
boolean result = nEscape % 2 == 1 ;
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "charIsEscaped", result);
return result;
}
|
[
"private",
"static",
"boolean",
"charIsEscaped",
"(",
"String",
"str",
",",
"int",
"index",
")",
"{",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"entry",
"(",
"tc",
",",
"\"charIsEscaped\"",
",",
"new",
"Object",
"[",
"]",
"{",
"str",
",",
"index",
"}",
")",
";",
"// precondition, null str or out of range index returns false.",
"if",
"(",
"str",
"==",
"null",
"||",
"index",
"<",
"0",
"||",
"index",
">=",
"str",
".",
"length",
"(",
")",
")",
"return",
"false",
";",
"// A character is escaped if it is preceded by an odd number of '\\'s.",
"int",
"nEscape",
"=",
"0",
";",
"int",
"i",
"=",
"index",
"-",
"1",
";",
"while",
"(",
"i",
">=",
"0",
"&&",
"str",
".",
"charAt",
"(",
"i",
")",
"==",
"'",
"'",
")",
"{",
"nEscape",
"++",
";",
"i",
"--",
";",
"}",
"boolean",
"result",
"=",
"nEscape",
"%",
"2",
"==",
"1",
";",
"if",
"(",
"TraceComponent",
".",
"isAnyTracingEnabled",
"(",
")",
"&&",
"tc",
".",
"isEntryEnabled",
"(",
")",
")",
"SibTr",
".",
"exit",
"(",
"tc",
",",
"\"charIsEscaped\"",
",",
"result",
")",
";",
"return",
"result",
";",
"}"
] |
Test if the specified character is escaped.
Checks whether the character at the specified index is preceded by an
escape character. The test is non-trivial because it has to check that
the escape character is itself non-escaped.
@param str The string in which to perform the check
@param index The index in the string of the character that we are interested in.
@return true if the specified character is escaped.
|
[
"Test",
"if",
"the",
"specified",
"character",
"is",
"escaped",
".",
"Checks",
"whether",
"the",
"character",
"at",
"the",
"specified",
"index",
"is",
"preceded",
"by",
"an",
"escape",
"character",
".",
"The",
"test",
"is",
"non",
"-",
"trivial",
"because",
"it",
"has",
"to",
"check",
"that",
"the",
"escape",
"character",
"is",
"itself",
"non",
"-",
"escaped",
"."
] |
train
|
https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.messaging.jms.2.0/src/com/ibm/ws/sib/api/jms/impl/URIDestinationCreator.java#L1012-L1029
|
threerings/nenya
|
core/src/main/java/com/threerings/openal/SoundGroup.java
|
SoundGroup.acquireSource
|
protected Source acquireSource (Sound acquirer)
{
// start at the beginning of the list looking for an available source
for (int ii = 0, ll = _sources.size(); ii < ll; ii++) {
PooledSource pooled = _sources.get(ii);
if (pooled.holder == null || pooled.holder.reclaim()) {
// note this source's new holder
pooled.holder = acquirer;
// move this source to the end of the list
_sources.remove(ii);
_sources.add(pooled);
return pooled.source;
}
}
return null;
}
|
java
|
protected Source acquireSource (Sound acquirer)
{
// start at the beginning of the list looking for an available source
for (int ii = 0, ll = _sources.size(); ii < ll; ii++) {
PooledSource pooled = _sources.get(ii);
if (pooled.holder == null || pooled.holder.reclaim()) {
// note this source's new holder
pooled.holder = acquirer;
// move this source to the end of the list
_sources.remove(ii);
_sources.add(pooled);
return pooled.source;
}
}
return null;
}
|
[
"protected",
"Source",
"acquireSource",
"(",
"Sound",
"acquirer",
")",
"{",
"// start at the beginning of the list looking for an available source",
"for",
"(",
"int",
"ii",
"=",
"0",
",",
"ll",
"=",
"_sources",
".",
"size",
"(",
")",
";",
"ii",
"<",
"ll",
";",
"ii",
"++",
")",
"{",
"PooledSource",
"pooled",
"=",
"_sources",
".",
"get",
"(",
"ii",
")",
";",
"if",
"(",
"pooled",
".",
"holder",
"==",
"null",
"||",
"pooled",
".",
"holder",
".",
"reclaim",
"(",
")",
")",
"{",
"// note this source's new holder",
"pooled",
".",
"holder",
"=",
"acquirer",
";",
"// move this source to the end of the list",
"_sources",
".",
"remove",
"(",
"ii",
")",
";",
"_sources",
".",
"add",
"(",
"pooled",
")",
";",
"return",
"pooled",
".",
"source",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Called by a {@link Sound} when it wants to obtain a source on which to play its clip.
|
[
"Called",
"by",
"a",
"{"
] |
train
|
https://github.com/threerings/nenya/blob/3165a012fd859009db3367f87bd2a5b820cc760a/core/src/main/java/com/threerings/openal/SoundGroup.java#L141-L156
|
aws/aws-sdk-java
|
aws-java-sdk-servicecatalog/src/main/java/com/amazonaws/services/servicecatalog/model/SearchProductsAsAdminRequest.java
|
SearchProductsAsAdminRequest.setFilters
|
public void setFilters(java.util.Map<String, java.util.List<String>> filters) {
this.filters = filters;
}
|
java
|
public void setFilters(java.util.Map<String, java.util.List<String>> filters) {
this.filters = filters;
}
|
[
"public",
"void",
"setFilters",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"java",
".",
"util",
".",
"List",
"<",
"String",
">",
">",
"filters",
")",
"{",
"this",
".",
"filters",
"=",
"filters",
";",
"}"
] |
<p>
The search filters. If no search filters are specified, the output includes all products to which the
administrator has access.
</p>
@param filters
The search filters. If no search filters are specified, the output includes all products to which the
administrator has access.
|
[
"<p",
">",
"The",
"search",
"filters",
".",
"If",
"no",
"search",
"filters",
"are",
"specified",
"the",
"output",
"includes",
"all",
"products",
"to",
"which",
"the",
"administrator",
"has",
"access",
".",
"<",
"/",
"p",
">"
] |
train
|
https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-servicecatalog/src/main/java/com/amazonaws/services/servicecatalog/model/SearchProductsAsAdminRequest.java#L299-L301
|
Azure/azure-sdk-for-java
|
network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/NetworkInterfacesInner.java
|
NetworkInterfacesInner.getVirtualMachineScaleSetNetworkInterfaceAsync
|
public Observable<NetworkInterfaceInner> getVirtualMachineScaleSetNetworkInterfaceAsync(String resourceGroupName, String virtualMachineScaleSetName, String virtualmachineIndex, String networkInterfaceName, String expand) {
return getVirtualMachineScaleSetNetworkInterfaceWithServiceResponseAsync(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, expand).map(new Func1<ServiceResponse<NetworkInterfaceInner>, NetworkInterfaceInner>() {
@Override
public NetworkInterfaceInner call(ServiceResponse<NetworkInterfaceInner> response) {
return response.body();
}
});
}
|
java
|
public Observable<NetworkInterfaceInner> getVirtualMachineScaleSetNetworkInterfaceAsync(String resourceGroupName, String virtualMachineScaleSetName, String virtualmachineIndex, String networkInterfaceName, String expand) {
return getVirtualMachineScaleSetNetworkInterfaceWithServiceResponseAsync(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, expand).map(new Func1<ServiceResponse<NetworkInterfaceInner>, NetworkInterfaceInner>() {
@Override
public NetworkInterfaceInner call(ServiceResponse<NetworkInterfaceInner> response) {
return response.body();
}
});
}
|
[
"public",
"Observable",
"<",
"NetworkInterfaceInner",
">",
"getVirtualMachineScaleSetNetworkInterfaceAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"virtualMachineScaleSetName",
",",
"String",
"virtualmachineIndex",
",",
"String",
"networkInterfaceName",
",",
"String",
"expand",
")",
"{",
"return",
"getVirtualMachineScaleSetNetworkInterfaceWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"virtualMachineScaleSetName",
",",
"virtualmachineIndex",
",",
"networkInterfaceName",
",",
"expand",
")",
".",
"map",
"(",
"new",
"Func1",
"<",
"ServiceResponse",
"<",
"NetworkInterfaceInner",
">",
",",
"NetworkInterfaceInner",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"NetworkInterfaceInner",
"call",
"(",
"ServiceResponse",
"<",
"NetworkInterfaceInner",
">",
"response",
")",
"{",
"return",
"response",
".",
"body",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Get the specified network interface in a virtual machine scale set.
@param resourceGroupName The name of the resource group.
@param virtualMachineScaleSetName The name of the virtual machine scale set.
@param virtualmachineIndex The virtual machine index.
@param networkInterfaceName The name of the network interface.
@param expand Expands referenced resources.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the NetworkInterfaceInner object
|
[
"Get",
"the",
"specified",
"network",
"interface",
"in",
"a",
"virtual",
"machine",
"scale",
"set",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_07_01/src/main/java/com/microsoft/azure/management/network/v2018_07_01/implementation/NetworkInterfacesInner.java#L1872-L1879
|
phoenixnap/springmvc-raml-plugin
|
src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiBodyMetadata.java
|
ApiBodyMetadata.getCodeModel
|
public JCodeModel getCodeModel(String basePackage, String schemaLocation, Annotator annotator) {
if (type != null) {
return codeModel;
} else {
return SchemaHelper.buildBodyJCodeModel(schemaLocation, basePackage, name, schema, annotator);
}
}
|
java
|
public JCodeModel getCodeModel(String basePackage, String schemaLocation, Annotator annotator) {
if (type != null) {
return codeModel;
} else {
return SchemaHelper.buildBodyJCodeModel(schemaLocation, basePackage, name, schema, annotator);
}
}
|
[
"public",
"JCodeModel",
"getCodeModel",
"(",
"String",
"basePackage",
",",
"String",
"schemaLocation",
",",
"Annotator",
"annotator",
")",
"{",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"return",
"codeModel",
";",
"}",
"else",
"{",
"return",
"SchemaHelper",
".",
"buildBodyJCodeModel",
"(",
"schemaLocation",
",",
"basePackage",
",",
"name",
",",
"schema",
",",
"annotator",
")",
";",
"}",
"}"
] |
Builds a JCodeModel for this body
@param basePackage
The package we will be using for the domain objects
@param schemaLocation
The location of this schema, will be used to create absolute
URIs for $ref tags eg "classpath:/"
@param annotator
JsonSchema2Pojo annotator. if null a default annotator will be
used
@return built JCodeModel
|
[
"Builds",
"a",
"JCodeModel",
"for",
"this",
"body"
] |
train
|
https://github.com/phoenixnap/springmvc-raml-plugin/blob/6387072317cd771eb7d6f30943f556ac20dd3c84/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/data/ApiBodyMetadata.java#L151-L157
|
uber/NullAway
|
nullaway/src/main/java/com/uber/nullaway/dataflow/DataFlow.java
|
DataFlow.expressionDataflow
|
@Nullable
public <A extends AbstractValue<A>, S extends Store<S>, T extends TransferFunction<A, S>>
A expressionDataflow(TreePath exprPath, Context context, T transfer) {
AnalysisResult<A, S> analysisResult = resultForExpr(exprPath, context, transfer);
return analysisResult == null ? null : analysisResult.getValue(exprPath.getLeaf());
}
|
java
|
@Nullable
public <A extends AbstractValue<A>, S extends Store<S>, T extends TransferFunction<A, S>>
A expressionDataflow(TreePath exprPath, Context context, T transfer) {
AnalysisResult<A, S> analysisResult = resultForExpr(exprPath, context, transfer);
return analysisResult == null ? null : analysisResult.getValue(exprPath.getLeaf());
}
|
[
"@",
"Nullable",
"public",
"<",
"A",
"extends",
"AbstractValue",
"<",
"A",
">",
",",
"S",
"extends",
"Store",
"<",
"S",
">",
",",
"T",
"extends",
"TransferFunction",
"<",
"A",
",",
"S",
">",
">",
"A",
"expressionDataflow",
"(",
"TreePath",
"exprPath",
",",
"Context",
"context",
",",
"T",
"transfer",
")",
"{",
"AnalysisResult",
"<",
"A",
",",
"S",
">",
"analysisResult",
"=",
"resultForExpr",
"(",
"exprPath",
",",
"context",
",",
"transfer",
")",
";",
"return",
"analysisResult",
"==",
"null",
"?",
"null",
":",
"analysisResult",
".",
"getValue",
"(",
"exprPath",
".",
"getLeaf",
"(",
")",
")",
";",
"}"
] |
Run the {@code transfer} dataflow analysis to compute the abstract value of the expression
which is the leaf of {@code exprPath}.
@param exprPath expression
@param context Javac context
@param transfer transfer functions
@param <A> values in abstraction
@param <S> store type
@param <T> transfer function type
@return dataflow value for expression
|
[
"Run",
"the",
"{",
"@code",
"transfer",
"}",
"dataflow",
"analysis",
"to",
"compute",
"the",
"abstract",
"value",
"of",
"the",
"expression",
"which",
"is",
"the",
"leaf",
"of",
"{",
"@code",
"exprPath",
"}",
"."
] |
train
|
https://github.com/uber/NullAway/blob/c3979b4241f80411dbba6aac3ff653acbb88d00b/nullaway/src/main/java/com/uber/nullaway/dataflow/DataFlow.java#L170-L175
|
santhosh-tekuri/jlibs
|
core/src/main/java/jlibs/core/lang/Ansi.java
|
Ansi.errFormat
|
public void errFormat(String format, Object... args){
format(System.err, format, args);
}
|
java
|
public void errFormat(String format, Object... args){
format(System.err, format, args);
}
|
[
"public",
"void",
"errFormat",
"(",
"String",
"format",
",",
"Object",
"...",
"args",
")",
"{",
"format",
"(",
"System",
".",
"err",
",",
"format",
",",
"args",
")",
";",
"}"
] |
Prints formatted and colorized {@code format} to {@link System#err}
@param format A format string whose output to be colorized
@param args Arguments referenced by the format specifiers in the format
|
[
"Prints",
"formatted",
"and",
"colorized",
"{",
"@code",
"format",
"}",
"to",
"{",
"@link",
"System#err",
"}"
] |
train
|
https://github.com/santhosh-tekuri/jlibs/blob/59c28719f054123cf778278154e1b92e943ad232/core/src/main/java/jlibs/core/lang/Ansi.java#L336-L338
|
javers/javers
|
javers-core/src/main/java/org/javers/core/metamodel/type/TypeMapper.java
|
TypeMapper.getJaversManagedType
|
public <T extends ManagedType> T getJaversManagedType(Class javaClass, Class<T> expectedType) {
JaversType mType = getJaversType(javaClass);
if (expectedType.isAssignableFrom(mType.getClass())) {
return (T) mType;
} else {
throw new JaversException(JaversExceptionCode.MANAGED_CLASS_MAPPING_ERROR,
javaClass,
mType.getClass().getSimpleName(),
expectedType.getSimpleName());
}
}
|
java
|
public <T extends ManagedType> T getJaversManagedType(Class javaClass, Class<T> expectedType) {
JaversType mType = getJaversType(javaClass);
if (expectedType.isAssignableFrom(mType.getClass())) {
return (T) mType;
} else {
throw new JaversException(JaversExceptionCode.MANAGED_CLASS_MAPPING_ERROR,
javaClass,
mType.getClass().getSimpleName(),
expectedType.getSimpleName());
}
}
|
[
"public",
"<",
"T",
"extends",
"ManagedType",
">",
"T",
"getJaversManagedType",
"(",
"Class",
"javaClass",
",",
"Class",
"<",
"T",
">",
"expectedType",
")",
"{",
"JaversType",
"mType",
"=",
"getJaversType",
"(",
"javaClass",
")",
";",
"if",
"(",
"expectedType",
".",
"isAssignableFrom",
"(",
"mType",
".",
"getClass",
"(",
")",
")",
")",
"{",
"return",
"(",
"T",
")",
"mType",
";",
"}",
"else",
"{",
"throw",
"new",
"JaversException",
"(",
"JaversExceptionCode",
".",
"MANAGED_CLASS_MAPPING_ERROR",
",",
"javaClass",
",",
"mType",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
",",
"expectedType",
".",
"getSimpleName",
"(",
")",
")",
";",
"}",
"}"
] |
If given javaClass is mapped to expected ManagedType, returns its JaversType
@throws JaversException MANAGED_CLASS_MAPPING_ERROR
|
[
"If",
"given",
"javaClass",
"is",
"mapped",
"to",
"expected",
"ManagedType",
"returns",
"its",
"JaversType"
] |
train
|
https://github.com/javers/javers/blob/a51511be7d8bcee3e1812db8b7e69a45330b4e14/javers-core/src/main/java/org/javers/core/metamodel/type/TypeMapper.java#L179-L190
|
jhunters/jprotobuf
|
src/main/java/com/baidu/bjf/remoting/protobuf/utils/MiniTemplator.java
|
MiniTemplator.setVariableEsc
|
public void setVariableEsc(String variableName, String variableValue, boolean isOptional)
throws VariableNotDefinedException {
setVariable(variableName, escapeHtml(variableValue), isOptional);
}
|
java
|
public void setVariableEsc(String variableName, String variableValue, boolean isOptional)
throws VariableNotDefinedException {
setVariable(variableName, escapeHtml(variableValue), isOptional);
}
|
[
"public",
"void",
"setVariableEsc",
"(",
"String",
"variableName",
",",
"String",
"variableValue",
",",
"boolean",
"isOptional",
")",
"throws",
"VariableNotDefinedException",
"{",
"setVariable",
"(",
"variableName",
",",
"escapeHtml",
"(",
"variableValue",
")",
",",
"isOptional",
")",
";",
"}"
] |
Sets a template variable to an escaped value.
<p>
Convenience method for:
<code>setVariable (variableName, MiniTemplator.escapeHtml(variableValue), isOptional)</code>
@param variableName the name of the variable to be set.
@param variableValue the new value of the variable. May be <code>null</code>. Special HTML/XML characters are
escaped.
@param isOptional specifies whether an exception should be thrown when the variable does not exist in the
template. If <code>isOptional</code> is <code>false</code> and the variable does not exist, an
exception is thrown.
@throws VariableNotDefinedException when no variable with the specified name exists in the template and
<code>isOptional</code> is <code>false</code>.
@see #setVariable(String, String, boolean)
@see #escapeHtml(String)
|
[
"Sets",
"a",
"template",
"variable",
"to",
"an",
"escaped",
"value",
".",
"<p",
">",
"Convenience",
"method",
"for",
":",
"<code",
">",
"setVariable",
"(",
"variableName",
"MiniTemplator",
".",
"escapeHtml",
"(",
"variableValue",
")",
"isOptional",
")",
"<",
"/",
"code",
">"
] |
train
|
https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/src/main/java/com/baidu/bjf/remoting/protobuf/utils/MiniTemplator.java#L451-L454
|
artikcloud/artikcloud-java
|
src/main/java/cloud/artik/api/WhitelistingApi.java
|
WhitelistingApi.deleteWhitelistCertificate
|
public WhitelistEnvelope deleteWhitelistCertificate(String dtid, String cid) throws ApiException {
ApiResponse<WhitelistEnvelope> resp = deleteWhitelistCertificateWithHttpInfo(dtid, cid);
return resp.getData();
}
|
java
|
public WhitelistEnvelope deleteWhitelistCertificate(String dtid, String cid) throws ApiException {
ApiResponse<WhitelistEnvelope> resp = deleteWhitelistCertificateWithHttpInfo(dtid, cid);
return resp.getData();
}
|
[
"public",
"WhitelistEnvelope",
"deleteWhitelistCertificate",
"(",
"String",
"dtid",
",",
"String",
"cid",
")",
"throws",
"ApiException",
"{",
"ApiResponse",
"<",
"WhitelistEnvelope",
">",
"resp",
"=",
"deleteWhitelistCertificateWithHttpInfo",
"(",
"dtid",
",",
"cid",
")",
";",
"return",
"resp",
".",
"getData",
"(",
")",
";",
"}"
] |
Delete a whitelist certificate associated with a devicetype.
Delete a whitelist certificate associated with a devicetype.
@param dtid Device Type ID. (required)
@param cid Certificate ID. (required)
@return WhitelistEnvelope
@throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
[
"Delete",
"a",
"whitelist",
"certificate",
"associated",
"with",
"a",
"devicetype",
".",
"Delete",
"a",
"whitelist",
"certificate",
"associated",
"with",
"a",
"devicetype",
"."
] |
train
|
https://github.com/artikcloud/artikcloud-java/blob/412f447573e7796ab4f685c0bdd5eb76185a365c/src/main/java/cloud/artik/api/WhitelistingApi.java#L265-L268
|
jhalterman/concurrentunit
|
src/main/java/net/jodah/concurrentunit/Waiter.java
|
Waiter.assertEquals
|
public void assertEquals(Object expected, Object actual) {
if (expected == null && actual == null)
return;
if (expected != null && expected.equals(actual))
return;
fail(format(expected, actual));
}
|
java
|
public void assertEquals(Object expected, Object actual) {
if (expected == null && actual == null)
return;
if (expected != null && expected.equals(actual))
return;
fail(format(expected, actual));
}
|
[
"public",
"void",
"assertEquals",
"(",
"Object",
"expected",
",",
"Object",
"actual",
")",
"{",
"if",
"(",
"expected",
"==",
"null",
"&&",
"actual",
"==",
"null",
")",
"return",
";",
"if",
"(",
"expected",
"!=",
"null",
"&&",
"expected",
".",
"equals",
"(",
"actual",
")",
")",
"return",
";",
"fail",
"(",
"format",
"(",
"expected",
",",
"actual",
")",
")",
";",
"}"
] |
Asserts that the {@code expected} values equals the {@code actual} value
@throws AssertionError when the assertion fails
|
[
"Asserts",
"that",
"the",
"{",
"@code",
"expected",
"}",
"values",
"equals",
"the",
"{",
"@code",
"actual",
"}",
"value"
] |
train
|
https://github.com/jhalterman/concurrentunit/blob/403b82537866e5ba598017d874753e12fa7aab10/src/main/java/net/jodah/concurrentunit/Waiter.java#L47-L53
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/BlockInStream.java
|
BlockInStream.createRemoteBlockInStream
|
public static BlockInStream createRemoteBlockInStream(FileSystemContext context, long blockId,
WorkerNetAddress address, BlockInStreamSource blockSource, long blockSize,
Protocol.OpenUfsBlockOptions ufsOptions) {
long chunkSize =
context.getClusterConf()
.getBytes(PropertyKey.USER_NETWORK_READER_CHUNK_SIZE_BYTES);
ReadRequest readRequest = ReadRequest.newBuilder().setBlockId(blockId)
.setOpenUfsBlockOptions(ufsOptions).setChunkSize(chunkSize).buildPartial();
DataReader.Factory factory = new GrpcDataReader.Factory(context, address,
readRequest.toBuilder().buildPartial());
return new BlockInStream(factory, address, blockSource, blockId, blockSize);
}
|
java
|
public static BlockInStream createRemoteBlockInStream(FileSystemContext context, long blockId,
WorkerNetAddress address, BlockInStreamSource blockSource, long blockSize,
Protocol.OpenUfsBlockOptions ufsOptions) {
long chunkSize =
context.getClusterConf()
.getBytes(PropertyKey.USER_NETWORK_READER_CHUNK_SIZE_BYTES);
ReadRequest readRequest = ReadRequest.newBuilder().setBlockId(blockId)
.setOpenUfsBlockOptions(ufsOptions).setChunkSize(chunkSize).buildPartial();
DataReader.Factory factory = new GrpcDataReader.Factory(context, address,
readRequest.toBuilder().buildPartial());
return new BlockInStream(factory, address, blockSource, blockId, blockSize);
}
|
[
"public",
"static",
"BlockInStream",
"createRemoteBlockInStream",
"(",
"FileSystemContext",
"context",
",",
"long",
"blockId",
",",
"WorkerNetAddress",
"address",
",",
"BlockInStreamSource",
"blockSource",
",",
"long",
"blockSize",
",",
"Protocol",
".",
"OpenUfsBlockOptions",
"ufsOptions",
")",
"{",
"long",
"chunkSize",
"=",
"context",
".",
"getClusterConf",
"(",
")",
".",
"getBytes",
"(",
"PropertyKey",
".",
"USER_NETWORK_READER_CHUNK_SIZE_BYTES",
")",
";",
"ReadRequest",
"readRequest",
"=",
"ReadRequest",
".",
"newBuilder",
"(",
")",
".",
"setBlockId",
"(",
"blockId",
")",
".",
"setOpenUfsBlockOptions",
"(",
"ufsOptions",
")",
".",
"setChunkSize",
"(",
"chunkSize",
")",
".",
"buildPartial",
"(",
")",
";",
"DataReader",
".",
"Factory",
"factory",
"=",
"new",
"GrpcDataReader",
".",
"Factory",
"(",
"context",
",",
"address",
",",
"readRequest",
".",
"toBuilder",
"(",
")",
".",
"buildPartial",
"(",
")",
")",
";",
"return",
"new",
"BlockInStream",
"(",
"factory",
",",
"address",
",",
"blockSource",
",",
"blockId",
",",
"blockSize",
")",
";",
"}"
] |
Creates a {@link BlockInStream} to read from a specific remote server. Should only be used
in cases where the data source and method of reading is known, ie. worker - worker
communication.
@param context the file system context
@param blockId the block id
@param address the address of the gRPC data server
@param blockSource the source location of the block
@param blockSize the size of the block
@param ufsOptions the ufs read options
@return the {@link BlockInStream} created
|
[
"Creates",
"a",
"{",
"@link",
"BlockInStream",
"}",
"to",
"read",
"from",
"a",
"specific",
"remote",
"server",
".",
"Should",
"only",
"be",
"used",
"in",
"cases",
"where",
"the",
"data",
"source",
"and",
"method",
"of",
"reading",
"is",
"known",
"ie",
".",
"worker",
"-",
"worker",
"communication",
"."
] |
train
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/BlockInStream.java#L193-L204
|
square/dagger
|
compiler/src/main/java/dagger/internal/codegen/Util.java
|
Util.rawTypeToString
|
public static String rawTypeToString(TypeMirror type, char innerClassSeparator) {
if (!(type instanceof DeclaredType)) {
throw new IllegalArgumentException("Unexpected type: " + type);
}
StringBuilder result = new StringBuilder();
DeclaredType declaredType = (DeclaredType) type;
rawTypeToString(result, (TypeElement) declaredType.asElement(), innerClassSeparator);
return result.toString();
}
|
java
|
public static String rawTypeToString(TypeMirror type, char innerClassSeparator) {
if (!(type instanceof DeclaredType)) {
throw new IllegalArgumentException("Unexpected type: " + type);
}
StringBuilder result = new StringBuilder();
DeclaredType declaredType = (DeclaredType) type;
rawTypeToString(result, (TypeElement) declaredType.asElement(), innerClassSeparator);
return result.toString();
}
|
[
"public",
"static",
"String",
"rawTypeToString",
"(",
"TypeMirror",
"type",
",",
"char",
"innerClassSeparator",
")",
"{",
"if",
"(",
"!",
"(",
"type",
"instanceof",
"DeclaredType",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unexpected type: \"",
"+",
"type",
")",
";",
"}",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"DeclaredType",
"declaredType",
"=",
"(",
"DeclaredType",
")",
"type",
";",
"rawTypeToString",
"(",
"result",
",",
"(",
"TypeElement",
")",
"declaredType",
".",
"asElement",
"(",
")",
",",
"innerClassSeparator",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Returns a string for the raw type of {@code type}. Primitive types are always boxed.
|
[
"Returns",
"a",
"string",
"for",
"the",
"raw",
"type",
"of",
"{"
] |
train
|
https://github.com/square/dagger/blob/572cdd2fe97fc3c148fb3d8e1b2ce7beb4dcbcde/compiler/src/main/java/dagger/internal/codegen/Util.java#L104-L112
|
qatools/properties
|
src/main/java/ru/qatools/properties/utils/PropsReplacer.java
|
PropsReplacer.replaceProps
|
public PropsReplacer replaceProps(String pattern, Properties properties) {
List<String> replaced = new ArrayList<>();
for (String path : paths) {
replaced.add(replaceProps(pattern, path, properties));
}
setPaths(replaced);
return this;
}
|
java
|
public PropsReplacer replaceProps(String pattern, Properties properties) {
List<String> replaced = new ArrayList<>();
for (String path : paths) {
replaced.add(replaceProps(pattern, path, properties));
}
setPaths(replaced);
return this;
}
|
[
"public",
"PropsReplacer",
"replaceProps",
"(",
"String",
"pattern",
",",
"Properties",
"properties",
")",
"{",
"List",
"<",
"String",
">",
"replaced",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"path",
":",
"paths",
")",
"{",
"replaced",
".",
"add",
"(",
"replaceProps",
"(",
"pattern",
",",
"path",
",",
"properties",
")",
")",
";",
"}",
"setPaths",
"(",
"replaced",
")",
";",
"return",
"this",
";",
"}"
] |
Fluent-api method. Replace properties in each path from paths field using pattern. Change paths filed value
@param pattern - pattern to replace. First group should contains property name
@param properties - list of properties using to replace
@return PropsReplacer
|
[
"Fluent",
"-",
"api",
"method",
".",
"Replace",
"properties",
"in",
"each",
"path",
"from",
"paths",
"field",
"using",
"pattern",
".",
"Change",
"paths",
"filed",
"value"
] |
train
|
https://github.com/qatools/properties/blob/ae50b460a6bb4fcb21afe888b2e86a7613cd2115/src/main/java/ru/qatools/properties/utils/PropsReplacer.java#L29-L36
|
biojava/biojava
|
biojava-structure/src/main/java/org/biojava/nbio/structure/Calc.java
|
Calc.getTMScore
|
public static double getTMScore(Atom[] atomSet1, Atom[] atomSet2, int len1, int len2) throws StructureException {
return getTMScore(atomSet1, atomSet2, len1, len2,true);
}
|
java
|
public static double getTMScore(Atom[] atomSet1, Atom[] atomSet2, int len1, int len2) throws StructureException {
return getTMScore(atomSet1, atomSet2, len1, len2,true);
}
|
[
"public",
"static",
"double",
"getTMScore",
"(",
"Atom",
"[",
"]",
"atomSet1",
",",
"Atom",
"[",
"]",
"atomSet2",
",",
"int",
"len1",
",",
"int",
"len2",
")",
"throws",
"StructureException",
"{",
"return",
"getTMScore",
"(",
"atomSet1",
",",
"atomSet2",
",",
"len1",
",",
"len2",
",",
"true",
")",
";",
"}"
] |
Calculate the TM-Score for the superposition.
<em>Normalizes by the <strong>minimum</strong>-length structure (that is, {@code min\{len1,len2\}}).</em>
Atom sets must be pre-rotated.
<p>
Citation:<br/>
<i>Zhang Y and Skolnick J (2004). "Scoring function for automated
assessment of protein structure template quality". Proteins 57: 702 -
710.</i>
@param atomSet1
atom array 1
@param atomSet2
atom array 2
@param len1
The full length of the protein supplying atomSet1
@param len2
The full length of the protein supplying atomSet2
@return The TM-Score
@throws StructureException
|
[
"Calculate",
"the",
"TM",
"-",
"Score",
"for",
"the",
"superposition",
"."
] |
train
|
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/Calc.java#L1285-L1287
|
gfk-ba/senbot
|
SenBotRunner/src/main/java/com/gfk/senbot/framework/data/SenBotReferenceService.java
|
SenBotReferenceService.getElementLocatorForElementReference
|
public By getElementLocatorForElementReference(String elementReference, String apendix) {
Map<String, By> objectReferenceMap = getObjectReferenceMap(By.class);
By elementLocator = objectReferenceMap.get(elementReference);
if (elementLocator instanceof ById) {
String xpathExpression = elementLocator.toString().replaceAll("By.id: ", "//*[@id='") + "']" + apendix;
elementLocator = By.xpath(xpathExpression);
} else if (elementLocator instanceof ByXPath) {
String xpathExpression = elementLocator.toString().replaceAll("By.xpath: ", "") + apendix;
elementLocator = By.xpath(xpathExpression);
} else {
fail("ElementLocator conversion error");
}
if (elementLocator == null) {
fail("No elementLocator is found for element name: '" + elementReference + "'. Available element references are: " + objectReferenceMap.keySet().toString());
}
return elementLocator;
}
|
java
|
public By getElementLocatorForElementReference(String elementReference, String apendix) {
Map<String, By> objectReferenceMap = getObjectReferenceMap(By.class);
By elementLocator = objectReferenceMap.get(elementReference);
if (elementLocator instanceof ById) {
String xpathExpression = elementLocator.toString().replaceAll("By.id: ", "//*[@id='") + "']" + apendix;
elementLocator = By.xpath(xpathExpression);
} else if (elementLocator instanceof ByXPath) {
String xpathExpression = elementLocator.toString().replaceAll("By.xpath: ", "") + apendix;
elementLocator = By.xpath(xpathExpression);
} else {
fail("ElementLocator conversion error");
}
if (elementLocator == null) {
fail("No elementLocator is found for element name: '" + elementReference + "'. Available element references are: " + objectReferenceMap.keySet().toString());
}
return elementLocator;
}
|
[
"public",
"By",
"getElementLocatorForElementReference",
"(",
"String",
"elementReference",
",",
"String",
"apendix",
")",
"{",
"Map",
"<",
"String",
",",
"By",
">",
"objectReferenceMap",
"=",
"getObjectReferenceMap",
"(",
"By",
".",
"class",
")",
";",
"By",
"elementLocator",
"=",
"objectReferenceMap",
".",
"get",
"(",
"elementReference",
")",
";",
"if",
"(",
"elementLocator",
"instanceof",
"ById",
")",
"{",
"String",
"xpathExpression",
"=",
"elementLocator",
".",
"toString",
"(",
")",
".",
"replaceAll",
"(",
"\"By.id: \"",
",",
"\"//*[@id='\"",
")",
"+",
"\"']\"",
"+",
"apendix",
";",
"elementLocator",
"=",
"By",
".",
"xpath",
"(",
"xpathExpression",
")",
";",
"}",
"else",
"if",
"(",
"elementLocator",
"instanceof",
"ByXPath",
")",
"{",
"String",
"xpathExpression",
"=",
"elementLocator",
".",
"toString",
"(",
")",
".",
"replaceAll",
"(",
"\"By.xpath: \"",
",",
"\"\"",
")",
"+",
"apendix",
";",
"elementLocator",
"=",
"By",
".",
"xpath",
"(",
"xpathExpression",
")",
";",
"}",
"else",
"{",
"fail",
"(",
"\"ElementLocator conversion error\"",
")",
";",
"}",
"if",
"(",
"elementLocator",
"==",
"null",
")",
"{",
"fail",
"(",
"\"No elementLocator is found for element name: '\"",
"+",
"elementReference",
"+",
"\"'. Available element references are: \"",
"+",
"objectReferenceMap",
".",
"keySet",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"elementLocator",
";",
"}"
] |
Find a {@link By} locator by its reference name and add something to the xpath before the element gets returned
The drawback of using this method is, that all locators are converted into By.xpath
@param elementReference The name under which the refference is found
@param apendix The part of the xpath that shall be added
@return {@link By}
|
[
"Find",
"a",
"{",
"@link",
"By",
"}",
"locator",
"by",
"its",
"reference",
"name",
"and",
"add",
"something",
"to",
"the",
"xpath",
"before",
"the",
"element",
"gets",
"returned",
"The",
"drawback",
"of",
"using",
"this",
"method",
"is",
"that",
"all",
"locators",
"are",
"converted",
"into",
"By",
".",
"xpath"
] |
train
|
https://github.com/gfk-ba/senbot/blob/e9a152aa67be48b1bb13a4691655caf6d873b553/SenBotRunner/src/main/java/com/gfk/senbot/framework/data/SenBotReferenceService.java#L167-L185
|
SonarSource/sonarqube
|
server/sonar-server/src/main/java/org/sonar/server/platform/PersistentSettings.java
|
PersistentSettings.saveProperty
|
public PersistentSettings saveProperty(DbSession dbSession, String key, @Nullable String value) {
savePropertyImpl(dbSession, key, value);
changeNotifier.onGlobalPropertyChange(key, value);
return this;
}
|
java
|
public PersistentSettings saveProperty(DbSession dbSession, String key, @Nullable String value) {
savePropertyImpl(dbSession, key, value);
changeNotifier.onGlobalPropertyChange(key, value);
return this;
}
|
[
"public",
"PersistentSettings",
"saveProperty",
"(",
"DbSession",
"dbSession",
",",
"String",
"key",
",",
"@",
"Nullable",
"String",
"value",
")",
"{",
"savePropertyImpl",
"(",
"dbSession",
",",
"key",
",",
"value",
")",
";",
"changeNotifier",
".",
"onGlobalPropertyChange",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Insert property into database if value is not {@code null}, else delete property from
database. Session is not committed but {@link org.sonar.api.config.GlobalPropertyChangeHandler}
are executed.
|
[
"Insert",
"property",
"into",
"database",
"if",
"value",
"is",
"not",
"{"
] |
train
|
https://github.com/SonarSource/sonarqube/blob/2fffa4c2f79ae3714844d7742796e82822b6a98a/server/sonar-server/src/main/java/org/sonar/server/platform/PersistentSettings.java#L51-L55
|
threerings/narya
|
core/src/main/java/com/threerings/presents/client/Client.java
|
Client.standaloneLogon
|
public void standaloneLogon (BootstrapData data, DObjectManager omgr)
{
if (!_standalone) {
throw new IllegalStateException("Must call prepareStandaloneLogon() first.");
}
gotBootstrap(data, omgr);
}
|
java
|
public void standaloneLogon (BootstrapData data, DObjectManager omgr)
{
if (!_standalone) {
throw new IllegalStateException("Must call prepareStandaloneLogon() first.");
}
gotBootstrap(data, omgr);
}
|
[
"public",
"void",
"standaloneLogon",
"(",
"BootstrapData",
"data",
",",
"DObjectManager",
"omgr",
")",
"{",
"if",
"(",
"!",
"_standalone",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Must call prepareStandaloneLogon() first.\"",
")",
";",
"}",
"gotBootstrap",
"(",
"data",
",",
"omgr",
")",
";",
"}"
] |
Logs this client on in standalone mode with the faked bootstrap data and shared local
distributed object manager.
|
[
"Logs",
"this",
"client",
"on",
"in",
"standalone",
"mode",
"with",
"the",
"faked",
"bootstrap",
"data",
"and",
"shared",
"local",
"distributed",
"object",
"manager",
"."
] |
train
|
https://github.com/threerings/narya/blob/5b01edc8850ed0c32d004b4049e1ac4a02027ede/core/src/main/java/com/threerings/presents/client/Client.java#L635-L641
|
orbisgis/h2gis
|
h2gis-functions/src/main/java/org/h2gis/functions/spatial/distance/ST_FurthestCoordinate.java
|
ST_FurthestCoordinate.getFurthestCoordinate
|
public static Geometry getFurthestCoordinate(Point point, Geometry geom) {
if (point == null || geom == null) {
return null;
}
double maxDistance = Double.NEGATIVE_INFINITY;
Coordinate pointCoordinate = point.getCoordinate();
Set<Coordinate> furthestCoordinates = new HashSet<Coordinate>();
for (Coordinate c : geom.getCoordinates()) {
double distance = c.distance(pointCoordinate);
if (Double.compare(distance, maxDistance) == 0) {
furthestCoordinates.add(c);
}
if (Double.compare(distance, maxDistance) > 0) {
maxDistance = distance;
furthestCoordinates.clear();
furthestCoordinates.add(c);
}
}
if (furthestCoordinates.size() == 1) {
return GEOMETRY_FACTORY.createPoint(furthestCoordinates.iterator().next());
}
return GEOMETRY_FACTORY.createMultiPoint(
furthestCoordinates.toArray(new Coordinate[0]));
}
|
java
|
public static Geometry getFurthestCoordinate(Point point, Geometry geom) {
if (point == null || geom == null) {
return null;
}
double maxDistance = Double.NEGATIVE_INFINITY;
Coordinate pointCoordinate = point.getCoordinate();
Set<Coordinate> furthestCoordinates = new HashSet<Coordinate>();
for (Coordinate c : geom.getCoordinates()) {
double distance = c.distance(pointCoordinate);
if (Double.compare(distance, maxDistance) == 0) {
furthestCoordinates.add(c);
}
if (Double.compare(distance, maxDistance) > 0) {
maxDistance = distance;
furthestCoordinates.clear();
furthestCoordinates.add(c);
}
}
if (furthestCoordinates.size() == 1) {
return GEOMETRY_FACTORY.createPoint(furthestCoordinates.iterator().next());
}
return GEOMETRY_FACTORY.createMultiPoint(
furthestCoordinates.toArray(new Coordinate[0]));
}
|
[
"public",
"static",
"Geometry",
"getFurthestCoordinate",
"(",
"Point",
"point",
",",
"Geometry",
"geom",
")",
"{",
"if",
"(",
"point",
"==",
"null",
"||",
"geom",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"double",
"maxDistance",
"=",
"Double",
".",
"NEGATIVE_INFINITY",
";",
"Coordinate",
"pointCoordinate",
"=",
"point",
".",
"getCoordinate",
"(",
")",
";",
"Set",
"<",
"Coordinate",
">",
"furthestCoordinates",
"=",
"new",
"HashSet",
"<",
"Coordinate",
">",
"(",
")",
";",
"for",
"(",
"Coordinate",
"c",
":",
"geom",
".",
"getCoordinates",
"(",
")",
")",
"{",
"double",
"distance",
"=",
"c",
".",
"distance",
"(",
"pointCoordinate",
")",
";",
"if",
"(",
"Double",
".",
"compare",
"(",
"distance",
",",
"maxDistance",
")",
"==",
"0",
")",
"{",
"furthestCoordinates",
".",
"add",
"(",
"c",
")",
";",
"}",
"if",
"(",
"Double",
".",
"compare",
"(",
"distance",
",",
"maxDistance",
")",
">",
"0",
")",
"{",
"maxDistance",
"=",
"distance",
";",
"furthestCoordinates",
".",
"clear",
"(",
")",
";",
"furthestCoordinates",
".",
"add",
"(",
"c",
")",
";",
"}",
"}",
"if",
"(",
"furthestCoordinates",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"return",
"GEOMETRY_FACTORY",
".",
"createPoint",
"(",
"furthestCoordinates",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
")",
";",
"}",
"return",
"GEOMETRY_FACTORY",
".",
"createMultiPoint",
"(",
"furthestCoordinates",
".",
"toArray",
"(",
"new",
"Coordinate",
"[",
"0",
"]",
")",
")",
";",
"}"
] |
Computes the furthest coordinate(s) contained in the given geometry starting
from the given point, using the 2D distance.
@param point Point
@param geom Geometry
@return The furthest coordinate(s) contained in the given geometry starting from
the given point, using the 2D distance
|
[
"Computes",
"the",
"furthest",
"coordinate",
"(",
"s",
")",
"contained",
"in",
"the",
"given",
"geometry",
"starting",
"from",
"the",
"given",
"point",
"using",
"the",
"2D",
"distance",
"."
] |
train
|
https://github.com/orbisgis/h2gis/blob/9cd70b447e6469cecbc2fc64b16774b59491df3b/h2gis-functions/src/main/java/org/h2gis/functions/spatial/distance/ST_FurthestCoordinate.java#L64-L87
|
apache/flink
|
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java
|
StreamExecutionEnvironment.readFile
|
public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
String filePath) {
return readFile(inputFormat, filePath, FileProcessingMode.PROCESS_ONCE, -1);
}
|
java
|
public <OUT> DataStreamSource<OUT> readFile(FileInputFormat<OUT> inputFormat,
String filePath) {
return readFile(inputFormat, filePath, FileProcessingMode.PROCESS_ONCE, -1);
}
|
[
"public",
"<",
"OUT",
">",
"DataStreamSource",
"<",
"OUT",
">",
"readFile",
"(",
"FileInputFormat",
"<",
"OUT",
">",
"inputFormat",
",",
"String",
"filePath",
")",
"{",
"return",
"readFile",
"(",
"inputFormat",
",",
"filePath",
",",
"FileProcessingMode",
".",
"PROCESS_ONCE",
",",
"-",
"1",
")",
";",
"}"
] |
Reads the contents of the user-specified {@code filePath} based on the given {@link FileInputFormat}.
<p>Since all data streams need specific information about their types, this method needs to determine the
type of the data produced by the input format. It will attempt to determine the data type by reflection,
unless the input format implements the {@link org.apache.flink.api.java.typeutils.ResultTypeQueryable} interface.
In the latter case, this method will invoke the
{@link org.apache.flink.api.java.typeutils.ResultTypeQueryable#getProducedType()} method to determine data
type produced by the input format.
<p><b>NOTES ON CHECKPOINTING: </b> The source monitors the path, creates the
{@link org.apache.flink.core.fs.FileInputSplit FileInputSplits} to be processed,
forwards them to the downstream {@link ContinuousFileReaderOperator readers} to read the actual data,
and exits, without waiting for the readers to finish reading. This implies that no more checkpoint
barriers are going to be forwarded after the source exits, thus having no checkpoints after that point.
@param filePath
The path of the file, as a URI (e.g., "file:///some/local/file" or "hdfs://host:port/file/path")
@param inputFormat
The input format used to create the data stream
@param <OUT>
The type of the returned data stream
@return The data stream that represents the data read from the given file
|
[
"Reads",
"the",
"contents",
"of",
"the",
"user",
"-",
"specified",
"{",
"@code",
"filePath",
"}",
"based",
"on",
"the",
"given",
"{",
"@link",
"FileInputFormat",
"}",
"."
] |
train
|
https://github.com/apache/flink/blob/b62db93bf63cb3bb34dd03d611a779d9e3fc61ac/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java#L994-L997
|
Azure/azure-sdk-for-java
|
sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/SyncMembersInner.java
|
SyncMembersInner.createOrUpdate
|
public SyncMemberInner createOrUpdate(String resourceGroupName, String serverName, String databaseName, String syncGroupName, String syncMemberName, SyncMemberInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters).toBlocking().last().body();
}
|
java
|
public SyncMemberInner createOrUpdate(String resourceGroupName, String serverName, String databaseName, String syncGroupName, String syncMemberName, SyncMemberInner parameters) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters).toBlocking().last().body();
}
|
[
"public",
"SyncMemberInner",
"createOrUpdate",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
",",
"String",
"databaseName",
",",
"String",
"syncGroupName",
",",
"String",
"syncMemberName",
",",
"SyncMemberInner",
"parameters",
")",
"{",
"return",
"createOrUpdateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName",
",",
"databaseName",
",",
"syncGroupName",
",",
"syncMemberName",
",",
"parameters",
")",
".",
"toBlocking",
"(",
")",
".",
"last",
"(",
")",
".",
"body",
"(",
")",
";",
"}"
] |
Creates or updates a sync member.
@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 on which the sync group is hosted.
@param syncGroupName The name of the sync group on which the sync member is hosted.
@param syncMemberName The name of the sync member.
@param parameters The requested sync member resource state.
@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 SyncMemberInner object if successful.
|
[
"Creates",
"or",
"updates",
"a",
"sync",
"member",
"."
] |
train
|
https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2015_05_01_preview/src/main/java/com/microsoft/azure/management/sql/v2015_05_01_preview/implementation/SyncMembersInner.java#L241-L243
|
iipc/webarchive-commons
|
src/main/java/org/archive/util/Recorder.java
|
Recorder.wrapInputStreamWithHttpRecord
|
public static Recorder wrapInputStreamWithHttpRecord(File dir,
String basename, InputStream in, String encoding)
throws IOException {
Recorder rec = new Recorder(dir, basename);
if (encoding != null && encoding.length() > 0) {
rec.setCharset(Charset.forName(encoding));
}
// Do not use FastBufferedInputStream here. It does not
// support mark.
InputStream is = rec.inputWrap(new BufferedInputStream(in));
final int BUFFER_SIZE = 1024 * 4;
byte [] buffer = new byte[BUFFER_SIZE];
while(true) {
// Just read it all down.
int x = is.read(buffer);
if (x == -1) {
break;
}
}
is.close();
return rec;
}
|
java
|
public static Recorder wrapInputStreamWithHttpRecord(File dir,
String basename, InputStream in, String encoding)
throws IOException {
Recorder rec = new Recorder(dir, basename);
if (encoding != null && encoding.length() > 0) {
rec.setCharset(Charset.forName(encoding));
}
// Do not use FastBufferedInputStream here. It does not
// support mark.
InputStream is = rec.inputWrap(new BufferedInputStream(in));
final int BUFFER_SIZE = 1024 * 4;
byte [] buffer = new byte[BUFFER_SIZE];
while(true) {
// Just read it all down.
int x = is.read(buffer);
if (x == -1) {
break;
}
}
is.close();
return rec;
}
|
[
"public",
"static",
"Recorder",
"wrapInputStreamWithHttpRecord",
"(",
"File",
"dir",
",",
"String",
"basename",
",",
"InputStream",
"in",
",",
"String",
"encoding",
")",
"throws",
"IOException",
"{",
"Recorder",
"rec",
"=",
"new",
"Recorder",
"(",
"dir",
",",
"basename",
")",
";",
"if",
"(",
"encoding",
"!=",
"null",
"&&",
"encoding",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"rec",
".",
"setCharset",
"(",
"Charset",
".",
"forName",
"(",
"encoding",
")",
")",
";",
"}",
"// Do not use FastBufferedInputStream here. It does not",
"// support mark.",
"InputStream",
"is",
"=",
"rec",
".",
"inputWrap",
"(",
"new",
"BufferedInputStream",
"(",
"in",
")",
")",
";",
"final",
"int",
"BUFFER_SIZE",
"=",
"1024",
"*",
"4",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"BUFFER_SIZE",
"]",
";",
"while",
"(",
"true",
")",
"{",
"// Just read it all down.",
"int",
"x",
"=",
"is",
".",
"read",
"(",
"buffer",
")",
";",
"if",
"(",
"x",
"==",
"-",
"1",
")",
"{",
"break",
";",
"}",
"}",
"is",
".",
"close",
"(",
")",
";",
"return",
"rec",
";",
"}"
] |
Record the input stream for later playback by an extractor, etc.
This is convenience method used to setup an artificial HttpRecorder
scenario used in unit tests, etc.
@param dir Directory to write backing file to.
@param basename of what we're recording.
@param in Stream to read.
@param encoding Stream encoding.
@throws IOException
@return An {@link org.archive.util.Recorder}.
|
[
"Record",
"the",
"input",
"stream",
"for",
"later",
"playback",
"by",
"an",
"extractor",
"etc",
".",
"This",
"is",
"convenience",
"method",
"used",
"to",
"setup",
"an",
"artificial",
"HttpRecorder",
"scenario",
"used",
"in",
"unit",
"tests",
"etc",
"."
] |
train
|
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/Recorder.java#L554-L575
|
webmetrics/browsermob-proxy
|
src/main/java/org/xbill/DNS/security/CERTConverter.java
|
CERTConverter.buildRecord
|
public static CERTRecord
buildRecord(Name name, int dclass, long ttl, Certificate cert, int tag,
int alg)
{
int type;
byte [] data;
try {
if (cert instanceof X509Certificate) {
type = CERTRecord.PKIX;
data = cert.getEncoded();
}
else
return null;
return new CERTRecord(name, dclass, ttl, type, tag, alg, data);
}
catch (CertificateException e) {
if (Options.check("verboseexceptions"))
System.err.println("Cert build exception:" + e);
return null;
}
}
|
java
|
public static CERTRecord
buildRecord(Name name, int dclass, long ttl, Certificate cert, int tag,
int alg)
{
int type;
byte [] data;
try {
if (cert instanceof X509Certificate) {
type = CERTRecord.PKIX;
data = cert.getEncoded();
}
else
return null;
return new CERTRecord(name, dclass, ttl, type, tag, alg, data);
}
catch (CertificateException e) {
if (Options.check("verboseexceptions"))
System.err.println("Cert build exception:" + e);
return null;
}
}
|
[
"public",
"static",
"CERTRecord",
"buildRecord",
"(",
"Name",
"name",
",",
"int",
"dclass",
",",
"long",
"ttl",
",",
"Certificate",
"cert",
",",
"int",
"tag",
",",
"int",
"alg",
")",
"{",
"int",
"type",
";",
"byte",
"[",
"]",
"data",
";",
"try",
"{",
"if",
"(",
"cert",
"instanceof",
"X509Certificate",
")",
"{",
"type",
"=",
"CERTRecord",
".",
"PKIX",
";",
"data",
"=",
"cert",
".",
"getEncoded",
"(",
")",
";",
"}",
"else",
"return",
"null",
";",
"return",
"new",
"CERTRecord",
"(",
"name",
",",
"dclass",
",",
"ttl",
",",
"type",
",",
"tag",
",",
"alg",
",",
"data",
")",
";",
"}",
"catch",
"(",
"CertificateException",
"e",
")",
"{",
"if",
"(",
"Options",
".",
"check",
"(",
"\"verboseexceptions\"",
")",
")",
"System",
".",
"err",
".",
"println",
"(",
"\"Cert build exception:\"",
"+",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Builds a CERT record from a Certificate associated with a key also in DNS
|
[
"Builds",
"a",
"CERT",
"record",
"from",
"a",
"Certificate",
"associated",
"with",
"a",
"key",
"also",
"in",
"DNS"
] |
train
|
https://github.com/webmetrics/browsermob-proxy/blob/a9252e62246ac33d55d51b993ba1159404e7d389/src/main/java/org/xbill/DNS/security/CERTConverter.java#L56-L78
|
codelibs/jcifs
|
src/main/java/jcifs/smb1/Config.java
|
Config.getLong
|
public static long getLong( String key, long def ) {
String s = prp.getProperty( key );
if( s != null ) {
try {
def = Long.parseLong( s );
} catch( NumberFormatException nfe ) {
if( log.level > 0 )
nfe.printStackTrace( log );
}
}
return def;
}
|
java
|
public static long getLong( String key, long def ) {
String s = prp.getProperty( key );
if( s != null ) {
try {
def = Long.parseLong( s );
} catch( NumberFormatException nfe ) {
if( log.level > 0 )
nfe.printStackTrace( log );
}
}
return def;
}
|
[
"public",
"static",
"long",
"getLong",
"(",
"String",
"key",
",",
"long",
"def",
")",
"{",
"String",
"s",
"=",
"prp",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"s",
"!=",
"null",
")",
"{",
"try",
"{",
"def",
"=",
"Long",
".",
"parseLong",
"(",
"s",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"if",
"(",
"log",
".",
"level",
">",
"0",
")",
"nfe",
".",
"printStackTrace",
"(",
"log",
")",
";",
"}",
"}",
"return",
"def",
";",
"}"
] |
Retrieve a <code>long</code>. If the key does not exist or
cannot be converted to a <code>long</code>, the provided default
argument will be returned.
|
[
"Retrieve",
"a",
"<code",
">",
"long<",
"/",
"code",
">",
".",
"If",
"the",
"key",
"does",
"not",
"exist",
"or",
"cannot",
"be",
"converted",
"to",
"a",
"<code",
">",
"long<",
"/",
"code",
">",
"the",
"provided",
"default",
"argument",
"will",
"be",
"returned",
"."
] |
train
|
https://github.com/codelibs/jcifs/blob/ac6a8ba2925648ae003ca2508aec32316065dc34/src/main/java/jcifs/smb1/Config.java#L259-L270
|
EdwardRaff/JSAT
|
JSAT/src/jsat/classifiers/boosting/Bagging.java
|
Bagging.getWeightSampledDataSet
|
public static RegressionDataSet getWeightSampledDataSet(RegressionDataSet dataSet, int[] sampledCounts)
{
RegressionDataSet destination = new RegressionDataSet(dataSet.getNumNumericalVars(), dataSet.getCategories());
for (int i = 0; i < sampledCounts.length; i++)
{
if(sampledCounts[i] <= 0)
continue;
DataPoint dp = dataSet.getDataPoint(i);
destination.addDataPoint(dp, dataSet.getTargetValue(i), dataSet.getWeight(i)*sampledCounts[i]);
}
return destination;
}
|
java
|
public static RegressionDataSet getWeightSampledDataSet(RegressionDataSet dataSet, int[] sampledCounts)
{
RegressionDataSet destination = new RegressionDataSet(dataSet.getNumNumericalVars(), dataSet.getCategories());
for (int i = 0; i < sampledCounts.length; i++)
{
if(sampledCounts[i] <= 0)
continue;
DataPoint dp = dataSet.getDataPoint(i);
destination.addDataPoint(dp, dataSet.getTargetValue(i), dataSet.getWeight(i)*sampledCounts[i]);
}
return destination;
}
|
[
"public",
"static",
"RegressionDataSet",
"getWeightSampledDataSet",
"(",
"RegressionDataSet",
"dataSet",
",",
"int",
"[",
"]",
"sampledCounts",
")",
"{",
"RegressionDataSet",
"destination",
"=",
"new",
"RegressionDataSet",
"(",
"dataSet",
".",
"getNumNumericalVars",
"(",
")",
",",
"dataSet",
".",
"getCategories",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sampledCounts",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"sampledCounts",
"[",
"i",
"]",
"<=",
"0",
")",
"continue",
";",
"DataPoint",
"dp",
"=",
"dataSet",
".",
"getDataPoint",
"(",
"i",
")",
";",
"destination",
".",
"addDataPoint",
"(",
"dp",
",",
"dataSet",
".",
"getTargetValue",
"(",
"i",
")",
",",
"dataSet",
".",
"getWeight",
"(",
"i",
")",
"*",
"sampledCounts",
"[",
"i",
"]",
")",
";",
"}",
"return",
"destination",
";",
"}"
] |
Creates a new data set from the given sample counts. Points sampled
multiple times will be added once to the data set with their weight
multiplied by the number of times it was sampled.
@param dataSet the data set that was sampled from
@param sampledCounts the sampling values obtained from
{@link #sampleWithReplacement(int[], int, java.util.Random) }
@return a new sampled classification data set
|
[
"Creates",
"a",
"new",
"data",
"set",
"from",
"the",
"given",
"sample",
"counts",
".",
"Points",
"sampled",
"multiple",
"times",
"will",
"be",
"added",
"once",
"to",
"the",
"data",
"set",
"with",
"their",
"weight",
"multiplied",
"by",
"the",
"number",
"of",
"times",
"it",
"was",
"sampled",
"."
] |
train
|
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/boosting/Bagging.java#L345-L358
|
groupe-sii/ogham
|
ogham-core/src/main/java/fr/sii/ogham/core/sender/MultiImplementationSender.java
|
MultiImplementationSender.addImplementation
|
public final MultiImplementationSender<M> addImplementation(Condition<Message> condition, MessageSender implementation) {
implementations.add(new Implementation(condition, implementation));
return this;
}
|
java
|
public final MultiImplementationSender<M> addImplementation(Condition<Message> condition, MessageSender implementation) {
implementations.add(new Implementation(condition, implementation));
return this;
}
|
[
"public",
"final",
"MultiImplementationSender",
"<",
"M",
">",
"addImplementation",
"(",
"Condition",
"<",
"Message",
">",
"condition",
",",
"MessageSender",
"implementation",
")",
"{",
"implementations",
".",
"add",
"(",
"new",
"Implementation",
"(",
"condition",
",",
"implementation",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Register a new possible implementation with the associated condition. The
implementation is added at the end so any other possible implementation
will be used before this one if the associated condition allow it.
@param condition
the condition that indicates if the implementation can be used
at runtime
@param implementation
the implementation to register
@return this instance for fluent chaining
|
[
"Register",
"a",
"new",
"possible",
"implementation",
"with",
"the",
"associated",
"condition",
".",
"The",
"implementation",
"is",
"added",
"at",
"the",
"end",
"so",
"any",
"other",
"possible",
"implementation",
"will",
"be",
"used",
"before",
"this",
"one",
"if",
"the",
"associated",
"condition",
"allow",
"it",
"."
] |
train
|
https://github.com/groupe-sii/ogham/blob/e273b845604add74b5a25dfd931cb3c166b1008f/ogham-core/src/main/java/fr/sii/ogham/core/sender/MultiImplementationSender.java#L90-L93
|
play1-maven-plugin/play1-maven-plugin
|
surefire-play-junit4/src/main/java/com/google/code/play/surefire/junit4/PlayJUnit4Provider.java
|
PlayJUnit4Provider.getPlayHome
|
private File getPlayHome( File applicationPath )
throws TestSetFailedException
{
File targetDir = new File( applicationPath, "target" );
File playTmpDir = new File( targetDir, "play" );
File playTmpHomeDir = new File( playTmpDir, "home" );
if ( !playTmpHomeDir.exists() )
{
throw new TestSetFailedException( String.format( "Play! home directory \"%s\" does not exist",
playTmpHomeDir.getAbsolutePath() ) );
}
if ( !playTmpHomeDir.isDirectory() )
{
throw new TestSetFailedException( String.format( "Play! home directory \"%s\" is not a directory",
playTmpHomeDir.getAbsolutePath() ) );
}
// Additional check whether the temporary Play! home directory is created by this plugin
File warningFile = new File( playTmpHomeDir, "WARNING.txt" );
if ( warningFile.exists() )
{
if ( !warningFile.isFile() )
{
throw new TestSetFailedException( String.format( "Play! home directory warning file \"%s\" is not a file",
warningFile.getAbsolutePath() ) );
}
}
else
{
throw new TestSetFailedException( String.format( "Play! home directory warning file \"%s\" does not exist",
warningFile.getAbsolutePath() ) );
}
return playTmpHomeDir;
}
|
java
|
private File getPlayHome( File applicationPath )
throws TestSetFailedException
{
File targetDir = new File( applicationPath, "target" );
File playTmpDir = new File( targetDir, "play" );
File playTmpHomeDir = new File( playTmpDir, "home" );
if ( !playTmpHomeDir.exists() )
{
throw new TestSetFailedException( String.format( "Play! home directory \"%s\" does not exist",
playTmpHomeDir.getAbsolutePath() ) );
}
if ( !playTmpHomeDir.isDirectory() )
{
throw new TestSetFailedException( String.format( "Play! home directory \"%s\" is not a directory",
playTmpHomeDir.getAbsolutePath() ) );
}
// Additional check whether the temporary Play! home directory is created by this plugin
File warningFile = new File( playTmpHomeDir, "WARNING.txt" );
if ( warningFile.exists() )
{
if ( !warningFile.isFile() )
{
throw new TestSetFailedException( String.format( "Play! home directory warning file \"%s\" is not a file",
warningFile.getAbsolutePath() ) );
}
}
else
{
throw new TestSetFailedException( String.format( "Play! home directory warning file \"%s\" does not exist",
warningFile.getAbsolutePath() ) );
}
return playTmpHomeDir;
}
|
[
"private",
"File",
"getPlayHome",
"(",
"File",
"applicationPath",
")",
"throws",
"TestSetFailedException",
"{",
"File",
"targetDir",
"=",
"new",
"File",
"(",
"applicationPath",
",",
"\"target\"",
")",
";",
"File",
"playTmpDir",
"=",
"new",
"File",
"(",
"targetDir",
",",
"\"play\"",
")",
";",
"File",
"playTmpHomeDir",
"=",
"new",
"File",
"(",
"playTmpDir",
",",
"\"home\"",
")",
";",
"if",
"(",
"!",
"playTmpHomeDir",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"TestSetFailedException",
"(",
"String",
".",
"format",
"(",
"\"Play! home directory \\\"%s\\\" does not exist\"",
",",
"playTmpHomeDir",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"playTmpHomeDir",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"TestSetFailedException",
"(",
"String",
".",
"format",
"(",
"\"Play! home directory \\\"%s\\\" is not a directory\"",
",",
"playTmpHomeDir",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"// Additional check whether the temporary Play! home directory is created by this plugin",
"File",
"warningFile",
"=",
"new",
"File",
"(",
"playTmpHomeDir",
",",
"\"WARNING.txt\"",
")",
";",
"if",
"(",
"warningFile",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"warningFile",
".",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"TestSetFailedException",
"(",
"String",
".",
"format",
"(",
"\"Play! home directory warning file \\\"%s\\\" is not a file\"",
",",
"warningFile",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"TestSetFailedException",
"(",
"String",
".",
"format",
"(",
"\"Play! home directory warning file \\\"%s\\\" does not exist\"",
",",
"warningFile",
".",
"getAbsolutePath",
"(",
")",
")",
")",
";",
"}",
"return",
"playTmpHomeDir",
";",
"}"
] |
Copy of AbstractPlayMojo.getPlayHome() method (with getCanonicalPath() changed to getAbsolutePath() )
|
[
"Copy",
"of",
"AbstractPlayMojo",
".",
"getPlayHome",
"()",
"method",
"(",
"with",
"getCanonicalPath",
"()",
"changed",
"to",
"getAbsolutePath",
"()",
")"
] |
train
|
https://github.com/play1-maven-plugin/play1-maven-plugin/blob/d5b2c29f4eb911e605a41529bf0aa0f83ec0aded/surefire-play-junit4/src/main/java/com/google/code/play/surefire/junit4/PlayJUnit4Provider.java#L134-L166
|
mebigfatguy/fb-contrib
|
src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java
|
LostExceptionStackTrace.addCatchBlock
|
private void addCatchBlock(int start, int finish) {
CatchInfo ci = new CatchInfo(start, finish);
catchInfos.add(ci);
}
|
java
|
private void addCatchBlock(int start, int finish) {
CatchInfo ci = new CatchInfo(start, finish);
catchInfos.add(ci);
}
|
[
"private",
"void",
"addCatchBlock",
"(",
"int",
"start",
",",
"int",
"finish",
")",
"{",
"CatchInfo",
"ci",
"=",
"new",
"CatchInfo",
"(",
"start",
",",
"finish",
")",
";",
"catchInfos",
".",
"add",
"(",
"ci",
")",
";",
"}"
] |
add a catch block info record for the catch block that is guessed to be in the range of start to finish
@param start
the handler pc
@param finish
the guessed end of the catch block
|
[
"add",
"a",
"catch",
"block",
"info",
"record",
"for",
"the",
"catch",
"block",
"that",
"is",
"guessed",
"to",
"be",
"in",
"the",
"range",
"of",
"start",
"to",
"finish"
] |
train
|
https://github.com/mebigfatguy/fb-contrib/blob/3b5203196f627b399fbcea3c2ab2b1f4e56cc7b8/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java#L423-L426
|
apache/groovy
|
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
|
DefaultGroovyMethods.groupBy
|
public static Map groupBy(Iterable self, Object... closures) {
final Closure head = closures.length == 0 ? Closure.IDENTITY : (Closure) closures[0];
@SuppressWarnings("unchecked")
Map<Object, List> first = groupBy(self, head);
if (closures.length < 2)
return first;
final Object[] tail = new Object[closures.length - 1];
System.arraycopy(closures, 1, tail, 0, closures.length - 1); // Arrays.copyOfRange only since JDK 1.6
// inject([:]) { a,e {@code ->} a {@code <<} [(e.key): e.value.groupBy(tail)] }
Map<Object, Map> acc = new LinkedHashMap<Object, Map>();
for (Map.Entry<Object, List> item : first.entrySet()) {
acc.put(item.getKey(), groupBy((Iterable)item.getValue(), tail));
}
return acc;
}
|
java
|
public static Map groupBy(Iterable self, Object... closures) {
final Closure head = closures.length == 0 ? Closure.IDENTITY : (Closure) closures[0];
@SuppressWarnings("unchecked")
Map<Object, List> first = groupBy(self, head);
if (closures.length < 2)
return first;
final Object[] tail = new Object[closures.length - 1];
System.arraycopy(closures, 1, tail, 0, closures.length - 1); // Arrays.copyOfRange only since JDK 1.6
// inject([:]) { a,e {@code ->} a {@code <<} [(e.key): e.value.groupBy(tail)] }
Map<Object, Map> acc = new LinkedHashMap<Object, Map>();
for (Map.Entry<Object, List> item : first.entrySet()) {
acc.put(item.getKey(), groupBy((Iterable)item.getValue(), tail));
}
return acc;
}
|
[
"public",
"static",
"Map",
"groupBy",
"(",
"Iterable",
"self",
",",
"Object",
"...",
"closures",
")",
"{",
"final",
"Closure",
"head",
"=",
"closures",
".",
"length",
"==",
"0",
"?",
"Closure",
".",
"IDENTITY",
":",
"(",
"Closure",
")",
"closures",
"[",
"0",
"]",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"Object",
",",
"List",
">",
"first",
"=",
"groupBy",
"(",
"self",
",",
"head",
")",
";",
"if",
"(",
"closures",
".",
"length",
"<",
"2",
")",
"return",
"first",
";",
"final",
"Object",
"[",
"]",
"tail",
"=",
"new",
"Object",
"[",
"closures",
".",
"length",
"-",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"closures",
",",
"1",
",",
"tail",
",",
"0",
",",
"closures",
".",
"length",
"-",
"1",
")",
";",
"// Arrays.copyOfRange only since JDK 1.6",
"// inject([:]) { a,e {@code ->} a {@code <<} [(e.key): e.value.groupBy(tail)] }",
"Map",
"<",
"Object",
",",
"Map",
">",
"acc",
"=",
"new",
"LinkedHashMap",
"<",
"Object",
",",
"Map",
">",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"List",
">",
"item",
":",
"first",
".",
"entrySet",
"(",
")",
")",
"{",
"acc",
".",
"put",
"(",
"item",
".",
"getKey",
"(",
")",
",",
"groupBy",
"(",
"(",
"Iterable",
")",
"item",
".",
"getValue",
"(",
")",
",",
"tail",
")",
")",
";",
"}",
"return",
"acc",
";",
"}"
] |
Sorts all Iterable members into (sub)groups determined by the supplied
mapping closures. Each closure should return the key that this item
should be grouped by. The returned LinkedHashMap will have an entry for each
distinct 'key path' returned from the closures, with each value being a list
of items for that 'group path'.
Example usage:
<pre class="groovyTestCase">def result = [1,2,3,4,5,6].groupBy({ it % 2 }, { it {@code <} 4 })
assert result == [1:[(true):[1, 3], (false):[5]], 0:[(true):[2], (false):[4, 6]]]</pre>
Another example:
<pre>def sql = groovy.sql.Sql.newInstance(/* ... */)
def data = sql.rows("SELECT * FROM a_table").groupBy({ it.column1 }, { it.column2 }, { it.column3 })
if (data.val1.val2.val3) {
// there exists a record where:
// a_table.column1 == val1
// a_table.column2 == val2, and
// a_table.column3 == val3
} else {
// there is no such record
}</pre>
If an empty array of closures is supplied the IDENTITY Closure will be used.
@param self a collection to group
@param closures an array of closures, each mapping entries on keys
@return a new Map grouped by keys on each criterion
@since 2.2.0
@see Closure#IDENTITY
|
[
"Sorts",
"all",
"Iterable",
"members",
"into",
"(",
"sub",
")",
"groups",
"determined",
"by",
"the",
"supplied",
"mapping",
"closures",
".",
"Each",
"closure",
"should",
"return",
"the",
"key",
"that",
"this",
"item",
"should",
"be",
"grouped",
"by",
".",
"The",
"returned",
"LinkedHashMap",
"will",
"have",
"an",
"entry",
"for",
"each",
"distinct",
"key",
"path",
"returned",
"from",
"the",
"closures",
"with",
"each",
"value",
"being",
"a",
"list",
"of",
"items",
"for",
"that",
"group",
"path",
"."
] |
train
|
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L5583-L5601
|
google/error-prone
|
core/src/main/java/com/google/errorprone/bugpatterns/AbstractMustBeClosedChecker.java
|
AbstractMustBeClosedChecker.matchNewClassOrMethodInvocation
|
protected Description matchNewClassOrMethodInvocation(ExpressionTree tree, VisitorState state) {
Description description = checkClosed(tree, state);
if (description == NO_MATCH) {
return NO_MATCH;
}
if (AbstractReturnValueIgnored.expectedExceptionTest(tree, state)
|| MOCKITO_MATCHER.matches(state.getPath().getParentPath().getLeaf(), state)) {
return NO_MATCH;
}
return description;
}
|
java
|
protected Description matchNewClassOrMethodInvocation(ExpressionTree tree, VisitorState state) {
Description description = checkClosed(tree, state);
if (description == NO_MATCH) {
return NO_MATCH;
}
if (AbstractReturnValueIgnored.expectedExceptionTest(tree, state)
|| MOCKITO_MATCHER.matches(state.getPath().getParentPath().getLeaf(), state)) {
return NO_MATCH;
}
return description;
}
|
[
"protected",
"Description",
"matchNewClassOrMethodInvocation",
"(",
"ExpressionTree",
"tree",
",",
"VisitorState",
"state",
")",
"{",
"Description",
"description",
"=",
"checkClosed",
"(",
"tree",
",",
"state",
")",
";",
"if",
"(",
"description",
"==",
"NO_MATCH",
")",
"{",
"return",
"NO_MATCH",
";",
"}",
"if",
"(",
"AbstractReturnValueIgnored",
".",
"expectedExceptionTest",
"(",
"tree",
",",
"state",
")",
"||",
"MOCKITO_MATCHER",
".",
"matches",
"(",
"state",
".",
"getPath",
"(",
")",
".",
"getParentPath",
"(",
")",
".",
"getLeaf",
"(",
")",
",",
"state",
")",
")",
"{",
"return",
"NO_MATCH",
";",
"}",
"return",
"description",
";",
"}"
] |
Check that constructors and methods annotated with {@link MustBeClosed} occur within the
resource variable initializer of a try-with-resources statement.
|
[
"Check",
"that",
"constructors",
"and",
"methods",
"annotated",
"with",
"{"
] |
train
|
https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/AbstractMustBeClosedChecker.java#L75-L85
|
UrielCh/ovh-java-sdk
|
ovh-java-sdk-core/src/main/java/net/minidev/ovh/core/ApiOvhConfigBasic.java
|
ApiOvhConfigBasic.gettmpStore
|
protected File gettmpStore(String nic) {
if (consumer_key_storage == null || !consumer_key_storage.isDirectory()) {
if (e1 == 0) {
e1++;
log.error(
"No cert directory, can not save consumer_key! please set `consumer_key_storage` variable to a valid directory in your {}, or in your environ variale OVH_CONSUMER_KEY_STORAGE",
configFiles);
}
return null;
}
return new File(consumer_key_storage, nic + ".ck.txt");
}
|
java
|
protected File gettmpStore(String nic) {
if (consumer_key_storage == null || !consumer_key_storage.isDirectory()) {
if (e1 == 0) {
e1++;
log.error(
"No cert directory, can not save consumer_key! please set `consumer_key_storage` variable to a valid directory in your {}, or in your environ variale OVH_CONSUMER_KEY_STORAGE",
configFiles);
}
return null;
}
return new File(consumer_key_storage, nic + ".ck.txt");
}
|
[
"protected",
"File",
"gettmpStore",
"(",
"String",
"nic",
")",
"{",
"if",
"(",
"consumer_key_storage",
"==",
"null",
"||",
"!",
"consumer_key_storage",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"e1",
"==",
"0",
")",
"{",
"e1",
"++",
";",
"log",
".",
"error",
"(",
"\"No cert directory, can not save consumer_key! please set `consumer_key_storage` variable to a valid directory in your {}, or in your environ variale OVH_CONSUMER_KEY_STORAGE\"",
",",
"configFiles",
")",
";",
"}",
"return",
"null",
";",
"}",
"return",
"new",
"File",
"(",
"consumer_key_storage",
",",
"nic",
"+",
"\".ck.txt\"",
")",
";",
"}"
] |
storage for previous CK
@return File used to store consumer key
|
[
"storage",
"for",
"previous",
"CK"
] |
train
|
https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-core/src/main/java/net/minidev/ovh/core/ApiOvhConfigBasic.java#L128-L140
|
alibaba/jstorm
|
jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java
|
FluxBuilder.buildTopology
|
public static StormTopology buildTopology(ExecutionContext context) throws IllegalAccessException,
InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
StormTopology topology = null;
TopologyDef topologyDef = context.getTopologyDef();
if(!topologyDef.validate()){
throw new IllegalArgumentException("Invalid topology config. Spouts, bolts and streams cannot be " +
"defined in the same configuration as a topologySource.");
}
// build components that may be referenced by spouts, bolts, etc.
// the map will be a String --> Object where the object is a fully
// constructed class instance
buildComponents(context);
if(topologyDef.isDslTopology()) {
// This is a DSL (YAML, etc.) topology...
LOG.info("Detected DSL topology...");
TopologyBuilder builder = new TopologyBuilder();
// create spouts
buildSpouts(context, builder);
// we need to be able to lookup bolts by id, then switch based
// on whether they are IBasicBolt or IRichBolt instances
buildBolts(context);
// process stream definitions
buildStreamDefinitions(context, builder);
topology = builder.createTopology();
} else {
// user class supplied...
// this also provides a bridge to Trident...
LOG.info("A topology source has been specified...");
ObjectDef def = topologyDef.getTopologySource();
topology = buildExternalTopology(def, context);
}
return topology;
}
|
java
|
public static StormTopology buildTopology(ExecutionContext context) throws IllegalAccessException,
InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
StormTopology topology = null;
TopologyDef topologyDef = context.getTopologyDef();
if(!topologyDef.validate()){
throw new IllegalArgumentException("Invalid topology config. Spouts, bolts and streams cannot be " +
"defined in the same configuration as a topologySource.");
}
// build components that may be referenced by spouts, bolts, etc.
// the map will be a String --> Object where the object is a fully
// constructed class instance
buildComponents(context);
if(topologyDef.isDslTopology()) {
// This is a DSL (YAML, etc.) topology...
LOG.info("Detected DSL topology...");
TopologyBuilder builder = new TopologyBuilder();
// create spouts
buildSpouts(context, builder);
// we need to be able to lookup bolts by id, then switch based
// on whether they are IBasicBolt or IRichBolt instances
buildBolts(context);
// process stream definitions
buildStreamDefinitions(context, builder);
topology = builder.createTopology();
} else {
// user class supplied...
// this also provides a bridge to Trident...
LOG.info("A topology source has been specified...");
ObjectDef def = topologyDef.getTopologySource();
topology = buildExternalTopology(def, context);
}
return topology;
}
|
[
"public",
"static",
"StormTopology",
"buildTopology",
"(",
"ExecutionContext",
"context",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"ClassNotFoundException",
",",
"NoSuchMethodException",
",",
"InvocationTargetException",
"{",
"StormTopology",
"topology",
"=",
"null",
";",
"TopologyDef",
"topologyDef",
"=",
"context",
".",
"getTopologyDef",
"(",
")",
";",
"if",
"(",
"!",
"topologyDef",
".",
"validate",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid topology config. Spouts, bolts and streams cannot be \"",
"+",
"\"defined in the same configuration as a topologySource.\"",
")",
";",
"}",
"// build components that may be referenced by spouts, bolts, etc.",
"// the map will be a String --> Object where the object is a fully",
"// constructed class instance",
"buildComponents",
"(",
"context",
")",
";",
"if",
"(",
"topologyDef",
".",
"isDslTopology",
"(",
")",
")",
"{",
"// This is a DSL (YAML, etc.) topology...",
"LOG",
".",
"info",
"(",
"\"Detected DSL topology...\"",
")",
";",
"TopologyBuilder",
"builder",
"=",
"new",
"TopologyBuilder",
"(",
")",
";",
"// create spouts",
"buildSpouts",
"(",
"context",
",",
"builder",
")",
";",
"// we need to be able to lookup bolts by id, then switch based",
"// on whether they are IBasicBolt or IRichBolt instances",
"buildBolts",
"(",
"context",
")",
";",
"// process stream definitions",
"buildStreamDefinitions",
"(",
"context",
",",
"builder",
")",
";",
"topology",
"=",
"builder",
".",
"createTopology",
"(",
")",
";",
"}",
"else",
"{",
"// user class supplied...",
"// this also provides a bridge to Trident...",
"LOG",
".",
"info",
"(",
"\"A topology source has been specified...\"",
")",
";",
"ObjectDef",
"def",
"=",
"topologyDef",
".",
"getTopologySource",
"(",
")",
";",
"topology",
"=",
"buildExternalTopology",
"(",
"def",
",",
"context",
")",
";",
"}",
"return",
"topology",
";",
"}"
] |
Given a topology definition, return a Storm topology that can be run either locally or remotely.
@param context
@return
@throws IllegalAccessException
@throws InstantiationException
@throws ClassNotFoundException
@throws NoSuchMethodException
@throws InvocationTargetException
|
[
"Given",
"a",
"topology",
"definition",
"return",
"a",
"Storm",
"topology",
"that",
"can",
"be",
"run",
"either",
"locally",
"or",
"remotely",
"."
] |
train
|
https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java#L62-L103
|
jbundle/jbundle
|
thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/ThinTableModel.java
|
ThinTableModel.isCellEditable
|
public boolean isCellEditable(int iRowIndex, int iColumnIndex)
{
FieldList fieldList = this.makeRowCurrent(iRowIndex, false);
if (fieldList != null) if (fieldList.getEditMode() == Constants.EDIT_NONE)
if ((m_iLastRecord == RECORD_UNKNOWN) || (iRowIndex != m_iLastRecord + 1))
return false; // Don't allow changes to deleted records
return true; // All my fields are editable
}
|
java
|
public boolean isCellEditable(int iRowIndex, int iColumnIndex)
{
FieldList fieldList = this.makeRowCurrent(iRowIndex, false);
if (fieldList != null) if (fieldList.getEditMode() == Constants.EDIT_NONE)
if ((m_iLastRecord == RECORD_UNKNOWN) || (iRowIndex != m_iLastRecord + 1))
return false; // Don't allow changes to deleted records
return true; // All my fields are editable
}
|
[
"public",
"boolean",
"isCellEditable",
"(",
"int",
"iRowIndex",
",",
"int",
"iColumnIndex",
")",
"{",
"FieldList",
"fieldList",
"=",
"this",
".",
"makeRowCurrent",
"(",
"iRowIndex",
",",
"false",
")",
";",
"if",
"(",
"fieldList",
"!=",
"null",
")",
"if",
"(",
"fieldList",
".",
"getEditMode",
"(",
")",
"==",
"Constants",
".",
"EDIT_NONE",
")",
"if",
"(",
"(",
"m_iLastRecord",
"==",
"RECORD_UNKNOWN",
")",
"||",
"(",
"iRowIndex",
"!=",
"m_iLastRecord",
"+",
"1",
")",
")",
"return",
"false",
";",
"// Don't allow changes to deleted records",
"return",
"true",
";",
"// All my fields are editable",
"}"
] |
Is this cell editable.
@return true unless this is a deleted record.
|
[
"Is",
"this",
"cell",
"editable",
"."
] |
train
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/grid/src/main/java/org/jbundle/thin/base/screen/grid/ThinTableModel.java#L184-L191
|
facebook/fresco
|
imagepipeline-base/src/main/java/com/facebook/imagepipeline/bitmaps/PlatformBitmapFactory.java
|
PlatformBitmapFactory.createBitmap
|
public CloseableReference<Bitmap> createBitmap(
Bitmap source,
int x,
int y,
int width,
int height) {
return createBitmap(source, x, y, width, height, null);
}
|
java
|
public CloseableReference<Bitmap> createBitmap(
Bitmap source,
int x,
int y,
int width,
int height) {
return createBitmap(source, x, y, width, height, null);
}
|
[
"public",
"CloseableReference",
"<",
"Bitmap",
">",
"createBitmap",
"(",
"Bitmap",
"source",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"return",
"createBitmap",
"(",
"source",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"null",
")",
";",
"}"
] |
Creates a bitmap from the specified subset of the source
bitmap. It is initialized with the same density as the original bitmap.
@param source The bitmap we are subsetting
@param x The x coordinate of the first pixel in source
@param y The y coordinate of the first pixel in source
@param width The number of pixels in each row
@param height The number of rows
@return a reference to the bitmap
@throws IllegalArgumentException if the x, y, width, height values are
outside of the dimensions of the source bitmap, or width is <= 0,
or height is <= 0
@throws TooManyBitmapsException if the pool is full
@throws java.lang.OutOfMemoryError if the Bitmap cannot be allocated
|
[
"Creates",
"a",
"bitmap",
"from",
"the",
"specified",
"subset",
"of",
"the",
"source",
"bitmap",
".",
"It",
"is",
"initialized",
"with",
"the",
"same",
"density",
"as",
"the",
"original",
"bitmap",
"."
] |
train
|
https://github.com/facebook/fresco/blob/0b85879d51c5036d5e46e627a6651afefc0b971a/imagepipeline-base/src/main/java/com/facebook/imagepipeline/bitmaps/PlatformBitmapFactory.java#L144-L151
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.