repository_name stringlengths 7 58 | func_path_in_repository stringlengths 18 192 | func_name stringlengths 5 108 | whole_func_string stringlengths 75 3.91k | language stringclasses 1
value | func_code_string stringlengths 75 3.91k | func_code_tokens listlengths 21 629 | func_documentation_string stringlengths 61 1.98k | func_documentation_tokens listlengths 1 647 | split_name stringclasses 1
value | func_code_url stringlengths 111 306 |
|---|---|---|---|---|---|---|---|---|---|---|
fhoeben/hsac-fitnesse-fixtures | src/main/java/nl/hsac/fitnesse/fixture/slim/MapFixture.java | MapFixture.setValuesForIn | public void setValuesForIn(String values, String name, Map<String, Object> map) {
getMapHelper().setValuesForIn(values, name, map);
} | java | public void setValuesForIn(String values, String name, Map<String, Object> map) {
getMapHelper().setValuesForIn(values, name, map);
} | [
"public",
"void",
"setValuesForIn",
"(",
"String",
"values",
",",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"{",
"getMapHelper",
"(",
")",
".",
"setValuesForIn",
"(",
"values",
",",
"name",
",",
"map",
")",
";",
"}"
] | Stores list of values in map.
@param values comma separated list of values.
@param name name to use this list for.
@param map map to store values in. | [
"Stores",
"list",
"of",
"values",
"in",
"map",
"."
] | train | https://github.com/fhoeben/hsac-fitnesse-fixtures/blob/4e9018d7386a9aa65bfcbf07eb28ae064edd1732/src/main/java/nl/hsac/fitnesse/fixture/slim/MapFixture.java#L114-L116 |
google/error-prone-javac | src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java | JShellTool.messageFormat | String messageFormat(String key, Object... args) {
String rs = getResourceString(key);
return MessageFormat.format(rs, args);
} | java | String messageFormat(String key, Object... args) {
String rs = getResourceString(key);
return MessageFormat.format(rs, args);
} | [
"String",
"messageFormat",
"(",
"String",
"key",
",",
"Object",
"...",
"args",
")",
"{",
"String",
"rs",
"=",
"getResourceString",
"(",
"key",
")",
";",
"return",
"MessageFormat",
".",
"format",
"(",
"rs",
",",
"args",
")",
";",
"}"
] | Format using resource bundle look-up using MessageFormat
@param key the resource key
@param args | [
"Format",
"using",
"resource",
"bundle",
"look",
"-",
"up",
"using",
"MessageFormat"
] | train | https://github.com/google/error-prone-javac/blob/a53d069bbdb2c60232ed3811c19b65e41c3e60e0/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java#L787-L790 |
joniles/mpxj | src/main/java/net/sf/mpxj/common/DateHelper.java | DateHelper.getTime | public static Date getTime(int hour, int minutes)
{
Calendar cal = popCalendar();
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minutes);
cal.set(Calendar.SECOND, 0);
Date result = cal.getTime();
pushCalendar(cal);
return result;
} | java | public static Date getTime(int hour, int minutes)
{
Calendar cal = popCalendar();
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minutes);
cal.set(Calendar.SECOND, 0);
Date result = cal.getTime();
pushCalendar(cal);
return result;
} | [
"public",
"static",
"Date",
"getTime",
"(",
"int",
"hour",
",",
"int",
"minutes",
")",
"{",
"Calendar",
"cal",
"=",
"popCalendar",
"(",
")",
";",
"cal",
".",
"set",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"hour",
")",
";",
"cal",
".",
"set",
"(",
... | Create a Date instance representing a specific time.
@param hour hour 0-23
@param minutes minutes 0-59
@return new Date instance | [
"Create",
"a",
"Date",
"instance",
"representing",
"a",
"specific",
"time",
"."
] | train | https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/DateHelper.java#L318-L327 |
BranchMetrics/android-branch-deep-linking | Branch-SDK/src/io/branch/referral/Branch.java | Branch.userCompletedAction | public void userCompletedAction(@NonNull final String action, JSONObject metadata) {
userCompletedAction(action, metadata, null);
} | java | public void userCompletedAction(@NonNull final String action, JSONObject metadata) {
userCompletedAction(action, metadata, null);
} | [
"public",
"void",
"userCompletedAction",
"(",
"@",
"NonNull",
"final",
"String",
"action",
",",
"JSONObject",
"metadata",
")",
"{",
"userCompletedAction",
"(",
"action",
",",
"metadata",
",",
"null",
")",
";",
"}"
] | <p>A void call to indicate that the user has performed a specific action and for that to be
reported to the Branch API, with additional app-defined meta data to go along with that action.</p>
@param action A {@link String} value to be passed as an action that the user has carried
out. For example "registered" or "logged in".
@param metadata A {@link JSONObject} containing app-defined meta-data to be attached to a
user action that has just been completed. | [
"<p",
">",
"A",
"void",
"call",
"to",
"indicate",
"that",
"the",
"user",
"has",
"performed",
"a",
"specific",
"action",
"and",
"for",
"that",
"to",
"be",
"reported",
"to",
"the",
"Branch",
"API",
"with",
"additional",
"app",
"-",
"defined",
"meta",
"data... | train | https://github.com/BranchMetrics/android-branch-deep-linking/blob/e3bee2ccfcbf6d4bf1a5815b5b86666e4ff8f848/Branch-SDK/src/io/branch/referral/Branch.java#L2011-L2013 |
hdbeukel/james-extensions | src/main/java/org/jamesframework/ext/analysis/AnalysisResults.java | AnalysisResults.registerSearchRun | public void registerSearchRun(String problemID, String searchID, SearchRunResults<SolutionType> run){
if(!results.containsKey(problemID)){
results.put(problemID, new HashMap<>());
}
if(!results.get(problemID).containsKey(searchID)){
results.get(problemID).put(searchID, new ArrayList<>());
}
results.get(problemID).get(searchID).add(run);
} | java | public void registerSearchRun(String problemID, String searchID, SearchRunResults<SolutionType> run){
if(!results.containsKey(problemID)){
results.put(problemID, new HashMap<>());
}
if(!results.get(problemID).containsKey(searchID)){
results.get(problemID).put(searchID, new ArrayList<>());
}
results.get(problemID).get(searchID).add(run);
} | [
"public",
"void",
"registerSearchRun",
"(",
"String",
"problemID",
",",
"String",
"searchID",
",",
"SearchRunResults",
"<",
"SolutionType",
">",
"run",
")",
"{",
"if",
"(",
"!",
"results",
".",
"containsKey",
"(",
"problemID",
")",
")",
"{",
"results",
".",
... | Register results of a search run, specifying the IDs of the problem being solved and the applied search.
If no runs have been registered before for this combination of problem and search, new entries are created.
Else, this run is appended to the existing runs.
@param problemID ID of the problem being solved
@param searchID ID of the applied search
@param run results of the search run | [
"Register",
"results",
"of",
"a",
"search",
"run",
"specifying",
"the",
"IDs",
"of",
"the",
"problem",
"being",
"solved",
"and",
"the",
"applied",
"search",
".",
"If",
"no",
"runs",
"have",
"been",
"registered",
"before",
"for",
"this",
"combination",
"of",
... | train | https://github.com/hdbeukel/james-extensions/blob/37a43aa6ac4d67575cabc7aed25fd96c91d4c7b2/src/main/java/org/jamesframework/ext/analysis/AnalysisResults.java#L82-L90 |
Wolfgang-Schuetzelhofer/jcypher | src/main/java/iot/jcypher/domainquery/QueryPersistor.java | QueryPersistor.augment | public QueryPersistor augment(DomainObjectMatch<?> domainObjectMatch, String as) {
if (this.augmentations == null)
this.augmentations = new HashMap<DomainObjectMatch<?>, String>();
this.augmentations.put(domainObjectMatch, as);
return this;
} | java | public QueryPersistor augment(DomainObjectMatch<?> domainObjectMatch, String as) {
if (this.augmentations == null)
this.augmentations = new HashMap<DomainObjectMatch<?>, String>();
this.augmentations.put(domainObjectMatch, as);
return this;
} | [
"public",
"QueryPersistor",
"augment",
"(",
"DomainObjectMatch",
"<",
"?",
">",
"domainObjectMatch",
",",
"String",
"as",
")",
"{",
"if",
"(",
"this",
".",
"augmentations",
"==",
"null",
")",
"this",
".",
"augmentations",
"=",
"new",
"HashMap",
"<",
"DomainO... | Give a name to a DomainObjectMatch for better readability in a Java-DSL like string representation
@param domainObjectMatch
@param as
@return | [
"Give",
"a",
"name",
"to",
"a",
"DomainObjectMatch",
"for",
"better",
"readability",
"in",
"a",
"Java",
"-",
"DSL",
"like",
"string",
"representation"
] | train | https://github.com/Wolfgang-Schuetzelhofer/jcypher/blob/0f36914b4d6993a004cc235bb18dd3e02a59d253/src/main/java/iot/jcypher/domainquery/QueryPersistor.java#L118-L123 |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiViewRobust.java | FactoryMultiViewRobust.baselineLMedS | public static ModelMatcherMultiview<Se3_F64, AssociatedPair> baselineLMedS( @Nullable ConfigEssential essential,
@Nonnull ConfigLMedS lmeds )
{
if( essential == null )
essential = new ConfigEssential();
else
essential.checkValidity();
Estimate1ofEpipolar epipolar = FactoryMultiView.
essential_1(essential.which, essential.numResolve);
Triangulate2ViewsMetric triangulate = FactoryMultiView.triangulate2ViewMetric(
new ConfigTriangulation(ConfigTriangulation.Type.GEOMETRIC));
ModelManager<Se3_F64> manager = new ModelManagerSe3_F64();
ModelGenerator<Se3_F64, AssociatedPair> generateEpipolarMotion =
new Se3FromEssentialGenerator(epipolar, triangulate);
DistanceFromModelMultiView<Se3_F64, AssociatedPair> distanceSe3 = new DistanceSe3SymmetricSq(triangulate);
LeastMedianOfSquaresMultiView<Se3_F64, AssociatedPair> config = new LeastMedianOfSquaresMultiView<>
(lmeds.randSeed, lmeds.totalCycles, manager, generateEpipolarMotion, distanceSe3);
config.setErrorFraction(lmeds.errorFraction);
return config;
} | java | public static ModelMatcherMultiview<Se3_F64, AssociatedPair> baselineLMedS( @Nullable ConfigEssential essential,
@Nonnull ConfigLMedS lmeds )
{
if( essential == null )
essential = new ConfigEssential();
else
essential.checkValidity();
Estimate1ofEpipolar epipolar = FactoryMultiView.
essential_1(essential.which, essential.numResolve);
Triangulate2ViewsMetric triangulate = FactoryMultiView.triangulate2ViewMetric(
new ConfigTriangulation(ConfigTriangulation.Type.GEOMETRIC));
ModelManager<Se3_F64> manager = new ModelManagerSe3_F64();
ModelGenerator<Se3_F64, AssociatedPair> generateEpipolarMotion =
new Se3FromEssentialGenerator(epipolar, triangulate);
DistanceFromModelMultiView<Se3_F64, AssociatedPair> distanceSe3 = new DistanceSe3SymmetricSq(triangulate);
LeastMedianOfSquaresMultiView<Se3_F64, AssociatedPair> config = new LeastMedianOfSquaresMultiView<>
(lmeds.randSeed, lmeds.totalCycles, manager, generateEpipolarMotion, distanceSe3);
config.setErrorFraction(lmeds.errorFraction);
return config;
} | [
"public",
"static",
"ModelMatcherMultiview",
"<",
"Se3_F64",
",",
"AssociatedPair",
">",
"baselineLMedS",
"(",
"@",
"Nullable",
"ConfigEssential",
"essential",
",",
"@",
"Nonnull",
"ConfigLMedS",
"lmeds",
")",
"{",
"if",
"(",
"essential",
"==",
"null",
")",
"ess... | Robust solution for estimating {@link Se3_F64} using epipolar geometry from two views with
{@link LeastMedianOfSquares LMedS}. Input observations are in normalized image coordinates.
<ul>
<li>Error units is pixels squared times two</li>
</ul>
<p>See code for all the details.</p>
@param essential Essential matrix estimation parameters. Can't be null.
@param lmeds Parameters for RANSAC. Can't be null.
@return Robust Se3_F64 estimator | [
"Robust",
"solution",
"for",
"estimating",
"{",
"@link",
"Se3_F64",
"}",
"using",
"epipolar",
"geometry",
"from",
"two",
"views",
"with",
"{",
"@link",
"LeastMedianOfSquares",
"LMedS",
"}",
".",
"Input",
"observations",
"are",
"in",
"normalized",
"image",
"coord... | train | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiViewRobust.java#L143-L166 |
liferay/com-liferay-commerce | commerce-wish-list-service/src/main/java/com/liferay/commerce/wish/list/service/persistence/impl/CommerceWishListPersistenceImpl.java | CommerceWishListPersistenceImpl.findByGroupId | @Override
public List<CommerceWishList> findByGroupId(long groupId) {
return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | java | @Override
public List<CommerceWishList> findByGroupId(long groupId) {
return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
} | [
"@",
"Override",
"public",
"List",
"<",
"CommerceWishList",
">",
"findByGroupId",
"(",
"long",
"groupId",
")",
"{",
"return",
"findByGroupId",
"(",
"groupId",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"QueryUtil",
".",
"ALL_POS",
",",
"null",
")",
";",
"}"
] | Returns all the commerce wish lists where groupId = ?.
@param groupId the group ID
@return the matching commerce wish lists | [
"Returns",
"all",
"the",
"commerce",
"wish",
"lists",
"where",
"groupId",
"=",
"?",
";",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-wish-list-service/src/main/java/com/liferay/commerce/wish/list/service/persistence/impl/CommerceWishListPersistenceImpl.java#L1516-L1519 |
google/error-prone | core/src/main/java/com/google/errorprone/bugpatterns/ThreeLetterTimeZoneID.java | ThreeLetterTimeZoneID.handleNonDaylightSavingsZone | static Replacement handleNonDaylightSavingsZone(
boolean inJodaTimeContext, String daylightSavingsZone, String fixedOffset) {
if (inJodaTimeContext) {
String newDescription =
SUMMARY
+ "\n\n"
+ observesDaylightSavingsMessage("DateTimeZone", daylightSavingsZone, fixedOffset);
return new Replacement(newDescription, ImmutableList.of(daylightSavingsZone, fixedOffset));
} else {
String newDescription =
SUMMARY
+ "\n\n"
+ "This TimeZone will not observe daylight savings. "
+ "If this is intended, use "
+ fixedOffset
+ " instead; to observe daylight savings, use "
+ daylightSavingsZone
+ ".";
return new Replacement(newDescription, ImmutableList.of(fixedOffset, daylightSavingsZone));
}
} | java | static Replacement handleNonDaylightSavingsZone(
boolean inJodaTimeContext, String daylightSavingsZone, String fixedOffset) {
if (inJodaTimeContext) {
String newDescription =
SUMMARY
+ "\n\n"
+ observesDaylightSavingsMessage("DateTimeZone", daylightSavingsZone, fixedOffset);
return new Replacement(newDescription, ImmutableList.of(daylightSavingsZone, fixedOffset));
} else {
String newDescription =
SUMMARY
+ "\n\n"
+ "This TimeZone will not observe daylight savings. "
+ "If this is intended, use "
+ fixedOffset
+ " instead; to observe daylight savings, use "
+ daylightSavingsZone
+ ".";
return new Replacement(newDescription, ImmutableList.of(fixedOffset, daylightSavingsZone));
}
} | [
"static",
"Replacement",
"handleNonDaylightSavingsZone",
"(",
"boolean",
"inJodaTimeContext",
",",
"String",
"daylightSavingsZone",
",",
"String",
"fixedOffset",
")",
"{",
"if",
"(",
"inJodaTimeContext",
")",
"{",
"String",
"newDescription",
"=",
"SUMMARY",
"+",
"\"\\... | How we handle it depends upon whether we are in a JodaTime context or not. | [
"How",
"we",
"handle",
"it",
"depends",
"upon",
"whether",
"we",
"are",
"in",
"a",
"JodaTime",
"context",
"or",
"not",
"."
] | train | https://github.com/google/error-prone/blob/fe2e3cc2cf1958cb7c487bfe89852bb4c225ba9d/core/src/main/java/com/google/errorprone/bugpatterns/ThreeLetterTimeZoneID.java#L127-L147 |
Erudika/para | para-core/src/main/java/com/erudika/para/utils/Utils.java | Utils.getObjectURI | public static String getObjectURI(ParaObject obj, boolean includeName, boolean includeId) {
if (obj == null) {
return "/";
}
if (includeId && obj.getId() != null) {
return (includeName && !StringUtils.isBlank(obj.getName())) ? obj.getObjectURI().concat("-").
concat(urlEncode(noSpaces(obj.getName(), "-"))) : obj.getObjectURI();
} else {
return obj.getObjectURI();
}
} | java | public static String getObjectURI(ParaObject obj, boolean includeName, boolean includeId) {
if (obj == null) {
return "/";
}
if (includeId && obj.getId() != null) {
return (includeName && !StringUtils.isBlank(obj.getName())) ? obj.getObjectURI().concat("-").
concat(urlEncode(noSpaces(obj.getName(), "-"))) : obj.getObjectURI();
} else {
return obj.getObjectURI();
}
} | [
"public",
"static",
"String",
"getObjectURI",
"(",
"ParaObject",
"obj",
",",
"boolean",
"includeName",
",",
"boolean",
"includeId",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"return",
"\"/\"",
";",
"}",
"if",
"(",
"includeId",
"&&",
"obj",
".",... | Returns the default URL for a given domain object.
@param obj the domain object
@param includeName true if we want to include the name of the object in the URL
@param includeId true if we want to include the ID of the object in the URL
@return the object's URL - e.g. /users/123-name, /users/, /users/123 | [
"Returns",
"the",
"default",
"URL",
"for",
"a",
"given",
"domain",
"object",
"."
] | train | https://github.com/Erudika/para/blob/5ba096c477042ea7b18e9a0e8b5b1ee0f5bd6ce9/para-core/src/main/java/com/erudika/para/utils/Utils.java#L697-L707 |
xdcrafts/flower | flower-tools/src/main/java/com/github/xdcrafts/flower/tools/map/MapApi.java | MapApi.getUnsafe | public static Object getUnsafe(final Map map, final Object... path) {
return getUnsafe(map, Object.class, path);
} | java | public static Object getUnsafe(final Map map, final Object... path) {
return getUnsafe(map, Object.class, path);
} | [
"public",
"static",
"Object",
"getUnsafe",
"(",
"final",
"Map",
"map",
",",
"final",
"Object",
"...",
"path",
")",
"{",
"return",
"getUnsafe",
"(",
"map",
",",
"Object",
".",
"class",
",",
"path",
")",
";",
"}"
] | Get object value by path.
@param map subject
@param path nodes to walk in map
@return value | [
"Get",
"object",
"value",
"by",
"path",
"."
] | train | https://github.com/xdcrafts/flower/blob/96a8e49102fea434bd383a3c7852f0ee9545f999/flower-tools/src/main/java/com/github/xdcrafts/flower/tools/map/MapApi.java#L157-L159 |
apache/incubator-druid | processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ByteBufferMinMaxOffsetHeap.java | ByteBufferMinMaxOffsetHeap.findMin | private int findMin(Comparator comparator, int index, int len)
{
if (index >= heapSize) {
return -1;
}
int limit = Math.min(index, heapSize - len) + len;
int minIndex = index;
for (int i = index + 1; i < limit; i++) {
if (comparator.compare(buf.getInt(i * Integer.BYTES), buf.getInt(minIndex * Integer.BYTES)) < 0) {
minIndex = i;
}
}
return minIndex;
} | java | private int findMin(Comparator comparator, int index, int len)
{
if (index >= heapSize) {
return -1;
}
int limit = Math.min(index, heapSize - len) + len;
int minIndex = index;
for (int i = index + 1; i < limit; i++) {
if (comparator.compare(buf.getInt(i * Integer.BYTES), buf.getInt(minIndex * Integer.BYTES)) < 0) {
minIndex = i;
}
}
return minIndex;
} | [
"private",
"int",
"findMin",
"(",
"Comparator",
"comparator",
",",
"int",
"index",
",",
"int",
"len",
")",
"{",
"if",
"(",
"index",
">=",
"heapSize",
")",
"{",
"return",
"-",
"1",
";",
"}",
"int",
"limit",
"=",
"Math",
".",
"min",
"(",
"index",
","... | Returns the index of minimum value between {@code index} and
{@code index + len}, or {@code -1} if {@code index} is greater than
{@code size}. | [
"Returns",
"the",
"index",
"of",
"minimum",
"value",
"between",
"{"
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ByteBufferMinMaxOffsetHeap.java#L357-L370 |
MTDdk/jawn | jawn-templates-stringtemplate/src/main/java/net/javapla/jawn/templates/stringtemplate/StringTemplateTemplateEngine.java | StringTemplateTemplateEngine.renderContentTemplate | private final String renderContentTemplate(final ST contentTemplate, final Map<String, Object> values, final ErrorBuffer error, boolean inErrorState) {
if (contentTemplate != null) { // it has to be possible to use a layout without defining a template
try (Writer sw = new StringBuilderWriter()) {
final ErrorBuffer templateErrors = new ErrorBuffer();
renderContentTemplate(contentTemplate, sw, values/*, language*/, templateErrors);
// handle potential errors
if (!templateErrors.errors.isEmpty() && !inErrorState) {
for (STMessage err : templateErrors.errors) {
if (err.error == ErrorType.INTERNAL_ERROR) {
log.warn("Reloading GroupDir as we have found a problem during rendering of template \"{}\"\n{}",contentTemplate.getName(), templateErrors.errors.toString());
//README when errors occur, try to reload the specified templates and try the whole thing again
// this often rectifies the problem
reloadGroup();
ST reloadedContentTemplate = readTemplate(contentTemplate.getName());
return renderContentTemplate(reloadedContentTemplate, values, error, true);
}
}
}
return sw.toString();
} catch (IOException noMethodsThrowsIOE) { }
}
return "";
} | java | private final String renderContentTemplate(final ST contentTemplate, final Map<String, Object> values, final ErrorBuffer error, boolean inErrorState) {
if (contentTemplate != null) { // it has to be possible to use a layout without defining a template
try (Writer sw = new StringBuilderWriter()) {
final ErrorBuffer templateErrors = new ErrorBuffer();
renderContentTemplate(contentTemplate, sw, values/*, language*/, templateErrors);
// handle potential errors
if (!templateErrors.errors.isEmpty() && !inErrorState) {
for (STMessage err : templateErrors.errors) {
if (err.error == ErrorType.INTERNAL_ERROR) {
log.warn("Reloading GroupDir as we have found a problem during rendering of template \"{}\"\n{}",contentTemplate.getName(), templateErrors.errors.toString());
//README when errors occur, try to reload the specified templates and try the whole thing again
// this often rectifies the problem
reloadGroup();
ST reloadedContentTemplate = readTemplate(contentTemplate.getName());
return renderContentTemplate(reloadedContentTemplate, values, error, true);
}
}
}
return sw.toString();
} catch (IOException noMethodsThrowsIOE) { }
}
return "";
} | [
"private",
"final",
"String",
"renderContentTemplate",
"(",
"final",
"ST",
"contentTemplate",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"values",
",",
"final",
"ErrorBuffer",
"error",
",",
"boolean",
"inErrorState",
")",
"{",
"if",
"(",
"contentT... | Renders template into string
@return The rendered template if exists, or empty string | [
"Renders",
"template",
"into",
"string"
] | train | https://github.com/MTDdk/jawn/blob/4ec2d09b97d413efdead7487e6075e5bfd13b925/jawn-templates-stringtemplate/src/main/java/net/javapla/jawn/templates/stringtemplate/StringTemplateTemplateEngine.java#L213-L238 |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/FileUtils.java | FileUtils.atomicMove | public static void atomicMove(File source, File dest) throws IOException {
Files.move(source.toPath(), dest.toPath(), ATOMIC_MOVE, REPLACE_EXISTING);
} | java | public static void atomicMove(File source, File dest) throws IOException {
Files.move(source.toPath(), dest.toPath(), ATOMIC_MOVE, REPLACE_EXISTING);
} | [
"public",
"static",
"void",
"atomicMove",
"(",
"File",
"source",
",",
"File",
"dest",
")",
"throws",
"IOException",
"{",
"Files",
".",
"move",
"(",
"source",
".",
"toPath",
"(",
")",
",",
"dest",
".",
"toPath",
"(",
")",
",",
"ATOMIC_MOVE",
",",
"REPLA... | Atomically move one file to another file.
@param source the source file.
@param dest the destination file.
@throws IOException if an I/O error occurs. | [
"Atomically",
"move",
"one",
"file",
"to",
"another",
"file",
"."
] | train | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/FileUtils.java#L141-L143 |
randomsync/robotframework-mqttlibrary-java | src/main/java/net/randomsync/robotframework/mqtt/MQTTLibrary.java | MQTTLibrary.publishToMQTTSynchronously | @RobotKeywordOverload
@ArgumentNames({ "topic", "message" })
public void publishToMQTTSynchronously(String topic, Object message)
throws MqttException {
publishToMQTTSynchronously(topic, message, 0, false);
} | java | @RobotKeywordOverload
@ArgumentNames({ "topic", "message" })
public void publishToMQTTSynchronously(String topic, Object message)
throws MqttException {
publishToMQTTSynchronously(topic, message, 0, false);
} | [
"@",
"RobotKeywordOverload",
"@",
"ArgumentNames",
"(",
"{",
"\"topic\"",
",",
"\"message\"",
"}",
")",
"public",
"void",
"publishToMQTTSynchronously",
"(",
"String",
"topic",
",",
"Object",
"message",
")",
"throws",
"MqttException",
"{",
"publishToMQTTSynchronously",... | Publish a message to a topic
@param topic
topic to which the message will be published
@param message
message payload to publish
@throws MqttException
if there is an issue publishing to the broker | [
"Publish",
"a",
"message",
"to",
"a",
"topic"
] | train | https://github.com/randomsync/robotframework-mqttlibrary-java/blob/b10e346ea159d86e60a73062297c4a0d57149c89/src/main/java/net/randomsync/robotframework/mqtt/MQTTLibrary.java#L75-L80 |
timewalker74/ffmq | core/src/main/java/net/timewalker/ffmq4/utils/JNDITools.java | JNDITools.getContext | public static Context getContext( String jdniInitialContextFactoryName , String providerURL , Hashtable<String,Object> extraEnv ) throws NamingException
{
Hashtable<String,Object> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, jdniInitialContextFactoryName);
env.put(Context.PROVIDER_URL, providerURL);
if (extraEnv != null)
env.putAll(extraEnv);
return createJndiContext(env);
} | java | public static Context getContext( String jdniInitialContextFactoryName , String providerURL , Hashtable<String,Object> extraEnv ) throws NamingException
{
Hashtable<String,Object> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, jdniInitialContextFactoryName);
env.put(Context.PROVIDER_URL, providerURL);
if (extraEnv != null)
env.putAll(extraEnv);
return createJndiContext(env);
} | [
"public",
"static",
"Context",
"getContext",
"(",
"String",
"jdniInitialContextFactoryName",
",",
"String",
"providerURL",
",",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"extraEnv",
")",
"throws",
"NamingException",
"{",
"Hashtable",
"<",
"String",
",",
"Obj... | Create a JNDI context for the current provider
@param jdniInitialContextFactoryName
@param providerURL
@param extraEnv
@return a JNDI context
@throws NamingException | [
"Create",
"a",
"JNDI",
"context",
"for",
"the",
"current",
"provider"
] | train | https://github.com/timewalker74/ffmq/blob/638773ee29a4a5f9c6119ed74ad14ac9c46382b3/core/src/main/java/net/timewalker/ffmq4/utils/JNDITools.java#L52-L60 |
ModeShape/modeshape | modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java | NodeSequence.batchOf | public static Batch batchOf( final Iterator<CachedNode> nodes,
final long nodeCount,
final float score,
final String workspaceName ) {
assert nodeCount >= -1;
if (nodes == null) return emptyBatch(workspaceName, 1);
return new Batch() {
private CachedNode current;
@Override
public int width() {
return 1;
}
@Override
public long rowCount() {
return nodeCount;
}
@Override
public boolean isEmpty() {
return nodeCount == 0;
}
@Override
public String getWorkspaceName() {
return workspaceName;
}
@Override
public boolean hasNext() {
return nodes.hasNext();
}
@Override
public void nextRow() {
current = nodes.next();
}
@Override
public CachedNode getNode() {
return current;
}
@Override
public CachedNode getNode( int index ) {
if (index != 0) throw new IndexOutOfBoundsException();
return current;
}
@Override
public float getScore() {
return score;
}
@Override
public float getScore( int index ) {
if (index != 0) throw new IndexOutOfBoundsException();
return score;
}
@Override
public String toString() {
return "(batch node-count=" + rowCount() + " score=" + getScore() + " )";
}
};
} | java | public static Batch batchOf( final Iterator<CachedNode> nodes,
final long nodeCount,
final float score,
final String workspaceName ) {
assert nodeCount >= -1;
if (nodes == null) return emptyBatch(workspaceName, 1);
return new Batch() {
private CachedNode current;
@Override
public int width() {
return 1;
}
@Override
public long rowCount() {
return nodeCount;
}
@Override
public boolean isEmpty() {
return nodeCount == 0;
}
@Override
public String getWorkspaceName() {
return workspaceName;
}
@Override
public boolean hasNext() {
return nodes.hasNext();
}
@Override
public void nextRow() {
current = nodes.next();
}
@Override
public CachedNode getNode() {
return current;
}
@Override
public CachedNode getNode( int index ) {
if (index != 0) throw new IndexOutOfBoundsException();
return current;
}
@Override
public float getScore() {
return score;
}
@Override
public float getScore( int index ) {
if (index != 0) throw new IndexOutOfBoundsException();
return score;
}
@Override
public String toString() {
return "(batch node-count=" + rowCount() + " score=" + getScore() + " )";
}
};
} | [
"public",
"static",
"Batch",
"batchOf",
"(",
"final",
"Iterator",
"<",
"CachedNode",
">",
"nodes",
",",
"final",
"long",
"nodeCount",
",",
"final",
"float",
"score",
",",
"final",
"String",
"workspaceName",
")",
"{",
"assert",
"nodeCount",
">=",
"-",
"1",
... | Create a batch of nodes around the supplied iterator. Note that the supplied iterator is accessed lazily only when the
batch is {@link Batch#nextRow() used}.
@param nodes the iterator over the nodes to be returned; if null, an {@link #emptySequence empty instance} is returned
@param nodeCount the number of nodes in the iterator; must be -1 if not known, 0 if known to be empty, or a positive number
if the number of nodes is known
@param score the score to return for all of the nodes
@param workspaceName the name of the workspace in which all of the nodes exist
@return the batch of nodes; never null | [
"Create",
"a",
"batch",
"of",
"nodes",
"around",
"the",
"supplied",
"iterator",
".",
"Note",
"that",
"the",
"supplied",
"iterator",
"is",
"accessed",
"lazily",
"only",
"when",
"the",
"batch",
"is",
"{",
"@link",
"Batch#nextRow",
"()",
"used",
"}",
"."
] | train | https://github.com/ModeShape/modeshape/blob/794cfdabb67a90f24629c4fff0424a6125f8f95b/modeshape-jcr/src/main/java/org/modeshape/jcr/query/NodeSequence.java#L1330-L1396 |
alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/TopologyAssign.java | TopologyAssign.sortSlots | public static List<WorkerSlot> sortSlots(Set<WorkerSlot> allSlots, int needSlotNum) {
Map<String, List<WorkerSlot>> nodeMap = new HashMap<>();
// group by first
for (WorkerSlot np : allSlots) {
String node = np.getNodeId();
List<WorkerSlot> list = nodeMap.get(node);
if (list == null) {
list = new ArrayList<>();
nodeMap.put(node, list);
}
list.add(np);
}
for (Entry<String, List<WorkerSlot>> entry : nodeMap.entrySet()) {
List<WorkerSlot> ports = entry.getValue();
Collections.sort(ports, new Comparator<WorkerSlot>() {
@Override
public int compare(WorkerSlot first, WorkerSlot second) {
String firstNode = first.getNodeId();
String secondNode = second.getNodeId();
if (!firstNode.equals(secondNode)) {
return firstNode.compareTo(secondNode);
} else {
return first.getPort() - second.getPort();
}
}
});
}
// interleave
List<List<WorkerSlot>> splitup = new ArrayList<>(nodeMap.values());
Collections.sort(splitup, new Comparator<List<WorkerSlot>>() {
public int compare(List<WorkerSlot> o1, List<WorkerSlot> o2) {
return o2.size() - o1.size();
}
});
List<WorkerSlot> sortedFreeSlots = JStormUtils.interleave_all(splitup);
if (sortedFreeSlots.size() <= needSlotNum) {
return sortedFreeSlots;
}
// sortedFreeSlots > needSlotNum
return sortedFreeSlots.subList(0, needSlotNum);
} | java | public static List<WorkerSlot> sortSlots(Set<WorkerSlot> allSlots, int needSlotNum) {
Map<String, List<WorkerSlot>> nodeMap = new HashMap<>();
// group by first
for (WorkerSlot np : allSlots) {
String node = np.getNodeId();
List<WorkerSlot> list = nodeMap.get(node);
if (list == null) {
list = new ArrayList<>();
nodeMap.put(node, list);
}
list.add(np);
}
for (Entry<String, List<WorkerSlot>> entry : nodeMap.entrySet()) {
List<WorkerSlot> ports = entry.getValue();
Collections.sort(ports, new Comparator<WorkerSlot>() {
@Override
public int compare(WorkerSlot first, WorkerSlot second) {
String firstNode = first.getNodeId();
String secondNode = second.getNodeId();
if (!firstNode.equals(secondNode)) {
return firstNode.compareTo(secondNode);
} else {
return first.getPort() - second.getPort();
}
}
});
}
// interleave
List<List<WorkerSlot>> splitup = new ArrayList<>(nodeMap.values());
Collections.sort(splitup, new Comparator<List<WorkerSlot>>() {
public int compare(List<WorkerSlot> o1, List<WorkerSlot> o2) {
return o2.size() - o1.size();
}
});
List<WorkerSlot> sortedFreeSlots = JStormUtils.interleave_all(splitup);
if (sortedFreeSlots.size() <= needSlotNum) {
return sortedFreeSlots;
}
// sortedFreeSlots > needSlotNum
return sortedFreeSlots.subList(0, needSlotNum);
} | [
"public",
"static",
"List",
"<",
"WorkerSlot",
">",
"sortSlots",
"(",
"Set",
"<",
"WorkerSlot",
">",
"allSlots",
",",
"int",
"needSlotNum",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"WorkerSlot",
">",
">",
"nodeMap",
"=",
"new",
"HashMap",
"<>",
... | sort slots, the purpose is to ensure that the tasks are assigned in balancing
@return List<WorkerSlot> | [
"sort",
"slots",
"the",
"purpose",
"is",
"to",
"ensure",
"that",
"the",
"tasks",
"are",
"assigned",
"in",
"balancing"
] | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/TopologyAssign.java#L648-L697 |
Impetus/Kundera | src/jpa-engine/core/src/main/java/com/impetus/kundera/query/KunderaQuery.java | KunderaQuery.setParameterValue | private void setParameterValue(String name, Object value) {
if (typedParameter != null) {
List<FilterClause> clauses =
typedParameter.getParameters() != null ? typedParameter.getParameters().get(name) : null;
if (clauses != null) {
for (FilterClause clause : clauses) {
clause.setValue(value);
}
} else {
if (typedParameter.getUpdateParameters() != null) {
UpdateClause updateClause = typedParameter.getUpdateParameters().get(name);
updateClause.setValue(value);
} else {
logger.error("Error while setting parameter.");
throw new QueryHandlerException("named parameter : " + name + " not found!");
}
}
} else {
throw new QueryHandlerException("No named parameter present for query");
}
} | java | private void setParameterValue(String name, Object value) {
if (typedParameter != null) {
List<FilterClause> clauses =
typedParameter.getParameters() != null ? typedParameter.getParameters().get(name) : null;
if (clauses != null) {
for (FilterClause clause : clauses) {
clause.setValue(value);
}
} else {
if (typedParameter.getUpdateParameters() != null) {
UpdateClause updateClause = typedParameter.getUpdateParameters().get(name);
updateClause.setValue(value);
} else {
logger.error("Error while setting parameter.");
throw new QueryHandlerException("named parameter : " + name + " not found!");
}
}
} else {
throw new QueryHandlerException("No named parameter present for query");
}
} | [
"private",
"void",
"setParameterValue",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"typedParameter",
"!=",
"null",
")",
"{",
"List",
"<",
"FilterClause",
">",
"clauses",
"=",
"typedParameter",
".",
"getParameters",
"(",
")",
"!=",
... | Sets parameter value into filterClause, depending upon {@link Type}.
@param name
parameter name.
@param value
parameter value. | [
"Sets",
"parameter",
"value",
"into",
"filterClause",
"depending",
"upon",
"{",
"@link",
"Type",
"}",
"."
] | train | https://github.com/Impetus/Kundera/blob/268958ab1ec09d14ec4d9184f0c8ded7a9158908/src/jpa-engine/core/src/main/java/com/impetus/kundera/query/KunderaQuery.java#L857-L877 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMDefaultBase.java | DTMDefaultBase.appendChild | public void appendChild(int newChild, boolean clone, boolean cloneDepth)
{
error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"appendChild not yet supported!");
} | java | public void appendChild(int newChild, boolean clone, boolean cloneDepth)
{
error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"appendChild not yet supported!");
} | [
"public",
"void",
"appendChild",
"(",
"int",
"newChild",
",",
"boolean",
"clone",
",",
"boolean",
"cloneDepth",
")",
"{",
"error",
"(",
"XMLMessages",
".",
"createXMLMessage",
"(",
"XMLErrorResources",
".",
"ER_METHOD_NOT_SUPPORTED",
",",
"null",
")",
")",
";",
... | Append a child to the end of the document. Please note that the node
is always cloned if it is owned by another document.
<p>%REVIEW% "End of the document" needs to be defined more clearly.
Does it become the last child of the Document? Of the root element?</p>
@param newChild Must be a valid new node handle.
@param clone true if the child should be cloned into the document.
@param cloneDepth if the clone argument is true, specifies that the
clone should include all it's children. | [
"Append",
"a",
"child",
"to",
"the",
"end",
"of",
"the",
"document",
".",
"Please",
"note",
"that",
"the",
"node",
"is",
"always",
"cloned",
"if",
"it",
"is",
"owned",
"by",
"another",
"document",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/dtm/ref/DTMDefaultBase.java#L2235-L2238 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/LocalTime.java | LocalTime.plusMinutes | public LocalTime plusMinutes(long minutesToAdd) {
if (minutesToAdd == 0) {
return this;
}
int mofd = hour * MINUTES_PER_HOUR + minute;
int newMofd = ((int) (minutesToAdd % MINUTES_PER_DAY) + mofd + MINUTES_PER_DAY) % MINUTES_PER_DAY;
if (mofd == newMofd) {
return this;
}
int newHour = newMofd / MINUTES_PER_HOUR;
int newMinute = newMofd % MINUTES_PER_HOUR;
return create(newHour, newMinute, second, nano);
} | java | public LocalTime plusMinutes(long minutesToAdd) {
if (minutesToAdd == 0) {
return this;
}
int mofd = hour * MINUTES_PER_HOUR + minute;
int newMofd = ((int) (minutesToAdd % MINUTES_PER_DAY) + mofd + MINUTES_PER_DAY) % MINUTES_PER_DAY;
if (mofd == newMofd) {
return this;
}
int newHour = newMofd / MINUTES_PER_HOUR;
int newMinute = newMofd % MINUTES_PER_HOUR;
return create(newHour, newMinute, second, nano);
} | [
"public",
"LocalTime",
"plusMinutes",
"(",
"long",
"minutesToAdd",
")",
"{",
"if",
"(",
"minutesToAdd",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"int",
"mofd",
"=",
"hour",
"*",
"MINUTES_PER_HOUR",
"+",
"minute",
";",
"int",
"newMofd",
"=",
"(",
... | Returns a copy of this {@code LocalTime} with the specified number of minutes added.
<p>
This adds the specified number of minutes to this time, returning a new time.
The calculation wraps around midnight.
<p>
This instance is immutable and unaffected by this method call.
@param minutesToAdd the minutes to add, may be negative
@return a {@code LocalTime} based on this time with the minutes added, not null | [
"Returns",
"a",
"copy",
"of",
"this",
"{",
"@code",
"LocalTime",
"}",
"with",
"the",
"specified",
"number",
"of",
"minutes",
"added",
".",
"<p",
">",
"This",
"adds",
"the",
"specified",
"number",
"of",
"minutes",
"to",
"this",
"time",
"returning",
"a",
"... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/time/LocalTime.java#L1085-L1097 |
jbundle/jbundle | base/base/src/main/java/org/jbundle/base/util/UserProperties.java | UserProperties.init | public void init(MainApplication app, String strKey)
{
m_app = app;
if (strKey == null)
strKey = Constants.BLANK;
m_strKey = strKey; // + "\\";
m_app.addUserProperties(this);
} | java | public void init(MainApplication app, String strKey)
{
m_app = app;
if (strKey == null)
strKey = Constants.BLANK;
m_strKey = strKey; // + "\\";
m_app.addUserProperties(this);
} | [
"public",
"void",
"init",
"(",
"MainApplication",
"app",
",",
"String",
"strKey",
")",
"{",
"m_app",
"=",
"app",
";",
"if",
"(",
"strKey",
"==",
"null",
")",
"strKey",
"=",
"Constants",
".",
"BLANK",
";",
"m_strKey",
"=",
"strKey",
";",
"// + \"\\\\\";",... | Constructor.
@param app The parent application for these properties.
@param strKey The lookup key for these properties. | [
"Constructor",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/util/UserProperties.java#L79-L86 |
xcesco/kripton | kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/BindDataSourceBuilder.java | BindDataSourceBuilder.generateDaoUids | public static void generateDaoUids(TypeSpec.Builder classBuilder, SQLiteDatabaseSchema schema) {
for (SQLiteDaoDefinition dao : schema.getCollection()) {
classBuilder.addField(
FieldSpec.builder(Integer.TYPE, dao.daoUidName, Modifier.FINAL, Modifier.STATIC, Modifier.PUBLIC)
.initializer("" + dao.daoUidValue)
.addJavadoc("Unique identifier for Dao $L\n", dao.getName()).build());
}
} | java | public static void generateDaoUids(TypeSpec.Builder classBuilder, SQLiteDatabaseSchema schema) {
for (SQLiteDaoDefinition dao : schema.getCollection()) {
classBuilder.addField(
FieldSpec.builder(Integer.TYPE, dao.daoUidName, Modifier.FINAL, Modifier.STATIC, Modifier.PUBLIC)
.initializer("" + dao.daoUidValue)
.addJavadoc("Unique identifier for Dao $L\n", dao.getName()).build());
}
} | [
"public",
"static",
"void",
"generateDaoUids",
"(",
"TypeSpec",
".",
"Builder",
"classBuilder",
",",
"SQLiteDatabaseSchema",
"schema",
")",
"{",
"for",
"(",
"SQLiteDaoDefinition",
"dao",
":",
"schema",
".",
"getCollection",
"(",
")",
")",
"{",
"classBuilder",
".... | Generate Dao's UID. If specified, prefix will be used to
@param classBuilder
the class builder
@param schema
the schema | [
"Generate",
"Dao",
"s",
"UID",
".",
"If",
"specified",
"prefix",
"will",
"be",
"used",
"to"
] | train | https://github.com/xcesco/kripton/blob/90de2c0523d39b99e81b8d38aa996898762f594a/kripton-processor/src/main/java/com/abubusoft/kripton/processor/sqlite/BindDataSourceBuilder.java#L445-L454 |
awslabs/amazon-sqs-java-messaging-lib | src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java | SQSMessage.setObjectProperty | @Override
public void setObjectProperty(String name, Object value) throws JMSException {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Property name can not be null or empty.");
}
if (value == null || "".equals(value)) {
throw new IllegalArgumentException("Property value can not be null or empty.");
}
if(!isValidPropertyValueType(value)) {
throw new MessageFormatException("Value of property with name " + name + " has incorrect type " + value.getClass().getName() + ".");
}
checkPropertyWritePermissions();
properties.put(name, new JMSMessagePropertyValue(value));
} | java | @Override
public void setObjectProperty(String name, Object value) throws JMSException {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Property name can not be null or empty.");
}
if (value == null || "".equals(value)) {
throw new IllegalArgumentException("Property value can not be null or empty.");
}
if(!isValidPropertyValueType(value)) {
throw new MessageFormatException("Value of property with name " + name + " has incorrect type " + value.getClass().getName() + ".");
}
checkPropertyWritePermissions();
properties.put(name, new JMSMessagePropertyValue(value));
} | [
"@",
"Override",
"public",
"void",
"setObjectProperty",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"throws",
"JMSException",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentEx... | Sets a Java object property value with the specified name into the
message.
<P>
Note that this method works only for the boxed primitive object types
(Integer, Double, Long ...) and String objects.
@param name
The name of the property to set.
@param value
The object value of the property to set.
@throws JMSException
On internal error.
@throws IllegalArgumentException
If the name or value is null or empty string.
@throws MessageFormatException
If the object is invalid type.
@throws MessageNotWriteableException
If properties are read-only. | [
"Sets",
"a",
"Java",
"object",
"property",
"value",
"with",
"the",
"specified",
"name",
"into",
"the",
"message",
".",
"<P",
">",
"Note",
"that",
"this",
"method",
"works",
"only",
"for",
"the",
"boxed",
"primitive",
"object",
"types",
"(",
"Integer",
"Dou... | train | https://github.com/awslabs/amazon-sqs-java-messaging-lib/blob/efa716d34d51ef1c5572790626cdb795419cb342/src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java#L902-L915 |
mapbox/mapbox-plugins-android | plugin-offline/src/main/java/com/mapbox/mapboxsdk/plugins/offline/offline/OfflineDownloadService.java | OfflineDownloadService.finishDownload | void finishDownload(OfflineDownloadOptions offlineDownload, OfflineRegion offlineRegion) {
OfflineDownloadStateReceiver.dispatchSuccessBroadcast(this, offlineDownload);
offlineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE);
offlineRegion.setObserver(null);
removeOfflineRegion(offlineDownload.uuid().intValue());
} | java | void finishDownload(OfflineDownloadOptions offlineDownload, OfflineRegion offlineRegion) {
OfflineDownloadStateReceiver.dispatchSuccessBroadcast(this, offlineDownload);
offlineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE);
offlineRegion.setObserver(null);
removeOfflineRegion(offlineDownload.uuid().intValue());
} | [
"void",
"finishDownload",
"(",
"OfflineDownloadOptions",
"offlineDownload",
",",
"OfflineRegion",
"offlineRegion",
")",
"{",
"OfflineDownloadStateReceiver",
".",
"dispatchSuccessBroadcast",
"(",
"this",
",",
"offlineDownload",
")",
";",
"offlineRegion",
".",
"setDownloadSta... | When a particular download has been completed, this method's called which handles removing the
notification and setting the download state.
@param offlineRegion the region which has finished being downloaded
@param offlineDownload the corresponding options used to define the offline region
@since 0.1.0 | [
"When",
"a",
"particular",
"download",
"has",
"been",
"completed",
"this",
"method",
"s",
"called",
"which",
"handles",
"removing",
"the",
"notification",
"and",
"setting",
"the",
"download",
"state",
"."
] | train | https://github.com/mapbox/mapbox-plugins-android/blob/c683cad4d8306945d71838d96fae73b8cbe2e6c9/plugin-offline/src/main/java/com/mapbox/mapboxsdk/plugins/offline/offline/OfflineDownloadService.java#L251-L256 |
aws/aws-sdk-java | aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/UpdateRouteRequest.java | UpdateRouteRequest.withRequestModels | public UpdateRouteRequest withRequestModels(java.util.Map<String, String> requestModels) {
setRequestModels(requestModels);
return this;
} | java | public UpdateRouteRequest withRequestModels(java.util.Map<String, String> requestModels) {
setRequestModels(requestModels);
return this;
} | [
"public",
"UpdateRouteRequest",
"withRequestModels",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"requestModels",
")",
"{",
"setRequestModels",
"(",
"requestModels",
")",
";",
"return",
"this",
";",
"}"
] | <p>
The request models for the route.
</p>
@param requestModels
The request models for the route.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"The",
"request",
"models",
"for",
"the",
"route",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/UpdateRouteRequest.java#L494-L497 |
BioPAX/Paxtools | pattern/src/main/java/org/biopax/paxtools/pattern/PatternBox.java | PatternBox.molecularInteraction | public static Pattern molecularInteraction()
{
Pattern p = new Pattern(SequenceEntityReference.class, "Protein 1");
p.add(linkedER(true), "Protein 1", "generic Protein 1");
p.add(erToPE(), "generic Protein 1", "SPE1");
p.add(linkToComplex(), "SPE1", "PE1");
p.add(new PathConstraint("PhysicalEntity/participantOf:MolecularInteraction"), "PE1", "MI");
p.add(participant(), "MI", "PE2");
p.add(equal(false), "PE1", "PE2");
// participants are not both baits or preys
p.add(new NOT(new AND(new MappedConst(isPrey(), 0), new MappedConst(isPrey(), 1))), "PE1", "PE2");
p.add(new NOT(new AND(new MappedConst(isBait(), 0), new MappedConst(isBait(), 1))), "PE1", "PE2");
p.add(linkToSpecific(), "PE2", "SPE2");
p.add(type(SequenceEntity.class), "SPE2");
p.add(new PEChainsIntersect(false), "SPE1", "PE1", "SPE2", "PE2");
p.add(peToER(), "SPE2", "generic Protein 2");
p.add(linkedER(false), "generic Protein 2", "Protein 2");
p.add(equal(false), "Protein 1", "Protein 2");
return p;
} | java | public static Pattern molecularInteraction()
{
Pattern p = new Pattern(SequenceEntityReference.class, "Protein 1");
p.add(linkedER(true), "Protein 1", "generic Protein 1");
p.add(erToPE(), "generic Protein 1", "SPE1");
p.add(linkToComplex(), "SPE1", "PE1");
p.add(new PathConstraint("PhysicalEntity/participantOf:MolecularInteraction"), "PE1", "MI");
p.add(participant(), "MI", "PE2");
p.add(equal(false), "PE1", "PE2");
// participants are not both baits or preys
p.add(new NOT(new AND(new MappedConst(isPrey(), 0), new MappedConst(isPrey(), 1))), "PE1", "PE2");
p.add(new NOT(new AND(new MappedConst(isBait(), 0), new MappedConst(isBait(), 1))), "PE1", "PE2");
p.add(linkToSpecific(), "PE2", "SPE2");
p.add(type(SequenceEntity.class), "SPE2");
p.add(new PEChainsIntersect(false), "SPE1", "PE1", "SPE2", "PE2");
p.add(peToER(), "SPE2", "generic Protein 2");
p.add(linkedER(false), "generic Protein 2", "Protein 2");
p.add(equal(false), "Protein 1", "Protein 2");
return p;
} | [
"public",
"static",
"Pattern",
"molecularInteraction",
"(",
")",
"{",
"Pattern",
"p",
"=",
"new",
"Pattern",
"(",
"SequenceEntityReference",
".",
"class",
",",
"\"Protein 1\"",
")",
";",
"p",
".",
"add",
"(",
"linkedER",
"(",
"true",
")",
",",
"\"Protein 1\"... | Constructs a pattern where first and last molecules are participants of a
MolecularInteraction.
@return the pattern | [
"Constructs",
"a",
"pattern",
"where",
"first",
"and",
"last",
"molecules",
"are",
"participants",
"of",
"a",
"MolecularInteraction",
"."
] | train | https://github.com/BioPAX/Paxtools/blob/2f93afa94426bf8b5afc2e0e61cd4b269a83288d/pattern/src/main/java/org/biopax/paxtools/pattern/PatternBox.java#L647-L668 |
raydac/java-binary-block-parser | jbbp/src/main/java/com/igormaznitsa/jbbp/mapper/JBBPMapper.java | JBBPMapper.allocateMemoryForClass | private static <T> T allocateMemoryForClass(final JBBPFieldStruct root, final Class<T> klazz) {
try {
return CLASS_INSTANTIATOR.makeClassInstance(klazz);
} catch (InstantiationException ex) {
throw new JBBPMapperException("Can't make an instance of a class", root, klazz, null, ex);
}
} | java | private static <T> T allocateMemoryForClass(final JBBPFieldStruct root, final Class<T> klazz) {
try {
return CLASS_INSTANTIATOR.makeClassInstance(klazz);
} catch (InstantiationException ex) {
throw new JBBPMapperException("Can't make an instance of a class", root, klazz, null, ex);
}
} | [
"private",
"static",
"<",
"T",
">",
"T",
"allocateMemoryForClass",
"(",
"final",
"JBBPFieldStruct",
"root",
",",
"final",
"Class",
"<",
"T",
">",
"klazz",
")",
"{",
"try",
"{",
"return",
"CLASS_INSTANTIATOR",
".",
"makeClassInstance",
"(",
"klazz",
")",
";",... | Makes an instance of a class without call of its constructor, just allocate
memory
@param <T> a class which instance is needed
@param root the structure to be mapped, it is needed as info for exception
@param klazz the class which instance is needed
@return an instance of the class without called constructor
@throws JBBPMapperException it will be thrown if it is impossible to make
an instance | [
"Makes",
"an",
"instance",
"of",
"a",
"class",
"without",
"call",
"of",
"its",
"constructor",
"just",
"allocate",
"memory"
] | train | https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/mapper/JBBPMapper.java#L601-L607 |
Stratio/deep-spark | deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java | Cells.getBigDecimal | public BigDecimal getBigDecimal(String nameSpace, String cellName) {
return getValue(nameSpace, cellName, BigDecimal.class);
} | java | public BigDecimal getBigDecimal(String nameSpace, String cellName) {
return getValue(nameSpace, cellName, BigDecimal.class);
} | [
"public",
"BigDecimal",
"getBigDecimal",
"(",
"String",
"nameSpace",
",",
"String",
"cellName",
")",
"{",
"return",
"getValue",
"(",
"nameSpace",
",",
"cellName",
",",
"BigDecimal",
".",
"class",
")",
";",
"}"
] | Returns the {@code BigInteger} value of the {@link Cell} (associated to {@code table}) whose name iscellName, or
null if this Cells object contains no cell whose name is cellName.
@param nameSpace the name of the owning table
@param cellName the name of the Cell we want to retrieve from this Cells object.
@return the {@code BigInteger} value of the {@link Cell} (associated to {@code table}) whose name is cellName, or
null if this Cells object contains no cell whose name is cellName | [
"Returns",
"the",
"{",
"@code",
"BigInteger",
"}",
"value",
"of",
"the",
"{",
"@link",
"Cell",
"}",
"(",
"associated",
"to",
"{",
"@code",
"table",
"}",
")",
"whose",
"name",
"iscellName",
"or",
"null",
"if",
"this",
"Cells",
"object",
"contains",
"no",
... | train | https://github.com/Stratio/deep-spark/blob/b9621c9b7a6d996f80fce1d073d696a157bed095/deep-commons/src/main/java/com/stratio/deep/commons/entity/Cells.java#L1267-L1269 |
Whiley/WhileyCompiler | src/main/java/wyc/io/WhileyFileParser.java | WhileyFileParser.parseLValTerm | private LVal parseLValTerm(int start, EnclosingScope scope) {
checkNotEof();
start = index;
// First, attempt to disambiguate the easy forms:
Token lookahead = tokens.get(index);
switch (lookahead.kind) {
case Identifier:
Identifier name = parseIdentifier();
LVal var;
if(scope.isVariable(name)) {
var = new Expr.VariableAccess(Type.Void, scope.getVariableDeclaration(name));
} else {
var = new Expr.StaticVariableAccess(Type.Void, new Decl.Link<>(new Name(name)));
}
return annotateSourceLocation(var, start);
case LeftBrace: {
match(LeftBrace);
LVal lval = parseLVal(start, scope);
match(RightBrace);
return lval;
}
case Star: {
match(Star);
LVal lval = parseLVal(start, scope);
return annotateSourceLocation(new Expr.Dereference(Type.Void, lval), start);
}
default:
syntaxError("unrecognised lval", lookahead);
return null; // dead-code
}
} | java | private LVal parseLValTerm(int start, EnclosingScope scope) {
checkNotEof();
start = index;
// First, attempt to disambiguate the easy forms:
Token lookahead = tokens.get(index);
switch (lookahead.kind) {
case Identifier:
Identifier name = parseIdentifier();
LVal var;
if(scope.isVariable(name)) {
var = new Expr.VariableAccess(Type.Void, scope.getVariableDeclaration(name));
} else {
var = new Expr.StaticVariableAccess(Type.Void, new Decl.Link<>(new Name(name)));
}
return annotateSourceLocation(var, start);
case LeftBrace: {
match(LeftBrace);
LVal lval = parseLVal(start, scope);
match(RightBrace);
return lval;
}
case Star: {
match(Star);
LVal lval = parseLVal(start, scope);
return annotateSourceLocation(new Expr.Dereference(Type.Void, lval), start);
}
default:
syntaxError("unrecognised lval", lookahead);
return null; // dead-code
}
} | [
"private",
"LVal",
"parseLValTerm",
"(",
"int",
"start",
",",
"EnclosingScope",
"scope",
")",
"{",
"checkNotEof",
"(",
")",
";",
"start",
"=",
"index",
";",
"// First, attempt to disambiguate the easy forms:",
"Token",
"lookahead",
"=",
"tokens",
".",
"get",
"(",
... | Parse an lval term, which is of the form:
<pre>
TermLVal ::= Identifier // Variable assignment
| '(' LVal ')' // Bracketed assignment
</pre>
@param scope
The enclosing scope for this statement, which determines the
set of visible (i.e. declared) variables and also the current
indentation level.
@return | [
"Parse",
"an",
"lval",
"term",
"which",
"is",
"of",
"the",
"form",
":"
] | train | https://github.com/Whiley/WhileyCompiler/blob/680f8a657d3fc286f8cc422755988b6d74ab3f4c/src/main/java/wyc/io/WhileyFileParser.java#L1526-L1556 |
lightblueseas/vintage-time | src/main/java/de/alpharogroup/date/CalculateDateExtensions.java | CalculateDateExtensions.addYears | public static Date addYears(final Date date, final int addYears)
{
final Calendar dateOnCalendar = Calendar.getInstance();
dateOnCalendar.setTime(date);
dateOnCalendar.add(Calendar.YEAR, addYears);
return dateOnCalendar.getTime();
} | java | public static Date addYears(final Date date, final int addYears)
{
final Calendar dateOnCalendar = Calendar.getInstance();
dateOnCalendar.setTime(date);
dateOnCalendar.add(Calendar.YEAR, addYears);
return dateOnCalendar.getTime();
} | [
"public",
"static",
"Date",
"addYears",
"(",
"final",
"Date",
"date",
",",
"final",
"int",
"addYears",
")",
"{",
"final",
"Calendar",
"dateOnCalendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"dateOnCalendar",
".",
"setTime",
"(",
"date",
")",
... | Adds years to the given Date object and returns it. Note: you can add negative values too for
get date in past.
@param date
The Date object to add the years.
@param addYears
The years to add.
@return The resulted Date object. | [
"Adds",
"years",
"to",
"the",
"given",
"Date",
"object",
"and",
"returns",
"it",
".",
"Note",
":",
"you",
"can",
"add",
"negative",
"values",
"too",
"for",
"get",
"date",
"in",
"past",
"."
] | train | https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/CalculateDateExtensions.java#L179-L185 |
SahaginOrg/sahagin-java | src/main/java/org/sahagin/share/yaml/YamlUtils.java | YamlUtils.getCaptureStyleValue | public static CaptureStyle getCaptureStyleValue(Map<String, Object> yamlObject,
String key, boolean allowsEmpty) throws YamlConvertException {
Object obj = getObjectValue(yamlObject, key, allowsEmpty);
if (obj == null && allowsEmpty) {
return null;
}
String objStr;
if (obj == null) {
objStr = null;
} else {
objStr = obj.toString();
}
CaptureStyle result = CaptureStyle.getEnum(objStr);
if (result != null) {
return result;
} else {
throw new YamlConvertException(String.format(MSG_VALUE_NOT_CAPTURE_STYLE, key, objStr));
}
} | java | public static CaptureStyle getCaptureStyleValue(Map<String, Object> yamlObject,
String key, boolean allowsEmpty) throws YamlConvertException {
Object obj = getObjectValue(yamlObject, key, allowsEmpty);
if (obj == null && allowsEmpty) {
return null;
}
String objStr;
if (obj == null) {
objStr = null;
} else {
objStr = obj.toString();
}
CaptureStyle result = CaptureStyle.getEnum(objStr);
if (result != null) {
return result;
} else {
throw new YamlConvertException(String.format(MSG_VALUE_NOT_CAPTURE_STYLE, key, objStr));
}
} | [
"public",
"static",
"CaptureStyle",
"getCaptureStyleValue",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"yamlObject",
",",
"String",
"key",
",",
"boolean",
"allowsEmpty",
")",
"throws",
"YamlConvertException",
"{",
"Object",
"obj",
"=",
"getObjectValue",
"(",
... | if allowsEmpty, returns null for the case no key entry or null value | [
"if",
"allowsEmpty",
"returns",
"null",
"for",
"the",
"case",
"no",
"key",
"entry",
"or",
"null",
"value"
] | train | https://github.com/SahaginOrg/sahagin-java/blob/7ace428adebe3466ceb5826bc9681f8e3d52be68/src/main/java/org/sahagin/share/yaml/YamlUtils.java#L136-L154 |
haraldk/TwelveMonkeys | common/common-image/src/main/java/com/twelvemonkeys/image/IndexImage.java | IndexImage.createSolid | private static BufferedImage createSolid(BufferedImage pOriginal, Color pBackground) {
// Create a temporary image of same dimension and type
BufferedImage solid = new BufferedImage(pOriginal.getColorModel(), pOriginal.copyData(null), pOriginal.isAlphaPremultiplied(), null);
Graphics2D g = solid.createGraphics();
try {
// Clear in background color
g.setColor(pBackground);
g.setComposite(AlphaComposite.DstOver);// Paint "underneath"
g.fillRect(0, 0, pOriginal.getWidth(), pOriginal.getHeight());
}
finally {
g.dispose();
}
return solid;
} | java | private static BufferedImage createSolid(BufferedImage pOriginal, Color pBackground) {
// Create a temporary image of same dimension and type
BufferedImage solid = new BufferedImage(pOriginal.getColorModel(), pOriginal.copyData(null), pOriginal.isAlphaPremultiplied(), null);
Graphics2D g = solid.createGraphics();
try {
// Clear in background color
g.setColor(pBackground);
g.setComposite(AlphaComposite.DstOver);// Paint "underneath"
g.fillRect(0, 0, pOriginal.getWidth(), pOriginal.getHeight());
}
finally {
g.dispose();
}
return solid;
} | [
"private",
"static",
"BufferedImage",
"createSolid",
"(",
"BufferedImage",
"pOriginal",
",",
"Color",
"pBackground",
")",
"{",
"// Create a temporary image of same dimension and type\r",
"BufferedImage",
"solid",
"=",
"new",
"BufferedImage",
"(",
"pOriginal",
".",
"getColor... | Creates a copy of the given image, with a solid background
@param pOriginal the original image
@param pBackground the background color
@return a new {@code BufferedImage} | [
"Creates",
"a",
"copy",
"of",
"the",
"given",
"image",
"with",
"a",
"solid",
"background"
] | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/common/common-image/src/main/java/com/twelvemonkeys/image/IndexImage.java#L1164-L1180 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/handler/impl/CudaZeroHandler.java | CudaZeroHandler.memcpyBlocking | @Override
public void memcpyBlocking(DataBuffer dstBuffer, Pointer srcPointer, long length, long dstOffset) {
// internally it's just memcpyAsync + sync
CudaContext context = getCudaContext();
memcpyAsync(dstBuffer, srcPointer, length, dstOffset);
context.syncOldStream();
} | java | @Override
public void memcpyBlocking(DataBuffer dstBuffer, Pointer srcPointer, long length, long dstOffset) {
// internally it's just memcpyAsync + sync
CudaContext context = getCudaContext();
memcpyAsync(dstBuffer, srcPointer, length, dstOffset);
context.syncOldStream();
} | [
"@",
"Override",
"public",
"void",
"memcpyBlocking",
"(",
"DataBuffer",
"dstBuffer",
",",
"Pointer",
"srcPointer",
",",
"long",
"length",
",",
"long",
"dstOffset",
")",
"{",
"// internally it's just memcpyAsync + sync",
"CudaContext",
"context",
"=",
"getCudaContext",
... | Synchronous version of memcpy.
@param dstBuffer
@param srcPointer
@param length
@param dstOffset | [
"Synchronous",
"version",
"of",
"memcpy",
"."
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/handler/impl/CudaZeroHandler.java#L696-L702 |
jamesagnew/hapi-fhir | hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/filters/Date.java | Date.trySeconds | private Long trySeconds(String str) {
for(String pattern : datePatterns) {
SimpleDateFormat parser = new SimpleDateFormat(pattern, locale);
try {
long milliseconds = parser.parse(str).getTime();
return milliseconds / 1000L;
}
catch(Exception e) {
// Just ignore and try the next pattern in `datePatterns`.
}
}
// Could not parse the string into a meaningful date, return null.
return null;
} | java | private Long trySeconds(String str) {
for(String pattern : datePatterns) {
SimpleDateFormat parser = new SimpleDateFormat(pattern, locale);
try {
long milliseconds = parser.parse(str).getTime();
return milliseconds / 1000L;
}
catch(Exception e) {
// Just ignore and try the next pattern in `datePatterns`.
}
}
// Could not parse the string into a meaningful date, return null.
return null;
} | [
"private",
"Long",
"trySeconds",
"(",
"String",
"str",
")",
"{",
"for",
"(",
"String",
"pattern",
":",
"datePatterns",
")",
"{",
"SimpleDateFormat",
"parser",
"=",
"new",
"SimpleDateFormat",
"(",
"pattern",
",",
"locale",
")",
";",
"try",
"{",
"long",
"mil... | /*
Try to parse `str` into a Date and return this Date as seconds
since EPOCH, or null if it could not be parsed. | [
"/",
"*",
"Try",
"to",
"parse",
"str",
"into",
"a",
"Date",
"and",
"return",
"this",
"Date",
"as",
"seconds",
"since",
"EPOCH",
"or",
"null",
"if",
"it",
"could",
"not",
"be",
"parsed",
"."
] | train | https://github.com/jamesagnew/hapi-fhir/blob/150a84d52fe691b7f48fcb28247c4bddb7aec352/hapi-fhir-narrativegenerator/src/main/java/ca/uhn/fhir/narrative/template/filters/Date.java#L237-L254 |
svenkubiak/mangooio | mangooio-core/src/main/java/io/mangoo/utils/RequestUtils.java | RequestUtils.hasValidAuthentication | public static boolean hasValidAuthentication(String cookie) {
boolean valid = false;
if (StringUtils.isNotBlank(cookie)) {
Config config = Application.getInstance(Config.class);
String value = null;
String [] contents = cookie.split(";");
for (String content : contents) {
if (StringUtils.isNotBlank(content) && content.startsWith(config.getAuthenticationCookieName())) {
value = StringUtils.substringAfter(content, config.getAuthenticationCookieName() + "=");
value = PATTERN.matcher(value).replaceAll("");
}
}
if (StringUtils.isNotBlank(value)) {
String jwt = Application.getInstance(Crypto.class).decrypt(value, config.getAuthenticationCookieEncryptionKey());
JwtConsumer jwtConsumer = new JwtConsumerBuilder()
.setRequireExpirationTime()
.setRequireSubject()
.setVerificationKey(new HmacKey(config.getAuthenticationCookieSignKey().getBytes(StandardCharsets.UTF_8)))
.setJwsAlgorithmConstraints(new AlgorithmConstraints(ConstraintType.WHITELIST, AlgorithmIdentifiers.HMAC_SHA512))
.build();
try {
jwtConsumer.processToClaims(jwt);
valid = true;
} catch (InvalidJwtException e) {
LOG.error("Failed to parse authentication cookie", e);
}
}
}
return valid;
} | java | public static boolean hasValidAuthentication(String cookie) {
boolean valid = false;
if (StringUtils.isNotBlank(cookie)) {
Config config = Application.getInstance(Config.class);
String value = null;
String [] contents = cookie.split(";");
for (String content : contents) {
if (StringUtils.isNotBlank(content) && content.startsWith(config.getAuthenticationCookieName())) {
value = StringUtils.substringAfter(content, config.getAuthenticationCookieName() + "=");
value = PATTERN.matcher(value).replaceAll("");
}
}
if (StringUtils.isNotBlank(value)) {
String jwt = Application.getInstance(Crypto.class).decrypt(value, config.getAuthenticationCookieEncryptionKey());
JwtConsumer jwtConsumer = new JwtConsumerBuilder()
.setRequireExpirationTime()
.setRequireSubject()
.setVerificationKey(new HmacKey(config.getAuthenticationCookieSignKey().getBytes(StandardCharsets.UTF_8)))
.setJwsAlgorithmConstraints(new AlgorithmConstraints(ConstraintType.WHITELIST, AlgorithmIdentifiers.HMAC_SHA512))
.build();
try {
jwtConsumer.processToClaims(jwt);
valid = true;
} catch (InvalidJwtException e) {
LOG.error("Failed to parse authentication cookie", e);
}
}
}
return valid;
} | [
"public",
"static",
"boolean",
"hasValidAuthentication",
"(",
"String",
"cookie",
")",
"{",
"boolean",
"valid",
"=",
"false",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"cookie",
")",
")",
"{",
"Config",
"config",
"=",
"Application",
".",
"getIns... | Checks if the given header contains a valid authentication
@param cookie The cookie to parse
@return True if the cookie contains a valid authentication, false otherwise | [
"Checks",
"if",
"the",
"given",
"header",
"contains",
"a",
"valid",
"authentication"
] | train | https://github.com/svenkubiak/mangooio/blob/b3beb6d09510dbbab0ed947d5069c463e1fda6e7/mangooio-core/src/main/java/io/mangoo/utils/RequestUtils.java#L121-L154 |
xqbase/tuna | misc/src/main/java/com/xqbase/tuna/misc/DoSServerFilter.java | DoSServerFilter.setParameters | public void setParameters(int period, int connections, int requests, int bytes) {
this.period = period;
this.connections_ = connections;
this.requests_ = requests;
this.bytes_ = bytes;
} | java | public void setParameters(int period, int connections, int requests, int bytes) {
this.period = period;
this.connections_ = connections;
this.requests_ = requests;
this.bytes_ = bytes;
} | [
"public",
"void",
"setParameters",
"(",
"int",
"period",
",",
"int",
"connections",
",",
"int",
"requests",
",",
"int",
"bytes",
")",
"{",
"this",
".",
"period",
"=",
"period",
";",
"this",
".",
"connections_",
"=",
"connections",
";",
"this",
".",
"requ... | Reset the parameters
@param period - The period, in milliseconds.
@param connections - Maximum concurrent connections the same IP.
@param requests - Maximum requests (connection events) in the period from the same IP.
@param bytes - Maximum sent bytes in the period from the same IP. | [
"Reset",
"the",
"parameters"
] | train | https://github.com/xqbase/tuna/blob/60d05a9e03877a3daafe9de83dc4427c6cbb9995/misc/src/main/java/com/xqbase/tuna/misc/DoSServerFilter.java#L127-L132 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/BaseNDArrayFactory.java | BaseNDArrayFactory.randn | @Override
public INDArray randn(int[] shape, org.nd4j.linalg.api.rng.Random r) {
return r.nextGaussian(shape);
} | java | @Override
public INDArray randn(int[] shape, org.nd4j.linalg.api.rng.Random r) {
return r.nextGaussian(shape);
} | [
"@",
"Override",
"public",
"INDArray",
"randn",
"(",
"int",
"[",
"]",
"shape",
",",
"org",
".",
"nd4j",
".",
"linalg",
".",
"api",
".",
"rng",
".",
"Random",
"r",
")",
"{",
"return",
"r",
".",
"nextGaussian",
"(",
"shape",
")",
";",
"}"
] | Random normal using the given rng
@param shape the shape of the ndarray
@param r the random generator to use
@return | [
"Random",
"normal",
"using",
"the",
"given",
"rng"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/BaseNDArrayFactory.java#L635-L638 |
alkacon/opencms-core | src/org/opencms/search/CmsSearchIndex.java | CmsSearchIndex.getLocaleForResource | @Override
public Locale getLocaleForResource(CmsObject cms, CmsResource resource, List<Locale> availableLocales) {
Locale result;
List<Locale> defaultLocales = OpenCms.getLocaleManager().getDefaultLocales(cms, resource);
List<Locale> locales = availableLocales;
if ((locales == null) || (locales.size() == 0)) {
locales = defaultLocales;
}
result = OpenCms.getLocaleManager().getBestMatchingLocale(getLocale(), defaultLocales, locales);
return result;
} | java | @Override
public Locale getLocaleForResource(CmsObject cms, CmsResource resource, List<Locale> availableLocales) {
Locale result;
List<Locale> defaultLocales = OpenCms.getLocaleManager().getDefaultLocales(cms, resource);
List<Locale> locales = availableLocales;
if ((locales == null) || (locales.size() == 0)) {
locales = defaultLocales;
}
result = OpenCms.getLocaleManager().getBestMatchingLocale(getLocale(), defaultLocales, locales);
return result;
} | [
"@",
"Override",
"public",
"Locale",
"getLocaleForResource",
"(",
"CmsObject",
"cms",
",",
"CmsResource",
"resource",
",",
"List",
"<",
"Locale",
">",
"availableLocales",
")",
"{",
"Locale",
"result",
";",
"List",
"<",
"Locale",
">",
"defaultLocales",
"=",
"Op... | Returns the language locale for the given resource in this index.<p>
@param cms the current OpenCms user context
@param resource the resource to check
@param availableLocales a list of locales supported by the resource
@return the language locale for the given resource in this index | [
"Returns",
"the",
"language",
"locale",
"for",
"the",
"given",
"resource",
"in",
"this",
"index",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/search/CmsSearchIndex.java#L679-L690 |
dropbox/dropbox-sdk-java | examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/DropboxAuth.java | DropboxAuth.doStart | public void doStart(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (!common.checkPost(request, response)) return;
User user = common.requireLoggedInUser(request, response);
if (user == null) return;
// Start the authorization process with Dropbox.
DbxWebAuth.Request authRequest = DbxWebAuth.newRequestBuilder()
// After we redirect the user to the Dropbox website for authorization,
// Dropbox will redirect them back here.
.withRedirectUri(getRedirectUri(request), getSessionStore(request))
.build();
String authorizeUrl = getWebAuth(request).authorize(authRequest);
// Redirect the user to the Dropbox website so they can approve our application.
// The Dropbox website will send them back to /dropbox-auth-finish when they're done.
response.sendRedirect(authorizeUrl);
} | java | public void doStart(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
if (!common.checkPost(request, response)) return;
User user = common.requireLoggedInUser(request, response);
if (user == null) return;
// Start the authorization process with Dropbox.
DbxWebAuth.Request authRequest = DbxWebAuth.newRequestBuilder()
// After we redirect the user to the Dropbox website for authorization,
// Dropbox will redirect them back here.
.withRedirectUri(getRedirectUri(request), getSessionStore(request))
.build();
String authorizeUrl = getWebAuth(request).authorize(authRequest);
// Redirect the user to the Dropbox website so they can approve our application.
// The Dropbox website will send them back to /dropbox-auth-finish when they're done.
response.sendRedirect(authorizeUrl);
} | [
"public",
"void",
"doStart",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"if",
"(",
"!",
"common",
".",
"checkPost",
"(",
"request",
",",
"response",
")",
")",
"return"... | Start the process of getting a Dropbox API access token for the user's Dropbox account. | [
"Start",
"the",
"process",
"of",
"getting",
"a",
"Dropbox",
"API",
"access",
"token",
"for",
"the",
"user",
"s",
"Dropbox",
"account",
"."
] | train | https://github.com/dropbox/dropbox-sdk-java/blob/d86157005fad6233c18b4b0f10f00b8d9d56ae92/examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/DropboxAuth.java#L31-L48 |
jcuda/jcudnn | JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java | JCudnn.cudnnGetReductionWorkspaceSize | public static int cudnnGetReductionWorkspaceSize(
cudnnHandle handle,
cudnnReduceTensorDescriptor reduceTensorDesc,
cudnnTensorDescriptor aDesc,
cudnnTensorDescriptor cDesc,
long[] sizeInBytes)
{
return checkResult(cudnnGetReductionWorkspaceSizeNative(handle, reduceTensorDesc, aDesc, cDesc, sizeInBytes));
} | java | public static int cudnnGetReductionWorkspaceSize(
cudnnHandle handle,
cudnnReduceTensorDescriptor reduceTensorDesc,
cudnnTensorDescriptor aDesc,
cudnnTensorDescriptor cDesc,
long[] sizeInBytes)
{
return checkResult(cudnnGetReductionWorkspaceSizeNative(handle, reduceTensorDesc, aDesc, cDesc, sizeInBytes));
} | [
"public",
"static",
"int",
"cudnnGetReductionWorkspaceSize",
"(",
"cudnnHandle",
"handle",
",",
"cudnnReduceTensorDescriptor",
"reduceTensorDesc",
",",
"cudnnTensorDescriptor",
"aDesc",
",",
"cudnnTensorDescriptor",
"cDesc",
",",
"long",
"[",
"]",
"sizeInBytes",
")",
"{",... | Helper function to return the minimum size of the workspace to be passed to the reduction given the input and output
tensors | [
"Helper",
"function",
"to",
"return",
"the",
"minimum",
"size",
"of",
"the",
"workspace",
"to",
"be",
"passed",
"to",
"the",
"reduction",
"given",
"the",
"input",
"and",
"output",
"tensors"
] | train | https://github.com/jcuda/jcudnn/blob/ce71f2fc02817cecace51a80e6db5f0c7f10cffc/JCudnnJava/src/main/java/jcuda/jcudnn/JCudnn.java#L638-L646 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildsInner.java | BuildsInner.update | public BuildInner update(String resourceGroupName, String registryName, String buildId) {
return updateWithServiceResponseAsync(resourceGroupName, registryName, buildId).toBlocking().last().body();
} | java | public BuildInner update(String resourceGroupName, String registryName, String buildId) {
return updateWithServiceResponseAsync(resourceGroupName, registryName, buildId).toBlocking().last().body();
} | [
"public",
"BuildInner",
"update",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"String",
"buildId",
")",
"{",
"return",
"updateWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryName",
",",
"buildId",
")",
".",
"toBlocking",
... | Patch the build properties.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param buildId The build ID.
@throws IllegalArgumentException thrown if parameters fail the validation
@throws CloudException thrown if the request is rejected by server
@throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
@return the BuildInner object if successful. | [
"Patch",
"the",
"build",
"properties",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2018_02_01_preview/src/main/java/com/microsoft/azure/management/containerregistry/v2018_02_01_preview/implementation/BuildsInner.java#L453-L455 |
hageldave/ImagingKit | ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/ComplexImg.java | ComplexImg.getValue | public double getValue(int channel, int x, int y, int boundaryMode) {
return delegate.getValue(channel, x, y, boundaryMode);
} | java | public double getValue(int channel, int x, int y, int boundaryMode) {
return delegate.getValue(channel, x, y, boundaryMode);
} | [
"public",
"double",
"getValue",
"(",
"int",
"channel",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"boundaryMode",
")",
"{",
"return",
"delegate",
".",
"getValue",
"(",
"channel",
",",
"x",
",",
"y",
",",
"boundaryMode",
")",
";",
"}"
] | See {@link ColorImg#getValue(int, int, int, int)}.
<p>
Please Notice that when using {@link #CHANNEL_POWER},
this will not calculate the power in case it is not up to date.
Use {@link #recomputePowerChannel()} to make sure this method yields reasonable results.
@param channel one of {@link #CHANNEL_REAL},{@link #CHANNEL_IMAG},{@link #CHANNEL_POWER}(0,1,2)
@param x coordinate
@param y coordinate
@param boundaryMode one of the boundary modes e.g. {@link ColorImg#boundary_mode_repeat_image}
@return value at specified position or a value depending on the
boundary mode for out of bounds positions. | [
"See",
"{"
] | train | https://github.com/hageldave/ImagingKit/blob/3837c7d550a12cf4dc5718b644ced94b97f52668/ImagingKit_Fourier/src/main/java/hageldave/imagingkit/fourier/ComplexImg.java#L255-L257 |
mikepenz/MaterialDrawer | library/src/main/java/com/mikepenz/materialdrawer/view/BezelImageView.java | BezelImageView.setSelectorColor | public void setSelectorColor(int selectorColor) {
this.mSelectorColor = selectorColor;
this.mSelectorFilter = new PorterDuffColorFilter(Color.argb(mSelectorAlpha, Color.red(mSelectorColor), Color.green(mSelectorColor), Color.blue(mSelectorColor)), PorterDuff.Mode.SRC_ATOP);
this.invalidate();
} | java | public void setSelectorColor(int selectorColor) {
this.mSelectorColor = selectorColor;
this.mSelectorFilter = new PorterDuffColorFilter(Color.argb(mSelectorAlpha, Color.red(mSelectorColor), Color.green(mSelectorColor), Color.blue(mSelectorColor)), PorterDuff.Mode.SRC_ATOP);
this.invalidate();
} | [
"public",
"void",
"setSelectorColor",
"(",
"int",
"selectorColor",
")",
"{",
"this",
".",
"mSelectorColor",
"=",
"selectorColor",
";",
"this",
".",
"mSelectorFilter",
"=",
"new",
"PorterDuffColorFilter",
"(",
"Color",
".",
"argb",
"(",
"mSelectorAlpha",
",",
"Co... | Sets the color of the selector to be draw over the
CircularImageView. Be sure to provide some opacity.
@param selectorColor The color (including alpha) to set for the selector overlay. | [
"Sets",
"the",
"color",
"of",
"the",
"selector",
"to",
"be",
"draw",
"over",
"the",
"CircularImageView",
".",
"Be",
"sure",
"to",
"provide",
"some",
"opacity",
"."
] | train | https://github.com/mikepenz/MaterialDrawer/blob/f4fb31635767edead0a01cee7b7588942b89d8d9/library/src/main/java/com/mikepenz/materialdrawer/view/BezelImageView.java#L300-L304 |
wisdom-framework/wisdom | core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/utils/ResourceCopy.java | ResourceCopy.copyInstances | public static void copyInstances(AbstractWisdomMojo mojo, MavenResourcesFiltering filtering) throws IOException {
File in = new File(mojo.basedir, Constants.INSTANCES_SRC_DIR);
if (in.isDirectory()) {
File out = new File(mojo.getWisdomRootDirectory(), Constants.APPLICATION_DIR);
filterAndCopy(mojo, filtering, in, out);
}
} | java | public static void copyInstances(AbstractWisdomMojo mojo, MavenResourcesFiltering filtering) throws IOException {
File in = new File(mojo.basedir, Constants.INSTANCES_SRC_DIR);
if (in.isDirectory()) {
File out = new File(mojo.getWisdomRootDirectory(), Constants.APPLICATION_DIR);
filterAndCopy(mojo, filtering, in, out);
}
} | [
"public",
"static",
"void",
"copyInstances",
"(",
"AbstractWisdomMojo",
"mojo",
",",
"MavenResourcesFiltering",
"filtering",
")",
"throws",
"IOException",
"{",
"File",
"in",
"=",
"new",
"File",
"(",
"mojo",
".",
"basedir",
",",
"Constants",
".",
"INSTANCES_SRC_DIR... | Copies the `cfg` files from `src/main/instances` to the Wisdom application directory.
@param mojo the mojo
@param filtering the filtering support
@throws IOException if file cannot be copied | [
"Copies",
"the",
"cfg",
"files",
"from",
"src",
"/",
"main",
"/",
"instances",
"to",
"the",
"Wisdom",
"application",
"directory",
"."
] | train | https://github.com/wisdom-framework/wisdom/blob/a35b6431200fec56b178c0ff60837ed73fd7874d/core/wisdom-maven-plugin/src/main/java/org/wisdom/maven/utils/ResourceCopy.java#L286-L292 |
google/closure-compiler | src/com/google/javascript/jscomp/OptimizeArgumentsArray.java | OptimizeArgumentsArray.changeBody | private void changeBody(ImmutableMap<Integer, String> argNames) {
for (Node ref : currentArgumentsAccesses) {
Node index = ref.getNext();
Node parent = ref.getParent();
int value = (int) index.getDouble(); // This was validated earlier.
@Nullable String name = argNames.get(value);
if (name == null) {
continue;
}
Node newName = IR.name(name).useSourceInfoIfMissingFrom(parent);
parent.replaceWith(newName);
// TODO(nickreid): See if we can do this fewer times. The accesses may be in different scopes.
compiler.reportChangeToEnclosingScope(newName);
}
} | java | private void changeBody(ImmutableMap<Integer, String> argNames) {
for (Node ref : currentArgumentsAccesses) {
Node index = ref.getNext();
Node parent = ref.getParent();
int value = (int) index.getDouble(); // This was validated earlier.
@Nullable String name = argNames.get(value);
if (name == null) {
continue;
}
Node newName = IR.name(name).useSourceInfoIfMissingFrom(parent);
parent.replaceWith(newName);
// TODO(nickreid): See if we can do this fewer times. The accesses may be in different scopes.
compiler.reportChangeToEnclosingScope(newName);
}
} | [
"private",
"void",
"changeBody",
"(",
"ImmutableMap",
"<",
"Integer",
",",
"String",
">",
"argNames",
")",
"{",
"for",
"(",
"Node",
"ref",
":",
"currentArgumentsAccesses",
")",
"{",
"Node",
"index",
"=",
"ref",
".",
"getNext",
"(",
")",
";",
"Node",
"par... | Performs the replacement of arguments[x] -> a if x is known.
@param argNames maps param index to param name, if the param with that index has a name. | [
"Performs",
"the",
"replacement",
"of",
"arguments",
"[",
"x",
"]",
"-",
">",
"a",
"if",
"x",
"is",
"known",
"."
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/OptimizeArgumentsArray.java#L248-L264 |
checkstyle-addons/checkstyle-addons | src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java | Util.readBytes | public static byte[] readBytes(@Nonnull final InputStream pInputStream)
throws IOException
{
ByteArrayOutputStream baos = null;
BufferedInputStream bis = null;
try {
baos = new ByteArrayOutputStream(IO_BUFFER_SIZE_BYTES);
bis = new BufferedInputStream(pInputStream, IO_BUFFER_SIZE_BYTES);
byte[] buffer = new byte[IO_BUFFER_SIZE_BYTES];
for (int bytesRead = bis.read(buffer); bytesRead > 0; bytesRead = bis.read(buffer)) {
baos.write(buffer, 0, bytesRead);
}
}
finally {
closeQuietly(bis);
closeQuietly(baos);
}
return baos.toByteArray();
} | java | public static byte[] readBytes(@Nonnull final InputStream pInputStream)
throws IOException
{
ByteArrayOutputStream baos = null;
BufferedInputStream bis = null;
try {
baos = new ByteArrayOutputStream(IO_BUFFER_SIZE_BYTES);
bis = new BufferedInputStream(pInputStream, IO_BUFFER_SIZE_BYTES);
byte[] buffer = new byte[IO_BUFFER_SIZE_BYTES];
for (int bytesRead = bis.read(buffer); bytesRead > 0; bytesRead = bis.read(buffer)) {
baos.write(buffer, 0, bytesRead);
}
}
finally {
closeQuietly(bis);
closeQuietly(baos);
}
return baos.toByteArray();
} | [
"public",
"static",
"byte",
"[",
"]",
"readBytes",
"(",
"@",
"Nonnull",
"final",
"InputStream",
"pInputStream",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"null",
";",
"BufferedInputStream",
"bis",
"=",
"null",
";",
"try",
"{",
"b... | Read all bytes from an InputStream into a byte array. Can be replaced with <code>Files.readAllBytes()</code> once
the code is migrated to Java 7.
@param pInputStream the input stream
@return the complete contents read from the input stream
@throws IOException I/O error | [
"Read",
"all",
"bytes",
"from",
"an",
"InputStream",
"into",
"a",
"byte",
"array",
".",
"Can",
"be",
"replaced",
"with",
"<code",
">",
"Files",
".",
"readAllBytes",
"()",
"<",
"/",
"code",
">",
"once",
"the",
"code",
"is",
"migrated",
"to",
"Java",
"7"... | train | https://github.com/checkstyle-addons/checkstyle-addons/blob/fae1b4d341639c8e32c3e59ec5abdc0ffc11b865/src/main/java/com/thomasjensen/checkstyle/addons/util/Util.java#L171-L190 |
Hygieia/Hygieia | collectors/cmdb/hpsm/src/main/java/com/capitalone/dashboard/collector/DefaultBaseClient.java | DefaultBaseClient.makeSoapCall | protected String makeSoapCall(String soapMessageString, HpsmSoapModel hpsmSoapModel) throws HygieiaException {
String requestAction = hpsmSoapModel.getSoapAction();
String response = "";
contentType = hpsmSettings.getContentType();
charset = hpsmSettings.getCharset();
try {
startHttpConnection();
RequestEntity entity = new StringRequestEntity(soapMessageString, contentType, charset);
post.setRequestEntity(entity);
post.setRequestHeader("SOAPAction", requestAction);
httpclient.executeMethod(post);
response = getResponseString(post.getResponseBodyAsStream());
if(!"OK".equals(post.getStatusText())){
throw new HygieiaException("Soap Request Failure: " + post.getStatusCode() + "|response: " +response, HygieiaException.BAD_DATA);
}
stopHttpConnection();
} catch (IOException e) {
LOG.error("Error while trying to make soap call: " + e);
}
return response;
} | java | protected String makeSoapCall(String soapMessageString, HpsmSoapModel hpsmSoapModel) throws HygieiaException {
String requestAction = hpsmSoapModel.getSoapAction();
String response = "";
contentType = hpsmSettings.getContentType();
charset = hpsmSettings.getCharset();
try {
startHttpConnection();
RequestEntity entity = new StringRequestEntity(soapMessageString, contentType, charset);
post.setRequestEntity(entity);
post.setRequestHeader("SOAPAction", requestAction);
httpclient.executeMethod(post);
response = getResponseString(post.getResponseBodyAsStream());
if(!"OK".equals(post.getStatusText())){
throw new HygieiaException("Soap Request Failure: " + post.getStatusCode() + "|response: " +response, HygieiaException.BAD_DATA);
}
stopHttpConnection();
} catch (IOException e) {
LOG.error("Error while trying to make soap call: " + e);
}
return response;
} | [
"protected",
"String",
"makeSoapCall",
"(",
"String",
"soapMessageString",
",",
"HpsmSoapModel",
"hpsmSoapModel",
")",
"throws",
"HygieiaException",
"{",
"String",
"requestAction",
"=",
"hpsmSoapModel",
".",
"getSoapAction",
"(",
")",
";",
"String",
"response",
"=",
... | Makes SOAP request for given soap message
@param soapMessageString Generated SOAP ready for POST
@param hpsmSoapModel hpsmSoapModel
@return Soap response | [
"Makes",
"SOAP",
"request",
"for",
"given",
"soap",
"message"
] | train | https://github.com/Hygieia/Hygieia/blob/d8b67a590da2744acf59bcd99d9b34ef1bb84890/collectors/cmdb/hpsm/src/main/java/com/capitalone/dashboard/collector/DefaultBaseClient.java#L72-L100 |
fernandospr/javapns-jdk16 | src/main/java/javapns/Push.java | Push.contentAvailable | public static PushedNotifications contentAvailable(Object keystore, String password, boolean production, Object devices) throws CommunicationException, KeystoreException {
return sendPayload(NewsstandNotificationPayload.contentAvailable(), keystore, password, production, devices);
} | java | public static PushedNotifications contentAvailable(Object keystore, String password, boolean production, Object devices) throws CommunicationException, KeystoreException {
return sendPayload(NewsstandNotificationPayload.contentAvailable(), keystore, password, production, devices);
} | [
"public",
"static",
"PushedNotifications",
"contentAvailable",
"(",
"Object",
"keystore",
",",
"String",
"password",
",",
"boolean",
"production",
",",
"Object",
"devices",
")",
"throws",
"CommunicationException",
",",
"KeystoreException",
"{",
"return",
"sendPayload",
... | Push a content-available notification for Newsstand.
@param keystore a keystore containing your private key and the certificate signed by Apple ({@link java.io.File}, {@link java.io.InputStream}, byte[], {@link java.security.KeyStore} or {@link java.lang.String} for a file path)
@param password the keystore's password.
@param production true to use Apple's production servers, false to use the sandbox servers.
@param devices a list or an array of tokens or devices: {@link java.lang.String String[]}, {@link java.util.List}<{@link java.lang.String}>, {@link javapns.devices.Device Device[]}, {@link java.util.List}<{@link javapns.devices.Device}>, {@link java.lang.String} or {@link javapns.devices.Device}
@return a list of pushed notifications, each with details on transmission results and error (if any)
@throws KeystoreException thrown if an error occurs when loading the keystore
@throws CommunicationException thrown if an unrecoverable error occurs while trying to communicate with Apple servers | [
"Push",
"a",
"content",
"-",
"available",
"notification",
"for",
"Newsstand",
"."
] | train | https://github.com/fernandospr/javapns-jdk16/blob/84de6d9328ab01af92f77cc60c4554de02420909/src/main/java/javapns/Push.java#L115-L117 |
BigBadaboom/androidsvg | androidsvg/src/main/java/com/caverock/androidsvg/SVGAndroidRenderer.java | SVGAndroidRenderer.doFilledPath | private void doFilledPath(SvgElement obj, Path path)
{
// First check for pattern fill. It requires special handling.
if (state.style.fill instanceof SVG.PaintReference)
{
SVG.SvgObject ref = document.resolveIRI(((SVG.PaintReference) state.style.fill).href);
if (ref instanceof SVG.Pattern) {
SVG.Pattern pattern = (SVG.Pattern)ref;
fillWithPattern(obj, path, pattern);
return;
}
}
// Otherwise do a normal fill
canvas.drawPath(path, state.fillPaint);
} | java | private void doFilledPath(SvgElement obj, Path path)
{
// First check for pattern fill. It requires special handling.
if (state.style.fill instanceof SVG.PaintReference)
{
SVG.SvgObject ref = document.resolveIRI(((SVG.PaintReference) state.style.fill).href);
if (ref instanceof SVG.Pattern) {
SVG.Pattern pattern = (SVG.Pattern)ref;
fillWithPattern(obj, path, pattern);
return;
}
}
// Otherwise do a normal fill
canvas.drawPath(path, state.fillPaint);
} | [
"private",
"void",
"doFilledPath",
"(",
"SvgElement",
"obj",
",",
"Path",
"path",
")",
"{",
"// First check for pattern fill. It requires special handling.\r",
"if",
"(",
"state",
".",
"style",
".",
"fill",
"instanceof",
"SVG",
".",
"PaintReference",
")",
"{",
"SVG"... | /*
Fill a path with either the given paint, or if a pattern is set, with the pattern. | [
"/",
"*",
"Fill",
"a",
"path",
"with",
"either",
"the",
"given",
"paint",
"or",
"if",
"a",
"pattern",
"is",
"set",
"with",
"the",
"pattern",
"."
] | train | https://github.com/BigBadaboom/androidsvg/blob/0d1614dd1a4da10ea4afe3b0cea1361a4ac6b45a/androidsvg/src/main/java/com/caverock/androidsvg/SVGAndroidRenderer.java#L469-L484 |
buschmais/jqa-maven3-plugin | src/main/java/com/buschmais/jqassistant/plugin/maven3/api/scanner/MavenRepositoryResolver.java | MavenRepositoryResolver.resolve | public static MavenRepositoryDescriptor resolve(Store store, String url) {
MavenRepositoryDescriptor repositoryDescriptor = store.find(MavenRepositoryDescriptor.class, url);
if (repositoryDescriptor == null) {
repositoryDescriptor = store.create(MavenRepositoryDescriptor.class);
repositoryDescriptor.setUrl(url);
}
return repositoryDescriptor;
} | java | public static MavenRepositoryDescriptor resolve(Store store, String url) {
MavenRepositoryDescriptor repositoryDescriptor = store.find(MavenRepositoryDescriptor.class, url);
if (repositoryDescriptor == null) {
repositoryDescriptor = store.create(MavenRepositoryDescriptor.class);
repositoryDescriptor.setUrl(url);
}
return repositoryDescriptor;
} | [
"public",
"static",
"MavenRepositoryDescriptor",
"resolve",
"(",
"Store",
"store",
",",
"String",
"url",
")",
"{",
"MavenRepositoryDescriptor",
"repositoryDescriptor",
"=",
"store",
".",
"find",
"(",
"MavenRepositoryDescriptor",
".",
"class",
",",
"url",
")",
";",
... | Finds or creates a repository descriptor for the given url.
@param store
the {@link Store}
@param url
the repository url
@return a {@link MavenRepositoryDescriptor} for the given url. | [
"Finds",
"or",
"creates",
"a",
"repository",
"descriptor",
"for",
"the",
"given",
"url",
"."
] | train | https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/api/scanner/MavenRepositoryResolver.java#L20-L27 |
nohana/Amalgam | amalgam/src/main/java/com/amalgam/os/BundleUtils.java | BundleUtils.optCharArray | @Nullable
public static char[] optCharArray(@Nullable Bundle bundle, @Nullable String key) {
return optCharArray(bundle, key, new char[0]);
} | java | @Nullable
public static char[] optCharArray(@Nullable Bundle bundle, @Nullable String key) {
return optCharArray(bundle, key, new char[0]);
} | [
"@",
"Nullable",
"public",
"static",
"char",
"[",
"]",
"optCharArray",
"(",
"@",
"Nullable",
"Bundle",
"bundle",
",",
"@",
"Nullable",
"String",
"key",
")",
"{",
"return",
"optCharArray",
"(",
"bundle",
",",
"key",
",",
"new",
"char",
"[",
"0",
"]",
")... | Returns a optional char array value. In other words, returns the value mapped by key if it exists and is a char array.
The bundle argument is allowed to be {@code null}. If the bundle is null, this method returns null.
@param bundle a bundle. If the bundle is null, this method will return null.
@param key a key for the value.
@return a char value if exists, null otherwise.
@see android.os.Bundle#getCharArray(String) | [
"Returns",
"a",
"optional",
"char",
"array",
"value",
".",
"In",
"other",
"words",
"returns",
"the",
"value",
"mapped",
"by",
"key",
"if",
"it",
"exists",
"and",
"is",
"a",
"char",
"array",
".",
"The",
"bundle",
"argument",
"is",
"allowed",
"to",
"be",
... | train | https://github.com/nohana/Amalgam/blob/57809ddbfe7897e979cf507982ce0b3aa5e0ed8a/amalgam/src/main/java/com/amalgam/os/BundleUtils.java#L299-L302 |
alkacon/opencms-core | src/org/opencms/file/CmsLinkRewriter.java | CmsLinkRewriter.rewriteContent | protected void rewriteContent(CmsFile file, Collection<CmsRelation> relations) throws CmsException {
LOG.info("Rewriting in-content links for " + file.getRootPath());
CmsPair<String, String> contentAndEncoding = decode(file);
String content = "";
if (OpenCms.getResourceManager().getResourceType(file) instanceof CmsResourceTypeXmlContent) {
CmsXmlContent contentXml = CmsXmlContentFactory.unmarshal(m_cms, file);
try {
contentXml.validateXmlStructure(new CmsXmlEntityResolver(m_cms));
} catch (CmsException e) {
LOG.info("XML content was corrected automatically for resource " + file.getRootPath());
contentXml.setAutoCorrectionEnabled(true);
contentXml.correctXmlStructure(m_cms);
try {
content = new String(contentXml.marshal(), contentAndEncoding.getSecond());
} catch (UnsupportedEncodingException e1) {
//
}
}
}
if (content.isEmpty()) {
content = contentAndEncoding.getFirst();
}
String encodingForSave = contentAndEncoding.getSecond();
String newContent = rewriteContentString(content);
byte[] newContentBytes;
try {
newContentBytes = newContent.getBytes(encodingForSave);
} catch (UnsupportedEncodingException e) {
newContentBytes = newContent.getBytes();
}
file.setContents(newContentBytes);
m_cms.writeFile(file);
} | java | protected void rewriteContent(CmsFile file, Collection<CmsRelation> relations) throws CmsException {
LOG.info("Rewriting in-content links for " + file.getRootPath());
CmsPair<String, String> contentAndEncoding = decode(file);
String content = "";
if (OpenCms.getResourceManager().getResourceType(file) instanceof CmsResourceTypeXmlContent) {
CmsXmlContent contentXml = CmsXmlContentFactory.unmarshal(m_cms, file);
try {
contentXml.validateXmlStructure(new CmsXmlEntityResolver(m_cms));
} catch (CmsException e) {
LOG.info("XML content was corrected automatically for resource " + file.getRootPath());
contentXml.setAutoCorrectionEnabled(true);
contentXml.correctXmlStructure(m_cms);
try {
content = new String(contentXml.marshal(), contentAndEncoding.getSecond());
} catch (UnsupportedEncodingException e1) {
//
}
}
}
if (content.isEmpty()) {
content = contentAndEncoding.getFirst();
}
String encodingForSave = contentAndEncoding.getSecond();
String newContent = rewriteContentString(content);
byte[] newContentBytes;
try {
newContentBytes = newContent.getBytes(encodingForSave);
} catch (UnsupportedEncodingException e) {
newContentBytes = newContent.getBytes();
}
file.setContents(newContentBytes);
m_cms.writeFile(file);
} | [
"protected",
"void",
"rewriteContent",
"(",
"CmsFile",
"file",
",",
"Collection",
"<",
"CmsRelation",
">",
"relations",
")",
"throws",
"CmsException",
"{",
"LOG",
".",
"info",
"(",
"\"Rewriting in-content links for \"",
"+",
"file",
".",
"getRootPath",
"(",
")",
... | Rewrites the links included in the content itself.<p>
@param file the file for which the links should be replaced
@param relations the original relations
@throws CmsException if something goes wrong | [
"Rewrites",
"the",
"links",
"included",
"in",
"the",
"content",
"itself",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/file/CmsLinkRewriter.java#L607-L644 |
google/closure-compiler | src/com/google/javascript/jscomp/DestructuredTarget.java | DestructuredTarget.createAllNonEmptyTargetsInPattern | static ImmutableList<DestructuredTarget> createAllNonEmptyTargetsInPattern(
JSTypeRegistry registry, JSType patternType, Node pattern) {
return createAllNonEmptyTargetsInPattern(registry, () -> patternType, pattern);
} | java | static ImmutableList<DestructuredTarget> createAllNonEmptyTargetsInPattern(
JSTypeRegistry registry, JSType patternType, Node pattern) {
return createAllNonEmptyTargetsInPattern(registry, () -> patternType, pattern);
} | [
"static",
"ImmutableList",
"<",
"DestructuredTarget",
">",
"createAllNonEmptyTargetsInPattern",
"(",
"JSTypeRegistry",
"registry",
",",
"JSType",
"patternType",
",",
"Node",
"pattern",
")",
"{",
"return",
"createAllNonEmptyTargetsInPattern",
"(",
"registry",
",",
"(",
"... | Returns all the targets directly in the given pattern, except for EMPTY nodes
<p>EMPTY nodes occur in array patterns with elisions, e.g. `[, , a] = []` | [
"Returns",
"all",
"the",
"targets",
"directly",
"in",
"the",
"given",
"pattern",
"except",
"for",
"EMPTY",
"nodes"
] | train | https://github.com/google/closure-compiler/blob/d81e36740f6a9e8ac31a825ee8758182e1dc5aae/src/com/google/javascript/jscomp/DestructuredTarget.java#L240-L243 |
jhunters/jprotobuf | src/main/java/com/baidu/bjf/remoting/protobuf/utils/MiniTemplator.java | MiniTemplator.setVariable | public void setVariable(String variableName, int variableValue) throws VariableNotDefinedException {
setVariable(variableName, Integer.toString(variableValue));
} | java | public void setVariable(String variableName, int variableValue) throws VariableNotDefinedException {
setVariable(variableName, Integer.toString(variableValue));
} | [
"public",
"void",
"setVariable",
"(",
"String",
"variableName",
",",
"int",
"variableValue",
")",
"throws",
"VariableNotDefinedException",
"{",
"setVariable",
"(",
"variableName",
",",
"Integer",
".",
"toString",
"(",
"variableValue",
")",
")",
";",
"}"
] | Sets a template variable to an integer value.
<p>
Convenience method for: <code>setVariable (variableName, Integer.toString(variableValue))</code>
@param variableName the name of the variable to be set. Case-insensitive.
@param variableValue the new value of the variable.
@throws VariableNotDefinedException when no variable with the specified name exists in the template. | [
"Sets",
"a",
"template",
"variable",
"to",
"an",
"integer",
"value",
".",
"<p",
">",
"Convenience",
"method",
"for",
":",
"<code",
">",
"setVariable",
"(",
"variableName",
"Integer",
".",
"toString",
"(",
"variableValue",
"))",
"<",
"/",
"code",
">"
] | train | https://github.com/jhunters/jprotobuf/blob/55832c9b4792afb128e5b35139d8a3891561d8a3/src/main/java/com/baidu/bjf/remoting/protobuf/utils/MiniTemplator.java#L400-L402 |
gmessner/gitlab4j-api | src/main/java/org/gitlab4j/api/RepositoryFileApi.java | RepositoryFileApi.updateFile | @Deprecated
public RepositoryFile updateFile(RepositoryFile file, Integer projectId, String branchName, String commitMessage) throws GitLabApiException {
return (updateFile(projectId, file, branchName, commitMessage));
} | java | @Deprecated
public RepositoryFile updateFile(RepositoryFile file, Integer projectId, String branchName, String commitMessage) throws GitLabApiException {
return (updateFile(projectId, file, branchName, commitMessage));
} | [
"@",
"Deprecated",
"public",
"RepositoryFile",
"updateFile",
"(",
"RepositoryFile",
"file",
",",
"Integer",
"projectId",
",",
"String",
"branchName",
",",
"String",
"commitMessage",
")",
"throws",
"GitLabApiException",
"{",
"return",
"(",
"updateFile",
"(",
"project... | Update existing file in repository
<pre><code>GitLab Endpoint: PUT /projects/:id/repository/files</code></pre>
file_path (required) - Full path to new file. Ex. lib/class.rb
branch_name (required) - The name of branch
encoding (optional) - 'text' or 'base64'. Text is default.
content (required) - File content
commit_message (required) - Commit message
@param file a ReposityoryFile instance with info for the file to update
@param projectId the project ID
@param branchName the name of branch
@param commitMessage the commit message
@return a RepositoryFile instance with the updated file info
@throws GitLabApiException if any exception occurs
@deprecated Will be removed in version 5.0, replaced by {@link #updateFile(Object, RepositoryFile, String, String)} | [
"Update",
"existing",
"file",
"in",
"repository"
] | train | https://github.com/gmessner/gitlab4j-api/blob/ab045070abac0a8f4ccbf17b5ed9bfdef5723eed/src/main/java/org/gitlab4j/api/RepositoryFileApi.java#L297-L300 |
petergeneric/stdlib | stdlib/src/main/java/com/peterphi/std/system/exec/Exec.java | Exec.start | public Execed start() throws IOException
{
Process p = getProcessBuilder().start();
return new Execed(cmd, p, builder.redirectErrorStream());
} | java | public Execed start() throws IOException
{
Process p = getProcessBuilder().start();
return new Execed(cmd, p, builder.redirectErrorStream());
} | [
"public",
"Execed",
"start",
"(",
")",
"throws",
"IOException",
"{",
"Process",
"p",
"=",
"getProcessBuilder",
"(",
")",
".",
"start",
"(",
")",
";",
"return",
"new",
"Execed",
"(",
"cmd",
",",
"p",
",",
"builder",
".",
"redirectErrorStream",
"(",
")",
... | Launches the process, returning a handle to it for IO ops, etc.<br />
The finish condition for the OutputProcess is that all processes outputting to standard out must be complete before
proceeding
@return
@throws IOException | [
"Launches",
"the",
"process",
"returning",
"a",
"handle",
"to",
"it",
"for",
"IO",
"ops",
"etc",
".",
"<br",
"/",
">",
"The",
"finish",
"condition",
"for",
"the",
"OutputProcess",
"is",
"that",
"all",
"processes",
"outputting",
"to",
"standard",
"out",
"mu... | train | https://github.com/petergeneric/stdlib/blob/d4025d2f881bc0542b1e004c5f65a1ccaf895836/stdlib/src/main/java/com/peterphi/std/system/exec/Exec.java#L147-L152 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/factory/ComponentFactory.java | ComponentFactory.newCheckBox | public static CheckBox newCheckBox(final String id, final IModel<Boolean> model)
{
final CheckBox checkBox = new CheckBox(id, model);
checkBox.setOutputMarkupId(true);
return checkBox;
} | java | public static CheckBox newCheckBox(final String id, final IModel<Boolean> model)
{
final CheckBox checkBox = new CheckBox(id, model);
checkBox.setOutputMarkupId(true);
return checkBox;
} | [
"public",
"static",
"CheckBox",
"newCheckBox",
"(",
"final",
"String",
"id",
",",
"final",
"IModel",
"<",
"Boolean",
">",
"model",
")",
"{",
"final",
"CheckBox",
"checkBox",
"=",
"new",
"CheckBox",
"(",
"id",
",",
"model",
")",
";",
"checkBox",
".",
"set... | Factory method for create a new {@link CheckBox}.
@param id
the id
@param model
the model
@return the new {@link CheckBox} | [
"Factory",
"method",
"for",
"create",
"a",
"new",
"{",
"@link",
"CheckBox",
"}",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/factory/ComponentFactory.java#L71-L76 |
lessthanoptimal/ejml | main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF4.java | CommonOps_DDF4.subtractEquals | public static void subtractEquals( DMatrix4 a , DMatrix4 b ) {
a.a1 -= b.a1;
a.a2 -= b.a2;
a.a3 -= b.a3;
a.a4 -= b.a4;
} | java | public static void subtractEquals( DMatrix4 a , DMatrix4 b ) {
a.a1 -= b.a1;
a.a2 -= b.a2;
a.a3 -= b.a3;
a.a4 -= b.a4;
} | [
"public",
"static",
"void",
"subtractEquals",
"(",
"DMatrix4",
"a",
",",
"DMatrix4",
"b",
")",
"{",
"a",
".",
"a1",
"-=",
"b",
".",
"a1",
";",
"a",
".",
"a2",
"-=",
"b",
".",
"a2",
";",
"a",
".",
"a3",
"-=",
"b",
".",
"a3",
";",
"a",
".",
"... | <p>Performs the following operation:<br>
<br>
a = a - b <br>
a<sub>i</sub> = a<sub>i</sub> - b<sub>i</sub> <br>
</p>
@param a A Vector. Modified.
@param b A Vector. Not modified. | [
"<p",
">",
"Performs",
"the",
"following",
"operation",
":",
"<br",
">",
"<br",
">",
"a",
"=",
"a",
"-",
"b",
"<br",
">",
"a<sub",
">",
"i<",
"/",
"sub",
">",
"=",
"a<sub",
">",
"i<",
"/",
"sub",
">",
"-",
"b<sub",
">",
"i<",
"/",
"sub",
">",... | train | https://github.com/lessthanoptimal/ejml/blob/1444680cc487af5e866730e62f48f5f9636850d9/main/ejml-ddense/src/org/ejml/dense/fixed/CommonOps_DDF4.java#L229-L234 |
VueGWT/vue-gwt | processors/src/main/java/com/axellience/vuegwt/processors/component/factory/AbstractVueComponentFactoryGenerator.java | AbstractVueComponentFactoryGenerator.createProperties | private void createProperties(ClassName vueFactoryType, Builder vueFactoryBuilder) {
vueFactoryBuilder.addField(FieldSpec
.builder(vueFactoryType, INSTANCE_PROP, Modifier.PRIVATE, Modifier.STATIC)
.build());
} | java | private void createProperties(ClassName vueFactoryType, Builder vueFactoryBuilder) {
vueFactoryBuilder.addField(FieldSpec
.builder(vueFactoryType, INSTANCE_PROP, Modifier.PRIVATE, Modifier.STATIC)
.build());
} | [
"private",
"void",
"createProperties",
"(",
"ClassName",
"vueFactoryType",
",",
"Builder",
"vueFactoryBuilder",
")",
"{",
"vueFactoryBuilder",
".",
"addField",
"(",
"FieldSpec",
".",
"builder",
"(",
"vueFactoryType",
",",
"INSTANCE_PROP",
",",
"Modifier",
".",
"PRIV... | Create the static properties used in our {@link VueComponentFactory}.
@param vueFactoryType The generated type name for our {@link VueComponentFactory}
@param vueFactoryBuilder The builder to create our {@link VueComponentFactory} class | [
"Create",
"the",
"static",
"properties",
"used",
"in",
"our",
"{",
"@link",
"VueComponentFactory",
"}",
"."
] | train | https://github.com/VueGWT/vue-gwt/blob/961cd83aed6fe8e2dd80c279847f1b3f62918a1f/processors/src/main/java/com/axellience/vuegwt/processors/component/factory/AbstractVueComponentFactoryGenerator.java#L149-L153 |
netscaler/nitro | src/main/java/com/citrix/netscaler/nitro/resource/config/network/nd6ravariables.java | nd6ravariables.get | public static nd6ravariables get(nitro_service service, Long vlan) throws Exception{
nd6ravariables obj = new nd6ravariables();
obj.set_vlan(vlan);
nd6ravariables response = (nd6ravariables) obj.get_resource(service);
return response;
} | java | public static nd6ravariables get(nitro_service service, Long vlan) throws Exception{
nd6ravariables obj = new nd6ravariables();
obj.set_vlan(vlan);
nd6ravariables response = (nd6ravariables) obj.get_resource(service);
return response;
} | [
"public",
"static",
"nd6ravariables",
"get",
"(",
"nitro_service",
"service",
",",
"Long",
"vlan",
")",
"throws",
"Exception",
"{",
"nd6ravariables",
"obj",
"=",
"new",
"nd6ravariables",
"(",
")",
";",
"obj",
".",
"set_vlan",
"(",
"vlan",
")",
";",
"nd6ravar... | Use this API to fetch nd6ravariables resource of given name . | [
"Use",
"this",
"API",
"to",
"fetch",
"nd6ravariables",
"resource",
"of",
"given",
"name",
"."
] | train | https://github.com/netscaler/nitro/blob/2a98692dcf4e4ec430c7d7baab8382e4ba5a35e4/src/main/java/com/citrix/netscaler/nitro/resource/config/network/nd6ravariables.java#L549-L554 |
pac4j/pac4j | pac4j-core/src/main/java/org/pac4j/core/engine/AbstractExceptionAwareLogic.java | AbstractExceptionAwareLogic.handleException | protected R handleException(final Exception e, final HttpActionAdapter<R, C> httpActionAdapter, final C context) {
if (httpActionAdapter == null || context == null) {
throw runtimeException(e);
} else if (e instanceof HttpAction) {
final HttpAction action = (HttpAction) e;
logger.debug("extra HTTP action required in security: {}", action.getCode());
return httpActionAdapter.adapt(action, context);
} else {
if (CommonHelper.isNotBlank(errorUrl)) {
final HttpAction action = RedirectionActionHelper.buildRedirectUrlAction(context, errorUrl);
return httpActionAdapter.adapt(action, context);
} else {
throw runtimeException(e);
}
}
} | java | protected R handleException(final Exception e, final HttpActionAdapter<R, C> httpActionAdapter, final C context) {
if (httpActionAdapter == null || context == null) {
throw runtimeException(e);
} else if (e instanceof HttpAction) {
final HttpAction action = (HttpAction) e;
logger.debug("extra HTTP action required in security: {}", action.getCode());
return httpActionAdapter.adapt(action, context);
} else {
if (CommonHelper.isNotBlank(errorUrl)) {
final HttpAction action = RedirectionActionHelper.buildRedirectUrlAction(context, errorUrl);
return httpActionAdapter.adapt(action, context);
} else {
throw runtimeException(e);
}
}
} | [
"protected",
"R",
"handleException",
"(",
"final",
"Exception",
"e",
",",
"final",
"HttpActionAdapter",
"<",
"R",
",",
"C",
">",
"httpActionAdapter",
",",
"final",
"C",
"context",
")",
"{",
"if",
"(",
"httpActionAdapter",
"==",
"null",
"||",
"context",
"==",... | Handle exceptions.
@param e the thrown exception
@param httpActionAdapter the HTTP action adapter
@param context the web context
@return the final HTTP result | [
"Handle",
"exceptions",
"."
] | train | https://github.com/pac4j/pac4j/blob/d9cd029f8783792b31dd48bf1e32f80628f2c4a3/pac4j-core/src/main/java/org/pac4j/core/engine/AbstractExceptionAwareLogic.java#L37-L52 |
groovy/groovy-core | src/main/org/codehaus/groovy/runtime/IOGroovyMethods.java | IOGroovyMethods.splitEachLine | public static <T> T splitEachLine(Reader self, Pattern pattern, @ClosureParams(value=FromString.class,options="List<String>") Closure<T> closure) throws IOException {
BufferedReader br;
T result = null;
if (self instanceof BufferedReader)
br = (BufferedReader) self;
else
br = new BufferedReader(self);
try {
while (true) {
String line = br.readLine();
if (line == null) {
break;
} else {
List vals = Arrays.asList(pattern.split(line));
result = closure.call(vals);
}
}
Reader temp = self;
self = null;
temp.close();
return result;
} finally {
closeWithWarning(self);
closeWithWarning(br);
}
} | java | public static <T> T splitEachLine(Reader self, Pattern pattern, @ClosureParams(value=FromString.class,options="List<String>") Closure<T> closure) throws IOException {
BufferedReader br;
T result = null;
if (self instanceof BufferedReader)
br = (BufferedReader) self;
else
br = new BufferedReader(self);
try {
while (true) {
String line = br.readLine();
if (line == null) {
break;
} else {
List vals = Arrays.asList(pattern.split(line));
result = closure.call(vals);
}
}
Reader temp = self;
self = null;
temp.close();
return result;
} finally {
closeWithWarning(self);
closeWithWarning(br);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"splitEachLine",
"(",
"Reader",
"self",
",",
"Pattern",
"pattern",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"FromString",
".",
"class",
",",
"options",
"=",
"\"List<String>\"",
")",
"Closure",
"<",
"T",
">",
"... | Iterates through the given reader line by line, splitting each line using
the given regex separator Pattern. For each line, the given closure is called with
a single parameter being the list of strings computed by splitting the line
around matches of the given regular expression. The Reader is closed afterwards.
<p>
Here is an example:
<pre>
def s = 'The 3 quick\nbrown 4 fox'
def result = ''
new StringReader(s).splitEachLine(~/\d/){ parts ->
result += "${parts[0]}_${parts[1]}|"
}
assert result == 'The _ quick|brown _ fox|'
</pre>
@param self a Reader, closed after the method returns
@param pattern the regular expression Pattern for the delimiter
@param closure a closure
@return the last value returned by the closure
@throws IOException if an IOException occurs.
@throws java.util.regex.PatternSyntaxException
if the regular expression's syntax is invalid
@see java.lang.String#split(java.lang.String)
@since 1.6.8 | [
"Iterates",
"through",
"the",
"given",
"reader",
"line",
"by",
"line",
"splitting",
"each",
"line",
"using",
"the",
"given",
"regex",
"separator",
"Pattern",
".",
"For",
"each",
"line",
"the",
"given",
"closure",
"is",
"called",
"with",
"a",
"single",
"param... | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/IOGroovyMethods.java#L557-L584 |
eobermuhlner/big-math | ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/stream/BigDecimalStream.java | BigDecimalStream.range | public static Stream<BigDecimal> range(BigDecimal startInclusive, BigDecimal endExclusive, BigDecimal step, MathContext mathContext) {
if (step.signum() == 0) {
throw new IllegalArgumentException("invalid step: 0");
}
if (endExclusive.subtract(startInclusive).signum() != step.signum()) {
return Stream.empty();
}
return StreamSupport.stream(new BigDecimalSpliterator(startInclusive, endExclusive, false, step, mathContext), false);
} | java | public static Stream<BigDecimal> range(BigDecimal startInclusive, BigDecimal endExclusive, BigDecimal step, MathContext mathContext) {
if (step.signum() == 0) {
throw new IllegalArgumentException("invalid step: 0");
}
if (endExclusive.subtract(startInclusive).signum() != step.signum()) {
return Stream.empty();
}
return StreamSupport.stream(new BigDecimalSpliterator(startInclusive, endExclusive, false, step, mathContext), false);
} | [
"public",
"static",
"Stream",
"<",
"BigDecimal",
">",
"range",
"(",
"BigDecimal",
"startInclusive",
",",
"BigDecimal",
"endExclusive",
",",
"BigDecimal",
"step",
",",
"MathContext",
"mathContext",
")",
"{",
"if",
"(",
"step",
".",
"signum",
"(",
")",
"==",
"... | Returns a sequential ordered {@code Stream<BigDecimal>} from {@code startInclusive}
(inclusive) to {@code endExclusive} (exclusive) by an incremental {@code step}.
<p>An equivalent sequence of increasing values can be produced
sequentially using a {@code for} loop as follows:
<pre>for (BigDecimal i = startInclusive; i.compareTo(endExclusive) < 0; i = i.add(step, mathContext)) {
...
}</pre>
@param startInclusive the (inclusive) initial value
@param endExclusive the exclusive upper bound
@param step the step between elements
@param mathContext the {@link MathContext} used for all mathematical operations
@return a sequential {@code Stream<BigDecimal>} | [
"Returns",
"a",
"sequential",
"ordered",
"{",
"@code",
"Stream<BigDecimal",
">",
"}",
"from",
"{",
"@code",
"startInclusive",
"}",
"(",
"inclusive",
")",
"to",
"{",
"@code",
"endExclusive",
"}",
"(",
"exclusive",
")",
"by",
"an",
"incremental",
"{",
"@code",... | train | https://github.com/eobermuhlner/big-math/blob/52c4fc334d0d722b295de740c1018ee400e3e8f2/ch.obermuhlner.math.big/src/main/java/ch/obermuhlner/math/big/stream/BigDecimalStream.java#L35-L43 |
kiswanij/jk-util | src/main/java/com/jk/util/JKIOUtil.java | JKIOUtil.writeFileToTempDirectory | public static File writeFileToTempDirectory(final byte[] data, final String fileName) {
try {
File file = createTempDirectory();
File out = new File(file, fileName);
out.deleteOnExit();
file.deleteOnExit();
return writeDataToFile(data, out);
} catch (IOException e) {
JKExceptionUtil.handle(e);
return null;
}
} | java | public static File writeFileToTempDirectory(final byte[] data, final String fileName) {
try {
File file = createTempDirectory();
File out = new File(file, fileName);
out.deleteOnExit();
file.deleteOnExit();
return writeDataToFile(data, out);
} catch (IOException e) {
JKExceptionUtil.handle(e);
return null;
}
} | [
"public",
"static",
"File",
"writeFileToTempDirectory",
"(",
"final",
"byte",
"[",
"]",
"data",
",",
"final",
"String",
"fileName",
")",
"{",
"try",
"{",
"File",
"file",
"=",
"createTempDirectory",
"(",
")",
";",
"File",
"out",
"=",
"new",
"File",
"(",
"... | Write file to temp directory.
@param data the data
@param fileName the file name
@return the file | [
"Write",
"file",
"to",
"temp",
"directory",
"."
] | train | https://github.com/kiswanij/jk-util/blob/8e0c85818423406f769444c76194a748e0a0fc0a/src/main/java/com/jk/util/JKIOUtil.java#L422-L433 |
landawn/AbacusUtil | src/com/landawn/abacus/hash/FarmHashFingerprint64.java | FarmHashFingerprint64.hashLength65Plus | private static long hashLength65Plus(byte[] bytes, int offset, int length) {
final int seed = 81;
// For strings over 64 bytes we loop. Internal state consists of 56 bytes: v, w, x, y, and z.
long x = seed;
// @SuppressWarnings("ConstantOverflow")
long y = seed * K1 + 113;
long z = shiftMix(y * K2 + 113) * K2;
long[] v = new long[2], w = new long[2];
x = x * K2 + load64(bytes, offset);
// Set end so that after the loop we have 1 to 64 bytes left to process.
int end = offset + ((length - 1) / 64) * 64;
int last64offset = end + ((length - 1) & 63) - 63;
do {
x = rotateRight(x + y + v[0] + load64(bytes, offset + 8), 37) * K1;
y = rotateRight(y + v[1] + load64(bytes, offset + 48), 42) * K1;
x ^= w[1];
y += v[0] + load64(bytes, offset + 40);
z = rotateRight(z + w[0], 33) * K1;
weakHashLength32WithSeeds(bytes, offset, v[1] * K1, x + w[0], v);
weakHashLength32WithSeeds(bytes, offset + 32, z + w[1], y + load64(bytes, offset + 16), w);
long tmp = x;
x = z;
z = tmp;
offset += 64;
} while (offset != end);
long mul = K1 + ((z & 0xFF) << 1);
// Operate on the last 64 bytes of input.
offset = last64offset;
w[0] += ((length - 1) & 63);
v[0] += w[0];
w[0] += v[0];
x = rotateRight(x + y + v[0] + load64(bytes, offset + 8), 37) * mul;
y = rotateRight(y + v[1] + load64(bytes, offset + 48), 42) * mul;
x ^= w[1] * 9;
y += v[0] * 9 + load64(bytes, offset + 40);
z = rotateRight(z + w[0], 33) * mul;
weakHashLength32WithSeeds(bytes, offset, v[1] * mul, x + w[0], v);
weakHashLength32WithSeeds(bytes, offset + 32, z + w[1], y + load64(bytes, offset + 16), w);
return hashLength16(hashLength16(v[0], w[0], mul) + shiftMix(y) * K0 + x, hashLength16(v[1], w[1], mul) + z, mul);
} | java | private static long hashLength65Plus(byte[] bytes, int offset, int length) {
final int seed = 81;
// For strings over 64 bytes we loop. Internal state consists of 56 bytes: v, w, x, y, and z.
long x = seed;
// @SuppressWarnings("ConstantOverflow")
long y = seed * K1 + 113;
long z = shiftMix(y * K2 + 113) * K2;
long[] v = new long[2], w = new long[2];
x = x * K2 + load64(bytes, offset);
// Set end so that after the loop we have 1 to 64 bytes left to process.
int end = offset + ((length - 1) / 64) * 64;
int last64offset = end + ((length - 1) & 63) - 63;
do {
x = rotateRight(x + y + v[0] + load64(bytes, offset + 8), 37) * K1;
y = rotateRight(y + v[1] + load64(bytes, offset + 48), 42) * K1;
x ^= w[1];
y += v[0] + load64(bytes, offset + 40);
z = rotateRight(z + w[0], 33) * K1;
weakHashLength32WithSeeds(bytes, offset, v[1] * K1, x + w[0], v);
weakHashLength32WithSeeds(bytes, offset + 32, z + w[1], y + load64(bytes, offset + 16), w);
long tmp = x;
x = z;
z = tmp;
offset += 64;
} while (offset != end);
long mul = K1 + ((z & 0xFF) << 1);
// Operate on the last 64 bytes of input.
offset = last64offset;
w[0] += ((length - 1) & 63);
v[0] += w[0];
w[0] += v[0];
x = rotateRight(x + y + v[0] + load64(bytes, offset + 8), 37) * mul;
y = rotateRight(y + v[1] + load64(bytes, offset + 48), 42) * mul;
x ^= w[1] * 9;
y += v[0] * 9 + load64(bytes, offset + 40);
z = rotateRight(z + w[0], 33) * mul;
weakHashLength32WithSeeds(bytes, offset, v[1] * mul, x + w[0], v);
weakHashLength32WithSeeds(bytes, offset + 32, z + w[1], y + load64(bytes, offset + 16), w);
return hashLength16(hashLength16(v[0], w[0], mul) + shiftMix(y) * K0 + x, hashLength16(v[1], w[1], mul) + z, mul);
} | [
"private",
"static",
"long",
"hashLength65Plus",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"final",
"int",
"seed",
"=",
"81",
";",
"// For strings over 64 bytes we loop. Internal state consists of 56 bytes: v, w, x, y, and z."... | /*
Compute an 8-byte hash of a byte array of length greater than 64 bytes. | [
"/",
"*",
"Compute",
"an",
"8",
"-",
"byte",
"hash",
"of",
"a",
"byte",
"array",
"of",
"length",
"greater",
"than",
"64",
"bytes",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/hash/FarmHashFingerprint64.java#L165-L205 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_conference_serviceName_webAccess_id_GET | public OvhConferenceWebAccess billingAccount_conference_serviceName_webAccess_id_GET(String billingAccount, String serviceName, Long id) throws IOException {
String qPath = "/telephony/{billingAccount}/conference/{serviceName}/webAccess/{id}";
StringBuilder sb = path(qPath, billingAccount, serviceName, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhConferenceWebAccess.class);
} | java | public OvhConferenceWebAccess billingAccount_conference_serviceName_webAccess_id_GET(String billingAccount, String serviceName, Long id) throws IOException {
String qPath = "/telephony/{billingAccount}/conference/{serviceName}/webAccess/{id}";
StringBuilder sb = path(qPath, billingAccount, serviceName, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhConferenceWebAccess.class);
} | [
"public",
"OvhConferenceWebAccess",
"billingAccount_conference_serviceName_webAccess_id_GET",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"Long",
"id",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/conference/{... | Get this object properties
REST: GET /telephony/{billingAccount}/conference/{serviceName}/webAccess/{id}
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param id [required] Id of the object | [
"Get",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L4824-L4829 |
apache/incubator-druid | server/src/main/java/org/apache/druid/server/coordination/SegmentLoadDropHandler.java | SegmentLoadDropHandler.loadSegment | private void loadSegment(DataSegment segment, DataSegmentChangeCallback callback) throws SegmentLoadingException
{
final boolean loaded;
try {
loaded = segmentManager.loadSegment(segment);
}
catch (Exception e) {
removeSegment(segment, callback, false);
throw new SegmentLoadingException(e, "Exception loading segment[%s]", segment.getId());
}
if (loaded) {
File segmentInfoCacheFile = new File(config.getInfoDir(), segment.getId().toString());
if (!segmentInfoCacheFile.exists()) {
try {
jsonMapper.writeValue(segmentInfoCacheFile, segment);
}
catch (IOException e) {
removeSegment(segment, callback, false);
throw new SegmentLoadingException(
e,
"Failed to write to disk segment info cache file[%s]",
segmentInfoCacheFile
);
}
}
}
} | java | private void loadSegment(DataSegment segment, DataSegmentChangeCallback callback) throws SegmentLoadingException
{
final boolean loaded;
try {
loaded = segmentManager.loadSegment(segment);
}
catch (Exception e) {
removeSegment(segment, callback, false);
throw new SegmentLoadingException(e, "Exception loading segment[%s]", segment.getId());
}
if (loaded) {
File segmentInfoCacheFile = new File(config.getInfoDir(), segment.getId().toString());
if (!segmentInfoCacheFile.exists()) {
try {
jsonMapper.writeValue(segmentInfoCacheFile, segment);
}
catch (IOException e) {
removeSegment(segment, callback, false);
throw new SegmentLoadingException(
e,
"Failed to write to disk segment info cache file[%s]",
segmentInfoCacheFile
);
}
}
}
} | [
"private",
"void",
"loadSegment",
"(",
"DataSegment",
"segment",
",",
"DataSegmentChangeCallback",
"callback",
")",
"throws",
"SegmentLoadingException",
"{",
"final",
"boolean",
"loaded",
";",
"try",
"{",
"loaded",
"=",
"segmentManager",
".",
"loadSegment",
"(",
"se... | Load a single segment. If the segment is loaded successfully, this function simply returns. Otherwise it will
throw a SegmentLoadingException
@throws SegmentLoadingException if it fails to load the given segment | [
"Load",
"a",
"single",
"segment",
".",
"If",
"the",
"segment",
"is",
"loaded",
"successfully",
"this",
"function",
"simply",
"returns",
".",
"Otherwise",
"it",
"will",
"throw",
"a",
"SegmentLoadingException"
] | train | https://github.com/apache/incubator-druid/blob/f776b9408962b9006cfcfe4d6c1794751972cc8e/server/src/main/java/org/apache/druid/server/coordination/SegmentLoadDropHandler.java#L260-L287 |
liferay/com-liferay-commerce | commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceCountryPersistenceImpl.java | CommerceCountryPersistenceImpl.findByG_N | @Override
public CommerceCountry findByG_N(long groupId, int numericISOCode)
throws NoSuchCountryException {
CommerceCountry commerceCountry = fetchByG_N(groupId, numericISOCode);
if (commerceCountry == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", numericISOCode=");
msg.append(numericISOCode);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCountryException(msg.toString());
}
return commerceCountry;
} | java | @Override
public CommerceCountry findByG_N(long groupId, int numericISOCode)
throws NoSuchCountryException {
CommerceCountry commerceCountry = fetchByG_N(groupId, numericISOCode);
if (commerceCountry == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", numericISOCode=");
msg.append(numericISOCode);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchCountryException(msg.toString());
}
return commerceCountry;
} | [
"@",
"Override",
"public",
"CommerceCountry",
"findByG_N",
"(",
"long",
"groupId",
",",
"int",
"numericISOCode",
")",
"throws",
"NoSuchCountryException",
"{",
"CommerceCountry",
"commerceCountry",
"=",
"fetchByG_N",
"(",
"groupId",
",",
"numericISOCode",
")",
";",
"... | Returns the commerce country where groupId = ? and numericISOCode = ? or throws a {@link NoSuchCountryException} if it could not be found.
@param groupId the group ID
@param numericISOCode the numeric iso code
@return the matching commerce country
@throws NoSuchCountryException if a matching commerce country could not be found | [
"Returns",
"the",
"commerce",
"country",
"where",
"groupId",
"=",
"?",
";",
"and",
"numericISOCode",
"=",
"?",
";",
"or",
"throws",
"a",
"{",
"@link",
"NoSuchCountryException",
"}",
"if",
"it",
"could",
"not",
"be",
"found",
"."
] | train | https://github.com/liferay/com-liferay-commerce/blob/9e54362d7f59531fc684016ba49ee7cdc3a2f22b/commerce-service/src/main/java/com/liferay/commerce/service/persistence/impl/CommerceCountryPersistenceImpl.java#L2257-L2283 |
PeterisP/LVTagger | src/main/java/edu/stanford/nlp/math/SloppyMath.java | SloppyMath.chiSquare2by2 | public static double chiSquare2by2(int k, int n, int r, int m) {
int[][] cg = {{k, r - k}, {m - k, n - (k + (r - k) + (m - k))}};
int[] cgr = {r, n - r};
int[] cgc = {m, n - m};
double total = 0.0;
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
double exp = (double) cgr[i] * cgc[j] / n;
total += (cg[i][j] - exp) * (cg[i][j] - exp) / exp;
}
}
return total;
} | java | public static double chiSquare2by2(int k, int n, int r, int m) {
int[][] cg = {{k, r - k}, {m - k, n - (k + (r - k) + (m - k))}};
int[] cgr = {r, n - r};
int[] cgc = {m, n - m};
double total = 0.0;
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
double exp = (double) cgr[i] * cgc[j] / n;
total += (cg[i][j] - exp) * (cg[i][j] - exp) / exp;
}
}
return total;
} | [
"public",
"static",
"double",
"chiSquare2by2",
"(",
"int",
"k",
",",
"int",
"n",
",",
"int",
"r",
",",
"int",
"m",
")",
"{",
"int",
"[",
"]",
"[",
"]",
"cg",
"=",
"{",
"{",
"k",
",",
"r",
"-",
"k",
"}",
",",
"{",
"m",
"-",
"k",
",",
"n",
... | Find a 2x2 chi-square value.
Note: could do this more neatly using simplified formula for 2x2 case.
@param k The number of black balls drawn
@param n The total number of balls
@param r The number of black balls
@param m The number of balls drawn
@return The Fisher's exact p-value | [
"Find",
"a",
"2x2",
"chi",
"-",
"square",
"value",
".",
"Note",
":",
"could",
"do",
"this",
"more",
"neatly",
"using",
"simplified",
"formula",
"for",
"2x2",
"case",
"."
] | train | https://github.com/PeterisP/LVTagger/blob/b3d44bab9ec07ace0d13612c448a6b7298c1f681/src/main/java/edu/stanford/nlp/math/SloppyMath.java#L591-L603 |
FXMisc/RichTextFX | richtextfx/src/main/java/org/fxmisc/richtext/util/SubscribeableContentsObsSet.java | SubscribeableContentsObsSet.addSubscriber | public Subscription addSubscriber(Function<? super E, Subscription> subscriber) {
Objects.requireNonNull(subscriber);
subscribers.add(subscriber);
List<E> keys = new ArrayList<>(map.keySet());
keys.forEach(key -> {
List<Subscription> otherSubs = map.get(key);
Subscription sub = subscriber.apply(key);
otherSubs.add(sub);
map.put(key, otherSubs);
});
return () -> removeSubscriber(subscriber);
} | java | public Subscription addSubscriber(Function<? super E, Subscription> subscriber) {
Objects.requireNonNull(subscriber);
subscribers.add(subscriber);
List<E> keys = new ArrayList<>(map.keySet());
keys.forEach(key -> {
List<Subscription> otherSubs = map.get(key);
Subscription sub = subscriber.apply(key);
otherSubs.add(sub);
map.put(key, otherSubs);
});
return () -> removeSubscriber(subscriber);
} | [
"public",
"Subscription",
"addSubscriber",
"(",
"Function",
"<",
"?",
"super",
"E",
",",
"Subscription",
">",
"subscriber",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"subscriber",
")",
";",
"subscribers",
".",
"add",
"(",
"subscriber",
")",
";",
"List... | Subscribes to all current and future elements' internal changes in this set until either they are removed
or this subscriber is removed by calling {@link Subscription#unsubscribe() unsubscribe} on the function's
returned {@link Subscription}. | [
"Subscribes",
"to",
"all",
"current",
"and",
"future",
"elements",
"internal",
"changes",
"in",
"this",
"set",
"until",
"either",
"they",
"are",
"removed",
"or",
"this",
"subscriber",
"is",
"removed",
"by",
"calling",
"{"
] | train | https://github.com/FXMisc/RichTextFX/blob/bc7cab6a637855e0f37d9b9c12a9172c31545f0b/richtextfx/src/main/java/org/fxmisc/richtext/util/SubscribeableContentsObsSet.java#L106-L119 |
opsmatters/newrelic-api | src/main/java/com/opsmatters/newrelic/api/services/HttpContext.java | HttpContext.PATCH | public void PATCH(String partialUrl, Object payload)
{
URI uri = buildUri(partialUrl);
executePatchRequest(uri, payload);
} | java | public void PATCH(String partialUrl, Object payload)
{
URI uri = buildUri(partialUrl);
executePatchRequest(uri, payload);
} | [
"public",
"void",
"PATCH",
"(",
"String",
"partialUrl",
",",
"Object",
"payload",
")",
"{",
"URI",
"uri",
"=",
"buildUri",
"(",
"partialUrl",
")",
";",
"executePatchRequest",
"(",
"uri",
",",
"payload",
")",
";",
"}"
] | Execute a PATCH call against the partial URL.
@param partialUrl The partial URL to build
@param payload The object to use for the PATCH | [
"Execute",
"a",
"PATCH",
"call",
"against",
"the",
"partial",
"URL",
"."
] | train | https://github.com/opsmatters/newrelic-api/blob/5bc2ea62ec368db891e4fd5fe3dcdf529d086b5e/src/main/java/com/opsmatters/newrelic/api/services/HttpContext.java#L247-L251 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/util/TransparentReplicaGetHelper.java | TransparentReplicaGetHelper.getFirstPrimaryOrReplica | @InterfaceStability.Experimental
@InterfaceAudience.Public
public Single<JsonDocument> getFirstPrimaryOrReplica(final String id,
final Bucket bucket, final long timeout) {
return getFirstPrimaryOrReplica(id, bucket, timeout, timeout);
} | java | @InterfaceStability.Experimental
@InterfaceAudience.Public
public Single<JsonDocument> getFirstPrimaryOrReplica(final String id,
final Bucket bucket, final long timeout) {
return getFirstPrimaryOrReplica(id, bucket, timeout, timeout);
} | [
"@",
"InterfaceStability",
".",
"Experimental",
"@",
"InterfaceAudience",
".",
"Public",
"public",
"Single",
"<",
"JsonDocument",
">",
"getFirstPrimaryOrReplica",
"(",
"final",
"String",
"id",
",",
"final",
"Bucket",
"bucket",
",",
"final",
"long",
"timeout",
")",... | Asynchronously fetch the document from the primary and if that operations fails try
all the replicas and return the first document that comes back from them (with a custom
timeout value applied to both primary and replica).
@param id the document ID to fetch.
@param bucket the bucket to use when fetching the doc.
@param timeout the timeout to use for both primary and replica fetches (separately)
@return an {@link Single} with either 0 or 1 {@link JsonDocument}. | [
"Asynchronously",
"fetch",
"the",
"document",
"from",
"the",
"primary",
"and",
"if",
"that",
"operations",
"fails",
"try",
"all",
"the",
"replicas",
"and",
"return",
"the",
"first",
"document",
"that",
"comes",
"back",
"from",
"them",
"(",
"with",
"a",
"cust... | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/util/TransparentReplicaGetHelper.java#L71-L76 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/cdn/CdnClient.java | CdnClient.getDomainCacheTTL | public GetDomainCacheTTLResponse getDomainCacheTTL(GetDomainCacheTTLRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DOMAIN, request.getDomain(), "config");
internalRequest.addParameter("cacheTTL","");
return invokeHttpClient(internalRequest, GetDomainCacheTTLResponse.class);
} | java | public GetDomainCacheTTLResponse getDomainCacheTTL(GetDomainCacheTTLRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DOMAIN, request.getDomain(), "config");
internalRequest.addParameter("cacheTTL","");
return invokeHttpClient(internalRequest, GetDomainCacheTTLResponse.class);
} | [
"public",
"GetDomainCacheTTLResponse",
"getDomainCacheTTL",
"(",
"GetDomainCacheTTLRequest",
"request",
")",
"{",
"checkNotNull",
"(",
"request",
",",
"\"The parameter request should NOT be null.\"",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"createRequest",
"(",
"... | Get cache policies of specified domain acceleration.
@param request The request containing all of the options related to the domain.
@return Detailed information about cache policies. | [
"Get",
"cache",
"policies",
"of",
"specified",
"domain",
"acceleration",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/cdn/CdnClient.java#L343-L348 |
williamwebb/alogger | BillingHelper/src/main/java/com/jug6ernaut/billing/IabHelper.java | IabHelper.consumeAsync | public void consumeAsync(List<Purchase> purchases, OnConsumeMultiFinishedListener listener) {
checkNotDisposed();
checkSetupDone("consume");
consumeAsyncInternal(purchases, null, listener);
} | java | public void consumeAsync(List<Purchase> purchases, OnConsumeMultiFinishedListener listener) {
checkNotDisposed();
checkSetupDone("consume");
consumeAsyncInternal(purchases, null, listener);
} | [
"public",
"void",
"consumeAsync",
"(",
"List",
"<",
"Purchase",
">",
"purchases",
",",
"OnConsumeMultiFinishedListener",
"listener",
")",
"{",
"checkNotDisposed",
"(",
")",
";",
"checkSetupDone",
"(",
"\"consume\"",
")",
";",
"consumeAsyncInternal",
"(",
"purchases"... | Same as {@link consumeAsync}, but for multiple items at once.
@param purchases The list of PurchaseInfo objects representing the purchases to consume.
@param listener The listener to notify when the consumption operation finishes. | [
"Same",
"as",
"{"
] | train | https://github.com/williamwebb/alogger/blob/61fca49e0b8d9c3a76c40da8883ac354b240351e/BillingHelper/src/main/java/com/jug6ernaut/billing/IabHelper.java#L747-L751 |
MenoData/Time4J | base/src/main/java/net/time4j/LongElement.java | LongElement.create | static LongElement create(
String name,
long defaultMin,
long defaultMax
) {
return new LongElement(name, defaultMin, defaultMax);
} | java | static LongElement create(
String name,
long defaultMin,
long defaultMax
) {
return new LongElement(name, defaultMin, defaultMax);
} | [
"static",
"LongElement",
"create",
"(",
"String",
"name",
",",
"long",
"defaultMin",
",",
"long",
"defaultMax",
")",
"{",
"return",
"new",
"LongElement",
"(",
"name",
",",
"defaultMin",
",",
"defaultMax",
")",
";",
"}"
] | <p>Erzeugt ein neues Uhrzeitelement ohne Formatsymbol. </p>
@param name name of element
@param defaultMin default minimum
@param defaultMax default maximum | [
"<p",
">",
"Erzeugt",
"ein",
"neues",
"Uhrzeitelement",
"ohne",
"Formatsymbol",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/MenoData/Time4J/blob/08b2eda6b2dbb140b92011cf7071bb087edd46a5/base/src/main/java/net/time4j/LongElement.java#L164-L172 |
jenkinsci/favorite-plugin | src/main/java/hudson/plugins/favorite/Favorites.java | Favorites.hasFavorite | public static boolean hasFavorite(@Nonnull User user, @Nonnull Item item) throws FavoriteException {
try {
FavoriteUserProperty property = getProperty(user);
return property.hasFavorite(item.getFullName());
} catch (IOException e) {
throw new FavoriteException("Could not determine Favorite state. User: <" + user.getFullName() + "> Item: <" + item.getFullName() + ">", e);
}
} | java | public static boolean hasFavorite(@Nonnull User user, @Nonnull Item item) throws FavoriteException {
try {
FavoriteUserProperty property = getProperty(user);
return property.hasFavorite(item.getFullName());
} catch (IOException e) {
throw new FavoriteException("Could not determine Favorite state. User: <" + user.getFullName() + "> Item: <" + item.getFullName() + ">", e);
}
} | [
"public",
"static",
"boolean",
"hasFavorite",
"(",
"@",
"Nonnull",
"User",
"user",
",",
"@",
"Nonnull",
"Item",
"item",
")",
"throws",
"FavoriteException",
"{",
"try",
"{",
"FavoriteUserProperty",
"property",
"=",
"getProperty",
"(",
"user",
")",
";",
"return"... | Check if the item has a favorite entry regardless of its state
This is useful for checking if a favorite/unfavorite operation has ever been performed against this user
@param user to check
@param item to check
@return favorite state
@throws FavoriteException | [
"Check",
"if",
"the",
"item",
"has",
"a",
"favorite",
"entry",
"regardless",
"of",
"its",
"state",
"This",
"is",
"useful",
"for",
"checking",
"if",
"a",
"favorite",
"/",
"unfavorite",
"operation",
"has",
"ever",
"been",
"performed",
"against",
"this",
"user"... | train | https://github.com/jenkinsci/favorite-plugin/blob/4ce9b195b4d888190fe12c92d546d64f22728c22/src/main/java/hudson/plugins/favorite/Favorites.java#L56-L63 |
landawn/AbacusUtil | src/com/landawn/abacus/util/IntList.java | IntList.anyMatch | public <E extends Exception> boolean anyMatch(Try.IntPredicate<E> filter) throws E {
return anyMatch(0, size(), filter);
} | java | public <E extends Exception> boolean anyMatch(Try.IntPredicate<E> filter) throws E {
return anyMatch(0, size(), filter);
} | [
"public",
"<",
"E",
"extends",
"Exception",
">",
"boolean",
"anyMatch",
"(",
"Try",
".",
"IntPredicate",
"<",
"E",
">",
"filter",
")",
"throws",
"E",
"{",
"return",
"anyMatch",
"(",
"0",
",",
"size",
"(",
")",
",",
"filter",
")",
";",
"}"
] | Returns whether any elements of this List match the provided predicate.
@param filter
@return | [
"Returns",
"whether",
"any",
"elements",
"of",
"this",
"List",
"match",
"the",
"provided",
"predicate",
"."
] | train | https://github.com/landawn/AbacusUtil/blob/544b7720175d15e9329f83dd22a8cc5fa4515e12/src/com/landawn/abacus/util/IntList.java#L1011-L1013 |
Bedework/bw-util | bw-util-xml/src/main/java/org/bedework/util/xml/XmlUtil.java | XmlUtil.getYesNoAttrVal | public static Boolean getYesNoAttrVal(final NamedNodeMap nnm, final String name)
throws SAXException {
String val = getAttrVal(nnm, name);
if (val == null) {
return null;
}
if ((!"yes".equals(val)) && (!"no".equals(val))) {
throw new SAXException("Invalid attribute value: " + val);
}
return new Boolean("yes".equals(val));
} | java | public static Boolean getYesNoAttrVal(final NamedNodeMap nnm, final String name)
throws SAXException {
String val = getAttrVal(nnm, name);
if (val == null) {
return null;
}
if ((!"yes".equals(val)) && (!"no".equals(val))) {
throw new SAXException("Invalid attribute value: " + val);
}
return new Boolean("yes".equals(val));
} | [
"public",
"static",
"Boolean",
"getYesNoAttrVal",
"(",
"final",
"NamedNodeMap",
"nnm",
",",
"final",
"String",
"name",
")",
"throws",
"SAXException",
"{",
"String",
"val",
"=",
"getAttrVal",
"(",
"nnm",
",",
"name",
")",
";",
"if",
"(",
"val",
"==",
"null"... | The attribute value of the named attribute in the given map must be
absent or "yes" or "no".
@param nnm NamedNodeMap
@param name String name of desired attribute
@return Boolean attribute value or null
@throws SAXException | [
"The",
"attribute",
"value",
"of",
"the",
"named",
"attribute",
"in",
"the",
"given",
"map",
"must",
"be",
"absent",
"or",
"yes",
"or",
"no",
"."
] | train | https://github.com/Bedework/bw-util/blob/f51de4af3d7eb88fe63a0e22be8898a16c6cc3ad/bw-util-xml/src/main/java/org/bedework/util/xml/XmlUtil.java#L270-L283 |
groovy/groovy-core | src/main/org/codehaus/groovy/runtime/IOGroovyMethods.java | IOGroovyMethods.filterLine | public static Writable filterLine(Reader reader, final @ClosureParams(value=SimpleType.class, options="java.lang.String") Closure closure) {
final BufferedReader br = new BufferedReader(reader);
return new Writable() {
public Writer writeTo(Writer out) throws IOException {
BufferedWriter bw = new BufferedWriter(out);
String line;
BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure);
while ((line = br.readLine()) != null) {
if (bcw.call(line)) {
bw.write(line);
bw.newLine();
}
}
bw.flush();
return out;
}
public String toString() {
StringWriter buffer = new StringWriter();
try {
writeTo(buffer);
} catch (IOException e) {
throw new StringWriterIOException(e);
}
return buffer.toString();
}
};
} | java | public static Writable filterLine(Reader reader, final @ClosureParams(value=SimpleType.class, options="java.lang.String") Closure closure) {
final BufferedReader br = new BufferedReader(reader);
return new Writable() {
public Writer writeTo(Writer out) throws IOException {
BufferedWriter bw = new BufferedWriter(out);
String line;
BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure);
while ((line = br.readLine()) != null) {
if (bcw.call(line)) {
bw.write(line);
bw.newLine();
}
}
bw.flush();
return out;
}
public String toString() {
StringWriter buffer = new StringWriter();
try {
writeTo(buffer);
} catch (IOException e) {
throw new StringWriterIOException(e);
}
return buffer.toString();
}
};
} | [
"public",
"static",
"Writable",
"filterLine",
"(",
"Reader",
"reader",
",",
"final",
"@",
"ClosureParams",
"(",
"value",
"=",
"SimpleType",
".",
"class",
",",
"options",
"=",
"\"java.lang.String\"",
")",
"Closure",
"closure",
")",
"{",
"final",
"BufferedReader",... | Filter the lines from this Reader, and return a Writable which can be
used to stream the filtered lines to a destination. The closure should
return <code>true</code> if the line should be passed to the writer.
@param reader this reader
@param closure a closure used for filtering
@return a Writable which will use the closure to filter each line
from the reader when the Writable#writeTo(Writer) is called.
@since 1.0 | [
"Filter",
"the",
"lines",
"from",
"this",
"Reader",
"and",
"return",
"a",
"Writable",
"which",
"can",
"be",
"used",
"to",
"stream",
"the",
"filtered",
"lines",
"to",
"a",
"destination",
".",
"The",
"closure",
"should",
"return",
"<code",
">",
"true<",
"/",... | train | https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/IOGroovyMethods.java#L1511-L1538 |
pressgang-ccms/PressGangCCMSQuery | src/main/java/org/jboss/pressgang/ccms/filter/base/BaseFilterQueryBuilder.java | BaseFilterQueryBuilder.addIdNotInCollectionCondition | protected void addIdNotInCollectionCondition(final Expression<?> property, final Collection<?> values) {
if (values != null && !values.isEmpty()) {
fieldConditions.add(getCriteriaBuilder().not(property.in(values)));
}
} | java | protected void addIdNotInCollectionCondition(final Expression<?> property, final Collection<?> values) {
if (values != null && !values.isEmpty()) {
fieldConditions.add(getCriteriaBuilder().not(property.in(values)));
}
} | [
"protected",
"void",
"addIdNotInCollectionCondition",
"(",
"final",
"Expression",
"<",
"?",
">",
"property",
",",
"final",
"Collection",
"<",
"?",
">",
"values",
")",
"{",
"if",
"(",
"values",
"!=",
"null",
"&&",
"!",
"values",
".",
"isEmpty",
"(",
")",
... | Add a Field Search Condition that will check if the id field exists in an array of values. eg. {@code field IN (values)}
@param property The field id as defined in the Entity mapping class.
@param values The List of Ids to be compared to. | [
"Add",
"a",
"Field",
"Search",
"Condition",
"that",
"will",
"check",
"if",
"the",
"id",
"field",
"exists",
"in",
"an",
"array",
"of",
"values",
".",
"eg",
".",
"{",
"@code",
"field",
"IN",
"(",
"values",
")",
"}"
] | train | https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/base/BaseFilterQueryBuilder.java#L382-L386 |
pwittchen/ReactiveNetwork | library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ReactiveNetwork.java | ReactiveNetwork.observeNetworkConnectivity | @RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE)
public static Observable<Connectivity> observeNetworkConnectivity(final Context context) {
final NetworkObservingStrategy strategy;
if (Preconditions.isAtLeastAndroidMarshmallow()) {
strategy = new MarshmallowNetworkObservingStrategy();
} else if (Preconditions.isAtLeastAndroidLollipop()) {
strategy = new LollipopNetworkObservingStrategy();
} else {
strategy = new PreLollipopNetworkObservingStrategy();
}
return observeNetworkConnectivity(context, strategy);
} | java | @RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE)
public static Observable<Connectivity> observeNetworkConnectivity(final Context context) {
final NetworkObservingStrategy strategy;
if (Preconditions.isAtLeastAndroidMarshmallow()) {
strategy = new MarshmallowNetworkObservingStrategy();
} else if (Preconditions.isAtLeastAndroidLollipop()) {
strategy = new LollipopNetworkObservingStrategy();
} else {
strategy = new PreLollipopNetworkObservingStrategy();
}
return observeNetworkConnectivity(context, strategy);
} | [
"@",
"RequiresPermission",
"(",
"Manifest",
".",
"permission",
".",
"ACCESS_NETWORK_STATE",
")",
"public",
"static",
"Observable",
"<",
"Connectivity",
">",
"observeNetworkConnectivity",
"(",
"final",
"Context",
"context",
")",
"{",
"final",
"NetworkObservingStrategy",
... | Observes network connectivity. Information about network state, type and typeName are contained
in
observed Connectivity object.
@param context Context of the activity or an application
@return RxJava Observable with Connectivity class containing information about network state,
type and typeName | [
"Observes",
"network",
"connectivity",
".",
"Information",
"about",
"network",
"state",
"type",
"and",
"typeName",
"are",
"contained",
"in",
"observed",
"Connectivity",
"object",
"."
] | train | https://github.com/pwittchen/ReactiveNetwork/blob/cfeb3b79a1e44d106581af5e6709ff206e60c369/library/src/main/java/com/github/pwittchen/reactivenetwork/library/rx2/ReactiveNetwork.java#L60-L73 |
Pi4J/pi4j | pi4j-gpio-extension/src/main/java/com/pi4j/gpio/extension/pca/PCA9685GpioProvider.java | PCA9685GpioProvider.setPwm | public void setPwm(Pin pin, int onPosition, int offPosition) {
validatePin(pin, onPosition, offPosition);
final int channel = pin.getAddress();
validatePwmValueInRange(onPosition);
validatePwmValueInRange(offPosition);
if (onPosition == offPosition) {
throw new ValidationException("ON [" + onPosition + "] and OFF [" + offPosition + "] values must be different.");
}
try {
device.write(PCA9685A_LED0_ON_L + 4 * channel, (byte) (onPosition & 0xFF));
device.write(PCA9685A_LED0_ON_H + 4 * channel, (byte) (onPosition >> 8));
device.write(PCA9685A_LED0_OFF_L + 4 * channel, (byte) (offPosition & 0xFF));
device.write(PCA9685A_LED0_OFF_H + 4 * channel, (byte) (offPosition >> 8));
} catch (IOException e) {
throw new RuntimeException("Unable to write to PWM channel [" + channel + "] values for ON [" + onPosition + "] and OFF [" + offPosition + "] position.", e);
}
cachePinValues(pin, onPosition, offPosition);
} | java | public void setPwm(Pin pin, int onPosition, int offPosition) {
validatePin(pin, onPosition, offPosition);
final int channel = pin.getAddress();
validatePwmValueInRange(onPosition);
validatePwmValueInRange(offPosition);
if (onPosition == offPosition) {
throw new ValidationException("ON [" + onPosition + "] and OFF [" + offPosition + "] values must be different.");
}
try {
device.write(PCA9685A_LED0_ON_L + 4 * channel, (byte) (onPosition & 0xFF));
device.write(PCA9685A_LED0_ON_H + 4 * channel, (byte) (onPosition >> 8));
device.write(PCA9685A_LED0_OFF_L + 4 * channel, (byte) (offPosition & 0xFF));
device.write(PCA9685A_LED0_OFF_H + 4 * channel, (byte) (offPosition >> 8));
} catch (IOException e) {
throw new RuntimeException("Unable to write to PWM channel [" + channel + "] values for ON [" + onPosition + "] and OFF [" + offPosition + "] position.", e);
}
cachePinValues(pin, onPosition, offPosition);
} | [
"public",
"void",
"setPwm",
"(",
"Pin",
"pin",
",",
"int",
"onPosition",
",",
"int",
"offPosition",
")",
"{",
"validatePin",
"(",
"pin",
",",
"onPosition",
",",
"offPosition",
")",
";",
"final",
"int",
"channel",
"=",
"pin",
".",
"getAddress",
"(",
")",
... | The LEDn_ON and LEDn_OFF counts can vary from 0 to 4095 max.<br>
The LEDn_ON and LEDn_OFF count registers should never be programmed with the same values.
<p>
Because the loading of the LEDn_ON and LEDn_OFF registers is via the I2C-bus, and
asynchronous to the internal oscillator, we want to ensure that we do not see any visual
artifacts of changing the ON and OFF values. This is achieved by updating the changes at
the end of the LOW cycle.
@param pin represents channel 0..15
@param onPosition value between 0 and 4095
@param offPosition value between 0 and 4095 | [
"The",
"LEDn_ON",
"and",
"LEDn_OFF",
"counts",
"can",
"vary",
"from",
"0",
"to",
"4095",
"max",
".",
"<br",
">",
"The",
"LEDn_ON",
"and",
"LEDn_OFF",
"count",
"registers",
"should",
"never",
"be",
"programmed",
"with",
"the",
"same",
"values",
".",
"<p",
... | train | https://github.com/Pi4J/pi4j/blob/03cacc62223cc59b3118bfcefadabab979fd84c7/pi4j-gpio-extension/src/main/java/com/pi4j/gpio/extension/pca/PCA9685GpioProvider.java#L186-L203 |
micronaut-projects/micronaut-core | core/src/main/java/io/micronaut/core/beans/SimpleBeanInfo.java | SimpleBeanInfo.introspectProperties | @SuppressWarnings("unchecked")
private List<PropertyDescriptor> introspectProperties(Method[] methodDescriptors) {
// Get the list of public non-static methods into an array
if (methodDescriptors == null) {
return null;
}
HashMap<String, HashMap> propertyTable = new HashMap<>(methodDescriptors.length);
// Search for methods that either get or set a Property
for (Method methodDescriptor : methodDescriptors) {
introspectGet(methodDescriptor, propertyTable);
introspectSet(methodDescriptor, propertyTable);
}
// fix possible getter & setter collisions
fixGetSet(propertyTable);
// Put the properties found into the PropertyDescriptor array
ArrayList<PropertyDescriptor> propertyList = new ArrayList<>();
for (Map.Entry<String, HashMap> entry : propertyTable.entrySet()) {
String propertyName = entry.getKey();
HashMap table = entry.getValue();
if (table == null) {
continue;
}
String normalTag = (String) table.get(STR_NORMAL);
if ((normalTag == null)) {
continue;
}
Method get = (Method) table.get(STR_NORMAL + PREFIX_GET);
Method set = (Method) table.get(STR_NORMAL + PREFIX_SET);
PropertyDescriptor propertyDesc = new PropertyDescriptor(propertyName, get, set);
propertyList.add(propertyDesc);
}
return Collections.unmodifiableList(propertyList);
} | java | @SuppressWarnings("unchecked")
private List<PropertyDescriptor> introspectProperties(Method[] methodDescriptors) {
// Get the list of public non-static methods into an array
if (methodDescriptors == null) {
return null;
}
HashMap<String, HashMap> propertyTable = new HashMap<>(methodDescriptors.length);
// Search for methods that either get or set a Property
for (Method methodDescriptor : methodDescriptors) {
introspectGet(methodDescriptor, propertyTable);
introspectSet(methodDescriptor, propertyTable);
}
// fix possible getter & setter collisions
fixGetSet(propertyTable);
// Put the properties found into the PropertyDescriptor array
ArrayList<PropertyDescriptor> propertyList = new ArrayList<>();
for (Map.Entry<String, HashMap> entry : propertyTable.entrySet()) {
String propertyName = entry.getKey();
HashMap table = entry.getValue();
if (table == null) {
continue;
}
String normalTag = (String) table.get(STR_NORMAL);
if ((normalTag == null)) {
continue;
}
Method get = (Method) table.get(STR_NORMAL + PREFIX_GET);
Method set = (Method) table.get(STR_NORMAL + PREFIX_SET);
PropertyDescriptor propertyDesc = new PropertyDescriptor(propertyName, get, set);
propertyList.add(propertyDesc);
}
return Collections.unmodifiableList(propertyList);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"List",
"<",
"PropertyDescriptor",
">",
"introspectProperties",
"(",
"Method",
"[",
"]",
"methodDescriptors",
")",
"{",
"// Get the list of public non-static methods into an array",
"if",
"(",
"methodDescriptors... | Introspects the supplied class and returns a list of the Properties of
the class.
@param methodDescriptors the method descriptors
@return The list of Properties as an array of PropertyDescriptors | [
"Introspects",
"the",
"supplied",
"class",
"and",
"returns",
"a",
"list",
"of",
"the",
"Properties",
"of",
"the",
"class",
"."
] | train | https://github.com/micronaut-projects/micronaut-core/blob/c31f5b03ce0eb88c2f6470710987db03b8967d5c/core/src/main/java/io/micronaut/core/beans/SimpleBeanInfo.java#L95-L137 |
jhalterman/concurrentunit | src/main/java/net/jodah/concurrentunit/internal/ReentrantCircuit.java | ReentrantCircuit.await | public boolean await(long waitDuration, TimeUnit timeUnit) throws InterruptedException {
return sync.tryAcquireSharedNanos(0, timeUnit.toNanos(waitDuration));
} | java | public boolean await(long waitDuration, TimeUnit timeUnit) throws InterruptedException {
return sync.tryAcquireSharedNanos(0, timeUnit.toNanos(waitDuration));
} | [
"public",
"boolean",
"await",
"(",
"long",
"waitDuration",
",",
"TimeUnit",
"timeUnit",
")",
"throws",
"InterruptedException",
"{",
"return",
"sync",
".",
"tryAcquireSharedNanos",
"(",
"0",
",",
"timeUnit",
".",
"toNanos",
"(",
"waitDuration",
")",
")",
";",
"... | Waits for the {@code waitDuration} until the circuit has been closed, aborting if interrupted,
returning true if the circuit is closed else false. | [
"Waits",
"for",
"the",
"{"
] | train | https://github.com/jhalterman/concurrentunit/blob/403b82537866e5ba598017d874753e12fa7aab10/src/main/java/net/jodah/concurrentunit/internal/ReentrantCircuit.java#L84-L86 |
deeplearning4j/deeplearning4j | nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/AbstractMultiDataSetNormalizer.java | AbstractMultiDataSetNormalizer.revertFeatures | public void revertFeatures(@NonNull INDArray[] features, INDArray[] maskArrays) {
for (int i = 0; i < features.length; i++) {
INDArray mask = (maskArrays == null ? null : maskArrays[i]);
revertFeatures(features[i], mask, i);
}
} | java | public void revertFeatures(@NonNull INDArray[] features, INDArray[] maskArrays) {
for (int i = 0; i < features.length; i++) {
INDArray mask = (maskArrays == null ? null : maskArrays[i]);
revertFeatures(features[i], mask, i);
}
} | [
"public",
"void",
"revertFeatures",
"(",
"@",
"NonNull",
"INDArray",
"[",
"]",
"features",
",",
"INDArray",
"[",
"]",
"maskArrays",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"features",
".",
"length",
";",
"i",
"++",
")",
"{",
"IND... | Undo (revert) the normalization applied by this normalizer to the features arrays
@param features Features to revert the normalization on | [
"Undo",
"(",
"revert",
")",
"the",
"normalization",
"applied",
"by",
"this",
"normalizer",
"to",
"the",
"features",
"arrays"
] | train | https://github.com/deeplearning4j/deeplearning4j/blob/effce52f2afd7eeb53c5bcca699fcd90bd06822f/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/AbstractMultiDataSetNormalizer.java#L220-L225 |
jeremylong/DependencyCheck | core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java | DependencyBundlingAnalyzer.namesAreEqual | private boolean namesAreEqual(Dependency dependency, Dependency nextDependency) {
return dependency.getName() != null && dependency.getName().equals(nextDependency.getName());
} | java | private boolean namesAreEqual(Dependency dependency, Dependency nextDependency) {
return dependency.getName() != null && dependency.getName().equals(nextDependency.getName());
} | [
"private",
"boolean",
"namesAreEqual",
"(",
"Dependency",
"dependency",
",",
"Dependency",
"nextDependency",
")",
"{",
"return",
"dependency",
".",
"getName",
"(",
")",
"!=",
"null",
"&&",
"dependency",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"nextDepend... | Determine if the dependency name is equal in the given dependencies.
@param dependency a dependency to compare
@param nextDependency a dependency to compare
@return true if the name is equal in both dependencies; otherwise false | [
"Determine",
"if",
"the",
"dependency",
"name",
"is",
"equal",
"in",
"the",
"given",
"dependencies",
"."
] | train | https://github.com/jeremylong/DependencyCheck/blob/6cc7690ea12e4ca1454210ceaa2e9a5523f0926c/core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java#L496-L498 |
Netflix/zeno | src/main/java/com/netflix/zeno/json/JsonFrameworkSerializer.java | JsonFrameworkSerializer.serializeObject | @Deprecated
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void serializeObject(JsonWriteGenericRecord record, String fieldName, String typeName, Object obj) {
try {
if (obj == null) {
record.getGenerator().writeObjectField(fieldName, null);
return;
}
if (isPrimitive(obj.getClass())) {
serializePrimitive(record, fieldName, obj);
return;
}
record.getGenerator().writeFieldName(fieldName);
record.getGenerator().writeStartObject();
NFTypeSerializer fieldSerializer = getSerializer(typeName);
JsonWriteGenericRecord fieldRecord = new JsonWriteGenericRecord(record.getGenerator());
fieldSerializer.serialize(obj, fieldRecord);
record.getGenerator().writeEndObject();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
} | java | @Deprecated
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void serializeObject(JsonWriteGenericRecord record, String fieldName, String typeName, Object obj) {
try {
if (obj == null) {
record.getGenerator().writeObjectField(fieldName, null);
return;
}
if (isPrimitive(obj.getClass())) {
serializePrimitive(record, fieldName, obj);
return;
}
record.getGenerator().writeFieldName(fieldName);
record.getGenerator().writeStartObject();
NFTypeSerializer fieldSerializer = getSerializer(typeName);
JsonWriteGenericRecord fieldRecord = new JsonWriteGenericRecord(record.getGenerator());
fieldSerializer.serialize(obj, fieldRecord);
record.getGenerator().writeEndObject();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
} | [
"@",
"Deprecated",
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"void",
"serializeObject",
"(",
"JsonWriteGenericRecord",
"record",
",",
"String",
"fieldName",
",",
"String",
"typeName",
",",
"Object... | /*
@Deprecated instead use serializeObject(HashGenericRecord rec, String fieldName, Object obj) | [
"/",
"*",
"@Deprecated",
"instead",
"use",
"serializeObject",
"(",
"HashGenericRecord",
"rec",
"String",
"fieldName",
"Object",
"obj",
")"
] | train | https://github.com/Netflix/zeno/blob/e571a3f1e304942724d454408fe6417fe18c20fd/src/main/java/com/netflix/zeno/json/JsonFrameworkSerializer.java#L81-L104 |
lionsoul2014/jcseg | jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java | ASegment.getNextLatinWord | protected IWord getNextLatinWord(int c, int pos) throws IOException
{
/*
* clear or just return the English punctuation as
* a single word with PUNCTUATION type and part of speech
*/
if ( StringUtil.isEnPunctuation( c ) ) {
String str = String.valueOf((char)c);
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, str) ) {
return null;
}
IWord w = new Word(str, IWord.T_PUNCTUATION);
w.setPosition(pos);
w.setPartSpeech(IWord.PUNCTUATION);
return w;
}
IWord w = nextLatinWord(c, pos);
w.setPosition(pos);
/* @added: 2013-12-16
* check and do the secondary segmentation work.
* This will split 'qq2013' to 'qq, 2013'.
*/
if ( config.EN_SECOND_SEG
&& (ctrlMask & ISegment.START_SS_MASK) != 0 ) {
enSecondSeg(w, false);
}
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, w.getValue()) ) {
w = null; //Let gc do its work
return null;
}
if ( config.APPEND_CJK_SYN ) {
appendLatinSyn(w);
}
return w;
} | java | protected IWord getNextLatinWord(int c, int pos) throws IOException
{
/*
* clear or just return the English punctuation as
* a single word with PUNCTUATION type and part of speech
*/
if ( StringUtil.isEnPunctuation( c ) ) {
String str = String.valueOf((char)c);
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, str) ) {
return null;
}
IWord w = new Word(str, IWord.T_PUNCTUATION);
w.setPosition(pos);
w.setPartSpeech(IWord.PUNCTUATION);
return w;
}
IWord w = nextLatinWord(c, pos);
w.setPosition(pos);
/* @added: 2013-12-16
* check and do the secondary segmentation work.
* This will split 'qq2013' to 'qq, 2013'.
*/
if ( config.EN_SECOND_SEG
&& (ctrlMask & ISegment.START_SS_MASK) != 0 ) {
enSecondSeg(w, false);
}
if ( config.CLEAR_STOPWORD
&& dic.match(ILexicon.STOP_WORD, w.getValue()) ) {
w = null; //Let gc do its work
return null;
}
if ( config.APPEND_CJK_SYN ) {
appendLatinSyn(w);
}
return w;
} | [
"protected",
"IWord",
"getNextLatinWord",
"(",
"int",
"c",
",",
"int",
"pos",
")",
"throws",
"IOException",
"{",
"/*\n * clear or just return the English punctuation as\n * a single word with PUNCTUATION type and part of speech \n */",
"if",
"(",
"StringUtil",
... | get the next Latin word from the current position of the input stream
@param c
@param pos
@return IWord could be null and that mean we reached a stop word
@throws IOException | [
"get",
"the",
"next",
"Latin",
"word",
"from",
"the",
"current",
"position",
"of",
"the",
"input",
"stream"
] | train | https://github.com/lionsoul2014/jcseg/blob/7c8a912e3bbcaf4f8de701180b9c24e2e444a94b/jcseg-core/src/main/java/org/lionsoul/jcseg/tokenizer/ASegment.java#L587-L629 |
baidubce/bce-sdk-java | src/main/java/com/baidubce/services/cdn/CdnClient.java | CdnClient.enableDomain | public EnableDomainResponse enableDomain(EnableDomainRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DOMAIN, request.getDomain());
internalRequest.addParameter("enable", "");
return invokeHttpClient(internalRequest, EnableDomainResponse.class);
} | java | public EnableDomainResponse enableDomain(EnableDomainRequest request) {
checkNotNull(request, "The parameter request should NOT be null.");
InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DOMAIN, request.getDomain());
internalRequest.addParameter("enable", "");
return invokeHttpClient(internalRequest, EnableDomainResponse.class);
} | [
"public",
"EnableDomainResponse",
"enableDomain",
"(",
"EnableDomainRequest",
"request",
")",
"{",
"checkNotNull",
"(",
"request",
",",
"\"The parameter request should NOT be null.\"",
")",
";",
"InternalRequest",
"internalRequest",
"=",
"createRequest",
"(",
"request",
","... | Enable an existing domain acceleration.
@param request The request containing user-defined domain information.
@return Result of the enableDomain operation returned by the service. | [
"Enable",
"an",
"existing",
"domain",
"acceleration",
"."
] | train | https://github.com/baidubce/bce-sdk-java/blob/f7140f28dd82121515c88ded7bfe769a37d0ec4a/src/main/java/com/baidubce/services/cdn/CdnClient.java#L204-L209 |
ArcBees/gwtquery | gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java | DocumentStyleImplIE.setStyleProperty | @Override
public void setStyleProperty(Element e, String prop, String val) {
if ("opacity".equals(prop)) {
setOpacity(e, val);
} else {
super.setStyleProperty(e, prop, val);
}
} | java | @Override
public void setStyleProperty(Element e, String prop, String val) {
if ("opacity".equals(prop)) {
setOpacity(e, val);
} else {
super.setStyleProperty(e, prop, val);
}
} | [
"@",
"Override",
"public",
"void",
"setStyleProperty",
"(",
"Element",
"e",
",",
"String",
"prop",
",",
"String",
"val",
")",
"{",
"if",
"(",
"\"opacity\"",
".",
"equals",
"(",
"prop",
")",
")",
"{",
"setOpacity",
"(",
"e",
",",
"val",
")",
";",
"}",... | Set the value of a style property of an element.
IE needs a special workaround to handle opacity | [
"Set",
"the",
"value",
"of",
"a",
"style",
"property",
"of",
"an",
"element",
".",
"IE",
"needs",
"a",
"special",
"workaround",
"to",
"handle",
"opacity"
] | train | https://github.com/ArcBees/gwtquery/blob/93e02bc8eb030081061c56134ebee1f585981107/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java#L76-L83 |
datacleaner/AnalyzerBeans | core/src/main/java/org/eobjects/analyzer/util/SystemProperties.java | SystemProperties.getInt | public static long getInt(String key, int valueIfNullOrNotParseable) {
String value = System.getProperty(key);
if (Strings.isNullOrEmpty(value)) {
return valueIfNullOrNotParseable;
}
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
return valueIfNullOrNotParseable;
}
} | java | public static long getInt(String key, int valueIfNullOrNotParseable) {
String value = System.getProperty(key);
if (Strings.isNullOrEmpty(value)) {
return valueIfNullOrNotParseable;
}
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
return valueIfNullOrNotParseable;
}
} | [
"public",
"static",
"long",
"getInt",
"(",
"String",
"key",
",",
"int",
"valueIfNullOrNotParseable",
")",
"{",
"String",
"value",
"=",
"System",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"value",
")",
")",
... | Gets a system property int, or a replacement value if the property is
null or blank or not parseable
@param key
@param valueIfNullOrNotParseable
@return | [
"Gets",
"a",
"system",
"property",
"int",
"or",
"a",
"replacement",
"value",
"if",
"the",
"property",
"is",
"null",
"or",
"blank",
"or",
"not",
"parseable"
] | train | https://github.com/datacleaner/AnalyzerBeans/blob/f82dae080d80d2a647b706a5fb22b3ea250613b3/core/src/main/java/org/eobjects/analyzer/util/SystemProperties.java#L83-L93 |
OpenBEL/openbel-framework | org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/cache/DefaultCacheableResourceService.java | DefaultCacheableResourceService.areHashFilesEqual | private boolean areHashFilesEqual(File hashFile1, File hashFile2,
String remoteLocation) throws ResourceDownloadError {
try {
String resource1Hash = readFileToString(hashFile1, UTF_8);
String resource2Hash = readFileToString(hashFile2, UTF_8);
return resource1Hash.trim().equalsIgnoreCase(resource2Hash.trim());
} catch (IOException e) {
throw new ResourceDownloadError(remoteLocation, e.getMessage());
}
} | java | private boolean areHashFilesEqual(File hashFile1, File hashFile2,
String remoteLocation) throws ResourceDownloadError {
try {
String resource1Hash = readFileToString(hashFile1, UTF_8);
String resource2Hash = readFileToString(hashFile2, UTF_8);
return resource1Hash.trim().equalsIgnoreCase(resource2Hash.trim());
} catch (IOException e) {
throw new ResourceDownloadError(remoteLocation, e.getMessage());
}
} | [
"private",
"boolean",
"areHashFilesEqual",
"(",
"File",
"hashFile1",
",",
"File",
"hashFile2",
",",
"String",
"remoteLocation",
")",
"throws",
"ResourceDownloadError",
"{",
"try",
"{",
"String",
"resource1Hash",
"=",
"readFileToString",
"(",
"hashFile1",
",",
"UTF_8... | Compares the hashes contained in the resource files. The hashes in the
files are compared case-insensitively in order to support hexadecimal
variations on a-f and A-F.
@param hashFile1 {@link File}, the first hash file
@param hashFile2 {@link File}, the second hash file
@param remoteLocation {@link String}, the resource remote location
@return <tt>boolean</tt> indicating <tt>true</tt>, if the hash files are
equal, or <tt>false</tt> if the hash files are not equal
@throws IOException Thrown if an IO error occurred reading the resource
hashes | [
"Compares",
"the",
"hashes",
"contained",
"in",
"the",
"resource",
"files",
".",
"The",
"hashes",
"in",
"the",
"files",
"are",
"compared",
"case",
"-",
"insensitively",
"in",
"order",
"to",
"support",
"hexadecimal",
"variations",
"on",
"a",
"-",
"f",
"and",
... | train | https://github.com/OpenBEL/openbel-framework/blob/149f80b1d6eabb15ab15815b6f745b0afa9fd2d3/org.openbel.framework.core/src/main/java/org/openbel/framework/core/df/cache/DefaultCacheableResourceService.java#L247-L257 |
apigee/usergrid-java-sdk | src/main/java/org/usergrid/java/client/Client.java | Client.postGroupActivity | public ApiResponse postGroupActivity(String groupId, Activity activity) {
return apiRequest(HttpMethod.POST, null, activity, organizationId, applicationId, "groups",
groupId, "activities");
} | java | public ApiResponse postGroupActivity(String groupId, Activity activity) {
return apiRequest(HttpMethod.POST, null, activity, organizationId, applicationId, "groups",
groupId, "activities");
} | [
"public",
"ApiResponse",
"postGroupActivity",
"(",
"String",
"groupId",
",",
"Activity",
"activity",
")",
"{",
"return",
"apiRequest",
"(",
"HttpMethod",
".",
"POST",
",",
"null",
",",
"activity",
",",
"organizationId",
",",
"applicationId",
",",
"\"groups\"",
"... | Posts an activity to a group. Activity must already be created.
@param userId
@param activity
@return | [
"Posts",
"an",
"activity",
"to",
"a",
"group",
".",
"Activity",
"must",
"already",
"be",
"created",
"."
] | train | https://github.com/apigee/usergrid-java-sdk/blob/6202745f184754defff13962dfc3d830bc7d8c63/src/main/java/org/usergrid/java/client/Client.java#L708-L711 |
segmentio/analytics-android | analytics/src/main/java/com/segment/analytics/internal/Utils.java | Utils.assertNotNull | @NonNull
public static <T> T assertNotNull(T object, String item) {
if (object == null) {
throw new NullPointerException(item + " == null");
}
return object;
} | java | @NonNull
public static <T> T assertNotNull(T object, String item) {
if (object == null) {
throw new NullPointerException(item + " == null");
}
return object;
} | [
"@",
"NonNull",
"public",
"static",
"<",
"T",
">",
"T",
"assertNotNull",
"(",
"T",
"object",
",",
"String",
"item",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"item",
"+",
"\" == null\"",
")",
";... | Throws a {@link NullPointerException} if the given object is null. | [
"Throws",
"a",
"{"
] | train | https://github.com/segmentio/analytics-android/blob/93c7d5bb09b593440a2347a6089db3e9f74012da/analytics/src/main/java/com/segment/analytics/internal/Utils.java#L227-L233 |
kirgor/enklib | rest/src/main/java/com/kirgor/enklib/rest/RESTClient.java | RESTClient.putWithListResult | public <T> EntityResponse<List<T>> putWithListResult(Class<T> entityClass, String path) throws IOException, RESTException {
return putWithListResult(entityClass, path, null, null);
} | java | public <T> EntityResponse<List<T>> putWithListResult(Class<T> entityClass, String path) throws IOException, RESTException {
return putWithListResult(entityClass, path, null, null);
} | [
"public",
"<",
"T",
">",
"EntityResponse",
"<",
"List",
"<",
"T",
">",
">",
"putWithListResult",
"(",
"Class",
"<",
"T",
">",
"entityClass",
",",
"String",
"path",
")",
"throws",
"IOException",
",",
"RESTException",
"{",
"return",
"putWithListResult",
"(",
... | Performs PUT request, while expected response entity is a list of specified type.
@param entityClass Class, which contains expected response entity fields.
@param path Request path.
@param <T> Type of class, which contains expected response entity fields.
@throws IOException If error during HTTP connection or entity parsing occurs.
@throws RESTException If HTTP response code is non OK. | [
"Performs",
"PUT",
"request",
"while",
"expected",
"response",
"entity",
"is",
"a",
"list",
"of",
"specified",
"type",
"."
] | train | https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/rest/src/main/java/com/kirgor/enklib/rest/RESTClient.java#L443-L445 |
super-csv/super-csv | super-csv/src/main/java/org/supercsv/cellprocessor/constraint/UniqueHashCode.java | UniqueHashCode.execute | public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
int hash = value.hashCode();
if( !uniqueSet.add(hash) ) {
throw new SuperCsvConstraintViolationException(
String.format("duplicate value '%s' encountered with hashcode %d", value, hash), context, this);
}
return next.execute(value, context);
} | java | public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
int hash = value.hashCode();
if( !uniqueSet.add(hash) ) {
throw new SuperCsvConstraintViolationException(
String.format("duplicate value '%s' encountered with hashcode %d", value, hash), context, this);
}
return next.execute(value, context);
} | [
"public",
"Object",
"execute",
"(",
"final",
"Object",
"value",
",",
"final",
"CsvContext",
"context",
")",
"{",
"validateInputNotNull",
"(",
"value",
",",
"context",
")",
";",
"int",
"hash",
"=",
"value",
".",
"hashCode",
"(",
")",
";",
"if",
"(",
"!",
... | {@inheritDoc}
@throws SuperCsvCellProcessorException
if value is null
@throws SuperCsvConstraintViolationException
if a non-unique value is encountered | [
"{",
"@inheritDoc",
"}"
] | train | https://github.com/super-csv/super-csv/blob/f18db724674dc1c4116e25142c1b5403ebf43e96/super-csv/src/main/java/org/supercsv/cellprocessor/constraint/UniqueHashCode.java#L72-L82 |
GenesysPureEngage/provisioning-client-java | src/main/java/com/genesys/provisioning/OptionsApi.java | OptionsApi.updateOptions | public void updateOptions(Map<String, Object> newOptions, Map<String, Object> changedOptions, Map<String, Object> deletedOptions) throws ProvisioningApiException {
try {
OptionsPutResponseStatusSuccess resp = optionsApi.optionsPut(
new OptionsPut()
.data(
new OptionsPutData()
.newOptions(newOptions)
.changedOptions(changedOptions)
.deletedOptions(deletedOptions)
)
);
if (!resp.getStatus().getCode().equals(0)) {
throw new ProvisioningApiException("Error updating options. Code: " + resp.getStatus().getCode());
}
} catch (ApiException e) {
throw new ProvisioningApiException("Error updating options", e);
}
} | java | public void updateOptions(Map<String, Object> newOptions, Map<String, Object> changedOptions, Map<String, Object> deletedOptions) throws ProvisioningApiException {
try {
OptionsPutResponseStatusSuccess resp = optionsApi.optionsPut(
new OptionsPut()
.data(
new OptionsPutData()
.newOptions(newOptions)
.changedOptions(changedOptions)
.deletedOptions(deletedOptions)
)
);
if (!resp.getStatus().getCode().equals(0)) {
throw new ProvisioningApiException("Error updating options. Code: " + resp.getStatus().getCode());
}
} catch (ApiException e) {
throw new ProvisioningApiException("Error updating options", e);
}
} | [
"public",
"void",
"updateOptions",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"newOptions",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"changedOptions",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"deletedOptions",
")",
"throws",
"ProvisioningApiE... | Add, edit or delete options values.
Add, edit or delete option values for the specified application.
@param newOptions options to add.
@param changedOptions options to change.
@param deletedOptions options to remove.
@throws ProvisioningApiException if the call is unsuccessful. | [
"Add",
"edit",
"or",
"delete",
"options",
"values",
".",
"Add",
"edit",
"or",
"delete",
"option",
"values",
"for",
"the",
"specified",
"application",
"."
] | train | https://github.com/GenesysPureEngage/provisioning-client-java/blob/1ad594c3767cec83052168e350994f922a26f75e/src/main/java/com/genesys/provisioning/OptionsApi.java#L84-L104 |
google/j2objc | jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java | AtomicIntegerFieldUpdater.updateAndGet | public final int updateAndGet(T obj, IntUnaryOperator updateFunction) {
int prev, next;
do {
prev = get(obj);
next = updateFunction.applyAsInt(prev);
} while (!compareAndSet(obj, prev, next));
return next;
} | java | public final int updateAndGet(T obj, IntUnaryOperator updateFunction) {
int prev, next;
do {
prev = get(obj);
next = updateFunction.applyAsInt(prev);
} while (!compareAndSet(obj, prev, next));
return next;
} | [
"public",
"final",
"int",
"updateAndGet",
"(",
"T",
"obj",
",",
"IntUnaryOperator",
"updateFunction",
")",
"{",
"int",
"prev",
",",
"next",
";",
"do",
"{",
"prev",
"=",
"get",
"(",
"obj",
")",
";",
"next",
"=",
"updateFunction",
".",
"applyAsInt",
"(",
... | Atomically updates the field of the given object managed by this updater
with the results of applying the given function, returning the updated
value. The function should be side-effect-free, since it may be
re-applied when attempted updates fail due to contention among threads.
@param obj An object whose field to get and set
@param updateFunction a side-effect-free function
@return the updated value
@since 1.8 | [
"Atomically",
"updates",
"the",
"field",
"of",
"the",
"given",
"object",
"managed",
"by",
"this",
"updater",
"with",
"the",
"results",
"of",
"applying",
"the",
"given",
"function",
"returning",
"the",
"updated",
"value",
".",
"The",
"function",
"should",
"be",... | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/jre_emul/android/platform/libcore/ojluni/src/main/java/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java#L305-L312 |
Javacord/Javacord | javacord-core/src/main/java/org/javacord/core/entity/message/MessageSetImpl.java | MessageSetImpl.getMessagesBetween | public static CompletableFuture<MessageSet> getMessagesBetween(TextChannel channel, long from, long to) {
CompletableFuture<MessageSet> future = new CompletableFuture<>();
channel.getApi().getThreadPool().getExecutorService().submit(() -> {
try {
future.complete(new MessageSetImpl(getMessagesBetweenAsStream(channel, from, to)
.collect(Collectors.toList())));
} catch (Throwable t) {
future.completeExceptionally(t);
}
});
return future;
} | java | public static CompletableFuture<MessageSet> getMessagesBetween(TextChannel channel, long from, long to) {
CompletableFuture<MessageSet> future = new CompletableFuture<>();
channel.getApi().getThreadPool().getExecutorService().submit(() -> {
try {
future.complete(new MessageSetImpl(getMessagesBetweenAsStream(channel, from, to)
.collect(Collectors.toList())));
} catch (Throwable t) {
future.completeExceptionally(t);
}
});
return future;
} | [
"public",
"static",
"CompletableFuture",
"<",
"MessageSet",
">",
"getMessagesBetween",
"(",
"TextChannel",
"channel",
",",
"long",
"from",
",",
"long",
"to",
")",
"{",
"CompletableFuture",
"<",
"MessageSet",
">",
"future",
"=",
"new",
"CompletableFuture",
"<>",
... | Gets all messages in the given channel between the first given message in any channel and the second given
message in any channel, excluding the boundaries.
Gets up to a given amount of messages in the given channel before a given message in any channel.
@param channel The channel of the messages.
@param from The id of the start boundary messages.
@param to The id of the other boundary messages.
@return The messages.
@see #getMessagesBetweenAsStream(TextChannel, long, long) | [
"Gets",
"all",
"messages",
"in",
"the",
"given",
"channel",
"between",
"the",
"first",
"given",
"message",
"in",
"any",
"channel",
"and",
"the",
"second",
"given",
"message",
"in",
"any",
"channel",
"excluding",
"the",
"boundaries",
".",
"Gets",
"up",
"to",
... | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-core/src/main/java/org/javacord/core/entity/message/MessageSetImpl.java#L651-L662 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.