id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
162,000 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java | MergeableManifest2.addRequiredBundles | public void addRequiredBundles(Set<String> requiredBundles) {
addRequiredBundles(requiredBundles.toArray(new String[requiredBundles.size()]));
} | java | public void addRequiredBundles(Set<String> requiredBundles) {
addRequiredBundles(requiredBundles.toArray(new String[requiredBundles.size()]));
} | [
"public",
"void",
"addRequiredBundles",
"(",
"Set",
"<",
"String",
">",
"requiredBundles",
")",
"{",
"addRequiredBundles",
"(",
"requiredBundles",
".",
"toArray",
"(",
"new",
"String",
"[",
"requiredBundles",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}"
] | Add the set with given bundles to the "Require-Bundle" main attribute.
@param requiredBundles The set with all bundles to add. | [
"Add",
"the",
"set",
"with",
"given",
"bundles",
"to",
"the",
"Require",
"-",
"Bundle",
"main",
"attribute",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java#L265-L267 |
162,001 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java | MergeableManifest2.addRequiredBundles | public void addRequiredBundles(String... requiredBundles) {
String oldBundles = mainAttributes.get(REQUIRE_BUNDLE);
if (oldBundles == null)
oldBundles = "";
BundleList oldResultList = BundleList.fromInput(oldBundles, newline);
BundleList resultList = BundleList.fromInput(oldBundles, newline);
for (String bundle : requiredBundles) {
Bundle newBundle = Bundle.fromInput(bundle);
if (name != null && name.equals(newBundle.getName()))
continue;
resultList.mergeInto(newBundle);
}
String result = resultList.toString();
boolean changed = !oldResultList.toString().equals(result);
modified |= changed;
if (changed)
mainAttributes.put(REQUIRE_BUNDLE, result);
} | java | public void addRequiredBundles(String... requiredBundles) {
String oldBundles = mainAttributes.get(REQUIRE_BUNDLE);
if (oldBundles == null)
oldBundles = "";
BundleList oldResultList = BundleList.fromInput(oldBundles, newline);
BundleList resultList = BundleList.fromInput(oldBundles, newline);
for (String bundle : requiredBundles) {
Bundle newBundle = Bundle.fromInput(bundle);
if (name != null && name.equals(newBundle.getName()))
continue;
resultList.mergeInto(newBundle);
}
String result = resultList.toString();
boolean changed = !oldResultList.toString().equals(result);
modified |= changed;
if (changed)
mainAttributes.put(REQUIRE_BUNDLE, result);
} | [
"public",
"void",
"addRequiredBundles",
"(",
"String",
"...",
"requiredBundles",
")",
"{",
"String",
"oldBundles",
"=",
"mainAttributes",
".",
"get",
"(",
"REQUIRE_BUNDLE",
")",
";",
"if",
"(",
"oldBundles",
"==",
"null",
")",
"oldBundles",
"=",
"\"\"",
";",
"BundleList",
"oldResultList",
"=",
"BundleList",
".",
"fromInput",
"(",
"oldBundles",
",",
"newline",
")",
";",
"BundleList",
"resultList",
"=",
"BundleList",
".",
"fromInput",
"(",
"oldBundles",
",",
"newline",
")",
";",
"for",
"(",
"String",
"bundle",
":",
"requiredBundles",
")",
"{",
"Bundle",
"newBundle",
"=",
"Bundle",
".",
"fromInput",
"(",
"bundle",
")",
";",
"if",
"(",
"name",
"!=",
"null",
"&&",
"name",
".",
"equals",
"(",
"newBundle",
".",
"getName",
"(",
")",
")",
")",
"continue",
";",
"resultList",
".",
"mergeInto",
"(",
"newBundle",
")",
";",
"}",
"String",
"result",
"=",
"resultList",
".",
"toString",
"(",
")",
";",
"boolean",
"changed",
"=",
"!",
"oldResultList",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"result",
")",
";",
"modified",
"|=",
"changed",
";",
"if",
"(",
"changed",
")",
"mainAttributes",
".",
"put",
"(",
"REQUIRE_BUNDLE",
",",
"result",
")",
";",
"}"
] | Add the list with given bundles to the "Require-Bundle" main attribute.
@param requiredBundles The list of all bundles to add. | [
"Add",
"the",
"list",
"with",
"given",
"bundles",
"to",
"the",
"Require",
"-",
"Bundle",
"main",
"attribute",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java#L274-L291 |
162,002 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java | MergeableManifest2.addImportedPackages | public void addImportedPackages(Set<String> importedPackages) {
addImportedPackages(importedPackages.toArray(new String[importedPackages.size()]));
} | java | public void addImportedPackages(Set<String> importedPackages) {
addImportedPackages(importedPackages.toArray(new String[importedPackages.size()]));
} | [
"public",
"void",
"addImportedPackages",
"(",
"Set",
"<",
"String",
">",
"importedPackages",
")",
"{",
"addImportedPackages",
"(",
"importedPackages",
".",
"toArray",
"(",
"new",
"String",
"[",
"importedPackages",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}"
] | Add the set with given bundles to the "Import-Package" main attribute.
@param importedPackages The set of all packages to add. | [
"Add",
"the",
"set",
"with",
"given",
"bundles",
"to",
"the",
"Import",
"-",
"Package",
"main",
"attribute",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java#L298-L300 |
162,003 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java | MergeableManifest2.addImportedPackages | public void addImportedPackages(String... importedPackages) {
String oldBundles = mainAttributes.get(IMPORT_PACKAGE);
if (oldBundles == null)
oldBundles = "";
BundleList oldResultList = BundleList.fromInput(oldBundles, newline);
BundleList resultList = BundleList.fromInput(oldBundles, newline);
for (String bundle : importedPackages)
resultList.mergeInto(Bundle.fromInput(bundle));
String result = resultList.toString();
boolean changed = !oldResultList.toString().equals(result);
modified |= changed;
if (changed)
mainAttributes.put(IMPORT_PACKAGE, result);
} | java | public void addImportedPackages(String... importedPackages) {
String oldBundles = mainAttributes.get(IMPORT_PACKAGE);
if (oldBundles == null)
oldBundles = "";
BundleList oldResultList = BundleList.fromInput(oldBundles, newline);
BundleList resultList = BundleList.fromInput(oldBundles, newline);
for (String bundle : importedPackages)
resultList.mergeInto(Bundle.fromInput(bundle));
String result = resultList.toString();
boolean changed = !oldResultList.toString().equals(result);
modified |= changed;
if (changed)
mainAttributes.put(IMPORT_PACKAGE, result);
} | [
"public",
"void",
"addImportedPackages",
"(",
"String",
"...",
"importedPackages",
")",
"{",
"String",
"oldBundles",
"=",
"mainAttributes",
".",
"get",
"(",
"IMPORT_PACKAGE",
")",
";",
"if",
"(",
"oldBundles",
"==",
"null",
")",
"oldBundles",
"=",
"\"\"",
";",
"BundleList",
"oldResultList",
"=",
"BundleList",
".",
"fromInput",
"(",
"oldBundles",
",",
"newline",
")",
";",
"BundleList",
"resultList",
"=",
"BundleList",
".",
"fromInput",
"(",
"oldBundles",
",",
"newline",
")",
";",
"for",
"(",
"String",
"bundle",
":",
"importedPackages",
")",
"resultList",
".",
"mergeInto",
"(",
"Bundle",
".",
"fromInput",
"(",
"bundle",
")",
")",
";",
"String",
"result",
"=",
"resultList",
".",
"toString",
"(",
")",
";",
"boolean",
"changed",
"=",
"!",
"oldResultList",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"result",
")",
";",
"modified",
"|=",
"changed",
";",
"if",
"(",
"changed",
")",
"mainAttributes",
".",
"put",
"(",
"IMPORT_PACKAGE",
",",
"result",
")",
";",
"}"
] | Add the list with given bundles to the "Import-Package" main attribute.
@param importedPackages The list of all packages to add. | [
"Add",
"the",
"list",
"with",
"given",
"bundles",
"to",
"the",
"Import",
"-",
"Package",
"main",
"attribute",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java#L307-L320 |
162,004 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java | MergeableManifest2.addExportedPackages | public void addExportedPackages(Set<String> exportedPackages) {
addExportedPackages(exportedPackages.toArray(new String[exportedPackages.size()]));
} | java | public void addExportedPackages(Set<String> exportedPackages) {
addExportedPackages(exportedPackages.toArray(new String[exportedPackages.size()]));
} | [
"public",
"void",
"addExportedPackages",
"(",
"Set",
"<",
"String",
">",
"exportedPackages",
")",
"{",
"addExportedPackages",
"(",
"exportedPackages",
".",
"toArray",
"(",
"new",
"String",
"[",
"exportedPackages",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}"
] | Add the set with given bundles to the "Export-Package" main attribute.
@param exportedPackages The set of all packages to add. | [
"Add",
"the",
"set",
"with",
"given",
"bundles",
"to",
"the",
"Export",
"-",
"Package",
"main",
"attribute",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java#L327-L329 |
162,005 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java | MergeableManifest2.addExportedPackages | public void addExportedPackages(String... exportedPackages) {
String oldBundles = mainAttributes.get(EXPORT_PACKAGE);
if (oldBundles == null)
oldBundles = "";
BundleList oldResultList = BundleList.fromInput(oldBundles, newline);
BundleList resultList = BundleList.fromInput(oldBundles, newline);
for (String bundle : exportedPackages)
resultList.mergeInto(Bundle.fromInput(bundle));
String result = resultList.toString();
boolean changed = !oldResultList.toString().equals(result);
modified |= changed;
if (changed)
mainAttributes.put(EXPORT_PACKAGE, result);
} | java | public void addExportedPackages(String... exportedPackages) {
String oldBundles = mainAttributes.get(EXPORT_PACKAGE);
if (oldBundles == null)
oldBundles = "";
BundleList oldResultList = BundleList.fromInput(oldBundles, newline);
BundleList resultList = BundleList.fromInput(oldBundles, newline);
for (String bundle : exportedPackages)
resultList.mergeInto(Bundle.fromInput(bundle));
String result = resultList.toString();
boolean changed = !oldResultList.toString().equals(result);
modified |= changed;
if (changed)
mainAttributes.put(EXPORT_PACKAGE, result);
} | [
"public",
"void",
"addExportedPackages",
"(",
"String",
"...",
"exportedPackages",
")",
"{",
"String",
"oldBundles",
"=",
"mainAttributes",
".",
"get",
"(",
"EXPORT_PACKAGE",
")",
";",
"if",
"(",
"oldBundles",
"==",
"null",
")",
"oldBundles",
"=",
"\"\"",
";",
"BundleList",
"oldResultList",
"=",
"BundleList",
".",
"fromInput",
"(",
"oldBundles",
",",
"newline",
")",
";",
"BundleList",
"resultList",
"=",
"BundleList",
".",
"fromInput",
"(",
"oldBundles",
",",
"newline",
")",
";",
"for",
"(",
"String",
"bundle",
":",
"exportedPackages",
")",
"resultList",
".",
"mergeInto",
"(",
"Bundle",
".",
"fromInput",
"(",
"bundle",
")",
")",
";",
"String",
"result",
"=",
"resultList",
".",
"toString",
"(",
")",
";",
"boolean",
"changed",
"=",
"!",
"oldResultList",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"result",
")",
";",
"modified",
"|=",
"changed",
";",
"if",
"(",
"changed",
")",
"mainAttributes",
".",
"put",
"(",
"EXPORT_PACKAGE",
",",
"result",
")",
";",
"}"
] | Add the list with given bundles to the "Export-Package" main attribute.
@param exportedPackages The list of all packages to add. | [
"Add",
"the",
"list",
"with",
"given",
"bundles",
"to",
"the",
"Export",
"-",
"Package",
"main",
"attribute",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java#L336-L349 |
162,006 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java | MergeableManifest2.setBREE | public void setBREE(String bree) {
String old = mainAttributes.get(BUNDLE_REQUIREDEXECUTIONENVIRONMENT);
if (!bree.equals(old)) {
this.mainAttributes.put(BUNDLE_REQUIREDEXECUTIONENVIRONMENT, bree);
this.modified = true;
this.bree = bree;
}
} | java | public void setBREE(String bree) {
String old = mainAttributes.get(BUNDLE_REQUIREDEXECUTIONENVIRONMENT);
if (!bree.equals(old)) {
this.mainAttributes.put(BUNDLE_REQUIREDEXECUTIONENVIRONMENT, bree);
this.modified = true;
this.bree = bree;
}
} | [
"public",
"void",
"setBREE",
"(",
"String",
"bree",
")",
"{",
"String",
"old",
"=",
"mainAttributes",
".",
"get",
"(",
"BUNDLE_REQUIREDEXECUTIONENVIRONMENT",
")",
";",
"if",
"(",
"!",
"bree",
".",
"equals",
"(",
"old",
")",
")",
"{",
"this",
".",
"mainAttributes",
".",
"put",
"(",
"BUNDLE_REQUIREDEXECUTIONENVIRONMENT",
",",
"bree",
")",
";",
"this",
".",
"modified",
"=",
"true",
";",
"this",
".",
"bree",
"=",
"bree",
";",
"}",
"}"
] | Set the main attribute "Bundle-RequiredExecutionEnvironment" to the given
value.
@param bree The new value | [
"Set",
"the",
"main",
"attribute",
"Bundle",
"-",
"RequiredExecutionEnvironment",
"to",
"the",
"given",
"value",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java#L357-L364 |
162,007 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java | MergeableManifest2.setBundleActivator | public void setBundleActivator(String bundleActivator) {
String old = mainAttributes.get(BUNDLE_ACTIVATOR);
if (!bundleActivator.equals(old)) {
this.mainAttributes.put(BUNDLE_ACTIVATOR, bundleActivator);
this.modified = true;
this.bundleActivator = bundleActivator;
}
} | java | public void setBundleActivator(String bundleActivator) {
String old = mainAttributes.get(BUNDLE_ACTIVATOR);
if (!bundleActivator.equals(old)) {
this.mainAttributes.put(BUNDLE_ACTIVATOR, bundleActivator);
this.modified = true;
this.bundleActivator = bundleActivator;
}
} | [
"public",
"void",
"setBundleActivator",
"(",
"String",
"bundleActivator",
")",
"{",
"String",
"old",
"=",
"mainAttributes",
".",
"get",
"(",
"BUNDLE_ACTIVATOR",
")",
";",
"if",
"(",
"!",
"bundleActivator",
".",
"equals",
"(",
"old",
")",
")",
"{",
"this",
".",
"mainAttributes",
".",
"put",
"(",
"BUNDLE_ACTIVATOR",
",",
"bundleActivator",
")",
";",
"this",
".",
"modified",
"=",
"true",
";",
"this",
".",
"bundleActivator",
"=",
"bundleActivator",
";",
"}",
"}"
] | Set the main attribute "Bundle-Activator" to the given value.
@param bundleActivator The new value | [
"Set",
"the",
"main",
"attribute",
"Bundle",
"-",
"Activator",
"to",
"the",
"given",
"value",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java#L379-L386 |
162,008 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java | MergeableManifest2.make512Safe | public static String make512Safe(StringBuffer input, String newline) {
StringBuilder result = new StringBuilder();
String content = input.toString();
String rest = content;
while (!rest.isEmpty()) {
if (rest.contains("\n")) {
String line = rest.substring(0, rest.indexOf("\n"));
rest = rest.substring(rest.indexOf("\n") + 1);
if (line.length() > 1 && line.charAt(line.length() - 1) == '\r')
line = line.substring(0, line.length() - 1);
append512Safe(line, result, newline);
} else {
append512Safe(rest, result, newline);
break;
}
}
return result.toString();
} | java | public static String make512Safe(StringBuffer input, String newline) {
StringBuilder result = new StringBuilder();
String content = input.toString();
String rest = content;
while (!rest.isEmpty()) {
if (rest.contains("\n")) {
String line = rest.substring(0, rest.indexOf("\n"));
rest = rest.substring(rest.indexOf("\n") + 1);
if (line.length() > 1 && line.charAt(line.length() - 1) == '\r')
line = line.substring(0, line.length() - 1);
append512Safe(line, result, newline);
} else {
append512Safe(rest, result, newline);
break;
}
}
return result.toString();
} | [
"public",
"static",
"String",
"make512Safe",
"(",
"StringBuffer",
"input",
",",
"String",
"newline",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"content",
"=",
"input",
".",
"toString",
"(",
")",
";",
"String",
"rest",
"=",
"content",
";",
"while",
"(",
"!",
"rest",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"rest",
".",
"contains",
"(",
"\"\\n\"",
")",
")",
"{",
"String",
"line",
"=",
"rest",
".",
"substring",
"(",
"0",
",",
"rest",
".",
"indexOf",
"(",
"\"\\n\"",
")",
")",
";",
"rest",
"=",
"rest",
".",
"substring",
"(",
"rest",
".",
"indexOf",
"(",
"\"\\n\"",
")",
"+",
"1",
")",
";",
"if",
"(",
"line",
".",
"length",
"(",
")",
">",
"1",
"&&",
"line",
".",
"charAt",
"(",
"line",
".",
"length",
"(",
")",
"-",
"1",
")",
"==",
"'",
"'",
")",
"line",
"=",
"line",
".",
"substring",
"(",
"0",
",",
"line",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"append512Safe",
"(",
"line",
",",
"result",
",",
"newline",
")",
";",
"}",
"else",
"{",
"append512Safe",
"(",
"rest",
",",
"result",
",",
"newline",
")",
";",
"break",
";",
"}",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Return a string that ensures that no line is longer then 512 characters
and lines are broken according to manifest specification.
@param input The buffer containing the content that should be made safe
@param newline The string to use to create newlines (usually "\n" or
"\r\n")
@return The string with no longer lines then 512, ready to be read again
by {@link MergeableManifest2}. | [
"Return",
"a",
"string",
"that",
"ensures",
"that",
"no",
"line",
"is",
"longer",
"then",
"512",
"characters",
"and",
"lines",
"are",
"broken",
"according",
"to",
"manifest",
"specification",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest2.java#L505-L522 |
162,009 | eclipse/xtext-core | org.eclipse.xtext/src/org/eclipse/xtext/formatting2/AbstractFormatter2.java | AbstractFormatter2._format | protected void _format(EObject obj, IFormattableDocument document) {
for (EObject child : obj.eContents())
document.format(child);
} | java | protected void _format(EObject obj, IFormattableDocument document) {
for (EObject child : obj.eContents())
document.format(child);
} | [
"protected",
"void",
"_format",
"(",
"EObject",
"obj",
",",
"IFormattableDocument",
"document",
")",
"{",
"for",
"(",
"EObject",
"child",
":",
"obj",
".",
"eContents",
"(",
")",
")",
"document",
".",
"format",
"(",
"child",
")",
";",
"}"
] | Fall-back for types that are not handled by a subclasse's dispatch method. | [
"Fall",
"-",
"back",
"for",
"types",
"that",
"are",
"not",
"handled",
"by",
"a",
"subclasse",
"s",
"dispatch",
"method",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src/org/eclipse/xtext/formatting2/AbstractFormatter2.java#L189-L192 |
162,010 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/concurrent/AbstractReadWriteAcces.java | AbstractReadWriteAcces.process | public <Result> Result process(IUnitOfWork<Result, State> work) {
releaseReadLock();
acquireWriteLock();
try {
if (log.isTraceEnabled())
log.trace("process - " + Thread.currentThread().getName());
return modify(work);
} finally {
if (log.isTraceEnabled())
log.trace("Downgrading from write lock to read lock...");
acquireReadLock();
releaseWriteLock();
}
} | java | public <Result> Result process(IUnitOfWork<Result, State> work) {
releaseReadLock();
acquireWriteLock();
try {
if (log.isTraceEnabled())
log.trace("process - " + Thread.currentThread().getName());
return modify(work);
} finally {
if (log.isTraceEnabled())
log.trace("Downgrading from write lock to read lock...");
acquireReadLock();
releaseWriteLock();
}
} | [
"public",
"<",
"Result",
">",
"Result",
"process",
"(",
"IUnitOfWork",
"<",
"Result",
",",
"State",
">",
"work",
")",
"{",
"releaseReadLock",
"(",
")",
";",
"acquireWriteLock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"log",
".",
"isTraceEnabled",
"(",
")",
")",
"log",
".",
"trace",
"(",
"\"process - \"",
"+",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"return",
"modify",
"(",
"work",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"log",
".",
"isTraceEnabled",
"(",
")",
")",
"log",
".",
"trace",
"(",
"\"Downgrading from write lock to read lock...\"",
")",
";",
"acquireReadLock",
"(",
")",
";",
"releaseWriteLock",
"(",
")",
";",
"}",
"}"
] | Upgrades a read transaction to a write transaction, executes the work then downgrades to a read transaction
again.
@since 2.4
@noreference | [
"Upgrades",
"a",
"read",
"transaction",
"to",
"a",
"write",
"transaction",
"executes",
"the",
"work",
"then",
"downgrades",
"to",
"a",
"read",
"transaction",
"again",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/concurrent/AbstractReadWriteAcces.java#L107-L120 |
162,011 | eclipse/xtext-core | org.eclipse.xtext/src/org/eclipse/xtext/parser/antlr/AbstractInternalAntlrParser.java | AbstractInternalAntlrParser.forceCreateModelElementAndSet | protected EObject forceCreateModelElementAndSet(Action action, EObject value) {
EObject result = semanticModelBuilder.create(action.getType().getClassifier());
semanticModelBuilder.set(result, action.getFeature(), value, null /* ParserRule */, currentNode);
insertCompositeNode(action);
associateNodeWithAstElement(currentNode, result);
return result;
} | java | protected EObject forceCreateModelElementAndSet(Action action, EObject value) {
EObject result = semanticModelBuilder.create(action.getType().getClassifier());
semanticModelBuilder.set(result, action.getFeature(), value, null /* ParserRule */, currentNode);
insertCompositeNode(action);
associateNodeWithAstElement(currentNode, result);
return result;
} | [
"protected",
"EObject",
"forceCreateModelElementAndSet",
"(",
"Action",
"action",
",",
"EObject",
"value",
")",
"{",
"EObject",
"result",
"=",
"semanticModelBuilder",
".",
"create",
"(",
"action",
".",
"getType",
"(",
")",
".",
"getClassifier",
"(",
")",
")",
";",
"semanticModelBuilder",
".",
"set",
"(",
"result",
",",
"action",
".",
"getFeature",
"(",
")",
",",
"value",
",",
"null",
"/* ParserRule */",
",",
"currentNode",
")",
";",
"insertCompositeNode",
"(",
"action",
")",
";",
"associateNodeWithAstElement",
"(",
"currentNode",
",",
"result",
")",
";",
"return",
"result",
";",
"}"
] | Assigned action code | [
"Assigned",
"action",
"code"
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src/org/eclipse/xtext/parser/antlr/AbstractInternalAntlrParser.java#L672-L678 |
162,012 | eclipse/xtext-core | org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/splitting/AntlrCodeQualityHelper.java | AntlrCodeQualityHelper.stripUnnecessaryComments | public String stripUnnecessaryComments(String javaContent, AntlrOptions options) {
if (!options.isOptimizeCodeQuality()) {
return javaContent;
}
javaContent = stripMachineDependentPaths(javaContent);
if (options.isStripAllComments()) {
javaContent = stripAllComments(javaContent);
}
return javaContent;
} | java | public String stripUnnecessaryComments(String javaContent, AntlrOptions options) {
if (!options.isOptimizeCodeQuality()) {
return javaContent;
}
javaContent = stripMachineDependentPaths(javaContent);
if (options.isStripAllComments()) {
javaContent = stripAllComments(javaContent);
}
return javaContent;
} | [
"public",
"String",
"stripUnnecessaryComments",
"(",
"String",
"javaContent",
",",
"AntlrOptions",
"options",
")",
"{",
"if",
"(",
"!",
"options",
".",
"isOptimizeCodeQuality",
"(",
")",
")",
"{",
"return",
"javaContent",
";",
"}",
"javaContent",
"=",
"stripMachineDependentPaths",
"(",
"javaContent",
")",
";",
"if",
"(",
"options",
".",
"isStripAllComments",
"(",
")",
")",
"{",
"javaContent",
"=",
"stripAllComments",
"(",
"javaContent",
")",
";",
"}",
"return",
"javaContent",
";",
"}"
] | Remove all unnecessary comments from a lexer or parser file | [
"Remove",
"all",
"unnecessary",
"comments",
"from",
"a",
"lexer",
"or",
"parser",
"file"
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/parser/antlr/splitting/AntlrCodeQualityHelper.java#L40-L49 |
162,013 | eclipse/xtext-core | org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/editor/contentassist/antlr/ContentAssistContextFactory.java | ContentAssistContextFactory.getPrefix | public String getPrefix(INode prefixNode) {
if (prefixNode instanceof ILeafNode) {
if (((ILeafNode) prefixNode).isHidden() && prefixNode.getGrammarElement() != null)
return "";
return getNodeTextUpToCompletionOffset(prefixNode);
}
StringBuilder result = new StringBuilder(prefixNode.getTotalLength());
doComputePrefix((ICompositeNode) prefixNode, result);
return result.toString();
} | java | public String getPrefix(INode prefixNode) {
if (prefixNode instanceof ILeafNode) {
if (((ILeafNode) prefixNode).isHidden() && prefixNode.getGrammarElement() != null)
return "";
return getNodeTextUpToCompletionOffset(prefixNode);
}
StringBuilder result = new StringBuilder(prefixNode.getTotalLength());
doComputePrefix((ICompositeNode) prefixNode, result);
return result.toString();
} | [
"public",
"String",
"getPrefix",
"(",
"INode",
"prefixNode",
")",
"{",
"if",
"(",
"prefixNode",
"instanceof",
"ILeafNode",
")",
"{",
"if",
"(",
"(",
"(",
"ILeafNode",
")",
"prefixNode",
")",
".",
"isHidden",
"(",
")",
"&&",
"prefixNode",
".",
"getGrammarElement",
"(",
")",
"!=",
"null",
")",
"return",
"\"\"",
";",
"return",
"getNodeTextUpToCompletionOffset",
"(",
"prefixNode",
")",
";",
"}",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"prefixNode",
".",
"getTotalLength",
"(",
")",
")",
";",
"doComputePrefix",
"(",
"(",
"ICompositeNode",
")",
"prefixNode",
",",
"result",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | replace region length | [
"replace",
"region",
"length"
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/editor/contentassist/antlr/ContentAssistContextFactory.java#L408-L417 |
162,014 | eclipse/xtext-core | org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/UriExtensions.java | UriExtensions.toUriString | public String toUriString(final java.net.URI uri) {
return this.toUriString(URI.createURI(uri.normalize().toString()));
} | java | public String toUriString(final java.net.URI uri) {
return this.toUriString(URI.createURI(uri.normalize().toString()));
} | [
"public",
"String",
"toUriString",
"(",
"final",
"java",
".",
"net",
".",
"URI",
"uri",
")",
"{",
"return",
"this",
".",
"toUriString",
"(",
"URI",
".",
"createURI",
"(",
"uri",
".",
"normalize",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"}"
] | converts a java.net.URI into a string representation with empty authority, if absent and has file scheme. | [
"converts",
"a",
"java",
".",
"net",
".",
"URI",
"into",
"a",
"string",
"representation",
"with",
"empty",
"authority",
"if",
"absent",
"and",
"has",
"file",
"scheme",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/server/UriExtensions.java#L32-L34 |
162,015 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/SimpleCache.java | SimpleCache.hasCachedValue | public boolean hasCachedValue(Key key) {
try {
readLock.lock();
return content.containsKey(key);
} finally {
readLock.unlock();
}
} | java | public boolean hasCachedValue(Key key) {
try {
readLock.lock();
return content.containsKey(key);
} finally {
readLock.unlock();
}
} | [
"public",
"boolean",
"hasCachedValue",
"(",
"Key",
"key",
")",
"{",
"try",
"{",
"readLock",
".",
"lock",
"(",
")",
";",
"return",
"content",
".",
"containsKey",
"(",
"key",
")",
";",
"}",
"finally",
"{",
"readLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | for testing purpose | [
"for",
"testing",
"purpose"
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/SimpleCache.java#L109-L116 |
162,016 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/resource/persistence/ResourceStorageLoadable.java | ResourceStorageLoadable.loadEntries | protected void loadEntries(final StorageAwareResource resource, final ZipInputStream zipIn) throws IOException {
zipIn.getNextEntry();
BufferedInputStream _bufferedInputStream = new BufferedInputStream(zipIn);
this.readContents(resource, _bufferedInputStream);
zipIn.getNextEntry();
BufferedInputStream _bufferedInputStream_1 = new BufferedInputStream(zipIn);
this.readResourceDescription(resource, _bufferedInputStream_1);
if (this.storeNodeModel) {
zipIn.getNextEntry();
BufferedInputStream _bufferedInputStream_2 = new BufferedInputStream(zipIn);
this.readNodeModel(resource, _bufferedInputStream_2);
}
} | java | protected void loadEntries(final StorageAwareResource resource, final ZipInputStream zipIn) throws IOException {
zipIn.getNextEntry();
BufferedInputStream _bufferedInputStream = new BufferedInputStream(zipIn);
this.readContents(resource, _bufferedInputStream);
zipIn.getNextEntry();
BufferedInputStream _bufferedInputStream_1 = new BufferedInputStream(zipIn);
this.readResourceDescription(resource, _bufferedInputStream_1);
if (this.storeNodeModel) {
zipIn.getNextEntry();
BufferedInputStream _bufferedInputStream_2 = new BufferedInputStream(zipIn);
this.readNodeModel(resource, _bufferedInputStream_2);
}
} | [
"protected",
"void",
"loadEntries",
"(",
"final",
"StorageAwareResource",
"resource",
",",
"final",
"ZipInputStream",
"zipIn",
")",
"throws",
"IOException",
"{",
"zipIn",
".",
"getNextEntry",
"(",
")",
";",
"BufferedInputStream",
"_bufferedInputStream",
"=",
"new",
"BufferedInputStream",
"(",
"zipIn",
")",
";",
"this",
".",
"readContents",
"(",
"resource",
",",
"_bufferedInputStream",
")",
";",
"zipIn",
".",
"getNextEntry",
"(",
")",
";",
"BufferedInputStream",
"_bufferedInputStream_1",
"=",
"new",
"BufferedInputStream",
"(",
"zipIn",
")",
";",
"this",
".",
"readResourceDescription",
"(",
"resource",
",",
"_bufferedInputStream_1",
")",
";",
"if",
"(",
"this",
".",
"storeNodeModel",
")",
"{",
"zipIn",
".",
"getNextEntry",
"(",
")",
";",
"BufferedInputStream",
"_bufferedInputStream_2",
"=",
"new",
"BufferedInputStream",
"(",
"zipIn",
")",
";",
"this",
".",
"readNodeModel",
"(",
"resource",
",",
"_bufferedInputStream_2",
")",
";",
"}",
"}"
] | Load entries from the storage.
Overriding methods should first delegate to super before adding their own entries. | [
"Load",
"entries",
"from",
"the",
"storage",
".",
"Overriding",
"methods",
"should",
"first",
"delegate",
"to",
"super",
"before",
"adding",
"their",
"own",
"entries",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/resource/persistence/ResourceStorageLoadable.java#L64-L76 |
162,017 | eclipse/xtext-core | org.eclipse.xtext/src/org/eclipse/xtext/generator/trace/AbstractTraceRegion.java | AbstractTraceRegion.leafIterator | public final Iterator<AbstractTraceRegion> leafIterator() {
if (nestedRegions == null)
return Collections.<AbstractTraceRegion> singleton(this).iterator();
return new LeafIterator(this);
} | java | public final Iterator<AbstractTraceRegion> leafIterator() {
if (nestedRegions == null)
return Collections.<AbstractTraceRegion> singleton(this).iterator();
return new LeafIterator(this);
} | [
"public",
"final",
"Iterator",
"<",
"AbstractTraceRegion",
">",
"leafIterator",
"(",
")",
"{",
"if",
"(",
"nestedRegions",
"==",
"null",
")",
"return",
"Collections",
".",
"<",
"AbstractTraceRegion",
">",
"singleton",
"(",
"this",
")",
".",
"iterator",
"(",
")",
";",
"return",
"new",
"LeafIterator",
"(",
"this",
")",
";",
"}"
] | Returns an iterator that will only offer leaf trace regions. If the nested regions have gaps, these will be
filled with parent data. If this region is a leaf, a singleton iterator will be returned.
@return an unmodifiable iterator for all leafs. Never <code>null</code>. | [
"Returns",
"an",
"iterator",
"that",
"will",
"only",
"offer",
"leaf",
"trace",
"regions",
".",
"If",
"the",
"nested",
"regions",
"have",
"gaps",
"these",
"will",
"be",
"filled",
"with",
"parent",
"data",
".",
"If",
"this",
"region",
"is",
"a",
"leaf",
"a",
"singleton",
"iterator",
"will",
"be",
"returned",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src/org/eclipse/xtext/generator/trace/AbstractTraceRegion.java#L305-L309 |
162,018 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/TracingSugar.java | TracingSugar.generateTracedFile | public void generateTracedFile(final IFileSystemAccess2 fsa, final String path, final EObject rootTrace, final StringConcatenationClient code) {
final CompositeGeneratorNode node = this.trace(rootTrace, code);
this.generateTracedFile(fsa, path, node);
} | java | public void generateTracedFile(final IFileSystemAccess2 fsa, final String path, final EObject rootTrace, final StringConcatenationClient code) {
final CompositeGeneratorNode node = this.trace(rootTrace, code);
this.generateTracedFile(fsa, path, node);
} | [
"public",
"void",
"generateTracedFile",
"(",
"final",
"IFileSystemAccess2",
"fsa",
",",
"final",
"String",
"path",
",",
"final",
"EObject",
"rootTrace",
",",
"final",
"StringConcatenationClient",
"code",
")",
"{",
"final",
"CompositeGeneratorNode",
"node",
"=",
"this",
".",
"trace",
"(",
"rootTrace",
",",
"code",
")",
";",
"this",
".",
"generateTracedFile",
"(",
"fsa",
",",
"path",
",",
"node",
")",
";",
"}"
] | Convenience extension, to generate traced code. | [
"Convenience",
"extension",
"to",
"generate",
"traced",
"code",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/TracingSugar.java#L43-L46 |
162,019 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/TracingSugar.java | TracingSugar.generateTracedFile | public void generateTracedFile(final IFileSystemAccess2 fsa, final String path, final CompositeGeneratorNode rootNode) {
final GeneratorNodeProcessor.Result result = this.processor.process(rootNode);
fsa.generateFile(path, result);
} | java | public void generateTracedFile(final IFileSystemAccess2 fsa, final String path, final CompositeGeneratorNode rootNode) {
final GeneratorNodeProcessor.Result result = this.processor.process(rootNode);
fsa.generateFile(path, result);
} | [
"public",
"void",
"generateTracedFile",
"(",
"final",
"IFileSystemAccess2",
"fsa",
",",
"final",
"String",
"path",
",",
"final",
"CompositeGeneratorNode",
"rootNode",
")",
"{",
"final",
"GeneratorNodeProcessor",
".",
"Result",
"result",
"=",
"this",
".",
"processor",
".",
"process",
"(",
"rootNode",
")",
";",
"fsa",
".",
"generateFile",
"(",
"path",
",",
"result",
")",
";",
"}"
] | Use to generate a file based on generator node. | [
"Use",
"to",
"generate",
"a",
"file",
"based",
"on",
"generator",
"node",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/TracingSugar.java#L51-L54 |
162,020 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/service/OperationCanceledManager.java | OperationCanceledManager.propagateAsErrorIfCancelException | public void propagateAsErrorIfCancelException(final Throwable t) {
if ((t instanceof OperationCanceledError)) {
throw ((OperationCanceledError)t);
}
final RuntimeException opCanceledException = this.getPlatformOperationCanceledException(t);
if ((opCanceledException != null)) {
throw new OperationCanceledError(opCanceledException);
}
} | java | public void propagateAsErrorIfCancelException(final Throwable t) {
if ((t instanceof OperationCanceledError)) {
throw ((OperationCanceledError)t);
}
final RuntimeException opCanceledException = this.getPlatformOperationCanceledException(t);
if ((opCanceledException != null)) {
throw new OperationCanceledError(opCanceledException);
}
} | [
"public",
"void",
"propagateAsErrorIfCancelException",
"(",
"final",
"Throwable",
"t",
")",
"{",
"if",
"(",
"(",
"t",
"instanceof",
"OperationCanceledError",
")",
")",
"{",
"throw",
"(",
"(",
"OperationCanceledError",
")",
"t",
")",
";",
"}",
"final",
"RuntimeException",
"opCanceledException",
"=",
"this",
".",
"getPlatformOperationCanceledException",
"(",
"t",
")",
";",
"if",
"(",
"(",
"opCanceledException",
"!=",
"null",
")",
")",
"{",
"throw",
"new",
"OperationCanceledError",
"(",
"opCanceledException",
")",
";",
"}",
"}"
] | Rethrows OperationCanceledErrors and wraps platform specific OperationCanceledExceptions. Does nothing for any other type of Throwable. | [
"Rethrows",
"OperationCanceledErrors",
"and",
"wraps",
"platform",
"specific",
"OperationCanceledExceptions",
".",
"Does",
"nothing",
"for",
"any",
"other",
"type",
"of",
"Throwable",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/service/OperationCanceledManager.java#L61-L69 |
162,021 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/service/OperationCanceledManager.java | OperationCanceledManager.propagateIfCancelException | public void propagateIfCancelException(final Throwable t) {
final RuntimeException cancelException = this.getPlatformOperationCanceledException(t);
if ((cancelException != null)) {
throw cancelException;
}
} | java | public void propagateIfCancelException(final Throwable t) {
final RuntimeException cancelException = this.getPlatformOperationCanceledException(t);
if ((cancelException != null)) {
throw cancelException;
}
} | [
"public",
"void",
"propagateIfCancelException",
"(",
"final",
"Throwable",
"t",
")",
"{",
"final",
"RuntimeException",
"cancelException",
"=",
"this",
".",
"getPlatformOperationCanceledException",
"(",
"t",
")",
";",
"if",
"(",
"(",
"cancelException",
"!=",
"null",
")",
")",
"{",
"throw",
"cancelException",
";",
"}",
"}"
] | Rethrows platform specific OperationCanceledExceptions and unwraps OperationCanceledErrors. Does nothing for any other type of Throwable. | [
"Rethrows",
"platform",
"specific",
"OperationCanceledExceptions",
"and",
"unwraps",
"OperationCanceledErrors",
".",
"Does",
"nothing",
"for",
"any",
"other",
"type",
"of",
"Throwable",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/service/OperationCanceledManager.java#L74-L79 |
162,022 | eclipse/xtext-core | org.eclipse.xtext/src/org/eclipse/xtext/linking/lazy/LazyURIEncoder.java | LazyURIEncoder.decode | public Triple<EObject, EReference, INode> decode(Resource res, String uriFragment) {
if (isUseIndexFragment(res)) {
return getLazyProxyInformation(res, uriFragment);
}
List<String> split = Strings.split(uriFragment, SEP);
EObject source = resolveShortFragment(res, split.get(1));
EReference ref = fromShortExternalForm(source.eClass(), split.get(2));
INode compositeNode = NodeModelUtils.getNode(source);
if (compositeNode==null)
throw new IllegalStateException("Couldn't resolve lazy link, because no node model is attached.");
INode textNode = getNode(compositeNode, split.get(3));
return Tuples.create(source, ref, textNode);
} | java | public Triple<EObject, EReference, INode> decode(Resource res, String uriFragment) {
if (isUseIndexFragment(res)) {
return getLazyProxyInformation(res, uriFragment);
}
List<String> split = Strings.split(uriFragment, SEP);
EObject source = resolveShortFragment(res, split.get(1));
EReference ref = fromShortExternalForm(source.eClass(), split.get(2));
INode compositeNode = NodeModelUtils.getNode(source);
if (compositeNode==null)
throw new IllegalStateException("Couldn't resolve lazy link, because no node model is attached.");
INode textNode = getNode(compositeNode, split.get(3));
return Tuples.create(source, ref, textNode);
} | [
"public",
"Triple",
"<",
"EObject",
",",
"EReference",
",",
"INode",
">",
"decode",
"(",
"Resource",
"res",
",",
"String",
"uriFragment",
")",
"{",
"if",
"(",
"isUseIndexFragment",
"(",
"res",
")",
")",
"{",
"return",
"getLazyProxyInformation",
"(",
"res",
",",
"uriFragment",
")",
";",
"}",
"List",
"<",
"String",
">",
"split",
"=",
"Strings",
".",
"split",
"(",
"uriFragment",
",",
"SEP",
")",
";",
"EObject",
"source",
"=",
"resolveShortFragment",
"(",
"res",
",",
"split",
".",
"get",
"(",
"1",
")",
")",
";",
"EReference",
"ref",
"=",
"fromShortExternalForm",
"(",
"source",
".",
"eClass",
"(",
")",
",",
"split",
".",
"get",
"(",
"2",
")",
")",
";",
"INode",
"compositeNode",
"=",
"NodeModelUtils",
".",
"getNode",
"(",
"source",
")",
";",
"if",
"(",
"compositeNode",
"==",
"null",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Couldn't resolve lazy link, because no node model is attached.\"",
")",
";",
"INode",
"textNode",
"=",
"getNode",
"(",
"compositeNode",
",",
"split",
".",
"get",
"(",
"3",
")",
")",
";",
"return",
"Tuples",
".",
"create",
"(",
"source",
",",
"ref",
",",
"textNode",
")",
";",
"}"
] | decodes the uriFragment
@param res the resource that contains the feature holder
@param uriFragment the fragment that should be decoded
@return the decoded information
@see LazyURIEncoder#encode(EObject, EReference, INode) | [
"decodes",
"the",
"uriFragment"
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src/org/eclipse/xtext/linking/lazy/LazyURIEncoder.java#L125-L137 |
162,023 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/OnChangeEvictingCache.java | OnChangeEvictingCache.get | @Override
public <T> T get(Object key, Resource resource, Provider<T> provider) {
if(resource == null) {
return provider.get();
}
CacheAdapter adapter = getOrCreate(resource);
T element = adapter.<T>internalGet(key);
if (element==null) {
element = provider.get();
cacheMiss(adapter);
adapter.set(key, element);
} else {
cacheHit(adapter);
}
if (element == CacheAdapter.NULL) {
return null;
}
return element;
} | java | @Override
public <T> T get(Object key, Resource resource, Provider<T> provider) {
if(resource == null) {
return provider.get();
}
CacheAdapter adapter = getOrCreate(resource);
T element = adapter.<T>internalGet(key);
if (element==null) {
element = provider.get();
cacheMiss(adapter);
adapter.set(key, element);
} else {
cacheHit(adapter);
}
if (element == CacheAdapter.NULL) {
return null;
}
return element;
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"get",
"(",
"Object",
"key",
",",
"Resource",
"resource",
",",
"Provider",
"<",
"T",
">",
"provider",
")",
"{",
"if",
"(",
"resource",
"==",
"null",
")",
"{",
"return",
"provider",
".",
"get",
"(",
")",
";",
"}",
"CacheAdapter",
"adapter",
"=",
"getOrCreate",
"(",
"resource",
")",
";",
"T",
"element",
"=",
"adapter",
".",
"<",
"T",
">",
"internalGet",
"(",
"key",
")",
";",
"if",
"(",
"element",
"==",
"null",
")",
"{",
"element",
"=",
"provider",
".",
"get",
"(",
")",
";",
"cacheMiss",
"(",
"adapter",
")",
";",
"adapter",
".",
"set",
"(",
"key",
",",
"element",
")",
";",
"}",
"else",
"{",
"cacheHit",
"(",
"adapter",
")",
";",
"}",
"if",
"(",
"element",
"==",
"CacheAdapter",
".",
"NULL",
")",
"{",
"return",
"null",
";",
"}",
"return",
"element",
";",
"}"
] | Try to obtain the value that is cached for the given key in the given resource.
If no value is cached, the provider is used to compute it and store it afterwards.
@param resource the resource. If it is <code>null</code>, the provider will be used to compute the value.
@param key the cache key. May not be <code>null</code>.
@param provider the strategy to compute the value if necessary. May not be <code>null</code>. | [
"Try",
"to",
"obtain",
"the",
"value",
"that",
"is",
"cached",
"for",
"the",
"given",
"key",
"in",
"the",
"given",
"resource",
".",
"If",
"no",
"value",
"is",
"cached",
"the",
"provider",
"is",
"used",
"to",
"compute",
"it",
"and",
"store",
"it",
"afterwards",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/OnChangeEvictingCache.java#L68-L86 |
162,024 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/OnChangeEvictingCache.java | OnChangeEvictingCache.execWithoutCacheClear | public <Result, Param extends Resource> Result execWithoutCacheClear(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException {
CacheAdapter cacheAdapter = getOrCreate(resource);
try {
cacheAdapter.ignoreNotifications();
return transaction.exec(resource);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new WrappedException(e);
} finally {
cacheAdapter.listenToNotifications();
}
} | java | public <Result, Param extends Resource> Result execWithoutCacheClear(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException {
CacheAdapter cacheAdapter = getOrCreate(resource);
try {
cacheAdapter.ignoreNotifications();
return transaction.exec(resource);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new WrappedException(e);
} finally {
cacheAdapter.listenToNotifications();
}
} | [
"public",
"<",
"Result",
",",
"Param",
"extends",
"Resource",
">",
"Result",
"execWithoutCacheClear",
"(",
"Param",
"resource",
",",
"IUnitOfWork",
"<",
"Result",
",",
"Param",
">",
"transaction",
")",
"throws",
"WrappedException",
"{",
"CacheAdapter",
"cacheAdapter",
"=",
"getOrCreate",
"(",
"resource",
")",
";",
"try",
"{",
"cacheAdapter",
".",
"ignoreNotifications",
"(",
")",
";",
"return",
"transaction",
".",
"exec",
"(",
"resource",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"WrappedException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"cacheAdapter",
".",
"listenToNotifications",
"(",
")",
";",
"}",
"}"
] | The transaction will be executed. While it is running, any semantic state change
in the given resource will be ignored and the cache will not be cleared. | [
"The",
"transaction",
"will",
"be",
"executed",
".",
"While",
"it",
"is",
"running",
"any",
"semantic",
"state",
"change",
"in",
"the",
"given",
"resource",
"will",
"be",
"ignored",
"and",
"the",
"cache",
"will",
"not",
"be",
"cleared",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/OnChangeEvictingCache.java#L124-L136 |
162,025 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/OnChangeEvictingCache.java | OnChangeEvictingCache.execWithTemporaryCaching | public <Result, Param extends Resource> Result execWithTemporaryCaching(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException {
CacheAdapter cacheAdapter = getOrCreate(resource);
IgnoreValuesMemento memento = cacheAdapter.ignoreNewValues();
try {
return transaction.exec(resource);
} catch (Exception e) {
throw new WrappedException(e);
} finally {
memento.done();
}
} | java | public <Result, Param extends Resource> Result execWithTemporaryCaching(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException {
CacheAdapter cacheAdapter = getOrCreate(resource);
IgnoreValuesMemento memento = cacheAdapter.ignoreNewValues();
try {
return transaction.exec(resource);
} catch (Exception e) {
throw new WrappedException(e);
} finally {
memento.done();
}
} | [
"public",
"<",
"Result",
",",
"Param",
"extends",
"Resource",
">",
"Result",
"execWithTemporaryCaching",
"(",
"Param",
"resource",
",",
"IUnitOfWork",
"<",
"Result",
",",
"Param",
">",
"transaction",
")",
"throws",
"WrappedException",
"{",
"CacheAdapter",
"cacheAdapter",
"=",
"getOrCreate",
"(",
"resource",
")",
";",
"IgnoreValuesMemento",
"memento",
"=",
"cacheAdapter",
".",
"ignoreNewValues",
"(",
")",
";",
"try",
"{",
"return",
"transaction",
".",
"exec",
"(",
"resource",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"WrappedException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"memento",
".",
"done",
"(",
")",
";",
"}",
"}"
] | The transaction will be executed with caching enabled. However, all newly cached values will be discarded as soon
as the transaction is over.
@since 2.1 | [
"The",
"transaction",
"will",
"be",
"executed",
"with",
"caching",
"enabled",
".",
"However",
"all",
"newly",
"cached",
"values",
"will",
"be",
"discarded",
"as",
"soon",
"as",
"the",
"transaction",
"is",
"over",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/OnChangeEvictingCache.java#L143-L153 |
162,026 | eclipse/xtext-core | org.eclipse.xtext/src/org/eclipse/xtext/linking/lazy/LazyLinkingResource.java | LazyLinkingResource.resolveLazyCrossReferences | public void resolveLazyCrossReferences(final CancelIndicator mon) {
final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon;
TreeIterator<Object> iterator = EcoreUtil.getAllContents(this, true);
while (iterator.hasNext()) {
operationCanceledManager.checkCanceled(monitor);
InternalEObject source = (InternalEObject) iterator.next();
EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) source.eClass()
.getEAllStructuralFeatures()).crossReferences();
if (eStructuralFeatures != null) {
for (EStructuralFeature crossRef : eStructuralFeatures) {
operationCanceledManager.checkCanceled(monitor);
resolveLazyCrossReference(source, crossRef);
}
}
}
} | java | public void resolveLazyCrossReferences(final CancelIndicator mon) {
final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon;
TreeIterator<Object> iterator = EcoreUtil.getAllContents(this, true);
while (iterator.hasNext()) {
operationCanceledManager.checkCanceled(monitor);
InternalEObject source = (InternalEObject) iterator.next();
EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) source.eClass()
.getEAllStructuralFeatures()).crossReferences();
if (eStructuralFeatures != null) {
for (EStructuralFeature crossRef : eStructuralFeatures) {
operationCanceledManager.checkCanceled(monitor);
resolveLazyCrossReference(source, crossRef);
}
}
}
} | [
"public",
"void",
"resolveLazyCrossReferences",
"(",
"final",
"CancelIndicator",
"mon",
")",
"{",
"final",
"CancelIndicator",
"monitor",
"=",
"mon",
"==",
"null",
"?",
"CancelIndicator",
".",
"NullImpl",
":",
"mon",
";",
"TreeIterator",
"<",
"Object",
">",
"iterator",
"=",
"EcoreUtil",
".",
"getAllContents",
"(",
"this",
",",
"true",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"operationCanceledManager",
".",
"checkCanceled",
"(",
"monitor",
")",
";",
"InternalEObject",
"source",
"=",
"(",
"InternalEObject",
")",
"iterator",
".",
"next",
"(",
")",
";",
"EStructuralFeature",
"[",
"]",
"eStructuralFeatures",
"=",
"(",
"(",
"EClassImpl",
".",
"FeatureSubsetSupplier",
")",
"source",
".",
"eClass",
"(",
")",
".",
"getEAllStructuralFeatures",
"(",
")",
")",
".",
"crossReferences",
"(",
")",
";",
"if",
"(",
"eStructuralFeatures",
"!=",
"null",
")",
"{",
"for",
"(",
"EStructuralFeature",
"crossRef",
":",
"eStructuralFeatures",
")",
"{",
"operationCanceledManager",
".",
"checkCanceled",
"(",
"monitor",
")",
";",
"resolveLazyCrossReference",
"(",
"source",
",",
"crossRef",
")",
";",
"}",
"}",
"}",
"}"
] | resolves any lazy cross references in this resource, adding Issues for unresolvable elements to this resource.
This resource might still contain resolvable proxies after this method has been called.
@param mon a {@link CancelIndicator} can be used to stop the resolution. | [
"resolves",
"any",
"lazy",
"cross",
"references",
"in",
"this",
"resource",
"adding",
"Issues",
"for",
"unresolvable",
"elements",
"to",
"this",
"resource",
".",
"This",
"resource",
"might",
"still",
"contain",
"resolvable",
"proxies",
"after",
"this",
"method",
"has",
"been",
"called",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src/org/eclipse/xtext/linking/lazy/LazyLinkingResource.java#L137-L152 |
162,027 | eclipse/xtext-core | org.eclipse.xtext/src/org/eclipse/xtext/resource/DescriptionUtils.java | DescriptionUtils.collectOutgoingReferences | public Set<URI> collectOutgoingReferences(IResourceDescription description) {
URI resourceURI = description.getURI();
Set<URI> result = null;
for(IReferenceDescription reference: description.getReferenceDescriptions()) {
URI targetResource = reference.getTargetEObjectUri().trimFragment();
if (!resourceURI.equals(targetResource)) {
if (result == null)
result = Sets.newHashSet(targetResource);
else
result.add(targetResource);
}
}
if (result != null)
return result;
return Collections.emptySet();
} | java | public Set<URI> collectOutgoingReferences(IResourceDescription description) {
URI resourceURI = description.getURI();
Set<URI> result = null;
for(IReferenceDescription reference: description.getReferenceDescriptions()) {
URI targetResource = reference.getTargetEObjectUri().trimFragment();
if (!resourceURI.equals(targetResource)) {
if (result == null)
result = Sets.newHashSet(targetResource);
else
result.add(targetResource);
}
}
if (result != null)
return result;
return Collections.emptySet();
} | [
"public",
"Set",
"<",
"URI",
">",
"collectOutgoingReferences",
"(",
"IResourceDescription",
"description",
")",
"{",
"URI",
"resourceURI",
"=",
"description",
".",
"getURI",
"(",
")",
";",
"Set",
"<",
"URI",
">",
"result",
"=",
"null",
";",
"for",
"(",
"IReferenceDescription",
"reference",
":",
"description",
".",
"getReferenceDescriptions",
"(",
")",
")",
"{",
"URI",
"targetResource",
"=",
"reference",
".",
"getTargetEObjectUri",
"(",
")",
".",
"trimFragment",
"(",
")",
";",
"if",
"(",
"!",
"resourceURI",
".",
"equals",
"(",
"targetResource",
")",
")",
"{",
"if",
"(",
"result",
"==",
"null",
")",
"result",
"=",
"Sets",
".",
"newHashSet",
"(",
"targetResource",
")",
";",
"else",
"result",
".",
"add",
"(",
"targetResource",
")",
";",
"}",
"}",
"if",
"(",
"result",
"!=",
"null",
")",
"return",
"result",
";",
"return",
"Collections",
".",
"emptySet",
"(",
")",
";",
"}"
] | Collect the URIs of resources, that are referenced by the given description.
@return the list of referenced URIs. Never <code>null</code>. | [
"Collect",
"the",
"URIs",
"of",
"resources",
"that",
"are",
"referenced",
"by",
"the",
"given",
"description",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src/org/eclipse/xtext/resource/DescriptionUtils.java#L26-L41 |
162,028 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/TailWriter.java | TailWriter.write | @Override
public void write(final char[] cbuf, final int off, final int len) throws IOException {
int offset = off;
int length = len;
while (suppressLineCount > 0 && length > 0) {
length = -1;
for (int i = 0; i < len && suppressLineCount > 0; i++) {
if (cbuf[off + i] == '\n') {
offset = off + i + 1;
length = len - i - 1;
suppressLineCount--;
}
}
if (length <= 0)
return;
}
delegate.write(cbuf, offset, length);
} | java | @Override
public void write(final char[] cbuf, final int off, final int len) throws IOException {
int offset = off;
int length = len;
while (suppressLineCount > 0 && length > 0) {
length = -1;
for (int i = 0; i < len && suppressLineCount > 0; i++) {
if (cbuf[off + i] == '\n') {
offset = off + i + 1;
length = len - i - 1;
suppressLineCount--;
}
}
if (length <= 0)
return;
}
delegate.write(cbuf, offset, length);
} | [
"@",
"Override",
"public",
"void",
"write",
"(",
"final",
"char",
"[",
"]",
"cbuf",
",",
"final",
"int",
"off",
",",
"final",
"int",
"len",
")",
"throws",
"IOException",
"{",
"int",
"offset",
"=",
"off",
";",
"int",
"length",
"=",
"len",
";",
"while",
"(",
"suppressLineCount",
">",
"0",
"&&",
"length",
">",
"0",
")",
"{",
"length",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"len",
"&&",
"suppressLineCount",
">",
"0",
";",
"i",
"++",
")",
"{",
"if",
"(",
"cbuf",
"[",
"off",
"+",
"i",
"]",
"==",
"'",
"'",
")",
"{",
"offset",
"=",
"off",
"+",
"i",
"+",
"1",
";",
"length",
"=",
"len",
"-",
"i",
"-",
"1",
";",
"suppressLineCount",
"--",
";",
"}",
"}",
"if",
"(",
"length",
"<=",
"0",
")",
"return",
";",
"}",
"delegate",
".",
"write",
"(",
"cbuf",
",",
"offset",
",",
"length",
")",
";",
"}"
] | Filter everything until we found the first NL character. | [
"Filter",
"everything",
"until",
"we",
"found",
"the",
"first",
"NL",
"character",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/TailWriter.java#L42-L59 |
162,029 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/tasks/DefaultTaskFinder.java | DefaultTaskFinder.setEndTag | @Inject(optional = true)
protected Pattern setEndTag(@Named(AbstractMultiLineCommentProvider.END_TAG) final String endTag) {
return this.endTagPattern = Pattern.compile((endTag + "\\z"));
} | java | @Inject(optional = true)
protected Pattern setEndTag(@Named(AbstractMultiLineCommentProvider.END_TAG) final String endTag) {
return this.endTagPattern = Pattern.compile((endTag + "\\z"));
} | [
"@",
"Inject",
"(",
"optional",
"=",
"true",
")",
"protected",
"Pattern",
"setEndTag",
"(",
"@",
"Named",
"(",
"AbstractMultiLineCommentProvider",
".",
"END_TAG",
")",
"final",
"String",
"endTag",
")",
"{",
"return",
"this",
".",
"endTagPattern",
"=",
"Pattern",
".",
"compile",
"(",
"(",
"endTag",
"+",
"\"\\\\z\"",
")",
")",
";",
"}"
] | this method is not intended to be called by clients
@since 2.12 | [
"this",
"method",
"is",
"not",
"intended",
"to",
"be",
"called",
"by",
"clients"
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/tasks/DefaultTaskFinder.java#L55-L58 |
162,030 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeExtensions.java | GeneratorNodeExtensions.indent | public CompositeGeneratorNode indent(final CompositeGeneratorNode parent, final String indentString) {
final IndentNode indent = new IndentNode(indentString);
List<IGeneratorNode> _children = parent.getChildren();
_children.add(indent);
return indent;
} | java | public CompositeGeneratorNode indent(final CompositeGeneratorNode parent, final String indentString) {
final IndentNode indent = new IndentNode(indentString);
List<IGeneratorNode> _children = parent.getChildren();
_children.add(indent);
return indent;
} | [
"public",
"CompositeGeneratorNode",
"indent",
"(",
"final",
"CompositeGeneratorNode",
"parent",
",",
"final",
"String",
"indentString",
")",
"{",
"final",
"IndentNode",
"indent",
"=",
"new",
"IndentNode",
"(",
"indentString",
")",
";",
"List",
"<",
"IGeneratorNode",
">",
"_children",
"=",
"parent",
".",
"getChildren",
"(",
")",
";",
"_children",
".",
"add",
"(",
"indent",
")",
";",
"return",
"indent",
";",
"}"
] | Appends the indentation string at the current position of the parent and adds a new composite node, indicating the same indentation for
subsequent lines.
@return an indentation node, using the given indentString, appended as a child on the given parent | [
"Appends",
"the",
"indentation",
"string",
"at",
"the",
"current",
"position",
"of",
"the",
"parent",
"and",
"adds",
"a",
"new",
"composite",
"node",
"indicating",
"the",
"same",
"indentation",
"for",
"subsequent",
"lines",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeExtensions.java#L84-L89 |
162,031 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeExtensions.java | GeneratorNodeExtensions.appendNewLineIfNotEmpty | public CompositeGeneratorNode appendNewLineIfNotEmpty(final CompositeGeneratorNode parent) {
List<IGeneratorNode> _children = parent.getChildren();
String _lineDelimiter = this.wsConfig.getLineDelimiter();
NewLineNode _newLineNode = new NewLineNode(_lineDelimiter, true);
_children.add(_newLineNode);
return parent;
} | java | public CompositeGeneratorNode appendNewLineIfNotEmpty(final CompositeGeneratorNode parent) {
List<IGeneratorNode> _children = parent.getChildren();
String _lineDelimiter = this.wsConfig.getLineDelimiter();
NewLineNode _newLineNode = new NewLineNode(_lineDelimiter, true);
_children.add(_newLineNode);
return parent;
} | [
"public",
"CompositeGeneratorNode",
"appendNewLineIfNotEmpty",
"(",
"final",
"CompositeGeneratorNode",
"parent",
")",
"{",
"List",
"<",
"IGeneratorNode",
">",
"_children",
"=",
"parent",
".",
"getChildren",
"(",
")",
";",
"String",
"_lineDelimiter",
"=",
"this",
".",
"wsConfig",
".",
"getLineDelimiter",
"(",
")",
";",
"NewLineNode",
"_newLineNode",
"=",
"new",
"NewLineNode",
"(",
"_lineDelimiter",
",",
"true",
")",
";",
"_children",
".",
"add",
"(",
"_newLineNode",
")",
";",
"return",
"parent",
";",
"}"
] | Appends a line separator node that will only be effective if the current line contains non-whitespace text.
@return the given parent node | [
"Appends",
"a",
"line",
"separator",
"node",
"that",
"will",
"only",
"be",
"effective",
"if",
"the",
"current",
"line",
"contains",
"non",
"-",
"whitespace",
"text",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeExtensions.java#L121-L127 |
162,032 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeExtensions.java | GeneratorNodeExtensions.appendTemplate | public CompositeGeneratorNode appendTemplate(final CompositeGeneratorNode parent, final StringConcatenationClient templateString) {
final TemplateNode proc = new TemplateNode(templateString, this);
List<IGeneratorNode> _children = parent.getChildren();
_children.add(proc);
return parent;
} | java | public CompositeGeneratorNode appendTemplate(final CompositeGeneratorNode parent, final StringConcatenationClient templateString) {
final TemplateNode proc = new TemplateNode(templateString, this);
List<IGeneratorNode> _children = parent.getChildren();
_children.add(proc);
return parent;
} | [
"public",
"CompositeGeneratorNode",
"appendTemplate",
"(",
"final",
"CompositeGeneratorNode",
"parent",
",",
"final",
"StringConcatenationClient",
"templateString",
")",
"{",
"final",
"TemplateNode",
"proc",
"=",
"new",
"TemplateNode",
"(",
"templateString",
",",
"this",
")",
";",
"List",
"<",
"IGeneratorNode",
">",
"_children",
"=",
"parent",
".",
"getChildren",
"(",
")",
";",
"_children",
".",
"add",
"(",
"proc",
")",
";",
"return",
"parent",
";",
"}"
] | Creates a template node for the given templateString and appends it to the given parent node.
Templates are translated to generator node trees and expressions in templates can be of type IGeneratorNode.
@return the given parent node | [
"Creates",
"a",
"template",
"node",
"for",
"the",
"given",
"templateString",
"and",
"appends",
"it",
"to",
"the",
"given",
"parent",
"node",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/generator/trace/node/GeneratorNodeExtensions.java#L161-L166 |
162,033 | eclipse/xtext-core | org.eclipse.xtext/src/org/eclipse/xtext/parser/antlr/AbstractIndentationTokenSource.java | AbstractIndentationTokenSource.doSplitTokenImpl | protected void doSplitTokenImpl(Token token, ITokenAcceptor result) {
String text = token.getText();
int indentation = computeIndentation(text);
if (indentation == -1 || indentation == currentIndentation) {
// no change of indentation level detected simply process the token
result.accept(token);
} else if (indentation > currentIndentation) {
// indentation level increased
splitIntoBeginToken(token, indentation, result);
} else if (indentation < currentIndentation) {
// indentation level decreased
int charCount = computeIndentationRelevantCharCount(text);
if (charCount > 0) {
// emit whitespace including newline
splitWithText(token, text.substring(0, charCount), result);
}
// emit end tokens at the beginning of the line
decreaseIndentation(indentation, result);
if (charCount != text.length()) {
handleRemainingText(token, text.substring(charCount), indentation, result);
}
} else {
throw new IllegalStateException(String.valueOf(indentation));
}
} | java | protected void doSplitTokenImpl(Token token, ITokenAcceptor result) {
String text = token.getText();
int indentation = computeIndentation(text);
if (indentation == -1 || indentation == currentIndentation) {
// no change of indentation level detected simply process the token
result.accept(token);
} else if (indentation > currentIndentation) {
// indentation level increased
splitIntoBeginToken(token, indentation, result);
} else if (indentation < currentIndentation) {
// indentation level decreased
int charCount = computeIndentationRelevantCharCount(text);
if (charCount > 0) {
// emit whitespace including newline
splitWithText(token, text.substring(0, charCount), result);
}
// emit end tokens at the beginning of the line
decreaseIndentation(indentation, result);
if (charCount != text.length()) {
handleRemainingText(token, text.substring(charCount), indentation, result);
}
} else {
throw new IllegalStateException(String.valueOf(indentation));
}
} | [
"protected",
"void",
"doSplitTokenImpl",
"(",
"Token",
"token",
",",
"ITokenAcceptor",
"result",
")",
"{",
"String",
"text",
"=",
"token",
".",
"getText",
"(",
")",
";",
"int",
"indentation",
"=",
"computeIndentation",
"(",
"text",
")",
";",
"if",
"(",
"indentation",
"==",
"-",
"1",
"||",
"indentation",
"==",
"currentIndentation",
")",
"{",
"// no change of indentation level detected simply process the token",
"result",
".",
"accept",
"(",
"token",
")",
";",
"}",
"else",
"if",
"(",
"indentation",
">",
"currentIndentation",
")",
"{",
"// indentation level increased",
"splitIntoBeginToken",
"(",
"token",
",",
"indentation",
",",
"result",
")",
";",
"}",
"else",
"if",
"(",
"indentation",
"<",
"currentIndentation",
")",
"{",
"// indentation level decreased",
"int",
"charCount",
"=",
"computeIndentationRelevantCharCount",
"(",
"text",
")",
";",
"if",
"(",
"charCount",
">",
"0",
")",
"{",
"// emit whitespace including newline",
"splitWithText",
"(",
"token",
",",
"text",
".",
"substring",
"(",
"0",
",",
"charCount",
")",
",",
"result",
")",
";",
"}",
"// emit end tokens at the beginning of the line",
"decreaseIndentation",
"(",
"indentation",
",",
"result",
")",
";",
"if",
"(",
"charCount",
"!=",
"text",
".",
"length",
"(",
")",
")",
"{",
"handleRemainingText",
"(",
"token",
",",
"text",
".",
"substring",
"(",
"charCount",
")",
",",
"indentation",
",",
"result",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"valueOf",
"(",
"indentation",
")",
")",
";",
"}",
"}"
] | The token was previously determined as potentially to-be-splitted thus we
emit additional indentation or dedenting tokens. | [
"The",
"token",
"was",
"previously",
"determined",
"as",
"potentially",
"to",
"-",
"be",
"-",
"splitted",
"thus",
"we",
"emit",
"additional",
"indentation",
"or",
"dedenting",
"tokens",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/src/org/eclipse/xtext/parser/antlr/AbstractIndentationTokenSource.java#L97-L121 |
162,034 | eclipse/xtext-core | org.eclipse.xtext/xtend-gen/org/eclipse/xtext/resource/persistence/ResourceStorageFacade.java | ResourceStorageFacade.getOrCreateResourceStorageLoadable | @Override
public ResourceStorageLoadable getOrCreateResourceStorageLoadable(final StorageAwareResource resource) {
try {
final ResourceStorageProviderAdapter stateProvider = IterableExtensions.<ResourceStorageProviderAdapter>head(Iterables.<ResourceStorageProviderAdapter>filter(resource.getResourceSet().eAdapters(), ResourceStorageProviderAdapter.class));
if ((stateProvider != null)) {
final ResourceStorageLoadable inputStream = stateProvider.getResourceStorageLoadable(resource);
if ((inputStream != null)) {
return inputStream;
}
}
InputStream _xifexpression = null;
boolean _exists = resource.getResourceSet().getURIConverter().exists(this.getBinaryStorageURI(resource.getURI()), CollectionLiterals.<Object, Object>emptyMap());
if (_exists) {
_xifexpression = resource.getResourceSet().getURIConverter().createInputStream(this.getBinaryStorageURI(resource.getURI()));
} else {
InputStream _xblockexpression = null;
{
final AbstractFileSystemAccess2 fsa = this.getFileSystemAccess(resource);
final String outputRelativePath = this.computeOutputPath(resource);
_xblockexpression = fsa.readBinaryFile(outputRelativePath);
}
_xifexpression = _xblockexpression;
}
final InputStream inputStream_1 = _xifexpression;
return this.createResourceStorageLoadable(inputStream_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
} | java | @Override
public ResourceStorageLoadable getOrCreateResourceStorageLoadable(final StorageAwareResource resource) {
try {
final ResourceStorageProviderAdapter stateProvider = IterableExtensions.<ResourceStorageProviderAdapter>head(Iterables.<ResourceStorageProviderAdapter>filter(resource.getResourceSet().eAdapters(), ResourceStorageProviderAdapter.class));
if ((stateProvider != null)) {
final ResourceStorageLoadable inputStream = stateProvider.getResourceStorageLoadable(resource);
if ((inputStream != null)) {
return inputStream;
}
}
InputStream _xifexpression = null;
boolean _exists = resource.getResourceSet().getURIConverter().exists(this.getBinaryStorageURI(resource.getURI()), CollectionLiterals.<Object, Object>emptyMap());
if (_exists) {
_xifexpression = resource.getResourceSet().getURIConverter().createInputStream(this.getBinaryStorageURI(resource.getURI()));
} else {
InputStream _xblockexpression = null;
{
final AbstractFileSystemAccess2 fsa = this.getFileSystemAccess(resource);
final String outputRelativePath = this.computeOutputPath(resource);
_xblockexpression = fsa.readBinaryFile(outputRelativePath);
}
_xifexpression = _xblockexpression;
}
final InputStream inputStream_1 = _xifexpression;
return this.createResourceStorageLoadable(inputStream_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
} | [
"@",
"Override",
"public",
"ResourceStorageLoadable",
"getOrCreateResourceStorageLoadable",
"(",
"final",
"StorageAwareResource",
"resource",
")",
"{",
"try",
"{",
"final",
"ResourceStorageProviderAdapter",
"stateProvider",
"=",
"IterableExtensions",
".",
"<",
"ResourceStorageProviderAdapter",
">",
"head",
"(",
"Iterables",
".",
"<",
"ResourceStorageProviderAdapter",
">",
"filter",
"(",
"resource",
".",
"getResourceSet",
"(",
")",
".",
"eAdapters",
"(",
")",
",",
"ResourceStorageProviderAdapter",
".",
"class",
")",
")",
";",
"if",
"(",
"(",
"stateProvider",
"!=",
"null",
")",
")",
"{",
"final",
"ResourceStorageLoadable",
"inputStream",
"=",
"stateProvider",
".",
"getResourceStorageLoadable",
"(",
"resource",
")",
";",
"if",
"(",
"(",
"inputStream",
"!=",
"null",
")",
")",
"{",
"return",
"inputStream",
";",
"}",
"}",
"InputStream",
"_xifexpression",
"=",
"null",
";",
"boolean",
"_exists",
"=",
"resource",
".",
"getResourceSet",
"(",
")",
".",
"getURIConverter",
"(",
")",
".",
"exists",
"(",
"this",
".",
"getBinaryStorageURI",
"(",
"resource",
".",
"getURI",
"(",
")",
")",
",",
"CollectionLiterals",
".",
"<",
"Object",
",",
"Object",
">",
"emptyMap",
"(",
")",
")",
";",
"if",
"(",
"_exists",
")",
"{",
"_xifexpression",
"=",
"resource",
".",
"getResourceSet",
"(",
")",
".",
"getURIConverter",
"(",
")",
".",
"createInputStream",
"(",
"this",
".",
"getBinaryStorageURI",
"(",
"resource",
".",
"getURI",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"InputStream",
"_xblockexpression",
"=",
"null",
";",
"{",
"final",
"AbstractFileSystemAccess2",
"fsa",
"=",
"this",
".",
"getFileSystemAccess",
"(",
"resource",
")",
";",
"final",
"String",
"outputRelativePath",
"=",
"this",
".",
"computeOutputPath",
"(",
"resource",
")",
";",
"_xblockexpression",
"=",
"fsa",
".",
"readBinaryFile",
"(",
"outputRelativePath",
")",
";",
"}",
"_xifexpression",
"=",
"_xblockexpression",
";",
"}",
"final",
"InputStream",
"inputStream_1",
"=",
"_xifexpression",
";",
"return",
"this",
".",
"createResourceStorageLoadable",
"(",
"inputStream_1",
")",
";",
"}",
"catch",
"(",
"Throwable",
"_e",
")",
"{",
"throw",
"Exceptions",
".",
"sneakyThrow",
"(",
"_e",
")",
";",
"}",
"}"
] | Finds or creates a ResourceStorageLoadable for the given resource.
Clients should first call shouldLoadFromStorage to check whether there exists a storage version
of the given resource.
@return an IResourceStorageLoadable | [
"Finds",
"or",
"creates",
"a",
"ResourceStorageLoadable",
"for",
"the",
"given",
"resource",
".",
"Clients",
"should",
"first",
"call",
"shouldLoadFromStorage",
"to",
"check",
"whether",
"there",
"exists",
"a",
"storage",
"version",
"of",
"the",
"given",
"resource",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext/xtend-gen/org/eclipse/xtext/resource/persistence/ResourceStorageFacade.java#L89-L117 |
162,035 | eclipse/xtext-core | org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/editor/contentassist/CompletionPrefixProvider.java | CompletionPrefixProvider.getLastCompleteNodeByOffset | public INode getLastCompleteNodeByOffset(INode node, int offsetPosition, int completionOffset) {
return internalGetLastCompleteNodeByOffset(node.getRootNode(), offsetPosition);
} | java | public INode getLastCompleteNodeByOffset(INode node, int offsetPosition, int completionOffset) {
return internalGetLastCompleteNodeByOffset(node.getRootNode(), offsetPosition);
} | [
"public",
"INode",
"getLastCompleteNodeByOffset",
"(",
"INode",
"node",
",",
"int",
"offsetPosition",
",",
"int",
"completionOffset",
")",
"{",
"return",
"internalGetLastCompleteNodeByOffset",
"(",
"node",
".",
"getRootNode",
"(",
")",
",",
"offsetPosition",
")",
";",
"}"
] | Returns the last node that appears to be part of the prefix. This will be used to determine the current model
object that'll be the most special context instance in the proposal provider. | [
"Returns",
"the",
"last",
"node",
"that",
"appears",
"to",
"be",
"part",
"of",
"the",
"prefix",
".",
"This",
"will",
"be",
"used",
"to",
"determine",
"the",
"current",
"model",
"object",
"that",
"ll",
"be",
"the",
"most",
"special",
"context",
"instance",
"in",
"the",
"proposal",
"provider",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/editor/contentassist/CompletionPrefixProvider.java#L36-L38 |
162,036 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest.java | MergeableManifest.addRequiredBundles | public void addRequiredBundles(Set<String> bundles) {
// TODO manage transitive dependencies
// don't require self
Set<String> bundlesToMerge;
String bundleName = (String) getMainAttributes().get(BUNDLE_SYMBOLIC_NAME);
if (bundleName != null) {
int idx = bundleName.indexOf(';');
if (idx >= 0) {
bundleName = bundleName.substring(0, idx);
}
}
if (bundleName != null && bundles.contains(bundleName)
|| projectName != null && bundles.contains(projectName)) {
bundlesToMerge = new LinkedHashSet<String>(bundles);
bundlesToMerge.remove(bundleName);
bundlesToMerge.remove(projectName);
} else {
bundlesToMerge = bundles;
}
String s = (String) getMainAttributes().get(REQUIRE_BUNDLE);
Wrapper<Boolean> modified = Wrapper.wrap(this.modified);
String result = mergeIntoCommaSeparatedList(s, bundlesToMerge, modified, lineDelimiter);
this.modified = modified.get();
getMainAttributes().put(REQUIRE_BUNDLE, result);
} | java | public void addRequiredBundles(Set<String> bundles) {
// TODO manage transitive dependencies
// don't require self
Set<String> bundlesToMerge;
String bundleName = (String) getMainAttributes().get(BUNDLE_SYMBOLIC_NAME);
if (bundleName != null) {
int idx = bundleName.indexOf(';');
if (idx >= 0) {
bundleName = bundleName.substring(0, idx);
}
}
if (bundleName != null && bundles.contains(bundleName)
|| projectName != null && bundles.contains(projectName)) {
bundlesToMerge = new LinkedHashSet<String>(bundles);
bundlesToMerge.remove(bundleName);
bundlesToMerge.remove(projectName);
} else {
bundlesToMerge = bundles;
}
String s = (String) getMainAttributes().get(REQUIRE_BUNDLE);
Wrapper<Boolean> modified = Wrapper.wrap(this.modified);
String result = mergeIntoCommaSeparatedList(s, bundlesToMerge, modified, lineDelimiter);
this.modified = modified.get();
getMainAttributes().put(REQUIRE_BUNDLE, result);
} | [
"public",
"void",
"addRequiredBundles",
"(",
"Set",
"<",
"String",
">",
"bundles",
")",
"{",
"// TODO manage transitive dependencies",
"// don't require self",
"Set",
"<",
"String",
">",
"bundlesToMerge",
";",
"String",
"bundleName",
"=",
"(",
"String",
")",
"getMainAttributes",
"(",
")",
".",
"get",
"(",
"BUNDLE_SYMBOLIC_NAME",
")",
";",
"if",
"(",
"bundleName",
"!=",
"null",
")",
"{",
"int",
"idx",
"=",
"bundleName",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"idx",
">=",
"0",
")",
"{",
"bundleName",
"=",
"bundleName",
".",
"substring",
"(",
"0",
",",
"idx",
")",
";",
"}",
"}",
"if",
"(",
"bundleName",
"!=",
"null",
"&&",
"bundles",
".",
"contains",
"(",
"bundleName",
")",
"||",
"projectName",
"!=",
"null",
"&&",
"bundles",
".",
"contains",
"(",
"projectName",
")",
")",
"{",
"bundlesToMerge",
"=",
"new",
"LinkedHashSet",
"<",
"String",
">",
"(",
"bundles",
")",
";",
"bundlesToMerge",
".",
"remove",
"(",
"bundleName",
")",
";",
"bundlesToMerge",
".",
"remove",
"(",
"projectName",
")",
";",
"}",
"else",
"{",
"bundlesToMerge",
"=",
"bundles",
";",
"}",
"String",
"s",
"=",
"(",
"String",
")",
"getMainAttributes",
"(",
")",
".",
"get",
"(",
"REQUIRE_BUNDLE",
")",
";",
"Wrapper",
"<",
"Boolean",
">",
"modified",
"=",
"Wrapper",
".",
"wrap",
"(",
"this",
".",
"modified",
")",
";",
"String",
"result",
"=",
"mergeIntoCommaSeparatedList",
"(",
"s",
",",
"bundlesToMerge",
",",
"modified",
",",
"lineDelimiter",
")",
";",
"this",
".",
"modified",
"=",
"modified",
".",
"get",
"(",
")",
";",
"getMainAttributes",
"(",
")",
".",
"put",
"(",
"REQUIRE_BUNDLE",
",",
"result",
")",
";",
"}"
] | adds the qualified names to the require-bundle attribute, if not already
present.
@param bundles - passing parameterized bundled (e.g. versions, etc.) is
not supported | [
"adds",
"the",
"qualified",
"names",
"to",
"the",
"require",
"-",
"bundle",
"attribute",
"if",
"not",
"already",
"present",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest.java#L221-L245 |
162,037 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest.java | MergeableManifest.addExportedPackages | public void addExportedPackages(Set<String> packages) {
String s = (String) getMainAttributes().get(EXPORT_PACKAGE);
Wrapper<Boolean> modified = Wrapper.wrap(this.modified);
String result = mergeIntoCommaSeparatedList(s, packages, modified, lineDelimiter);
this.modified = modified.get();
getMainAttributes().put(EXPORT_PACKAGE, result);
} | java | public void addExportedPackages(Set<String> packages) {
String s = (String) getMainAttributes().get(EXPORT_PACKAGE);
Wrapper<Boolean> modified = Wrapper.wrap(this.modified);
String result = mergeIntoCommaSeparatedList(s, packages, modified, lineDelimiter);
this.modified = modified.get();
getMainAttributes().put(EXPORT_PACKAGE, result);
} | [
"public",
"void",
"addExportedPackages",
"(",
"Set",
"<",
"String",
">",
"packages",
")",
"{",
"String",
"s",
"=",
"(",
"String",
")",
"getMainAttributes",
"(",
")",
".",
"get",
"(",
"EXPORT_PACKAGE",
")",
";",
"Wrapper",
"<",
"Boolean",
">",
"modified",
"=",
"Wrapper",
".",
"wrap",
"(",
"this",
".",
"modified",
")",
";",
"String",
"result",
"=",
"mergeIntoCommaSeparatedList",
"(",
"s",
",",
"packages",
",",
"modified",
",",
"lineDelimiter",
")",
";",
"this",
".",
"modified",
"=",
"modified",
".",
"get",
"(",
")",
";",
"getMainAttributes",
"(",
")",
".",
"put",
"(",
"EXPORT_PACKAGE",
",",
"result",
")",
";",
"}"
] | adds the qualified names to the export-package attribute, if not already
present.
@param packages - passing parameterized packages is not supported | [
"adds",
"the",
"qualified",
"names",
"to",
"the",
"export",
"-",
"package",
"attribute",
"if",
"not",
"already",
"present",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/MergeableManifest.java#L329-L335 |
162,038 | eclipse/xtext-core | org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/editor/contentassist/IdeContentProposalProvider.java | IdeContentProposalProvider.createProposals | public void createProposals(final Collection<ContentAssistContext> contexts, final IIdeContentProposalAcceptor acceptor) {
Iterable<ContentAssistContext> _filteredContexts = this.getFilteredContexts(contexts);
for (final ContentAssistContext context : _filteredContexts) {
ImmutableList<AbstractElement> _firstSetGrammarElements = context.getFirstSetGrammarElements();
for (final AbstractElement element : _firstSetGrammarElements) {
{
boolean _canAcceptMoreProposals = acceptor.canAcceptMoreProposals();
boolean _not = (!_canAcceptMoreProposals);
if (_not) {
return;
}
this.createProposals(element, context, acceptor);
}
}
}
} | java | public void createProposals(final Collection<ContentAssistContext> contexts, final IIdeContentProposalAcceptor acceptor) {
Iterable<ContentAssistContext> _filteredContexts = this.getFilteredContexts(contexts);
for (final ContentAssistContext context : _filteredContexts) {
ImmutableList<AbstractElement> _firstSetGrammarElements = context.getFirstSetGrammarElements();
for (final AbstractElement element : _firstSetGrammarElements) {
{
boolean _canAcceptMoreProposals = acceptor.canAcceptMoreProposals();
boolean _not = (!_canAcceptMoreProposals);
if (_not) {
return;
}
this.createProposals(element, context, acceptor);
}
}
}
} | [
"public",
"void",
"createProposals",
"(",
"final",
"Collection",
"<",
"ContentAssistContext",
">",
"contexts",
",",
"final",
"IIdeContentProposalAcceptor",
"acceptor",
")",
"{",
"Iterable",
"<",
"ContentAssistContext",
">",
"_filteredContexts",
"=",
"this",
".",
"getFilteredContexts",
"(",
"contexts",
")",
";",
"for",
"(",
"final",
"ContentAssistContext",
"context",
":",
"_filteredContexts",
")",
"{",
"ImmutableList",
"<",
"AbstractElement",
">",
"_firstSetGrammarElements",
"=",
"context",
".",
"getFirstSetGrammarElements",
"(",
")",
";",
"for",
"(",
"final",
"AbstractElement",
"element",
":",
"_firstSetGrammarElements",
")",
"{",
"{",
"boolean",
"_canAcceptMoreProposals",
"=",
"acceptor",
".",
"canAcceptMoreProposals",
"(",
")",
";",
"boolean",
"_not",
"=",
"(",
"!",
"_canAcceptMoreProposals",
")",
";",
"if",
"(",
"_not",
")",
"{",
"return",
";",
"}",
"this",
".",
"createProposals",
"(",
"element",
",",
"context",
",",
"acceptor",
")",
";",
"}",
"}",
"}",
"}"
] | Create content assist proposals and pass them to the given acceptor. | [
"Create",
"content",
"assist",
"proposals",
"and",
"pass",
"them",
"to",
"the",
"given",
"acceptor",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.ide/xtend-gen/org/eclipse/xtext/ide/editor/contentassist/IdeContentProposalProvider.java#L83-L98 |
162,039 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/JavaStringConverter.java | JavaStringConverter.convertFromJavaString | public String convertFromJavaString(String string, boolean useUnicode) {
int firstEscapeSequence = string.indexOf('\\');
if (firstEscapeSequence == -1) {
return string;
}
int length = string.length();
StringBuilder result = new StringBuilder(length);
appendRegion(string, 0, firstEscapeSequence, result);
return convertFromJavaString(string, useUnicode, firstEscapeSequence, result);
} | java | public String convertFromJavaString(String string, boolean useUnicode) {
int firstEscapeSequence = string.indexOf('\\');
if (firstEscapeSequence == -1) {
return string;
}
int length = string.length();
StringBuilder result = new StringBuilder(length);
appendRegion(string, 0, firstEscapeSequence, result);
return convertFromJavaString(string, useUnicode, firstEscapeSequence, result);
} | [
"public",
"String",
"convertFromJavaString",
"(",
"String",
"string",
",",
"boolean",
"useUnicode",
")",
"{",
"int",
"firstEscapeSequence",
"=",
"string",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"firstEscapeSequence",
"==",
"-",
"1",
")",
"{",
"return",
"string",
";",
"}",
"int",
"length",
"=",
"string",
".",
"length",
"(",
")",
";",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"length",
")",
";",
"appendRegion",
"(",
"string",
",",
"0",
",",
"firstEscapeSequence",
",",
"result",
")",
";",
"return",
"convertFromJavaString",
"(",
"string",
",",
"useUnicode",
",",
"firstEscapeSequence",
",",
"result",
")",
";",
"}"
] | Resolve Java control character sequences to the actual character value.
Optionally handle unicode escape sequences, too. | [
"Resolve",
"Java",
"control",
"character",
"sequences",
"to",
"the",
"actual",
"character",
"value",
".",
"Optionally",
"handle",
"unicode",
"escape",
"sequences",
"too",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/JavaStringConverter.java#L23-L32 |
162,040 | eclipse/xtext-core | org.eclipse.xtext.util/src/org/eclipse/xtext/util/JavaStringConverter.java | JavaStringConverter.convertToJavaString | public String convertToJavaString(String input, boolean useUnicode) {
int length = input.length();
StringBuilder result = new StringBuilder(length + 4);
for (int i = 0; i < length; i++) {
escapeAndAppendTo(input.charAt(i), useUnicode, result);
}
return result.toString();
} | java | public String convertToJavaString(String input, boolean useUnicode) {
int length = input.length();
StringBuilder result = new StringBuilder(length + 4);
for (int i = 0; i < length; i++) {
escapeAndAppendTo(input.charAt(i), useUnicode, result);
}
return result.toString();
} | [
"public",
"String",
"convertToJavaString",
"(",
"String",
"input",
",",
"boolean",
"useUnicode",
")",
"{",
"int",
"length",
"=",
"input",
".",
"length",
"(",
")",
";",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
"length",
"+",
"4",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"escapeAndAppendTo",
"(",
"input",
".",
"charAt",
"(",
"i",
")",
",",
"useUnicode",
",",
"result",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] | Escapes control characters with a preceding backslash.
Optionally encodes special chars as unicode escape sequence.
The resulting string is safe to be put into a Java string literal between
the quotes. | [
"Escapes",
"control",
"characters",
"with",
"a",
"preceding",
"backslash",
".",
"Optionally",
"encodes",
"special",
"chars",
"as",
"unicode",
"escape",
"sequence",
".",
"The",
"resulting",
"string",
"is",
"safe",
"to",
"be",
"put",
"into",
"a",
"Java",
"string",
"literal",
"between",
"the",
"quotes",
"."
] | bac941cb75cb24706519845ec174cfef874d7557 | https://github.com/eclipse/xtext-core/blob/bac941cb75cb24706519845ec174cfef874d7557/org.eclipse.xtext.util/src/org/eclipse/xtext/util/JavaStringConverter.java#L181-L188 |
162,041 | michel-kraemer/gradle-download-task | src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java | DownloadAction.performDownload | private void performDownload(HttpResponse response, File destFile)
throws IOException {
HttpEntity entity = response.getEntity();
if (entity == null) {
return;
}
//get content length
long contentLength = entity.getContentLength();
if (contentLength >= 0) {
size = toLengthText(contentLength);
}
processedBytes = 0;
loggedKb = 0;
//open stream and start downloading
InputStream is = entity.getContent();
streamAndMove(is, destFile);
} | java | private void performDownload(HttpResponse response, File destFile)
throws IOException {
HttpEntity entity = response.getEntity();
if (entity == null) {
return;
}
//get content length
long contentLength = entity.getContentLength();
if (contentLength >= 0) {
size = toLengthText(contentLength);
}
processedBytes = 0;
loggedKb = 0;
//open stream and start downloading
InputStream is = entity.getContent();
streamAndMove(is, destFile);
} | [
"private",
"void",
"performDownload",
"(",
"HttpResponse",
"response",
",",
"File",
"destFile",
")",
"throws",
"IOException",
"{",
"HttpEntity",
"entity",
"=",
"response",
".",
"getEntity",
"(",
")",
";",
"if",
"(",
"entity",
"==",
"null",
")",
"{",
"return",
";",
"}",
"//get content length",
"long",
"contentLength",
"=",
"entity",
".",
"getContentLength",
"(",
")",
";",
"if",
"(",
"contentLength",
">=",
"0",
")",
"{",
"size",
"=",
"toLengthText",
"(",
"contentLength",
")",
";",
"}",
"processedBytes",
"=",
"0",
";",
"loggedKb",
"=",
"0",
";",
"//open stream and start downloading",
"InputStream",
"is",
"=",
"entity",
".",
"getContent",
"(",
")",
";",
"streamAndMove",
"(",
"is",
",",
"destFile",
")",
";",
"}"
] | Save an HTTP response to a file
@param response the response to save
@param destFile the destination file
@throws IOException if the response could not be downloaded | [
"Save",
"an",
"HTTP",
"response",
"to",
"a",
"file"
] | a20c7f29c15ccb699700518f860373692148e3fc | https://github.com/michel-kraemer/gradle-download-task/blob/a20c7f29c15ccb699700518f860373692148e3fc/src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java#L297-L316 |
162,042 | michel-kraemer/gradle-download-task | src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java | DownloadAction.stream | private void stream(InputStream is, File destFile) throws IOException {
try {
startProgress();
OutputStream os = new FileOutputStream(destFile);
boolean finished = false;
try {
byte[] buf = new byte[1024 * 10];
int read;
while ((read = is.read(buf)) >= 0) {
os.write(buf, 0, read);
processedBytes += read;
logProgress();
}
os.flush();
finished = true;
} finally {
os.close();
if (!finished) {
destFile.delete();
}
}
} finally {
is.close();
completeProgress();
}
} | java | private void stream(InputStream is, File destFile) throws IOException {
try {
startProgress();
OutputStream os = new FileOutputStream(destFile);
boolean finished = false;
try {
byte[] buf = new byte[1024 * 10];
int read;
while ((read = is.read(buf)) >= 0) {
os.write(buf, 0, read);
processedBytes += read;
logProgress();
}
os.flush();
finished = true;
} finally {
os.close();
if (!finished) {
destFile.delete();
}
}
} finally {
is.close();
completeProgress();
}
} | [
"private",
"void",
"stream",
"(",
"InputStream",
"is",
",",
"File",
"destFile",
")",
"throws",
"IOException",
"{",
"try",
"{",
"startProgress",
"(",
")",
";",
"OutputStream",
"os",
"=",
"new",
"FileOutputStream",
"(",
"destFile",
")",
";",
"boolean",
"finished",
"=",
"false",
";",
"try",
"{",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"1024",
"*",
"10",
"]",
";",
"int",
"read",
";",
"while",
"(",
"(",
"read",
"=",
"is",
".",
"read",
"(",
"buf",
")",
")",
">=",
"0",
")",
"{",
"os",
".",
"write",
"(",
"buf",
",",
"0",
",",
"read",
")",
";",
"processedBytes",
"+=",
"read",
";",
"logProgress",
"(",
")",
";",
"}",
"os",
".",
"flush",
"(",
")",
";",
"finished",
"=",
"true",
";",
"}",
"finally",
"{",
"os",
".",
"close",
"(",
")",
";",
"if",
"(",
"!",
"finished",
")",
"{",
"destFile",
".",
"delete",
"(",
")",
";",
"}",
"}",
"}",
"finally",
"{",
"is",
".",
"close",
"(",
")",
";",
"completeProgress",
"(",
")",
";",
"}",
"}"
] | Copy bytes from an input stream to a file and log progress
@param is the input stream to read
@param destFile the file to write to
@throws IOException if an I/O error occurs | [
"Copy",
"bytes",
"from",
"an",
"input",
"stream",
"to",
"a",
"file",
"and",
"log",
"progress"
] | a20c7f29c15ccb699700518f860373692148e3fc | https://github.com/michel-kraemer/gradle-download-task/blob/a20c7f29c15ccb699700518f860373692148e3fc/src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java#L363-L390 |
162,043 | michel-kraemer/gradle-download-task | src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java | DownloadAction.getCachedETag | private String getCachedETag(HttpHost host, String file) {
Map<String, Object> cachedETags = readCachedETags();
@SuppressWarnings("unchecked")
Map<String, Object> hostMap =
(Map<String, Object>)cachedETags.get(host.toURI());
if (hostMap == null) {
return null;
}
@SuppressWarnings("unchecked")
Map<String, String> etagMap = (Map<String, String>)hostMap.get(file);
if (etagMap == null) {
return null;
}
return etagMap.get("ETag");
} | java | private String getCachedETag(HttpHost host, String file) {
Map<String, Object> cachedETags = readCachedETags();
@SuppressWarnings("unchecked")
Map<String, Object> hostMap =
(Map<String, Object>)cachedETags.get(host.toURI());
if (hostMap == null) {
return null;
}
@SuppressWarnings("unchecked")
Map<String, String> etagMap = (Map<String, String>)hostMap.get(file);
if (etagMap == null) {
return null;
}
return etagMap.get("ETag");
} | [
"private",
"String",
"getCachedETag",
"(",
"HttpHost",
"host",
",",
"String",
"file",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"cachedETags",
"=",
"readCachedETags",
"(",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"String",
",",
"Object",
">",
"hostMap",
"=",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"cachedETags",
".",
"get",
"(",
"host",
".",
"toURI",
"(",
")",
")",
";",
"if",
"(",
"hostMap",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"String",
",",
"String",
">",
"etagMap",
"=",
"(",
"Map",
"<",
"String",
",",
"String",
">",
")",
"hostMap",
".",
"get",
"(",
"file",
")",
";",
"if",
"(",
"etagMap",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"etagMap",
".",
"get",
"(",
"\"ETag\"",
")",
";",
"}"
] | Get the cached ETag for the given host and file
@param host the host
@param file the file
@return the cached ETag or null if there is no ETag in the cache | [
"Get",
"the",
"cached",
"ETag",
"for",
"the",
"given",
"host",
"and",
"file"
] | a20c7f29c15ccb699700518f860373692148e3fc | https://github.com/michel-kraemer/gradle-download-task/blob/a20c7f29c15ccb699700518f860373692148e3fc/src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java#L416-L433 |
162,044 | michel-kraemer/gradle-download-task | src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java | DownloadAction.makeDestFile | private File makeDestFile(URL src) {
if (dest == null) {
throw new IllegalArgumentException("Please provide a download destination");
}
File destFile = dest;
if (destFile.isDirectory()) {
//guess name from URL
String name = src.toString();
if (name.endsWith("/")) {
name = name.substring(0, name.length() - 1);
}
name = name.substring(name.lastIndexOf('/') + 1);
destFile = new File(dest, name);
} else {
//create destination directory
File parent = destFile.getParentFile();
if (parent != null) {
parent.mkdirs();
}
}
return destFile;
} | java | private File makeDestFile(URL src) {
if (dest == null) {
throw new IllegalArgumentException("Please provide a download destination");
}
File destFile = dest;
if (destFile.isDirectory()) {
//guess name from URL
String name = src.toString();
if (name.endsWith("/")) {
name = name.substring(0, name.length() - 1);
}
name = name.substring(name.lastIndexOf('/') + 1);
destFile = new File(dest, name);
} else {
//create destination directory
File parent = destFile.getParentFile();
if (parent != null) {
parent.mkdirs();
}
}
return destFile;
} | [
"private",
"File",
"makeDestFile",
"(",
"URL",
"src",
")",
"{",
"if",
"(",
"dest",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Please provide a download destination\"",
")",
";",
"}",
"File",
"destFile",
"=",
"dest",
";",
"if",
"(",
"destFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"//guess name from URL",
"String",
"name",
"=",
"src",
".",
"toString",
"(",
")",
";",
"if",
"(",
"name",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"name",
"=",
"name",
".",
"substring",
"(",
"0",
",",
"name",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"name",
"=",
"name",
".",
"substring",
"(",
"name",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"destFile",
"=",
"new",
"File",
"(",
"dest",
",",
"name",
")",
";",
"}",
"else",
"{",
"//create destination directory",
"File",
"parent",
"=",
"destFile",
".",
"getParentFile",
"(",
")",
";",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"parent",
".",
"mkdirs",
"(",
")",
";",
"}",
"}",
"return",
"destFile",
";",
"}"
] | Generates the path to an output file for a given source URL. Creates
all necessary parent directories for the destination file.
@param src the source
@return the path to the output file | [
"Generates",
"the",
"path",
"to",
"an",
"output",
"file",
"for",
"a",
"given",
"source",
"URL",
".",
"Creates",
"all",
"necessary",
"parent",
"directories",
"for",
"the",
"destination",
"file",
"."
] | a20c7f29c15ccb699700518f860373692148e3fc | https://github.com/michel-kraemer/gradle-download-task/blob/a20c7f29c15ccb699700518f860373692148e3fc/src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java#L517-L539 |
162,045 | michel-kraemer/gradle-download-task | src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java | DownloadAction.addAuthentication | private void addAuthentication(HttpHost host, Credentials credentials,
AuthScheme authScheme, HttpClientContext context) {
AuthCache authCache = context.getAuthCache();
if (authCache == null) {
authCache = new BasicAuthCache();
context.setAuthCache(authCache);
}
CredentialsProvider credsProvider = context.getCredentialsProvider();
if (credsProvider == null) {
credsProvider = new BasicCredentialsProvider();
context.setCredentialsProvider(credsProvider);
}
credsProvider.setCredentials(new AuthScope(host), credentials);
if (authScheme != null) {
authCache.put(host, authScheme);
}
} | java | private void addAuthentication(HttpHost host, Credentials credentials,
AuthScheme authScheme, HttpClientContext context) {
AuthCache authCache = context.getAuthCache();
if (authCache == null) {
authCache = new BasicAuthCache();
context.setAuthCache(authCache);
}
CredentialsProvider credsProvider = context.getCredentialsProvider();
if (credsProvider == null) {
credsProvider = new BasicCredentialsProvider();
context.setCredentialsProvider(credsProvider);
}
credsProvider.setCredentials(new AuthScope(host), credentials);
if (authScheme != null) {
authCache.put(host, authScheme);
}
} | [
"private",
"void",
"addAuthentication",
"(",
"HttpHost",
"host",
",",
"Credentials",
"credentials",
",",
"AuthScheme",
"authScheme",
",",
"HttpClientContext",
"context",
")",
"{",
"AuthCache",
"authCache",
"=",
"context",
".",
"getAuthCache",
"(",
")",
";",
"if",
"(",
"authCache",
"==",
"null",
")",
"{",
"authCache",
"=",
"new",
"BasicAuthCache",
"(",
")",
";",
"context",
".",
"setAuthCache",
"(",
"authCache",
")",
";",
"}",
"CredentialsProvider",
"credsProvider",
"=",
"context",
".",
"getCredentialsProvider",
"(",
")",
";",
"if",
"(",
"credsProvider",
"==",
"null",
")",
"{",
"credsProvider",
"=",
"new",
"BasicCredentialsProvider",
"(",
")",
";",
"context",
".",
"setCredentialsProvider",
"(",
"credsProvider",
")",
";",
"}",
"credsProvider",
".",
"setCredentials",
"(",
"new",
"AuthScope",
"(",
"host",
")",
",",
"credentials",
")",
";",
"if",
"(",
"authScheme",
"!=",
"null",
")",
"{",
"authCache",
".",
"put",
"(",
"host",
",",
"authScheme",
")",
";",
"}",
"}"
] | Add authentication information for the given host
@param host the host
@param credentials the credentials
@param authScheme the scheme for preemptive authentication (should be
<code>null</code> if adding authentication for a proxy server)
@param context the context in which the authentication information
should be saved | [
"Add",
"authentication",
"information",
"for",
"the",
"given",
"host"
] | a20c7f29c15ccb699700518f860373692148e3fc | https://github.com/michel-kraemer/gradle-download-task/blob/a20c7f29c15ccb699700518f860373692148e3fc/src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java#L656-L675 |
162,046 | michel-kraemer/gradle-download-task | src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java | DownloadAction.toLengthText | private String toLengthText(long bytes) {
if (bytes < 1024) {
return bytes + " B";
} else if (bytes < 1024 * 1024) {
return (bytes / 1024) + " KB";
} else if (bytes < 1024 * 1024 * 1024) {
return String.format("%.2f MB", bytes / (1024.0 * 1024.0));
} else {
return String.format("%.2f GB", bytes / (1024.0 * 1024.0 * 1024.0));
}
} | java | private String toLengthText(long bytes) {
if (bytes < 1024) {
return bytes + " B";
} else if (bytes < 1024 * 1024) {
return (bytes / 1024) + " KB";
} else if (bytes < 1024 * 1024 * 1024) {
return String.format("%.2f MB", bytes / (1024.0 * 1024.0));
} else {
return String.format("%.2f GB", bytes / (1024.0 * 1024.0 * 1024.0));
}
} | [
"private",
"String",
"toLengthText",
"(",
"long",
"bytes",
")",
"{",
"if",
"(",
"bytes",
"<",
"1024",
")",
"{",
"return",
"bytes",
"+",
"\" B\"",
";",
"}",
"else",
"if",
"(",
"bytes",
"<",
"1024",
"*",
"1024",
")",
"{",
"return",
"(",
"bytes",
"/",
"1024",
")",
"+",
"\" KB\"",
";",
"}",
"else",
"if",
"(",
"bytes",
"<",
"1024",
"*",
"1024",
"*",
"1024",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%.2f MB\"",
",",
"bytes",
"/",
"(",
"1024.0",
"*",
"1024.0",
")",
")",
";",
"}",
"else",
"{",
"return",
"String",
".",
"format",
"(",
"\"%.2f GB\"",
",",
"bytes",
"/",
"(",
"1024.0",
"*",
"1024.0",
"*",
"1024.0",
")",
")",
";",
"}",
"}"
] | Converts a number of bytes to a human-readable string
@param bytes the bytes
@return the human-readable string | [
"Converts",
"a",
"number",
"of",
"bytes",
"to",
"a",
"human",
"-",
"readable",
"string"
] | a20c7f29c15ccb699700518f860373692148e3fc | https://github.com/michel-kraemer/gradle-download-task/blob/a20c7f29c15ccb699700518f860373692148e3fc/src/main/java/de/undercouch/gradle/tasks/download/DownloadAction.java#L682-L692 |
162,047 | michel-kraemer/gradle-download-task | src/main/java/de/undercouch/gradle/tasks/download/internal/CachingHttpClientFactory.java | CachingHttpClientFactory.close | public void close() throws IOException {
for (CloseableHttpClient c : cachedClients.values()) {
c.close();
}
cachedClients.clear();
} | java | public void close() throws IOException {
for (CloseableHttpClient c : cachedClients.values()) {
c.close();
}
cachedClients.clear();
} | [
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"for",
"(",
"CloseableHttpClient",
"c",
":",
"cachedClients",
".",
"values",
"(",
")",
")",
"{",
"c",
".",
"close",
"(",
")",
";",
"}",
"cachedClients",
".",
"clear",
"(",
")",
";",
"}"
] | Close all HTTP clients created by this factory
@throws IOException if an I/O error occurs | [
"Close",
"all",
"HTTP",
"clients",
"created",
"by",
"this",
"factory"
] | a20c7f29c15ccb699700518f860373692148e3fc | https://github.com/michel-kraemer/gradle-download-task/blob/a20c7f29c15ccb699700518f860373692148e3fc/src/main/java/de/undercouch/gradle/tasks/download/internal/CachingHttpClientFactory.java#L54-L59 |
162,048 | tulskiy/jkeymaster | core/src/main/java/com/tulskiy/keymaster/common/Provider.java | Provider.getCurrentProvider | public static Provider getCurrentProvider(boolean useSwingEventQueue) {
Provider provider;
if (Platform.isX11()) {
provider = new X11Provider();
} else if (Platform.isWindows()) {
provider = new WindowsProvider();
} else if (Platform.isMac()) {
provider = new CarbonProvider();
} else {
LOGGER.warn("No suitable provider for " + System.getProperty("os.name"));
return null;
}
provider.setUseSwingEventQueue(useSwingEventQueue);
provider.init();
return provider;
} | java | public static Provider getCurrentProvider(boolean useSwingEventQueue) {
Provider provider;
if (Platform.isX11()) {
provider = new X11Provider();
} else if (Platform.isWindows()) {
provider = new WindowsProvider();
} else if (Platform.isMac()) {
provider = new CarbonProvider();
} else {
LOGGER.warn("No suitable provider for " + System.getProperty("os.name"));
return null;
}
provider.setUseSwingEventQueue(useSwingEventQueue);
provider.init();
return provider;
} | [
"public",
"static",
"Provider",
"getCurrentProvider",
"(",
"boolean",
"useSwingEventQueue",
")",
"{",
"Provider",
"provider",
";",
"if",
"(",
"Platform",
".",
"isX11",
"(",
")",
")",
"{",
"provider",
"=",
"new",
"X11Provider",
"(",
")",
";",
"}",
"else",
"if",
"(",
"Platform",
".",
"isWindows",
"(",
")",
")",
"{",
"provider",
"=",
"new",
"WindowsProvider",
"(",
")",
";",
"}",
"else",
"if",
"(",
"Platform",
".",
"isMac",
"(",
")",
")",
"{",
"provider",
"=",
"new",
"CarbonProvider",
"(",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"No suitable provider for \"",
"+",
"System",
".",
"getProperty",
"(",
"\"os.name\"",
")",
")",
";",
"return",
"null",
";",
"}",
"provider",
".",
"setUseSwingEventQueue",
"(",
"useSwingEventQueue",
")",
";",
"provider",
".",
"init",
"(",
")",
";",
"return",
"provider",
";",
"}"
] | Get global hotkey provider for current platform
@param useSwingEventQueue whether the provider should be using Swing Event queue or a regular thread
@return new instance of Provider, or null if platform is not supported
@see X11Provider
@see WindowsProvider
@see CarbonProvider | [
"Get",
"global",
"hotkey",
"provider",
"for",
"current",
"platform"
] | 85ac2fa90d26d8d0e4ee4e3fa57c9d56c7946371 | https://github.com/tulskiy/jkeymaster/blob/85ac2fa90d26d8d0e4ee4e3fa57c9d56c7946371/core/src/main/java/com/tulskiy/keymaster/common/Provider.java#L55-L71 |
162,049 | tulskiy/jkeymaster | core/src/main/java/com/tulskiy/keymaster/common/Provider.java | Provider.fireEvent | protected void fireEvent(HotKey hotKey) {
HotKeyEvent event = new HotKeyEvent(hotKey);
if (useSwingEventQueue) {
SwingUtilities.invokeLater(event);
} else {
if (eventQueue == null) {
eventQueue = Executors.newSingleThreadExecutor();
}
eventQueue.execute(event);
}
} | java | protected void fireEvent(HotKey hotKey) {
HotKeyEvent event = new HotKeyEvent(hotKey);
if (useSwingEventQueue) {
SwingUtilities.invokeLater(event);
} else {
if (eventQueue == null) {
eventQueue = Executors.newSingleThreadExecutor();
}
eventQueue.execute(event);
}
} | [
"protected",
"void",
"fireEvent",
"(",
"HotKey",
"hotKey",
")",
"{",
"HotKeyEvent",
"event",
"=",
"new",
"HotKeyEvent",
"(",
"hotKey",
")",
";",
"if",
"(",
"useSwingEventQueue",
")",
"{",
"SwingUtilities",
".",
"invokeLater",
"(",
"event",
")",
";",
"}",
"else",
"{",
"if",
"(",
"eventQueue",
"==",
"null",
")",
"{",
"eventQueue",
"=",
"Executors",
".",
"newSingleThreadExecutor",
"(",
")",
";",
"}",
"eventQueue",
".",
"execute",
"(",
"event",
")",
";",
"}",
"}"
] | Helper method fro providers to fire hotkey event in a separate thread
@param hotKey hotkey to fire | [
"Helper",
"method",
"fro",
"providers",
"to",
"fire",
"hotkey",
"event",
"in",
"a",
"separate",
"thread"
] | 85ac2fa90d26d8d0e4ee4e3fa57c9d56c7946371 | https://github.com/tulskiy/jkeymaster/blob/85ac2fa90d26d8d0e4ee4e3fa57c9d56c7946371/core/src/main/java/com/tulskiy/keymaster/common/Provider.java#L128-L138 |
162,050 | jbehave/jbehave-core | jbehave-groovy/src/main/java/org/jbehave/core/configuration/groovy/GroovyContext.java | GroovyContext.newInstance | public Object newInstance(String resource) {
try {
String name = resource.startsWith("/") ? resource : "/" + resource;
File file = new File(this.getClass().getResource(name).toURI());
return newInstance(classLoader.parseClass(new GroovyCodeSource(file), true));
} catch (Exception e) {
throw new GroovyClassInstantiationFailed(classLoader, resource, e);
}
} | java | public Object newInstance(String resource) {
try {
String name = resource.startsWith("/") ? resource : "/" + resource;
File file = new File(this.getClass().getResource(name).toURI());
return newInstance(classLoader.parseClass(new GroovyCodeSource(file), true));
} catch (Exception e) {
throw new GroovyClassInstantiationFailed(classLoader, resource, e);
}
} | [
"public",
"Object",
"newInstance",
"(",
"String",
"resource",
")",
"{",
"try",
"{",
"String",
"name",
"=",
"resource",
".",
"startsWith",
"(",
"\"/\"",
")",
"?",
"resource",
":",
"\"/\"",
"+",
"resource",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"this",
".",
"getClass",
"(",
")",
".",
"getResource",
"(",
"name",
")",
".",
"toURI",
"(",
")",
")",
";",
"return",
"newInstance",
"(",
"classLoader",
".",
"parseClass",
"(",
"new",
"GroovyCodeSource",
"(",
"file",
")",
",",
"true",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"GroovyClassInstantiationFailed",
"(",
"classLoader",
",",
"resource",
",",
"e",
")",
";",
"}",
"}"
] | Creates an object instance from the Groovy resource
@param resource the Groovy resource to parse
@return An Object instance | [
"Creates",
"an",
"object",
"instance",
"from",
"the",
"Groovy",
"resource"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-groovy/src/main/java/org/jbehave/core/configuration/groovy/GroovyContext.java#L59-L67 |
162,051 | jbehave/jbehave-core | jbehave-guice/src/main/java/org/jbehave/core/steps/guice/GuiceStepsFactory.java | GuiceStepsFactory.addTypes | private void addTypes(Injector injector, List<Class<?>> types) {
for (Binding<?> binding : injector.getBindings().values()) {
Key<?> key = binding.getKey();
Type type = key.getTypeLiteral().getType();
if (hasAnnotatedMethods(type)) {
types.add(((Class<?>)type));
}
}
if (injector.getParent() != null) {
addTypes(injector.getParent(), types);
}
} | java | private void addTypes(Injector injector, List<Class<?>> types) {
for (Binding<?> binding : injector.getBindings().values()) {
Key<?> key = binding.getKey();
Type type = key.getTypeLiteral().getType();
if (hasAnnotatedMethods(type)) {
types.add(((Class<?>)type));
}
}
if (injector.getParent() != null) {
addTypes(injector.getParent(), types);
}
} | [
"private",
"void",
"addTypes",
"(",
"Injector",
"injector",
",",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"types",
")",
"{",
"for",
"(",
"Binding",
"<",
"?",
">",
"binding",
":",
"injector",
".",
"getBindings",
"(",
")",
".",
"values",
"(",
")",
")",
"{",
"Key",
"<",
"?",
">",
"key",
"=",
"binding",
".",
"getKey",
"(",
")",
";",
"Type",
"type",
"=",
"key",
".",
"getTypeLiteral",
"(",
")",
".",
"getType",
"(",
")",
";",
"if",
"(",
"hasAnnotatedMethods",
"(",
"type",
")",
")",
"{",
"types",
".",
"add",
"(",
"(",
"(",
"Class",
"<",
"?",
">",
")",
"type",
")",
")",
";",
"}",
"}",
"if",
"(",
"injector",
".",
"getParent",
"(",
")",
"!=",
"null",
")",
"{",
"addTypes",
"(",
"injector",
".",
"getParent",
"(",
")",
",",
"types",
")",
";",
"}",
"}"
] | Adds steps types from given injector and recursively its parent
@param injector the current Inject
@param types the List of steps types | [
"Adds",
"steps",
"types",
"from",
"given",
"injector",
"and",
"recursively",
"its",
"parent"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-guice/src/main/java/org/jbehave/core/steps/guice/GuiceStepsFactory.java#L46-L57 |
162,052 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/embedder/StoryMapper.java | StoryMapper.map | public void map(Story story, MetaFilter metaFilter) {
if (metaFilter.allow(story.getMeta())) {
boolean allowed = false;
for (Scenario scenario : story.getScenarios()) {
// scenario also inherits meta from story
Meta inherited = scenario.getMeta().inheritFrom(story.getMeta());
if (metaFilter.allow(inherited)) {
allowed = true;
break;
}
}
if (allowed) {
add(metaFilter.asString(), story);
}
}
} | java | public void map(Story story, MetaFilter metaFilter) {
if (metaFilter.allow(story.getMeta())) {
boolean allowed = false;
for (Scenario scenario : story.getScenarios()) {
// scenario also inherits meta from story
Meta inherited = scenario.getMeta().inheritFrom(story.getMeta());
if (metaFilter.allow(inherited)) {
allowed = true;
break;
}
}
if (allowed) {
add(metaFilter.asString(), story);
}
}
} | [
"public",
"void",
"map",
"(",
"Story",
"story",
",",
"MetaFilter",
"metaFilter",
")",
"{",
"if",
"(",
"metaFilter",
".",
"allow",
"(",
"story",
".",
"getMeta",
"(",
")",
")",
")",
"{",
"boolean",
"allowed",
"=",
"false",
";",
"for",
"(",
"Scenario",
"scenario",
":",
"story",
".",
"getScenarios",
"(",
")",
")",
"{",
"// scenario also inherits meta from story",
"Meta",
"inherited",
"=",
"scenario",
".",
"getMeta",
"(",
")",
".",
"inheritFrom",
"(",
"story",
".",
"getMeta",
"(",
")",
")",
";",
"if",
"(",
"metaFilter",
".",
"allow",
"(",
"inherited",
")",
")",
"{",
"allowed",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"allowed",
")",
"{",
"add",
"(",
"metaFilter",
".",
"asString",
"(",
")",
",",
"story",
")",
";",
"}",
"}",
"}"
] | Maps a story if it is allowed by the meta filter
@param story
the Story
@param metaFilter
the meta filter | [
"Maps",
"a",
"story",
"if",
"it",
"is",
"allowed",
"by",
"the",
"meta",
"filter"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryMapper.java#L33-L48 |
162,053 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/embedder/MetaFilter.java | MetaFilter.createMetaMatcher | protected MetaMatcher createMetaMatcher(String filterAsString, Map<String, MetaMatcher> metaMatchers) {
for ( String key : metaMatchers.keySet() ){
if ( filterAsString.startsWith(key)){
return metaMatchers.get(key);
}
}
if (filterAsString.startsWith(GROOVY)) {
return new GroovyMetaMatcher();
}
return new DefaultMetaMatcher();
} | java | protected MetaMatcher createMetaMatcher(String filterAsString, Map<String, MetaMatcher> metaMatchers) {
for ( String key : metaMatchers.keySet() ){
if ( filterAsString.startsWith(key)){
return metaMatchers.get(key);
}
}
if (filterAsString.startsWith(GROOVY)) {
return new GroovyMetaMatcher();
}
return new DefaultMetaMatcher();
} | [
"protected",
"MetaMatcher",
"createMetaMatcher",
"(",
"String",
"filterAsString",
",",
"Map",
"<",
"String",
",",
"MetaMatcher",
">",
"metaMatchers",
")",
"{",
"for",
"(",
"String",
"key",
":",
"metaMatchers",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"filterAsString",
".",
"startsWith",
"(",
"key",
")",
")",
"{",
"return",
"metaMatchers",
".",
"get",
"(",
"key",
")",
";",
"}",
"}",
"if",
"(",
"filterAsString",
".",
"startsWith",
"(",
"GROOVY",
")",
")",
"{",
"return",
"new",
"GroovyMetaMatcher",
"(",
")",
";",
"}",
"return",
"new",
"DefaultMetaMatcher",
"(",
")",
";",
"}"
] | Creates a MetaMatcher based on the filter content.
@param filterAsString the String representation of the filter
@param metaMatchers the Map of custom MetaMatchers
@return A MetaMatcher used to match the filter content | [
"Creates",
"a",
"MetaMatcher",
"based",
"on",
"the",
"filter",
"content",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/MetaFilter.java#L112-L122 |
162,054 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java | CodeLocations.codeLocationFromClass | public static URL codeLocationFromClass(Class<?> codeLocationClass) {
String pathOfClass = codeLocationClass.getName().replace(".", "/") + ".class";
URL classResource = codeLocationClass.getClassLoader().getResource(pathOfClass);
String codeLocationPath = removeEnd(getPathFromURL(classResource), pathOfClass);
if(codeLocationPath.endsWith(".jar!/")) {
codeLocationPath=removeEnd(codeLocationPath,"!/");
}
return codeLocationFromPath(codeLocationPath);
} | java | public static URL codeLocationFromClass(Class<?> codeLocationClass) {
String pathOfClass = codeLocationClass.getName().replace(".", "/") + ".class";
URL classResource = codeLocationClass.getClassLoader().getResource(pathOfClass);
String codeLocationPath = removeEnd(getPathFromURL(classResource), pathOfClass);
if(codeLocationPath.endsWith(".jar!/")) {
codeLocationPath=removeEnd(codeLocationPath,"!/");
}
return codeLocationFromPath(codeLocationPath);
} | [
"public",
"static",
"URL",
"codeLocationFromClass",
"(",
"Class",
"<",
"?",
">",
"codeLocationClass",
")",
"{",
"String",
"pathOfClass",
"=",
"codeLocationClass",
".",
"getName",
"(",
")",
".",
"replace",
"(",
"\".\"",
",",
"\"/\"",
")",
"+",
"\".class\"",
";",
"URL",
"classResource",
"=",
"codeLocationClass",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"pathOfClass",
")",
";",
"String",
"codeLocationPath",
"=",
"removeEnd",
"(",
"getPathFromURL",
"(",
"classResource",
")",
",",
"pathOfClass",
")",
";",
"if",
"(",
"codeLocationPath",
".",
"endsWith",
"(",
"\".jar!/\"",
")",
")",
"{",
"codeLocationPath",
"=",
"removeEnd",
"(",
"codeLocationPath",
",",
"\"!/\"",
")",
";",
"}",
"return",
"codeLocationFromPath",
"(",
"codeLocationPath",
")",
";",
"}"
] | Creates a code location URL from a class
@param codeLocationClass the class
@return A URL created from Class
@throws InvalidCodeLocation if URL creation fails | [
"Creates",
"a",
"code",
"location",
"URL",
"from",
"a",
"class"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java#L23-L31 |
162,055 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java | CodeLocations.codeLocationFromPath | public static URL codeLocationFromPath(String filePath) {
try {
return new File(filePath).toURI().toURL();
} catch (Exception e) {
throw new InvalidCodeLocation(filePath);
}
} | java | public static URL codeLocationFromPath(String filePath) {
try {
return new File(filePath).toURI().toURL();
} catch (Exception e) {
throw new InvalidCodeLocation(filePath);
}
} | [
"public",
"static",
"URL",
"codeLocationFromPath",
"(",
"String",
"filePath",
")",
"{",
"try",
"{",
"return",
"new",
"File",
"(",
"filePath",
")",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"InvalidCodeLocation",
"(",
"filePath",
")",
";",
"}",
"}"
] | Creates a code location URL from a file path
@param filePath the file path
@return A URL created from File
@throws InvalidCodeLocation if URL creation fails | [
"Creates",
"a",
"code",
"location",
"URL",
"from",
"a",
"file",
"path"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java#L40-L46 |
162,056 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java | CodeLocations.codeLocationFromURL | public static URL codeLocationFromURL(String url) {
try {
return new URL(url);
} catch (Exception e) {
throw new InvalidCodeLocation(url);
}
} | java | public static URL codeLocationFromURL(String url) {
try {
return new URL(url);
} catch (Exception e) {
throw new InvalidCodeLocation(url);
}
} | [
"public",
"static",
"URL",
"codeLocationFromURL",
"(",
"String",
"url",
")",
"{",
"try",
"{",
"return",
"new",
"URL",
"(",
"url",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"InvalidCodeLocation",
"(",
"url",
")",
";",
"}",
"}"
] | Creates a code location URL from a URL
@param url the URL external form
@return A URL created from URL
@throws InvalidCodeLocation if URL creation fails | [
"Creates",
"a",
"code",
"location",
"URL",
"from",
"a",
"URL"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java#L55-L61 |
162,057 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java | StoryRunner.run | public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story) throws Throwable {
run(configuration, candidateSteps, story, MetaFilter.EMPTY);
} | java | public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story) throws Throwable {
run(configuration, candidateSteps, story, MetaFilter.EMPTY);
} | [
"public",
"void",
"run",
"(",
"Configuration",
"configuration",
",",
"List",
"<",
"CandidateSteps",
">",
"candidateSteps",
",",
"Story",
"story",
")",
"throws",
"Throwable",
"{",
"run",
"(",
"configuration",
",",
"candidateSteps",
",",
"story",
",",
"MetaFilter",
".",
"EMPTY",
")",
";",
"}"
] | Runs a Story with the given configuration and steps.
@param configuration the Configuration used to run story
@param candidateSteps the List of CandidateSteps containing the candidate
steps methods
@param story the Story to run
@throws Throwable if failures occurred and FailureStrategy dictates it to
be re-thrown. | [
"Runs",
"a",
"Story",
"with",
"the",
"given",
"configuration",
"and",
"steps",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L123-L125 |
162,058 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java | StoryRunner.run | public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter)
throws Throwable {
run(configuration, candidateSteps, story, filter, null);
} | java | public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter)
throws Throwable {
run(configuration, candidateSteps, story, filter, null);
} | [
"public",
"void",
"run",
"(",
"Configuration",
"configuration",
",",
"List",
"<",
"CandidateSteps",
">",
"candidateSteps",
",",
"Story",
"story",
",",
"MetaFilter",
"filter",
")",
"throws",
"Throwable",
"{",
"run",
"(",
"configuration",
",",
"candidateSteps",
",",
"story",
",",
"filter",
",",
"null",
")",
";",
"}"
] | Runs a Story with the given configuration and steps, applying the given
meta filter.
@param configuration the Configuration used to run story
@param candidateSteps the List of CandidateSteps containing the candidate
steps methods
@param story the Story to run
@param filter the Filter to apply to the story Meta
@throws Throwable if failures occurred and FailureStrategy dictates it to
be re-thrown. | [
"Runs",
"a",
"Story",
"with",
"the",
"given",
"configuration",
"and",
"steps",
"applying",
"the",
"given",
"meta",
"filter",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L139-L142 |
162,059 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java | StoryRunner.run | public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter,
State beforeStories) throws Throwable {
run(configuration, new ProvidedStepsFactory(candidateSteps), story, filter, beforeStories);
} | java | public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter,
State beforeStories) throws Throwable {
run(configuration, new ProvidedStepsFactory(candidateSteps), story, filter, beforeStories);
} | [
"public",
"void",
"run",
"(",
"Configuration",
"configuration",
",",
"List",
"<",
"CandidateSteps",
">",
"candidateSteps",
",",
"Story",
"story",
",",
"MetaFilter",
"filter",
",",
"State",
"beforeStories",
")",
"throws",
"Throwable",
"{",
"run",
"(",
"configuration",
",",
"new",
"ProvidedStepsFactory",
"(",
"candidateSteps",
")",
",",
"story",
",",
"filter",
",",
"beforeStories",
")",
";",
"}"
] | Runs a Story with the given configuration and steps, applying the given
meta filter, and staring from given state.
@param configuration the Configuration used to run story
@param candidateSteps the List of CandidateSteps containing the candidate
steps methods
@param story the Story to run
@param filter the Filter to apply to the story Meta
@param beforeStories the State before running any of the stories, if not
<code>null</code>
@throws Throwable if failures occurred and FailureStrategy dictates it to
be re-thrown. | [
"Runs",
"a",
"Story",
"with",
"the",
"given",
"configuration",
"and",
"steps",
"applying",
"the",
"given",
"meta",
"filter",
"and",
"staring",
"from",
"given",
"state",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L158-L161 |
162,060 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java | StoryRunner.run | public void run(Configuration configuration, InjectableStepsFactory stepsFactory, Story story, MetaFilter filter,
State beforeStories) throws Throwable {
RunContext context = new RunContext(configuration, stepsFactory, story.getPath(), filter);
if (beforeStories != null) {
context.stateIs(beforeStories);
}
Map<String, String> storyParameters = new HashMap<>();
run(context, story, storyParameters);
} | java | public void run(Configuration configuration, InjectableStepsFactory stepsFactory, Story story, MetaFilter filter,
State beforeStories) throws Throwable {
RunContext context = new RunContext(configuration, stepsFactory, story.getPath(), filter);
if (beforeStories != null) {
context.stateIs(beforeStories);
}
Map<String, String> storyParameters = new HashMap<>();
run(context, story, storyParameters);
} | [
"public",
"void",
"run",
"(",
"Configuration",
"configuration",
",",
"InjectableStepsFactory",
"stepsFactory",
",",
"Story",
"story",
",",
"MetaFilter",
"filter",
",",
"State",
"beforeStories",
")",
"throws",
"Throwable",
"{",
"RunContext",
"context",
"=",
"new",
"RunContext",
"(",
"configuration",
",",
"stepsFactory",
",",
"story",
".",
"getPath",
"(",
")",
",",
"filter",
")",
";",
"if",
"(",
"beforeStories",
"!=",
"null",
")",
"{",
"context",
".",
"stateIs",
"(",
"beforeStories",
")",
";",
"}",
"Map",
"<",
"String",
",",
"String",
">",
"storyParameters",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"run",
"(",
"context",
",",
"story",
",",
"storyParameters",
")",
";",
"}"
] | Runs a Story with the given steps factory, applying the given meta
filter, and staring from given state.
@param configuration the Configuration used to run story
@param stepsFactory the InjectableStepsFactory used to created the
candidate steps methods
@param story the Story to run
@param filter the Filter to apply to the story Meta
@param beforeStories the State before running any of the stories, if not
<code>null</code>
@throws Throwable if failures occurred and FailureStrategy dictates it to
be re-thrown. | [
"Runs",
"a",
"Story",
"with",
"the",
"given",
"steps",
"factory",
"applying",
"the",
"given",
"meta",
"filter",
"and",
"staring",
"from",
"given",
"state",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L178-L186 |
162,061 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java | StoryRunner.storyOfPath | public Story storyOfPath(Configuration configuration, String storyPath) {
String storyAsText = configuration.storyLoader().loadStoryAsText(storyPath);
return configuration.storyParser().parseStory(storyAsText, storyPath);
} | java | public Story storyOfPath(Configuration configuration, String storyPath) {
String storyAsText = configuration.storyLoader().loadStoryAsText(storyPath);
return configuration.storyParser().parseStory(storyAsText, storyPath);
} | [
"public",
"Story",
"storyOfPath",
"(",
"Configuration",
"configuration",
",",
"String",
"storyPath",
")",
"{",
"String",
"storyAsText",
"=",
"configuration",
".",
"storyLoader",
"(",
")",
".",
"loadStoryAsText",
"(",
"storyPath",
")",
";",
"return",
"configuration",
".",
"storyParser",
"(",
")",
".",
"parseStory",
"(",
"storyAsText",
",",
"storyPath",
")",
";",
"}"
] | Returns the parsed story from the given path
@param configuration the Configuration used to run story
@param storyPath the story path
@return The parsed Story | [
"Returns",
"the",
"parsed",
"story",
"from",
"the",
"given",
"path"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L195-L198 |
162,062 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java | StoryRunner.storyOfText | public Story storyOfText(Configuration configuration, String storyAsText, String storyId) {
return configuration.storyParser().parseStory(storyAsText, storyId);
} | java | public Story storyOfText(Configuration configuration, String storyAsText, String storyId) {
return configuration.storyParser().parseStory(storyAsText, storyId);
} | [
"public",
"Story",
"storyOfText",
"(",
"Configuration",
"configuration",
",",
"String",
"storyAsText",
",",
"String",
"storyId",
")",
"{",
"return",
"configuration",
".",
"storyParser",
"(",
")",
".",
"parseStory",
"(",
"storyAsText",
",",
"storyId",
")",
";",
"}"
] | Returns the parsed story from the given text
@param configuration the Configuration used to run story
@param storyAsText the story text
@param storyId the story Id, which will be returned as story path
@return The parsed Story | [
"Returns",
"the",
"parsed",
"story",
"from",
"the",
"given",
"text"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L208-L210 |
162,063 | jbehave/jbehave-core | jbehave-scala/src/main/java/org/jbehave/core/configuration/scala/ScalaContext.java | ScalaContext.newInstance | public Object newInstance(String className) {
try {
return classLoader.loadClass(className).newInstance();
} catch (Exception e) {
throw new ScalaInstanceNotFound(className);
}
} | java | public Object newInstance(String className) {
try {
return classLoader.loadClass(className).newInstance();
} catch (Exception e) {
throw new ScalaInstanceNotFound(className);
}
} | [
"public",
"Object",
"newInstance",
"(",
"String",
"className",
")",
"{",
"try",
"{",
"return",
"classLoader",
".",
"loadClass",
"(",
"className",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ScalaInstanceNotFound",
"(",
"className",
")",
";",
"}",
"}"
] | Creates an object instance from the Scala class name
@param className the Scala class name
@return An Object instance | [
"Creates",
"an",
"object",
"instance",
"from",
"the",
"Scala",
"class",
"name"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-scala/src/main/java/org/jbehave/core/configuration/scala/ScalaContext.java#L43-L49 |
162,064 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/steps/ChainedRow.java | ChainedRow.values | @Override
public Map<String, String> values() {
Map<String, String> values = new LinkedHashMap<>();
for (Row each : delegates) {
for (Entry<String, String> entry : each.values().entrySet()) {
String name = entry.getKey();
if (!values.containsKey(name)) {
values.put(name, entry.getValue());
}
}
}
return values;
} | java | @Override
public Map<String, String> values() {
Map<String, String> values = new LinkedHashMap<>();
for (Row each : delegates) {
for (Entry<String, String> entry : each.values().entrySet()) {
String name = entry.getKey();
if (!values.containsKey(name)) {
values.put(name, entry.getValue());
}
}
}
return values;
} | [
"@",
"Override",
"public",
"Map",
"<",
"String",
",",
"String",
">",
"values",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"values",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Row",
"each",
":",
"delegates",
")",
"{",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"each",
".",
"values",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"name",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"!",
"values",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"values",
".",
"put",
"(",
"name",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"values",
";",
"}"
] | Returns values aggregated from all the delegates, without overriding
values that already exist.
@return The Map of aggregated values | [
"Returns",
"values",
"aggregated",
"from",
"all",
"the",
"delegates",
"without",
"overriding",
"values",
"that",
"already",
"exist",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/steps/ChainedRow.java#L24-L36 |
162,065 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/steps/StepFinder.java | StepFinder.stepsInstances | public List<Object> stepsInstances(List<CandidateSteps> candidateSteps) {
List<Object> instances = new ArrayList<>();
for (CandidateSteps steps : candidateSteps) {
if (steps instanceof Steps) {
instances.add(((Steps) steps).instance());
}
}
return instances;
} | java | public List<Object> stepsInstances(List<CandidateSteps> candidateSteps) {
List<Object> instances = new ArrayList<>();
for (CandidateSteps steps : candidateSteps) {
if (steps instanceof Steps) {
instances.add(((Steps) steps).instance());
}
}
return instances;
} | [
"public",
"List",
"<",
"Object",
">",
"stepsInstances",
"(",
"List",
"<",
"CandidateSteps",
">",
"candidateSteps",
")",
"{",
"List",
"<",
"Object",
">",
"instances",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"CandidateSteps",
"steps",
":",
"candidateSteps",
")",
"{",
"if",
"(",
"steps",
"instanceof",
"Steps",
")",
"{",
"instances",
".",
"add",
"(",
"(",
"(",
"Steps",
")",
"steps",
")",
".",
"instance",
"(",
")",
")",
";",
"}",
"}",
"return",
"instances",
";",
"}"
] | Returns the steps instances associated to CandidateSteps
@param candidateSteps
the List of CandidateSteps
@return The List of steps instances | [
"Returns",
"the",
"steps",
"instances",
"associated",
"to",
"CandidateSteps"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/steps/StepFinder.java#L90-L98 |
162,066 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/steps/StepFinder.java | StepFinder.prioritise | public List<StepCandidate> prioritise(String stepAsText, List<StepCandidate> candidates) {
return prioritisingStrategy.prioritise(stepAsText, candidates);
} | java | public List<StepCandidate> prioritise(String stepAsText, List<StepCandidate> candidates) {
return prioritisingStrategy.prioritise(stepAsText, candidates);
} | [
"public",
"List",
"<",
"StepCandidate",
">",
"prioritise",
"(",
"String",
"stepAsText",
",",
"List",
"<",
"StepCandidate",
">",
"candidates",
")",
"{",
"return",
"prioritisingStrategy",
".",
"prioritise",
"(",
"stepAsText",
",",
"candidates",
")",
";",
"}"
] | Prioritises the list of step candidates that match a given step.
@param stepAsText
the textual step to match
@param candidates
the List of StepCandidate
@return The prioritised list according to the
{@link PrioritisingStrategy}. | [
"Prioritises",
"the",
"list",
"of",
"step",
"candidates",
"that",
"match",
"a",
"given",
"step",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/steps/StepFinder.java#L125-L127 |
162,067 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java | PrintStreamOutput.format | protected String format(String key, String defaultPattern, Object... args) {
String escape = escape(defaultPattern);
String s = lookupPattern(key, escape);
Object[] objects = escapeAll(args);
return MessageFormat.format(s, objects);
} | java | protected String format(String key, String defaultPattern, Object... args) {
String escape = escape(defaultPattern);
String s = lookupPattern(key, escape);
Object[] objects = escapeAll(args);
return MessageFormat.format(s, objects);
} | [
"protected",
"String",
"format",
"(",
"String",
"key",
",",
"String",
"defaultPattern",
",",
"Object",
"...",
"args",
")",
"{",
"String",
"escape",
"=",
"escape",
"(",
"defaultPattern",
")",
";",
"String",
"s",
"=",
"lookupPattern",
"(",
"key",
",",
"escape",
")",
";",
"Object",
"[",
"]",
"objects",
"=",
"escapeAll",
"(",
"args",
")",
";",
"return",
"MessageFormat",
".",
"format",
"(",
"s",
",",
"objects",
")",
";",
"}"
] | Formats event output by key, usually equal to the method name.
@param key the event key
@param defaultPattern the default pattern to return if a custom pattern
is not found
@param args the args used to format output
@return A formatted event output | [
"Formats",
"event",
"output",
"by",
"key",
"usually",
"equal",
"to",
"the",
"method",
"name",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java#L462-L467 |
162,068 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java | PrintStreamOutput.escape | protected Object[] escape(final Format format, Object... args) {
// Transformer that escapes HTML,XML,JSON strings
Transformer<Object, Object> escapingTransformer = new Transformer<Object, Object>() {
@Override
public Object transform(Object object) {
return format.escapeValue(object);
}
};
List<Object> list = Arrays.asList(ArrayUtils.clone(args));
CollectionUtils.transform(list, escapingTransformer);
return list.toArray();
} | java | protected Object[] escape(final Format format, Object... args) {
// Transformer that escapes HTML,XML,JSON strings
Transformer<Object, Object> escapingTransformer = new Transformer<Object, Object>() {
@Override
public Object transform(Object object) {
return format.escapeValue(object);
}
};
List<Object> list = Arrays.asList(ArrayUtils.clone(args));
CollectionUtils.transform(list, escapingTransformer);
return list.toArray();
} | [
"protected",
"Object",
"[",
"]",
"escape",
"(",
"final",
"Format",
"format",
",",
"Object",
"...",
"args",
")",
"{",
"// Transformer that escapes HTML,XML,JSON strings",
"Transformer",
"<",
"Object",
",",
"Object",
">",
"escapingTransformer",
"=",
"new",
"Transformer",
"<",
"Object",
",",
"Object",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Object",
"transform",
"(",
"Object",
"object",
")",
"{",
"return",
"format",
".",
"escapeValue",
"(",
"object",
")",
";",
"}",
"}",
";",
"List",
"<",
"Object",
">",
"list",
"=",
"Arrays",
".",
"asList",
"(",
"ArrayUtils",
".",
"clone",
"(",
"args",
")",
")",
";",
"CollectionUtils",
".",
"transform",
"(",
"list",
",",
"escapingTransformer",
")",
";",
"return",
"list",
".",
"toArray",
"(",
")",
";",
"}"
] | Escapes args' string values according to format
@param format the Format used by the PrintStream
@param args the array of args to escape
@return The cloned and escaped array of args | [
"Escapes",
"args",
"string",
"values",
"according",
"to",
"format"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java#L508-L519 |
162,069 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java | PrintStreamOutput.print | protected void print(String text) {
String tableStart = format(PARAMETER_TABLE_START, PARAMETER_TABLE_START);
String tableEnd = format(PARAMETER_TABLE_END, PARAMETER_TABLE_END);
boolean containsTable = text.contains(tableStart) && text.contains(tableEnd);
String textToPrint = containsTable ? transformPrintingTable(text, tableStart, tableEnd) : text;
print(output, textToPrint
.replace(format(PARAMETER_VALUE_START, PARAMETER_VALUE_START), format("parameterValueStart", EMPTY))
.replace(format(PARAMETER_VALUE_END, PARAMETER_VALUE_END), format("parameterValueEnd", EMPTY))
.replace(format(PARAMETER_VALUE_NEWLINE, PARAMETER_VALUE_NEWLINE), format("parameterValueNewline", NL)));
} | java | protected void print(String text) {
String tableStart = format(PARAMETER_TABLE_START, PARAMETER_TABLE_START);
String tableEnd = format(PARAMETER_TABLE_END, PARAMETER_TABLE_END);
boolean containsTable = text.contains(tableStart) && text.contains(tableEnd);
String textToPrint = containsTable ? transformPrintingTable(text, tableStart, tableEnd) : text;
print(output, textToPrint
.replace(format(PARAMETER_VALUE_START, PARAMETER_VALUE_START), format("parameterValueStart", EMPTY))
.replace(format(PARAMETER_VALUE_END, PARAMETER_VALUE_END), format("parameterValueEnd", EMPTY))
.replace(format(PARAMETER_VALUE_NEWLINE, PARAMETER_VALUE_NEWLINE), format("parameterValueNewline", NL)));
} | [
"protected",
"void",
"print",
"(",
"String",
"text",
")",
"{",
"String",
"tableStart",
"=",
"format",
"(",
"PARAMETER_TABLE_START",
",",
"PARAMETER_TABLE_START",
")",
";",
"String",
"tableEnd",
"=",
"format",
"(",
"PARAMETER_TABLE_END",
",",
"PARAMETER_TABLE_END",
")",
";",
"boolean",
"containsTable",
"=",
"text",
".",
"contains",
"(",
"tableStart",
")",
"&&",
"text",
".",
"contains",
"(",
"tableEnd",
")",
";",
"String",
"textToPrint",
"=",
"containsTable",
"?",
"transformPrintingTable",
"(",
"text",
",",
"tableStart",
",",
"tableEnd",
")",
":",
"text",
";",
"print",
"(",
"output",
",",
"textToPrint",
".",
"replace",
"(",
"format",
"(",
"PARAMETER_VALUE_START",
",",
"PARAMETER_VALUE_START",
")",
",",
"format",
"(",
"\"parameterValueStart\"",
",",
"EMPTY",
")",
")",
".",
"replace",
"(",
"format",
"(",
"PARAMETER_VALUE_END",
",",
"PARAMETER_VALUE_END",
")",
",",
"format",
"(",
"\"parameterValueEnd\"",
",",
"EMPTY",
")",
")",
".",
"replace",
"(",
"format",
"(",
"PARAMETER_VALUE_NEWLINE",
",",
"PARAMETER_VALUE_NEWLINE",
")",
",",
"format",
"(",
"\"parameterValueNewline\"",
",",
"NL",
")",
")",
")",
";",
"}"
] | Prints text to output stream, replacing parameter start and end
placeholders
@param text the String to print | [
"Prints",
"text",
"to",
"output",
"stream",
"replacing",
"parameter",
"start",
"and",
"end",
"placeholders"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java#L572-L581 |
162,070 | jbehave/jbehave-core | jbehave-needle/src/main/java/org/jbehave/core/steps/needle/NeedleStepsFactory.java | NeedleStepsFactory.methodReturningConverters | private List<ParameterConverter> methodReturningConverters(final Class<?> type) {
final List<ParameterConverter> converters = new ArrayList<>();
for (final Method method : type.getMethods()) {
if (method.isAnnotationPresent(AsParameterConverter.class)) {
converters.add(new MethodReturningConverter(method, type, this));
}
}
return converters;
} | java | private List<ParameterConverter> methodReturningConverters(final Class<?> type) {
final List<ParameterConverter> converters = new ArrayList<>();
for (final Method method : type.getMethods()) {
if (method.isAnnotationPresent(AsParameterConverter.class)) {
converters.add(new MethodReturningConverter(method, type, this));
}
}
return converters;
} | [
"private",
"List",
"<",
"ParameterConverter",
">",
"methodReturningConverters",
"(",
"final",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"final",
"List",
"<",
"ParameterConverter",
">",
"converters",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Method",
"method",
":",
"type",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"method",
".",
"isAnnotationPresent",
"(",
"AsParameterConverter",
".",
"class",
")",
")",
"{",
"converters",
".",
"add",
"(",
"new",
"MethodReturningConverter",
"(",
"method",
",",
"type",
",",
"this",
")",
")",
";",
"}",
"}",
"return",
"converters",
";",
"}"
] | Create parameter converters from methods annotated with @AsParameterConverter
@see {@link AbstractStepsFactory} | [
"Create",
"parameter",
"converters",
"from",
"methods",
"annotated",
"with"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-needle/src/main/java/org/jbehave/core/steps/needle/NeedleStepsFactory.java#L137-L145 |
162,071 | jbehave/jbehave-core | jbehave-needle/src/main/java/org/jbehave/core/steps/needle/NeedleStepsFactory.java | NeedleStepsFactory.toArray | static InjectionProvider<?>[] toArray(final Set<InjectionProvider<?>> injectionProviders) {
return injectionProviders.toArray(new InjectionProvider<?>[injectionProviders.size()]);
} | java | static InjectionProvider<?>[] toArray(final Set<InjectionProvider<?>> injectionProviders) {
return injectionProviders.toArray(new InjectionProvider<?>[injectionProviders.size()]);
} | [
"static",
"InjectionProvider",
"<",
"?",
">",
"[",
"]",
"toArray",
"(",
"final",
"Set",
"<",
"InjectionProvider",
"<",
"?",
">",
">",
"injectionProviders",
")",
"{",
"return",
"injectionProviders",
".",
"toArray",
"(",
"new",
"InjectionProvider",
"<",
"?",
">",
"[",
"injectionProviders",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] | Set to array.
@param injectionProviders
set of providers
@return array of providers | [
"Set",
"to",
"array",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-needle/src/main/java/org/jbehave/core/steps/needle/NeedleStepsFactory.java#L195-L197 |
162,072 | jbehave/jbehave-core | examples/core/src/main/java/org/jbehave/examples/core/steps/TraderSteps.java | TraderSteps.retrieveTrader | @AsParameterConverter
public Trader retrieveTrader(String name) {
for (Trader trader : traders) {
if (trader.getName().equals(name)) {
return trader;
}
}
return mockTradePersister().retrieveTrader(name);
} | java | @AsParameterConverter
public Trader retrieveTrader(String name) {
for (Trader trader : traders) {
if (trader.getName().equals(name)) {
return trader;
}
}
return mockTradePersister().retrieveTrader(name);
} | [
"@",
"AsParameterConverter",
"public",
"Trader",
"retrieveTrader",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"Trader",
"trader",
":",
"traders",
")",
"{",
"if",
"(",
"trader",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"return",
"trader",
";",
"}",
"}",
"return",
"mockTradePersister",
"(",
")",
".",
"retrieveTrader",
"(",
"name",
")",
";",
"}"
] | Method used as dynamical parameter converter | [
"Method",
"used",
"as",
"dynamical",
"parameter",
"converter"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/examples/core/src/main/java/org/jbehave/examples/core/steps/TraderSteps.java#L219-L227 |
162,073 | jbehave/jbehave-core | jbehave-spring/src/main/java/org/jbehave/core/steps/spring/SpringStepsFactory.java | SpringStepsFactory.beanType | private Class<?> beanType(String name) {
Class<?> type = context.getType(name);
if (ClassUtils.isCglibProxyClass(type)) {
return AopProxyUtils.ultimateTargetClass(context.getBean(name));
}
return type;
} | java | private Class<?> beanType(String name) {
Class<?> type = context.getType(name);
if (ClassUtils.isCglibProxyClass(type)) {
return AopProxyUtils.ultimateTargetClass(context.getBean(name));
}
return type;
} | [
"private",
"Class",
"<",
"?",
">",
"beanType",
"(",
"String",
"name",
")",
"{",
"Class",
"<",
"?",
">",
"type",
"=",
"context",
".",
"getType",
"(",
"name",
")",
";",
"if",
"(",
"ClassUtils",
".",
"isCglibProxyClass",
"(",
"type",
")",
")",
"{",
"return",
"AopProxyUtils",
".",
"ultimateTargetClass",
"(",
"context",
".",
"getBean",
"(",
"name",
")",
")",
";",
"}",
"return",
"type",
";",
"}"
] | Return the bean type, untangling the proxy if needed
@param name
the bean name
@return The Class of the bean | [
"Return",
"the",
"bean",
"type",
"untangling",
"the",
"proxy",
"if",
"needed"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-spring/src/main/java/org/jbehave/core/steps/spring/SpringStepsFactory.java#L78-L84 |
162,074 | jbehave/jbehave-core | jbehave-guice/src/main/java/org/jbehave/core/configuration/guice/GuiceAnnotationBuilder.java | GuiceAnnotationBuilder.findBinding | private boolean findBinding(Injector injector, Class<?> type) {
boolean found = false;
for (Key<?> key : injector.getBindings().keySet()) {
if (key.getTypeLiteral().getRawType().equals(type)) {
found = true;
break;
}
}
if (!found && injector.getParent() != null) {
return findBinding(injector.getParent(), type);
}
return found;
} | java | private boolean findBinding(Injector injector, Class<?> type) {
boolean found = false;
for (Key<?> key : injector.getBindings().keySet()) {
if (key.getTypeLiteral().getRawType().equals(type)) {
found = true;
break;
}
}
if (!found && injector.getParent() != null) {
return findBinding(injector.getParent(), type);
}
return found;
} | [
"private",
"boolean",
"findBinding",
"(",
"Injector",
"injector",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"Key",
"<",
"?",
">",
"key",
":",
"injector",
".",
"getBindings",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"key",
".",
"getTypeLiteral",
"(",
")",
".",
"getRawType",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
"&&",
"injector",
".",
"getParent",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"findBinding",
"(",
"injector",
".",
"getParent",
"(",
")",
",",
"type",
")",
";",
"}",
"return",
"found",
";",
"}"
] | Finds binding for a type in the given injector and, if not found,
recurses to its parent
@param injector
the current Injector
@param type
the Class representing the type
@return A boolean flag, <code>true</code> if binding found | [
"Finds",
"binding",
"for",
"a",
"type",
"in",
"the",
"given",
"injector",
"and",
"if",
"not",
"found",
"recurses",
"to",
"its",
"parent"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-guice/src/main/java/org/jbehave/core/configuration/guice/GuiceAnnotationBuilder.java#L165-L178 |
162,075 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/io/JarFileScanner.java | JarFileScanner.scan | public List<String> scan() {
try {
JarFile jar = new JarFile(jarURL.getFile());
try {
List<String> result = new ArrayList<>();
Enumeration<JarEntry> en = jar.entries();
while (en.hasMoreElements()) {
JarEntry entry = en.nextElement();
String path = entry.getName();
boolean match = includes.size() == 0;
if (!match) {
for (String pattern : includes) {
if ( patternMatches(pattern, path)) {
match = true;
break;
}
}
}
if (match) {
for (String pattern : excludes) {
if ( patternMatches(pattern, path)) {
match = false;
break;
}
}
}
if (match) {
result.add(path);
}
}
return result;
} finally {
jar.close();
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
} | java | public List<String> scan() {
try {
JarFile jar = new JarFile(jarURL.getFile());
try {
List<String> result = new ArrayList<>();
Enumeration<JarEntry> en = jar.entries();
while (en.hasMoreElements()) {
JarEntry entry = en.nextElement();
String path = entry.getName();
boolean match = includes.size() == 0;
if (!match) {
for (String pattern : includes) {
if ( patternMatches(pattern, path)) {
match = true;
break;
}
}
}
if (match) {
for (String pattern : excludes) {
if ( patternMatches(pattern, path)) {
match = false;
break;
}
}
}
if (match) {
result.add(path);
}
}
return result;
} finally {
jar.close();
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
} | [
"public",
"List",
"<",
"String",
">",
"scan",
"(",
")",
"{",
"try",
"{",
"JarFile",
"jar",
"=",
"new",
"JarFile",
"(",
"jarURL",
".",
"getFile",
"(",
")",
")",
";",
"try",
"{",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Enumeration",
"<",
"JarEntry",
">",
"en",
"=",
"jar",
".",
"entries",
"(",
")",
";",
"while",
"(",
"en",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"JarEntry",
"entry",
"=",
"en",
".",
"nextElement",
"(",
")",
";",
"String",
"path",
"=",
"entry",
".",
"getName",
"(",
")",
";",
"boolean",
"match",
"=",
"includes",
".",
"size",
"(",
")",
"==",
"0",
";",
"if",
"(",
"!",
"match",
")",
"{",
"for",
"(",
"String",
"pattern",
":",
"includes",
")",
"{",
"if",
"(",
"patternMatches",
"(",
"pattern",
",",
"path",
")",
")",
"{",
"match",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"match",
")",
"{",
"for",
"(",
"String",
"pattern",
":",
"excludes",
")",
"{",
"if",
"(",
"patternMatches",
"(",
"pattern",
",",
"path",
")",
")",
"{",
"match",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"match",
")",
"{",
"result",
".",
"add",
"(",
"path",
")",
";",
"}",
"}",
"return",
"result",
";",
"}",
"finally",
"{",
"jar",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}"
] | Scans the jar file and returns the paths that match the includes and excludes.
@return A List of paths
@throws An IllegalStateException when an I/O error occurs in reading the jar file. | [
"Scans",
"the",
"jar",
"file",
"and",
"returns",
"the",
"paths",
"that",
"match",
"the",
"includes",
"and",
"excludes",
"."
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/io/JarFileScanner.java#L52-L89 |
162,076 | jbehave/jbehave-core | jbehave-core/src/main/java/org/jbehave/core/steps/Stepdoc.java | Stepdoc.getMethodSignature | public String getMethodSignature() {
if (method != null) {
String methodSignature = method.toString();
return methodSignature.replaceFirst("public void ", "");
}
return null;
} | java | public String getMethodSignature() {
if (method != null) {
String methodSignature = method.toString();
return methodSignature.replaceFirst("public void ", "");
}
return null;
} | [
"public",
"String",
"getMethodSignature",
"(",
")",
"{",
"if",
"(",
"method",
"!=",
"null",
")",
"{",
"String",
"methodSignature",
"=",
"method",
".",
"toString",
"(",
")",
";",
"return",
"methodSignature",
".",
"replaceFirst",
"(",
"\"public void \"",
",",
"\"\"",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Method signature without "public void" prefix
@return The method signature in String format | [
"Method",
"signature",
"without",
"public",
"void",
"prefix"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/steps/Stepdoc.java#L60-L66 |
162,077 | jbehave/jbehave-core | examples/gameoflife/src/main/java/com/lunivore/gameoflife/GridStory.java | GridStory.configuration | @Override
public Configuration configuration() {
return new MostUsefulConfiguration()
// where to find the stories
.useStoryLoader(new LoadFromClasspath(this.getClass()))
// CONSOLE and TXT reporting
.useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(Format.CONSOLE, Format.TXT));
} | java | @Override
public Configuration configuration() {
return new MostUsefulConfiguration()
// where to find the stories
.useStoryLoader(new LoadFromClasspath(this.getClass()))
// CONSOLE and TXT reporting
.useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(Format.CONSOLE, Format.TXT));
} | [
"@",
"Override",
"public",
"Configuration",
"configuration",
"(",
")",
"{",
"return",
"new",
"MostUsefulConfiguration",
"(",
")",
"// where to find the stories",
".",
"useStoryLoader",
"(",
"new",
"LoadFromClasspath",
"(",
"this",
".",
"getClass",
"(",
")",
")",
")",
"// CONSOLE and TXT reporting",
".",
"useStoryReporterBuilder",
"(",
"new",
"StoryReporterBuilder",
"(",
")",
".",
"withDefaultFormats",
"(",
")",
".",
"withFormats",
"(",
"Format",
".",
"CONSOLE",
",",
"Format",
".",
"TXT",
")",
")",
";",
"}"
] | Here we specify the configuration, starting from default MostUsefulConfiguration, and changing only what is needed | [
"Here",
"we",
"specify",
"the",
"configuration",
"starting",
"from",
"default",
"MostUsefulConfiguration",
"and",
"changing",
"only",
"what",
"is",
"needed"
] | bdd6a6199528df3c35087e72d4644870655b23e6 | https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/examples/gameoflife/src/main/java/com/lunivore/gameoflife/GridStory.java#L19-L26 |
162,078 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/requestOptions/GetAssignmentGroupOptions.java | GetAssignmentGroupOptions.includes | public GetAssignmentGroupOptions includes(List<Include> includes) {
List<Include> assignmentDependents = Arrays.asList(Include.DISCUSSION_TOPIC, Include.ASSIGNMENT_VISIBILITY, Include.SUBMISSION);
if(includes.stream().anyMatch(assignmentDependents::contains) && !includes.contains(Include.ASSIGNMENTS)) {
throw new IllegalArgumentException("Including discussion topics, all dates, assignment visibility or submissions is only valid if you also include submissions");
}
addEnumList("include[]", includes);
return this;
} | java | public GetAssignmentGroupOptions includes(List<Include> includes) {
List<Include> assignmentDependents = Arrays.asList(Include.DISCUSSION_TOPIC, Include.ASSIGNMENT_VISIBILITY, Include.SUBMISSION);
if(includes.stream().anyMatch(assignmentDependents::contains) && !includes.contains(Include.ASSIGNMENTS)) {
throw new IllegalArgumentException("Including discussion topics, all dates, assignment visibility or submissions is only valid if you also include submissions");
}
addEnumList("include[]", includes);
return this;
} | [
"public",
"GetAssignmentGroupOptions",
"includes",
"(",
"List",
"<",
"Include",
">",
"includes",
")",
"{",
"List",
"<",
"Include",
">",
"assignmentDependents",
"=",
"Arrays",
".",
"asList",
"(",
"Include",
".",
"DISCUSSION_TOPIC",
",",
"Include",
".",
"ASSIGNMENT_VISIBILITY",
",",
"Include",
".",
"SUBMISSION",
")",
";",
"if",
"(",
"includes",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"assignmentDependents",
"::",
"contains",
")",
"&&",
"!",
"includes",
".",
"contains",
"(",
"Include",
".",
"ASSIGNMENTS",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Including discussion topics, all dates, assignment visibility or submissions is only valid if you also include submissions\"",
")",
";",
"}",
"addEnumList",
"(",
"\"include[]\"",
",",
"includes",
")",
";",
"return",
"this",
";",
"}"
] | Additional objects to include with the requested group.
Note that all the optional includes depend on "assignments" also being included.
@param includes List of included objects to return
@return this object to continue building options | [
"Additional",
"objects",
"to",
"include",
"with",
"the",
"requested",
"group",
".",
"Note",
"that",
"all",
"the",
"optional",
"includes",
"depend",
"on",
"assignments",
"also",
"being",
"included",
"."
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/GetAssignmentGroupOptions.java#L44-L51 |
162,079 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/impl/ExternalToolImpl.java | ExternalToolImpl.ensureToolValidForCreation | private void ensureToolValidForCreation(ExternalTool tool) {
//check for the unconditionally required fields
if(StringUtils.isAnyBlank(tool.getName(), tool.getPrivacyLevel(), tool.getConsumerKey(), tool.getSharedSecret())) {
throw new IllegalArgumentException("External tool requires all of the following for creation: name, privacy level, consumer key, shared secret");
}
//check that there is either a URL or a domain. One or the other is required
if(StringUtils.isBlank(tool.getUrl()) && StringUtils.isBlank(tool.getDomain())) {
throw new IllegalArgumentException("External tool requires either a URL or domain for creation");
}
} | java | private void ensureToolValidForCreation(ExternalTool tool) {
//check for the unconditionally required fields
if(StringUtils.isAnyBlank(tool.getName(), tool.getPrivacyLevel(), tool.getConsumerKey(), tool.getSharedSecret())) {
throw new IllegalArgumentException("External tool requires all of the following for creation: name, privacy level, consumer key, shared secret");
}
//check that there is either a URL or a domain. One or the other is required
if(StringUtils.isBlank(tool.getUrl()) && StringUtils.isBlank(tool.getDomain())) {
throw new IllegalArgumentException("External tool requires either a URL or domain for creation");
}
} | [
"private",
"void",
"ensureToolValidForCreation",
"(",
"ExternalTool",
"tool",
")",
"{",
"//check for the unconditionally required fields",
"if",
"(",
"StringUtils",
".",
"isAnyBlank",
"(",
"tool",
".",
"getName",
"(",
")",
",",
"tool",
".",
"getPrivacyLevel",
"(",
")",
",",
"tool",
".",
"getConsumerKey",
"(",
")",
",",
"tool",
".",
"getSharedSecret",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"External tool requires all of the following for creation: name, privacy level, consumer key, shared secret\"",
")",
";",
"}",
"//check that there is either a URL or a domain. One or the other is required",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"tool",
".",
"getUrl",
"(",
")",
")",
"&&",
"StringUtils",
".",
"isBlank",
"(",
"tool",
".",
"getDomain",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"External tool requires either a URL or domain for creation\"",
")",
";",
"}",
"}"
] | Ensure that a tool object is valid for creation. The API requires certain fields to be filled out.
Throws an IllegalArgumentException if the conditions are not met.
@param tool The external tool object we are trying to create | [
"Ensure",
"that",
"a",
"tool",
"object",
"is",
"valid",
"for",
"creation",
".",
"The",
"API",
"requires",
"certain",
"fields",
"to",
"be",
"filled",
"out",
".",
"Throws",
"an",
"IllegalArgumentException",
"if",
"the",
"conditions",
"are",
"not",
"met",
"."
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/impl/ExternalToolImpl.java#L139-L148 |
162,080 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/requestOptions/GetSingleConversationOptions.java | GetSingleConversationOptions.filters | public GetSingleConversationOptions filters(List<String> filters) {
if(filters.size() == 1) { //Canvas API doesn't want the [] if it is only one value
addSingleItem("filter", filters.get(0));
} else {
optionsMap.put("filter[]", filters);
}
return this;
} | java | public GetSingleConversationOptions filters(List<String> filters) {
if(filters.size() == 1) { //Canvas API doesn't want the [] if it is only one value
addSingleItem("filter", filters.get(0));
} else {
optionsMap.put("filter[]", filters);
}
return this;
} | [
"public",
"GetSingleConversationOptions",
"filters",
"(",
"List",
"<",
"String",
">",
"filters",
")",
"{",
"if",
"(",
"filters",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"//Canvas API doesn't want the [] if it is only one value",
"addSingleItem",
"(",
"\"filter\"",
",",
"filters",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"else",
"{",
"optionsMap",
".",
"put",
"(",
"\"filter[]\"",
",",
"filters",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Used when setting the "visible" field in the response. See the "List Conversations" docs for details
@param filters Filter strings to be applied to the visibility of conversations
@return this to continue building options | [
"Used",
"when",
"setting",
"the",
"visible",
"field",
"in",
"the",
"response",
".",
"See",
"the",
"List",
"Conversations",
"docs",
"for",
"details"
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/GetSingleConversationOptions.java#L28-L35 |
162,081 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/CanvasApiFactory.java | CanvasApiFactory.getReader | public <T extends CanvasReader> T getReader(Class<T> type, OauthToken oauthToken) {
return getReader(type, oauthToken, null);
} | java | public <T extends CanvasReader> T getReader(Class<T> type, OauthToken oauthToken) {
return getReader(type, oauthToken, null);
} | [
"public",
"<",
"T",
"extends",
"CanvasReader",
">",
"T",
"getReader",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"OauthToken",
"oauthToken",
")",
"{",
"return",
"getReader",
"(",
"type",
",",
"oauthToken",
",",
"null",
")",
";",
"}"
] | Get a reader implementation class to perform API calls with.
@param type Interface type you wish to get an implementation for
@param oauthToken An OAuth token to use for authentication when making API calls
@param <T> The reader type to request an instance of
@return A reader implementation class | [
"Get",
"a",
"reader",
"implementation",
"class",
"to",
"perform",
"API",
"calls",
"with",
"."
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/CanvasApiFactory.java#L67-L69 |
162,082 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/CanvasApiFactory.java | CanvasApiFactory.getReader | public <T extends CanvasReader> T getReader(Class<T> type, OauthToken oauthToken, Integer paginationPageSize) {
LOG.debug("Factory call to instantiate class: " + type.getName());
RestClient restClient = new RefreshingRestClient();
@SuppressWarnings("unchecked")
Class<T> concreteClass = (Class<T>)readerMap.get(type);
if (concreteClass == null) {
throw new UnsupportedOperationException("No implementation for requested interface found: " + type.getName());
}
LOG.debug("got class: " + concreteClass);
try {
Constructor<T> constructor = concreteClass.getConstructor(String.class, Integer.class,
OauthToken.class, RestClient.class, Integer.TYPE, Integer.TYPE, Integer.class, Boolean.class);
return constructor.newInstance(canvasBaseUrl, CANVAS_API_VERSION, oauthToken, restClient,
connectTimeout, readTimeout, paginationPageSize, false);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) {
throw new UnsupportedOperationException("Unknown error instantiating the concrete API class: " + type.getName(), e);
}
} | java | public <T extends CanvasReader> T getReader(Class<T> type, OauthToken oauthToken, Integer paginationPageSize) {
LOG.debug("Factory call to instantiate class: " + type.getName());
RestClient restClient = new RefreshingRestClient();
@SuppressWarnings("unchecked")
Class<T> concreteClass = (Class<T>)readerMap.get(type);
if (concreteClass == null) {
throw new UnsupportedOperationException("No implementation for requested interface found: " + type.getName());
}
LOG.debug("got class: " + concreteClass);
try {
Constructor<T> constructor = concreteClass.getConstructor(String.class, Integer.class,
OauthToken.class, RestClient.class, Integer.TYPE, Integer.TYPE, Integer.class, Boolean.class);
return constructor.newInstance(canvasBaseUrl, CANVAS_API_VERSION, oauthToken, restClient,
connectTimeout, readTimeout, paginationPageSize, false);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) {
throw new UnsupportedOperationException("Unknown error instantiating the concrete API class: " + type.getName(), e);
}
} | [
"public",
"<",
"T",
"extends",
"CanvasReader",
">",
"T",
"getReader",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"OauthToken",
"oauthToken",
",",
"Integer",
"paginationPageSize",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Factory call to instantiate class: \"",
"+",
"type",
".",
"getName",
"(",
")",
")",
";",
"RestClient",
"restClient",
"=",
"new",
"RefreshingRestClient",
"(",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Class",
"<",
"T",
">",
"concreteClass",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"readerMap",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"concreteClass",
"==",
"null",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"No implementation for requested interface found: \"",
"+",
"type",
".",
"getName",
"(",
")",
")",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"got class: \"",
"+",
"concreteClass",
")",
";",
"try",
"{",
"Constructor",
"<",
"T",
">",
"constructor",
"=",
"concreteClass",
".",
"getConstructor",
"(",
"String",
".",
"class",
",",
"Integer",
".",
"class",
",",
"OauthToken",
".",
"class",
",",
"RestClient",
".",
"class",
",",
"Integer",
".",
"TYPE",
",",
"Integer",
".",
"TYPE",
",",
"Integer",
".",
"class",
",",
"Boolean",
".",
"class",
")",
";",
"return",
"constructor",
".",
"newInstance",
"(",
"canvasBaseUrl",
",",
"CANVAS_API_VERSION",
",",
"oauthToken",
",",
"restClient",
",",
"connectTimeout",
",",
"readTimeout",
",",
"paginationPageSize",
",",
"false",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"|",
"InvocationTargetException",
"|",
"IllegalAccessException",
"|",
"InstantiationException",
"e",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Unknown error instantiating the concrete API class: \"",
"+",
"type",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Get a reader implementation class to perform API calls with while specifying
an explicit page size for paginated API calls. This gets translated to a per_page=
parameter on API requests. Note that Canvas does not guarantee it will honor this page size request.
There is an explicit maximum page size on the server side which could change. The default page size
is 10 which can be limiting when, for example, trying to get all users in a 800 person course.
@param type Interface type you wish to get an implementation for
@param oauthToken An OAuth token to use for authentication when making API calls
@param paginationPageSize Requested pagination page size
@param <T> The reader type to request an instance of
@return An instance of the requested reader class | [
"Get",
"a",
"reader",
"implementation",
"class",
"to",
"perform",
"API",
"calls",
"with",
"while",
"specifying",
"an",
"explicit",
"page",
"size",
"for",
"paginated",
"API",
"calls",
".",
"This",
"gets",
"translated",
"to",
"a",
"per_page",
"=",
"parameter",
"on",
"API",
"requests",
".",
"Note",
"that",
"Canvas",
"does",
"not",
"guarantee",
"it",
"will",
"honor",
"this",
"page",
"size",
"request",
".",
"There",
"is",
"an",
"explicit",
"maximum",
"page",
"size",
"on",
"the",
"server",
"side",
"which",
"could",
"change",
".",
"The",
"default",
"page",
"size",
"is",
"10",
"which",
"can",
"be",
"limiting",
"when",
"for",
"example",
"trying",
"to",
"get",
"all",
"users",
"in",
"a",
"800",
"person",
"course",
"."
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/CanvasApiFactory.java#L83-L103 |
162,083 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/CanvasApiFactory.java | CanvasApiFactory.getWriter | public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken) {
return getWriter(type, oauthToken, false);
} | java | public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken) {
return getWriter(type, oauthToken, false);
} | [
"public",
"<",
"T",
"extends",
"CanvasWriter",
">",
"T",
"getWriter",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"OauthToken",
"oauthToken",
")",
"{",
"return",
"getWriter",
"(",
"type",
",",
"oauthToken",
",",
"false",
")",
";",
"}"
] | Get a writer implementation to push data into Canvas.
@param type Interface type you wish to get an implementation for
@param oauthToken An OAuth token to use for authentication when making API calls
@param <T> A writer implementation
@return A writer implementation class | [
"Get",
"a",
"writer",
"implementation",
"to",
"push",
"data",
"into",
"Canvas",
"."
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/CanvasApiFactory.java#L112-L114 |
162,084 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/CanvasApiFactory.java | CanvasApiFactory.getWriter | public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken, Boolean serializeNulls) {
LOG.debug("Factory call to instantiate class: " + type.getName());
RestClient restClient = new RefreshingRestClient();
@SuppressWarnings("unchecked")
Class<T> concreteClass = (Class<T>) writerMap.get(type);
if (concreteClass == null) {
throw new UnsupportedOperationException("No implementation for requested interface found: " + type.getName());
}
LOG.debug("got writer class: " + concreteClass);
try {
Constructor<T> constructor = concreteClass.getConstructor(String.class, Integer.class, OauthToken.class,
RestClient.class, Integer.TYPE, Integer.TYPE, Integer.class, Boolean.class);
return constructor.newInstance(canvasBaseUrl, CANVAS_API_VERSION, oauthToken, restClient,
connectTimeout, readTimeout, null, serializeNulls);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) {
throw new UnsupportedOperationException("Unknown error instantiating the concrete API class: " + type.getName(), e);
}
} | java | public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken, Boolean serializeNulls) {
LOG.debug("Factory call to instantiate class: " + type.getName());
RestClient restClient = new RefreshingRestClient();
@SuppressWarnings("unchecked")
Class<T> concreteClass = (Class<T>) writerMap.get(type);
if (concreteClass == null) {
throw new UnsupportedOperationException("No implementation for requested interface found: " + type.getName());
}
LOG.debug("got writer class: " + concreteClass);
try {
Constructor<T> constructor = concreteClass.getConstructor(String.class, Integer.class, OauthToken.class,
RestClient.class, Integer.TYPE, Integer.TYPE, Integer.class, Boolean.class);
return constructor.newInstance(canvasBaseUrl, CANVAS_API_VERSION, oauthToken, restClient,
connectTimeout, readTimeout, null, serializeNulls);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) {
throw new UnsupportedOperationException("Unknown error instantiating the concrete API class: " + type.getName(), e);
}
} | [
"public",
"<",
"T",
"extends",
"CanvasWriter",
">",
"T",
"getWriter",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"OauthToken",
"oauthToken",
",",
"Boolean",
"serializeNulls",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Factory call to instantiate class: \"",
"+",
"type",
".",
"getName",
"(",
")",
")",
";",
"RestClient",
"restClient",
"=",
"new",
"RefreshingRestClient",
"(",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Class",
"<",
"T",
">",
"concreteClass",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"writerMap",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"concreteClass",
"==",
"null",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"No implementation for requested interface found: \"",
"+",
"type",
".",
"getName",
"(",
")",
")",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"got writer class: \"",
"+",
"concreteClass",
")",
";",
"try",
"{",
"Constructor",
"<",
"T",
">",
"constructor",
"=",
"concreteClass",
".",
"getConstructor",
"(",
"String",
".",
"class",
",",
"Integer",
".",
"class",
",",
"OauthToken",
".",
"class",
",",
"RestClient",
".",
"class",
",",
"Integer",
".",
"TYPE",
",",
"Integer",
".",
"TYPE",
",",
"Integer",
".",
"class",
",",
"Boolean",
".",
"class",
")",
";",
"return",
"constructor",
".",
"newInstance",
"(",
"canvasBaseUrl",
",",
"CANVAS_API_VERSION",
",",
"oauthToken",
",",
"restClient",
",",
"connectTimeout",
",",
"readTimeout",
",",
"null",
",",
"serializeNulls",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"|",
"InvocationTargetException",
"|",
"IllegalAccessException",
"|",
"InstantiationException",
"e",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Unknown error instantiating the concrete API class: \"",
"+",
"type",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Get a writer implementation to push data into Canvas while being able to control the behavior of blank values.
If the serializeNulls parameter is set to true, this writer will serialize null fields in the JSON being
sent to Canvas. This is required if you want to explicitly blank out a value that is currently set to something.
@param type Interface type you wish to get an implementation for
@param oauthToken An OAuth token to use for authentication when making API calls
@param serializeNulls Whether or not to include null fields in the serialized JSON. Defaults to false if null
@param <T> A writer implementation
@return An instantiated instance of the requested writer type | [
"Get",
"a",
"writer",
"implementation",
"to",
"push",
"data",
"into",
"Canvas",
"while",
"being",
"able",
"to",
"control",
"the",
"behavior",
"of",
"blank",
"values",
".",
"If",
"the",
"serializeNulls",
"parameter",
"is",
"set",
"to",
"true",
"this",
"writer",
"will",
"serialize",
"null",
"fields",
"in",
"the",
"JSON",
"being",
"sent",
"to",
"Canvas",
".",
"This",
"is",
"required",
"if",
"you",
"want",
"to",
"explicitly",
"blank",
"out",
"a",
"value",
"that",
"is",
"currently",
"set",
"to",
"something",
"."
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/CanvasApiFactory.java#L126-L146 |
162,085 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/requestOptions/ListActiveCoursesInAccountOptions.java | ListActiveCoursesInAccountOptions.searchTerm | public ListActiveCoursesInAccountOptions searchTerm(String searchTerm) {
if(searchTerm == null || searchTerm.length() < 3) {
throw new IllegalArgumentException("Search term must be at least 3 characters");
}
addSingleItem("search_term", searchTerm);
return this;
} | java | public ListActiveCoursesInAccountOptions searchTerm(String searchTerm) {
if(searchTerm == null || searchTerm.length() < 3) {
throw new IllegalArgumentException("Search term must be at least 3 characters");
}
addSingleItem("search_term", searchTerm);
return this;
} | [
"public",
"ListActiveCoursesInAccountOptions",
"searchTerm",
"(",
"String",
"searchTerm",
")",
"{",
"if",
"(",
"searchTerm",
"==",
"null",
"||",
"searchTerm",
".",
"length",
"(",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Search term must be at least 3 characters\"",
")",
";",
"}",
"addSingleItem",
"(",
"\"search_term\"",
",",
"searchTerm",
")",
";",
"return",
"this",
";",
"}"
] | Filter on a search term. Can be course name, code or full ID. Must be at least 3 characters
@param searchTerm Search term to filter by
@return This object to allow adding more options | [
"Filter",
"on",
"a",
"search",
"term",
".",
"Can",
"be",
"course",
"name",
"code",
"or",
"full",
"ID",
".",
"Must",
"be",
"at",
"least",
"3",
"characters"
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/ListActiveCoursesInAccountOptions.java#L147-L153 |
162,086 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/requestOptions/ListExternalToolsOptions.java | ListExternalToolsOptions.searchTerm | public ListExternalToolsOptions searchTerm(String searchTerm) {
if(searchTerm == null || searchTerm.length() < 3) {
throw new IllegalArgumentException("Search term must be at least 3 characters");
}
addSingleItem("search_term", searchTerm);
return this;
} | java | public ListExternalToolsOptions searchTerm(String searchTerm) {
if(searchTerm == null || searchTerm.length() < 3) {
throw new IllegalArgumentException("Search term must be at least 3 characters");
}
addSingleItem("search_term", searchTerm);
return this;
} | [
"public",
"ListExternalToolsOptions",
"searchTerm",
"(",
"String",
"searchTerm",
")",
"{",
"if",
"(",
"searchTerm",
"==",
"null",
"||",
"searchTerm",
".",
"length",
"(",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Search term must be at least 3 characters\"",
")",
";",
"}",
"addSingleItem",
"(",
"\"search_term\"",
",",
"searchTerm",
")",
";",
"return",
"this",
";",
"}"
] | Only return tools with a name matching this partial string
@param searchTerm Tool name to search for
@return This object to allow adding more options | [
"Only",
"return",
"tools",
"with",
"a",
"name",
"matching",
"this",
"partial",
"string"
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/ListExternalToolsOptions.java#L20-L26 |
162,087 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/impl/EnrollmentTermImpl.java | EnrollmentTermImpl.parseEnrollmentTermList | private List<EnrollmentTerm> parseEnrollmentTermList(final List<Response> responses) {
return responses.stream().
map(this::parseEnrollmentTermList).
flatMap(Collection::stream).
collect(Collectors.toList());
} | java | private List<EnrollmentTerm> parseEnrollmentTermList(final List<Response> responses) {
return responses.stream().
map(this::parseEnrollmentTermList).
flatMap(Collection::stream).
collect(Collectors.toList());
} | [
"private",
"List",
"<",
"EnrollmentTerm",
">",
"parseEnrollmentTermList",
"(",
"final",
"List",
"<",
"Response",
">",
"responses",
")",
"{",
"return",
"responses",
".",
"stream",
"(",
")",
".",
"map",
"(",
"this",
"::",
"parseEnrollmentTermList",
")",
".",
"flatMap",
"(",
"Collection",
"::",
"stream",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | a useless object at the top level of the response JSON for no reason at all. | [
"a",
"useless",
"object",
"at",
"the",
"top",
"level",
"of",
"the",
"response",
"JSON",
"for",
"no",
"reason",
"at",
"all",
"."
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/impl/EnrollmentTermImpl.java#L41-L46 |
162,088 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/net/SimpleRestClient.java | SimpleRestClient.sendJsonPostOrPut | private Response sendJsonPostOrPut(OauthToken token, String url, String json,
int connectTimeout, int readTimeout, String method) throws IOException {
LOG.debug("Sending JSON " + method + " to URL: " + url);
Response response = new Response();
HttpClient httpClient = createHttpClient(connectTimeout, readTimeout);
HttpEntityEnclosingRequestBase action;
if("POST".equals(method)) {
action = new HttpPost(url);
} else if("PUT".equals(method)) {
action = new HttpPut(url);
} else {
throw new IllegalArgumentException("Method must be either POST or PUT");
}
Long beginTime = System.currentTimeMillis();
action.setHeader("Authorization", "Bearer" + " " + token.getAccessToken());
StringEntity requestBody = new StringEntity(json, ContentType.APPLICATION_JSON);
action.setEntity(requestBody);
try {
HttpResponse httpResponse = httpClient.execute(action);
String content = handleResponse(httpResponse, action);
response.setContent(content);
response.setResponseCode(httpResponse.getStatusLine().getStatusCode());
Long endTime = System.currentTimeMillis();
LOG.debug("POST call took: " + (endTime - beginTime) + "ms");
} finally {
action.releaseConnection();
}
return response;
} | java | private Response sendJsonPostOrPut(OauthToken token, String url, String json,
int connectTimeout, int readTimeout, String method) throws IOException {
LOG.debug("Sending JSON " + method + " to URL: " + url);
Response response = new Response();
HttpClient httpClient = createHttpClient(connectTimeout, readTimeout);
HttpEntityEnclosingRequestBase action;
if("POST".equals(method)) {
action = new HttpPost(url);
} else if("PUT".equals(method)) {
action = new HttpPut(url);
} else {
throw new IllegalArgumentException("Method must be either POST or PUT");
}
Long beginTime = System.currentTimeMillis();
action.setHeader("Authorization", "Bearer" + " " + token.getAccessToken());
StringEntity requestBody = new StringEntity(json, ContentType.APPLICATION_JSON);
action.setEntity(requestBody);
try {
HttpResponse httpResponse = httpClient.execute(action);
String content = handleResponse(httpResponse, action);
response.setContent(content);
response.setResponseCode(httpResponse.getStatusLine().getStatusCode());
Long endTime = System.currentTimeMillis();
LOG.debug("POST call took: " + (endTime - beginTime) + "ms");
} finally {
action.releaseConnection();
}
return response;
} | [
"private",
"Response",
"sendJsonPostOrPut",
"(",
"OauthToken",
"token",
",",
"String",
"url",
",",
"String",
"json",
",",
"int",
"connectTimeout",
",",
"int",
"readTimeout",
",",
"String",
"method",
")",
"throws",
"IOException",
"{",
"LOG",
".",
"debug",
"(",
"\"Sending JSON \"",
"+",
"method",
"+",
"\" to URL: \"",
"+",
"url",
")",
";",
"Response",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"HttpClient",
"httpClient",
"=",
"createHttpClient",
"(",
"connectTimeout",
",",
"readTimeout",
")",
";",
"HttpEntityEnclosingRequestBase",
"action",
";",
"if",
"(",
"\"POST\"",
".",
"equals",
"(",
"method",
")",
")",
"{",
"action",
"=",
"new",
"HttpPost",
"(",
"url",
")",
";",
"}",
"else",
"if",
"(",
"\"PUT\"",
".",
"equals",
"(",
"method",
")",
")",
"{",
"action",
"=",
"new",
"HttpPut",
"(",
"url",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Method must be either POST or PUT\"",
")",
";",
"}",
"Long",
"beginTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"action",
".",
"setHeader",
"(",
"\"Authorization\"",
",",
"\"Bearer\"",
"+",
"\" \"",
"+",
"token",
".",
"getAccessToken",
"(",
")",
")",
";",
"StringEntity",
"requestBody",
"=",
"new",
"StringEntity",
"(",
"json",
",",
"ContentType",
".",
"APPLICATION_JSON",
")",
";",
"action",
".",
"setEntity",
"(",
"requestBody",
")",
";",
"try",
"{",
"HttpResponse",
"httpResponse",
"=",
"httpClient",
".",
"execute",
"(",
"action",
")",
";",
"String",
"content",
"=",
"handleResponse",
"(",
"httpResponse",
",",
"action",
")",
";",
"response",
".",
"setContent",
"(",
"content",
")",
";",
"response",
".",
"setResponseCode",
"(",
"httpResponse",
".",
"getStatusLine",
"(",
")",
".",
"getStatusCode",
"(",
")",
")",
";",
"Long",
"endTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"POST call took: \"",
"+",
"(",
"endTime",
"-",
"beginTime",
")",
"+",
"\"ms\"",
")",
";",
"}",
"finally",
"{",
"action",
".",
"releaseConnection",
"(",
")",
";",
"}",
"return",
"response",
";",
"}"
] | PUT and POST are identical calls except for the header specifying the method | [
"PUT",
"and",
"POST",
"are",
"identical",
"calls",
"except",
"for",
"the",
"header",
"specifying",
"the",
"method"
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/net/SimpleRestClient.java#L102-L135 |
162,089 | kstateome/canvas-api | src/main/java/edu/ksu/canvas/requestOptions/BaseOptions.java | BaseOptions.addEnumList | protected void addEnumList(String key, List<? extends Enum> list) {
optionsMap.put(key, list.stream().map(i -> i.toString()).collect(Collectors.toList()));
} | java | protected void addEnumList(String key, List<? extends Enum> list) {
optionsMap.put(key, list.stream().map(i -> i.toString()).collect(Collectors.toList()));
} | [
"protected",
"void",
"addEnumList",
"(",
"String",
"key",
",",
"List",
"<",
"?",
"extends",
"Enum",
">",
"list",
")",
"{",
"optionsMap",
".",
"put",
"(",
"key",
",",
"list",
".",
"stream",
"(",
")",
".",
"map",
"(",
"i",
"->",
"i",
".",
"toString",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"}"
] | Add a list of enums to the options map
@param key The key for the options map (ex: "include[]")
@param list A list of enums | [
"Add",
"a",
"list",
"of",
"enums",
"to",
"the",
"options",
"map"
] | 426bf403a8fd7aca3f170348005feda25b374e5a | https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/BaseOptions.java#L23-L25 |
162,090 | awslabs/amazon-sqs-java-extended-client-lib | src/main/java/com/amazon/sqs/javamessaging/ExtendedClientConfiguration.java | ExtendedClientConfiguration.setLargePayloadSupportEnabled | public void setLargePayloadSupportEnabled(AmazonS3 s3, String s3BucketName) {
if (s3 == null || s3BucketName == null) {
String errorMessage = "S3 client and/or S3 bucket name cannot be null.";
LOG.error(errorMessage);
throw new AmazonClientException(errorMessage);
}
if (isLargePayloadSupportEnabled()) {
LOG.warn("Large-payload support is already enabled. Overwriting AmazonS3Client and S3BucketName.");
}
this.s3 = s3;
this.s3BucketName = s3BucketName;
largePayloadSupport = true;
LOG.info("Large-payload support enabled.");
} | java | public void setLargePayloadSupportEnabled(AmazonS3 s3, String s3BucketName) {
if (s3 == null || s3BucketName == null) {
String errorMessage = "S3 client and/or S3 bucket name cannot be null.";
LOG.error(errorMessage);
throw new AmazonClientException(errorMessage);
}
if (isLargePayloadSupportEnabled()) {
LOG.warn("Large-payload support is already enabled. Overwriting AmazonS3Client and S3BucketName.");
}
this.s3 = s3;
this.s3BucketName = s3BucketName;
largePayloadSupport = true;
LOG.info("Large-payload support enabled.");
} | [
"public",
"void",
"setLargePayloadSupportEnabled",
"(",
"AmazonS3",
"s3",
",",
"String",
"s3BucketName",
")",
"{",
"if",
"(",
"s3",
"==",
"null",
"||",
"s3BucketName",
"==",
"null",
")",
"{",
"String",
"errorMessage",
"=",
"\"S3 client and/or S3 bucket name cannot be null.\"",
";",
"LOG",
".",
"error",
"(",
"errorMessage",
")",
";",
"throw",
"new",
"AmazonClientException",
"(",
"errorMessage",
")",
";",
"}",
"if",
"(",
"isLargePayloadSupportEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Large-payload support is already enabled. Overwriting AmazonS3Client and S3BucketName.\"",
")",
";",
"}",
"this",
".",
"s3",
"=",
"s3",
";",
"this",
".",
"s3BucketName",
"=",
"s3BucketName",
";",
"largePayloadSupport",
"=",
"true",
";",
"LOG",
".",
"info",
"(",
"\"Large-payload support enabled.\"",
")",
";",
"}"
] | Enables support for large-payload messages.
@param s3
Amazon S3 client which is going to be used for storing
large-payload messages.
@param s3BucketName
Name of the bucket which is going to be used for storing
large-payload messages. The bucket must be already created and
configured in s3. | [
"Enables",
"support",
"for",
"large",
"-",
"payload",
"messages",
"."
] | df0c6251b99e682d6179938fe784590e662b84ea | https://github.com/awslabs/amazon-sqs-java-extended-client-lib/blob/df0c6251b99e682d6179938fe784590e662b84ea/src/main/java/com/amazon/sqs/javamessaging/ExtendedClientConfiguration.java#L64-L77 |
162,091 | twitter/hbc | hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java | DelimitedStreamReader.readLine | private String readLine(boolean trim) throws IOException {
boolean done = false;
boolean sawCarriage = false;
// bytes to trim (the \r and the \n)
int removalBytes = 0;
while (!done) {
if (isReadBufferEmpty()) {
offset = 0;
end = 0;
int bytesRead = inputStream.read(buffer, end, Math.min(DEFAULT_READ_COUNT, buffer.length - end));
if (bytesRead < 0) {
// we failed to read anything more...
throw new IOException("Reached the end of the stream");
} else {
end += bytesRead;
}
}
int originalOffset = offset;
for (; !done && offset < end; offset++) {
if (buffer[offset] == LF) {
int cpLength = offset - originalOffset + 1;
if (trim) {
int length = 0;
if (buffer[offset] == LF) {
length ++;
if (sawCarriage) {
length++;
}
}
cpLength -= length;
}
if (cpLength > 0) {
copyToStrBuffer(buffer, originalOffset, cpLength);
} else {
// negative length means we need to trim a \r from strBuffer
removalBytes = cpLength;
}
done = true;
} else {
// did not see newline:
sawCarriage = buffer[offset] == CR;
}
}
if (!done) {
copyToStrBuffer(buffer, originalOffset, end - originalOffset);
offset = end;
}
}
int strLength = strBufferIndex + removalBytes;
strBufferIndex = 0;
return new String(strBuffer, 0, strLength, charset);
} | java | private String readLine(boolean trim) throws IOException {
boolean done = false;
boolean sawCarriage = false;
// bytes to trim (the \r and the \n)
int removalBytes = 0;
while (!done) {
if (isReadBufferEmpty()) {
offset = 0;
end = 0;
int bytesRead = inputStream.read(buffer, end, Math.min(DEFAULT_READ_COUNT, buffer.length - end));
if (bytesRead < 0) {
// we failed to read anything more...
throw new IOException("Reached the end of the stream");
} else {
end += bytesRead;
}
}
int originalOffset = offset;
for (; !done && offset < end; offset++) {
if (buffer[offset] == LF) {
int cpLength = offset - originalOffset + 1;
if (trim) {
int length = 0;
if (buffer[offset] == LF) {
length ++;
if (sawCarriage) {
length++;
}
}
cpLength -= length;
}
if (cpLength > 0) {
copyToStrBuffer(buffer, originalOffset, cpLength);
} else {
// negative length means we need to trim a \r from strBuffer
removalBytes = cpLength;
}
done = true;
} else {
// did not see newline:
sawCarriage = buffer[offset] == CR;
}
}
if (!done) {
copyToStrBuffer(buffer, originalOffset, end - originalOffset);
offset = end;
}
}
int strLength = strBufferIndex + removalBytes;
strBufferIndex = 0;
return new String(strBuffer, 0, strLength, charset);
} | [
"private",
"String",
"readLine",
"(",
"boolean",
"trim",
")",
"throws",
"IOException",
"{",
"boolean",
"done",
"=",
"false",
";",
"boolean",
"sawCarriage",
"=",
"false",
";",
"// bytes to trim (the \\r and the \\n)",
"int",
"removalBytes",
"=",
"0",
";",
"while",
"(",
"!",
"done",
")",
"{",
"if",
"(",
"isReadBufferEmpty",
"(",
")",
")",
"{",
"offset",
"=",
"0",
";",
"end",
"=",
"0",
";",
"int",
"bytesRead",
"=",
"inputStream",
".",
"read",
"(",
"buffer",
",",
"end",
",",
"Math",
".",
"min",
"(",
"DEFAULT_READ_COUNT",
",",
"buffer",
".",
"length",
"-",
"end",
")",
")",
";",
"if",
"(",
"bytesRead",
"<",
"0",
")",
"{",
"// we failed to read anything more...",
"throw",
"new",
"IOException",
"(",
"\"Reached the end of the stream\"",
")",
";",
"}",
"else",
"{",
"end",
"+=",
"bytesRead",
";",
"}",
"}",
"int",
"originalOffset",
"=",
"offset",
";",
"for",
"(",
";",
"!",
"done",
"&&",
"offset",
"<",
"end",
";",
"offset",
"++",
")",
"{",
"if",
"(",
"buffer",
"[",
"offset",
"]",
"==",
"LF",
")",
"{",
"int",
"cpLength",
"=",
"offset",
"-",
"originalOffset",
"+",
"1",
";",
"if",
"(",
"trim",
")",
"{",
"int",
"length",
"=",
"0",
";",
"if",
"(",
"buffer",
"[",
"offset",
"]",
"==",
"LF",
")",
"{",
"length",
"++",
";",
"if",
"(",
"sawCarriage",
")",
"{",
"length",
"++",
";",
"}",
"}",
"cpLength",
"-=",
"length",
";",
"}",
"if",
"(",
"cpLength",
">",
"0",
")",
"{",
"copyToStrBuffer",
"(",
"buffer",
",",
"originalOffset",
",",
"cpLength",
")",
";",
"}",
"else",
"{",
"// negative length means we need to trim a \\r from strBuffer",
"removalBytes",
"=",
"cpLength",
";",
"}",
"done",
"=",
"true",
";",
"}",
"else",
"{",
"// did not see newline:",
"sawCarriage",
"=",
"buffer",
"[",
"offset",
"]",
"==",
"CR",
";",
"}",
"}",
"if",
"(",
"!",
"done",
")",
"{",
"copyToStrBuffer",
"(",
"buffer",
",",
"originalOffset",
",",
"end",
"-",
"originalOffset",
")",
";",
"offset",
"=",
"end",
";",
"}",
"}",
"int",
"strLength",
"=",
"strBufferIndex",
"+",
"removalBytes",
";",
"strBufferIndex",
"=",
"0",
";",
"return",
"new",
"String",
"(",
"strBuffer",
",",
"0",
",",
"strLength",
",",
"charset",
")",
";",
"}"
] | Reads a line from the input stream, where a line is terminated by \r, \n, or \r\n
@param trim whether to trim trailing \r and \ns | [
"Reads",
"a",
"line",
"from",
"the",
"input",
"stream",
"where",
"a",
"line",
"is",
"terminated",
"by",
"\\",
"r",
"\\",
"n",
"or",
"\\",
"r",
"\\",
"n"
] | 72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c | https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java#L63-L117 |
162,092 | twitter/hbc | hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java | DelimitedStreamReader.copyToStrBuffer | private void copyToStrBuffer(byte[] buffer, int offset, int length) {
Preconditions.checkArgument(length >= 0);
if (strBuffer.length - strBufferIndex < length) {
// cannot fit, expanding buffer
expandStrBuffer(length);
}
System.arraycopy(
buffer, offset, strBuffer, strBufferIndex, Math.min(length, MAX_ALLOWABLE_BUFFER_SIZE - strBufferIndex));
strBufferIndex += length;
} | java | private void copyToStrBuffer(byte[] buffer, int offset, int length) {
Preconditions.checkArgument(length >= 0);
if (strBuffer.length - strBufferIndex < length) {
// cannot fit, expanding buffer
expandStrBuffer(length);
}
System.arraycopy(
buffer, offset, strBuffer, strBufferIndex, Math.min(length, MAX_ALLOWABLE_BUFFER_SIZE - strBufferIndex));
strBufferIndex += length;
} | [
"private",
"void",
"copyToStrBuffer",
"(",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"length",
">=",
"0",
")",
";",
"if",
"(",
"strBuffer",
".",
"length",
"-",
"strBufferIndex",
"<",
"length",
")",
"{",
"// cannot fit, expanding buffer",
"expandStrBuffer",
"(",
"length",
")",
";",
"}",
"System",
".",
"arraycopy",
"(",
"buffer",
",",
"offset",
",",
"strBuffer",
",",
"strBufferIndex",
",",
"Math",
".",
"min",
"(",
"length",
",",
"MAX_ALLOWABLE_BUFFER_SIZE",
"-",
"strBufferIndex",
")",
")",
";",
"strBufferIndex",
"+=",
"length",
";",
"}"
] | Copies from buffer to our internal strBufferIndex, expanding the internal buffer if necessary
@param offset offset in the buffer to start copying from
@param length length to copy | [
"Copies",
"from",
"buffer",
"to",
"our",
"internal",
"strBufferIndex",
"expanding",
"the",
"internal",
"buffer",
"if",
"necessary"
] | 72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c | https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java#L124-L133 |
162,093 | twitter/hbc | hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java | DelimitedStreamReader.read | public String read(int numBytes) throws IOException {
Preconditions.checkArgument(numBytes >= 0);
Preconditions.checkArgument(numBytes <= MAX_ALLOWABLE_BUFFER_SIZE);
int numBytesRemaining = numBytes;
// first read whatever we need from our buffer
if (!isReadBufferEmpty()) {
int length = Math.min(end - offset, numBytesRemaining);
copyToStrBuffer(buffer, offset, length);
offset += length;
numBytesRemaining -= length;
}
// next read the remaining chars directly into our strBuffer
if (numBytesRemaining > 0) {
readAmountToStrBuffer(numBytesRemaining);
}
if (strBufferIndex > 0 && strBuffer[strBufferIndex - 1] != LF) {
// the last byte doesn't correspond to lf
return readLine(false);
}
int strBufferLength = strBufferIndex;
strBufferIndex = 0;
return new String(strBuffer, 0, strBufferLength, charset);
} | java | public String read(int numBytes) throws IOException {
Preconditions.checkArgument(numBytes >= 0);
Preconditions.checkArgument(numBytes <= MAX_ALLOWABLE_BUFFER_SIZE);
int numBytesRemaining = numBytes;
// first read whatever we need from our buffer
if (!isReadBufferEmpty()) {
int length = Math.min(end - offset, numBytesRemaining);
copyToStrBuffer(buffer, offset, length);
offset += length;
numBytesRemaining -= length;
}
// next read the remaining chars directly into our strBuffer
if (numBytesRemaining > 0) {
readAmountToStrBuffer(numBytesRemaining);
}
if (strBufferIndex > 0 && strBuffer[strBufferIndex - 1] != LF) {
// the last byte doesn't correspond to lf
return readLine(false);
}
int strBufferLength = strBufferIndex;
strBufferIndex = 0;
return new String(strBuffer, 0, strBufferLength, charset);
} | [
"public",
"String",
"read",
"(",
"int",
"numBytes",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"numBytes",
">=",
"0",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"numBytes",
"<=",
"MAX_ALLOWABLE_BUFFER_SIZE",
")",
";",
"int",
"numBytesRemaining",
"=",
"numBytes",
";",
"// first read whatever we need from our buffer",
"if",
"(",
"!",
"isReadBufferEmpty",
"(",
")",
")",
"{",
"int",
"length",
"=",
"Math",
".",
"min",
"(",
"end",
"-",
"offset",
",",
"numBytesRemaining",
")",
";",
"copyToStrBuffer",
"(",
"buffer",
",",
"offset",
",",
"length",
")",
";",
"offset",
"+=",
"length",
";",
"numBytesRemaining",
"-=",
"length",
";",
"}",
"// next read the remaining chars directly into our strBuffer",
"if",
"(",
"numBytesRemaining",
">",
"0",
")",
"{",
"readAmountToStrBuffer",
"(",
"numBytesRemaining",
")",
";",
"}",
"if",
"(",
"strBufferIndex",
">",
"0",
"&&",
"strBuffer",
"[",
"strBufferIndex",
"-",
"1",
"]",
"!=",
"LF",
")",
"{",
"// the last byte doesn't correspond to lf",
"return",
"readLine",
"(",
"false",
")",
";",
"}",
"int",
"strBufferLength",
"=",
"strBufferIndex",
";",
"strBufferIndex",
"=",
"0",
";",
"return",
"new",
"String",
"(",
"strBuffer",
",",
"0",
",",
"strBufferLength",
",",
"charset",
")",
";",
"}"
] | Reads numBytes bytes, and returns the corresponding string | [
"Reads",
"numBytes",
"bytes",
"and",
"returns",
"the",
"corresponding",
"string"
] | 72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c | https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java#L151-L176 |
162,094 | twitter/hbc | hbc-core/src/main/java/com/twitter/hbc/core/endpoint/DefaultStreamingEndpoint.java | DefaultStreamingEndpoint.languages | public DefaultStreamingEndpoint languages(List<String> languages) {
addPostParameter(Constants.LANGUAGE_PARAM, Joiner.on(',').join(languages));
return this;
} | java | public DefaultStreamingEndpoint languages(List<String> languages) {
addPostParameter(Constants.LANGUAGE_PARAM, Joiner.on(',').join(languages));
return this;
} | [
"public",
"DefaultStreamingEndpoint",
"languages",
"(",
"List",
"<",
"String",
">",
"languages",
")",
"{",
"addPostParameter",
"(",
"Constants",
".",
"LANGUAGE_PARAM",
",",
"Joiner",
".",
"on",
"(",
"'",
"'",
")",
".",
"join",
"(",
"languages",
")",
")",
";",
"return",
"this",
";",
"}"
] | Filter for public tweets on these languages.
@param languages
Valid BCP 47 (http://tools.ietf.org/html/bcp47) language identifiers,
and may represent any of the languages listed on Twitter's advanced search page
(https://twitter.com/search-advanced), or "und" if no language could be detected.
These strings should NOT be url-encoded.
@return this | [
"Filter",
"for",
"public",
"tweets",
"on",
"these",
"languages",
"."
] | 72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c | https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/core/endpoint/DefaultStreamingEndpoint.java#L89-L92 |
162,095 | twitter/hbc | hbc-twitter4j/src/main/java/com/twitter/hbc/twitter4j/BaseTwitter4jClient.java | BaseTwitter4jClient.process | @Override
public void process() {
if (client.isDone() || executorService.isTerminated()) {
throw new IllegalStateException("Client is already stopped");
}
Runnable runner = new Runnable() {
@Override
public void run() {
try {
while (!client.isDone()) {
String msg = messageQueue.take();
try {
parseMessage(msg);
} catch (Exception e) {
logger.warn("Exception thrown during parsing msg " + msg, e);
onException(e);
}
}
} catch (Exception e) {
onException(e);
}
}
};
executorService.execute(runner);
} | java | @Override
public void process() {
if (client.isDone() || executorService.isTerminated()) {
throw new IllegalStateException("Client is already stopped");
}
Runnable runner = new Runnable() {
@Override
public void run() {
try {
while (!client.isDone()) {
String msg = messageQueue.take();
try {
parseMessage(msg);
} catch (Exception e) {
logger.warn("Exception thrown during parsing msg " + msg, e);
onException(e);
}
}
} catch (Exception e) {
onException(e);
}
}
};
executorService.execute(runner);
} | [
"@",
"Override",
"public",
"void",
"process",
"(",
")",
"{",
"if",
"(",
"client",
".",
"isDone",
"(",
")",
"||",
"executorService",
".",
"isTerminated",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Client is already stopped\"",
")",
";",
"}",
"Runnable",
"runner",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"while",
"(",
"!",
"client",
".",
"isDone",
"(",
")",
")",
"{",
"String",
"msg",
"=",
"messageQueue",
".",
"take",
"(",
")",
";",
"try",
"{",
"parseMessage",
"(",
"msg",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Exception thrown during parsing msg \"",
"+",
"msg",
",",
"e",
")",
";",
"onException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"onException",
"(",
"e",
")",
";",
"}",
"}",
"}",
";",
"executorService",
".",
"execute",
"(",
"runner",
")",
";",
"}"
] | Forks off a runnable with the executor provided. Multiple calls are allowed, but the listeners must be
threadsafe. | [
"Forks",
"off",
"a",
"runnable",
"with",
"the",
"executor",
"provided",
".",
"Multiple",
"calls",
"are",
"allowed",
"but",
"the",
"listeners",
"must",
"be",
"threadsafe",
"."
] | 72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c | https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-twitter4j/src/main/java/com/twitter/hbc/twitter4j/BaseTwitter4jClient.java#L64-L89 |
162,096 | twitter/hbc | hbc-core/src/main/java/com/twitter/hbc/httpclient/ClientBase.java | ClientBase.stop | public void stop(int waitMillis) throws InterruptedException {
try {
if (!isDone()) {
setExitStatus(new Event(EventType.STOPPED_BY_USER, String.format("Stopped by user: waiting for %d ms", waitMillis)));
}
if (!waitForFinish(waitMillis)) {
logger.warn("{} Client thread failed to finish in {} millis", name, waitMillis);
}
} finally {
rateTracker.shutdown();
}
} | java | public void stop(int waitMillis) throws InterruptedException {
try {
if (!isDone()) {
setExitStatus(new Event(EventType.STOPPED_BY_USER, String.format("Stopped by user: waiting for %d ms", waitMillis)));
}
if (!waitForFinish(waitMillis)) {
logger.warn("{} Client thread failed to finish in {} millis", name, waitMillis);
}
} finally {
rateTracker.shutdown();
}
} | [
"public",
"void",
"stop",
"(",
"int",
"waitMillis",
")",
"throws",
"InterruptedException",
"{",
"try",
"{",
"if",
"(",
"!",
"isDone",
"(",
")",
")",
"{",
"setExitStatus",
"(",
"new",
"Event",
"(",
"EventType",
".",
"STOPPED_BY_USER",
",",
"String",
".",
"format",
"(",
"\"Stopped by user: waiting for %d ms\"",
",",
"waitMillis",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"waitForFinish",
"(",
"waitMillis",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"{} Client thread failed to finish in {} millis\"",
",",
"name",
",",
"waitMillis",
")",
";",
"}",
"}",
"finally",
"{",
"rateTracker",
".",
"shutdown",
"(",
")",
";",
"}",
"}"
] | Stops the current connection. No reconnecting will occur. Kills thread + cleanup.
Waits for the loop to end | [
"Stops",
"the",
"current",
"connection",
".",
"No",
"reconnecting",
"will",
"occur",
".",
"Kills",
"thread",
"+",
"cleanup",
".",
"Waits",
"for",
"the",
"loop",
"to",
"end"
] | 72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c | https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/httpclient/ClientBase.java#L299-L310 |
162,097 | gresrun/jesque | src/main/java/net/greghaines/jesque/worker/WorkerListenerDelegate.java | WorkerListenerDelegate.fireEvent | public void fireEvent(final WorkerEvent event, final Worker worker, final String queue, final Job job,
final Object runner, final Object result, final Throwable t) {
final ConcurrentSet<WorkerListener> listeners = this.eventListenerMap.get(event);
if (listeners != null) {
for (final WorkerListener listener : listeners) {
if (listener != null) {
try {
listener.onEvent(event, worker, queue, job, runner, result, t);
} catch (Exception e) {
log.error("Failure executing listener " + listener + " for event " + event
+ " from queue " + queue + " on worker " + worker, e);
}
}
}
}
} | java | public void fireEvent(final WorkerEvent event, final Worker worker, final String queue, final Job job,
final Object runner, final Object result, final Throwable t) {
final ConcurrentSet<WorkerListener> listeners = this.eventListenerMap.get(event);
if (listeners != null) {
for (final WorkerListener listener : listeners) {
if (listener != null) {
try {
listener.onEvent(event, worker, queue, job, runner, result, t);
} catch (Exception e) {
log.error("Failure executing listener " + listener + " for event " + event
+ " from queue " + queue + " on worker " + worker, e);
}
}
}
}
} | [
"public",
"void",
"fireEvent",
"(",
"final",
"WorkerEvent",
"event",
",",
"final",
"Worker",
"worker",
",",
"final",
"String",
"queue",
",",
"final",
"Job",
"job",
",",
"final",
"Object",
"runner",
",",
"final",
"Object",
"result",
",",
"final",
"Throwable",
"t",
")",
"{",
"final",
"ConcurrentSet",
"<",
"WorkerListener",
">",
"listeners",
"=",
"this",
".",
"eventListenerMap",
".",
"get",
"(",
"event",
")",
";",
"if",
"(",
"listeners",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"WorkerListener",
"listener",
":",
"listeners",
")",
"{",
"if",
"(",
"listener",
"!=",
"null",
")",
"{",
"try",
"{",
"listener",
".",
"onEvent",
"(",
"event",
",",
"worker",
",",
"queue",
",",
"job",
",",
"runner",
",",
"result",
",",
"t",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Failure executing listener \"",
"+",
"listener",
"+",
"\" for event \"",
"+",
"event",
"+",
"\" from queue \"",
"+",
"queue",
"+",
"\" on worker \"",
"+",
"worker",
",",
"e",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Notify all WorkerListeners currently registered for the given WorkerEvent.
@param event the WorkerEvent that occurred
@param worker the Worker that the event occurred in
@param queue the queue the Worker is processing
@param job the Job related to the event (only supply for JOB_PROCESS, JOB_EXECUTE, JOB_SUCCESS, and
JOB_FAILURE events)
@param runner the materialized object that the Job specified (only supply for JOB_EXECUTE and
JOB_SUCCESS events)
@param result the result of the successful execution of the Job (only set for JOB_SUCCESS and if the Job was
a Callable that returned a value)
@param t the Throwable that caused the event (only supply for JOB_FAILURE and ERROR events) | [
"Notify",
"all",
"WorkerListeners",
"currently",
"registered",
"for",
"the",
"given",
"WorkerEvent",
"."
] | 44749183dccc40962a94c2af547ea7d0d880b5d1 | https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/WorkerListenerDelegate.java#L130-L145 |
162,098 | gresrun/jesque | src/main/java/net/greghaines/jesque/utils/JesqueUtils.java | JesqueUtils.createBacktrace | public static List<String> createBacktrace(final Throwable t) {
final List<String> bTrace = new LinkedList<String>();
for (final StackTraceElement ste : t.getStackTrace()) {
bTrace.add(BT_PREFIX + ste.toString());
}
if (t.getCause() != null) {
addCauseToBacktrace(t.getCause(), bTrace);
}
return bTrace;
} | java | public static List<String> createBacktrace(final Throwable t) {
final List<String> bTrace = new LinkedList<String>();
for (final StackTraceElement ste : t.getStackTrace()) {
bTrace.add(BT_PREFIX + ste.toString());
}
if (t.getCause() != null) {
addCauseToBacktrace(t.getCause(), bTrace);
}
return bTrace;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"createBacktrace",
"(",
"final",
"Throwable",
"t",
")",
"{",
"final",
"List",
"<",
"String",
">",
"bTrace",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"final",
"StackTraceElement",
"ste",
":",
"t",
".",
"getStackTrace",
"(",
")",
")",
"{",
"bTrace",
".",
"add",
"(",
"BT_PREFIX",
"+",
"ste",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"t",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"addCauseToBacktrace",
"(",
"t",
".",
"getCause",
"(",
")",
",",
"bTrace",
")",
";",
"}",
"return",
"bTrace",
";",
"}"
] | Creates a Resque backtrace from a Throwable's stack trace. Includes
causes.
@param t
the Exception to use
@return a list of strings that represent how the exception's stacktrace
appears. | [
"Creates",
"a",
"Resque",
"backtrace",
"from",
"a",
"Throwable",
"s",
"stack",
"trace",
".",
"Includes",
"causes",
"."
] | 44749183dccc40962a94c2af547ea7d0d880b5d1 | https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JesqueUtils.java#L131-L140 |
162,099 | gresrun/jesque | src/main/java/net/greghaines/jesque/utils/JesqueUtils.java | JesqueUtils.addCauseToBacktrace | private static void addCauseToBacktrace(final Throwable cause, final List<String> bTrace) {
if (cause.getMessage() == null) {
bTrace.add(BT_CAUSED_BY_PREFIX + cause.getClass().getName());
} else {
bTrace.add(BT_CAUSED_BY_PREFIX + cause.getClass().getName() + ": " + cause.getMessage());
}
for (final StackTraceElement ste : cause.getStackTrace()) {
bTrace.add(BT_PREFIX + ste.toString());
}
if (cause.getCause() != null) {
addCauseToBacktrace(cause.getCause(), bTrace);
}
} | java | private static void addCauseToBacktrace(final Throwable cause, final List<String> bTrace) {
if (cause.getMessage() == null) {
bTrace.add(BT_CAUSED_BY_PREFIX + cause.getClass().getName());
} else {
bTrace.add(BT_CAUSED_BY_PREFIX + cause.getClass().getName() + ": " + cause.getMessage());
}
for (final StackTraceElement ste : cause.getStackTrace()) {
bTrace.add(BT_PREFIX + ste.toString());
}
if (cause.getCause() != null) {
addCauseToBacktrace(cause.getCause(), bTrace);
}
} | [
"private",
"static",
"void",
"addCauseToBacktrace",
"(",
"final",
"Throwable",
"cause",
",",
"final",
"List",
"<",
"String",
">",
"bTrace",
")",
"{",
"if",
"(",
"cause",
".",
"getMessage",
"(",
")",
"==",
"null",
")",
"{",
"bTrace",
".",
"add",
"(",
"BT_CAUSED_BY_PREFIX",
"+",
"cause",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"bTrace",
".",
"add",
"(",
"BT_CAUSED_BY_PREFIX",
"+",
"cause",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"cause",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"for",
"(",
"final",
"StackTraceElement",
"ste",
":",
"cause",
".",
"getStackTrace",
"(",
")",
")",
"{",
"bTrace",
".",
"add",
"(",
"BT_PREFIX",
"+",
"ste",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"cause",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"{",
"addCauseToBacktrace",
"(",
"cause",
".",
"getCause",
"(",
")",
",",
"bTrace",
")",
";",
"}",
"}"
] | Add a cause to the backtrace.
@param cause
the cause
@param bTrace
the backtrace list | [
"Add",
"a",
"cause",
"to",
"the",
"backtrace",
"."
] | 44749183dccc40962a94c2af547ea7d0d880b5d1 | https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JesqueUtils.java#L150-L162 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.