repository_name stringlengths 7 58 | func_path_in_repository stringlengths 11 204 | func_name stringlengths 5 103 | whole_func_string stringlengths 87 3.44k | language stringclasses 1
value | func_code_string stringlengths 87 3.44k | func_code_tokens listlengths 21 714 | func_documentation_string stringlengths 61 1.95k | func_documentation_tokens listlengths 1 482 | split_name stringclasses 1
value | func_code_url stringlengths 102 309 |
|---|---|---|---|---|---|---|---|---|---|---|
strator-dev/greenpepper | greenpepper/core/src/main/java/com/greenpepper/util/BOMUtil.java | BOMUtil.getBOMType | public static int getBOMType(byte[] bytes, int length)
{
for (int i = 0; i < BOMBYTES.length; i++)
{
for (int j = 0; j < length && j < BOMBYTES[i].length; j++)
{
if (bytes[j] != BOMBYTES[i][j])
{
break;
}
if (bytes[j] == BOMBYTES[i][j] && j == BOMBYTES[i].length - 1)
{
return i;
}
}
}
return NONE;
} | java | public static int getBOMType(byte[] bytes, int length)
{
for (int i = 0; i < BOMBYTES.length; i++)
{
for (int j = 0; j < length && j < BOMBYTES[i].length; j++)
{
if (bytes[j] != BOMBYTES[i][j])
{
break;
}
if (bytes[j] == BOMBYTES[i][j] && j == BOMBYTES[i].length - 1)
{
return i;
}
}
}
return NONE;
} | [
"public",
"static",
"int",
"getBOMType",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"length",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"BOMBYTES",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
"... | <p>getBOMType.</p>
@param bytes an array of byte.
@param length a int.
@return a int. | [
"<p",
">",
"getBOMType",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/strator-dev/greenpepper/blob/2a61e6c179b74085babcc559d677490b0cad2d30/greenpepper/core/src/main/java/com/greenpepper/util/BOMUtil.java#L78-L95 |
NoraUi/NoraUi | src/main/java/com/github/noraui/application/steps/CommonSteps.java | CommonSteps.updateTextWithRamdomValueMatchRegexp | @Conditioned
@Quand("Je mets à jour le texte '(.*)-(.*)' avec une valeur aléatoire qui vérifie '(.*)'[\\.|\\?]")
@When("I update text '(.*)-(.*)' with ramdom match '(.*)'[\\.|\\?]")
public void updateTextWithRamdomValueMatchRegexp(String page, String elementName, String randRegex, List<GherkinStepCondition> conditions) throws TechnicalException, FailureException {
updateText(Page.getInstance(page).getPageElementByKey('-' + elementName), new Generex(randRegex).random());
} | java | @Conditioned
@Quand("Je mets à jour le texte '(.*)-(.*)' avec une valeur aléatoire qui vérifie '(.*)'[\\.|\\?]")
@When("I update text '(.*)-(.*)' with ramdom match '(.*)'[\\.|\\?]")
public void updateTextWithRamdomValueMatchRegexp(String page, String elementName, String randRegex, List<GherkinStepCondition> conditions) throws TechnicalException, FailureException {
updateText(Page.getInstance(page).getPageElementByKey('-' + elementName), new Generex(randRegex).random());
} | [
"@",
"Conditioned",
"@",
"Quand",
"(",
"\"Je mets à jour le texte '(.*)-(.*)' avec une valeur aléatoire qui vérifie '(.*)'[\\\\.|\\\\?]\")\r",
"",
"@",
"When",
"(",
"\"I update text '(.*)-(.*)' with ramdom match '(.*)'[\\\\.|\\\\?]\"",
")",
"public",
"void",
"updateTextWithRamdomValueMat... | Update a html input text with a random text.
@param page
The concerned page of elementName
@param elementName
Is target element
@param randRegex
Is the new data (random value generated and match with randRegex)
@param conditions
list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
@throws TechnicalException
is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_ERROR_ON_INPUT} message (with screenshot, no exception)
@throws FailureException
if the scenario encounters a functional error | [
"Update",
"a",
"html",
"input",
"text",
"with",
"a",
"random",
"text",
"."
] | train | https://github.com/NoraUi/NoraUi/blob/5f491a3339c7d3c20d7207760bdaf2acdb8f260c/src/main/java/com/github/noraui/application/steps/CommonSteps.java#L606-L611 |
mockito/mockito | src/main/java/org/mockito/internal/matchers/text/ValuePrinter.java | ValuePrinter.printValues | public static String printValues(String start, String separator, String end, Iterator<?> values) {
if(start == null){
start = "(";
}
if (separator == null){
separator = ",";
}
if (end == null){
end = ")";
}
StringBuilder sb = new StringBuilder(start);
while(values.hasNext()) {
sb.append(print(values.next()));
if (values.hasNext()) {
sb.append(separator);
}
}
return sb.append(end).toString();
} | java | public static String printValues(String start, String separator, String end, Iterator<?> values) {
if(start == null){
start = "(";
}
if (separator == null){
separator = ",";
}
if (end == null){
end = ")";
}
StringBuilder sb = new StringBuilder(start);
while(values.hasNext()) {
sb.append(print(values.next()));
if (values.hasNext()) {
sb.append(separator);
}
}
return sb.append(end).toString();
} | [
"public",
"static",
"String",
"printValues",
"(",
"String",
"start",
",",
"String",
"separator",
",",
"String",
"end",
",",
"Iterator",
"<",
"?",
">",
"values",
")",
"{",
"if",
"(",
"start",
"==",
"null",
")",
"{",
"start",
"=",
"\"(\"",
";",
"}",
"i... | Print values in a nice format, e.g. (1, 2, 3)
@param start the beginning of the values, e.g. "("
@param separator the separator of values, e.g. ", "
@param end the end of the values, e.g. ")"
@param values the values to print
@return neatly formatted value list | [
"Print",
"values",
"in",
"a",
"nice",
"format",
"e",
".",
"g",
".",
"(",
"1",
"2",
"3",
")"
] | train | https://github.com/mockito/mockito/blob/c5e2b80af76e3192cae7c9550b70c4d1ab312034/src/main/java/org/mockito/internal/matchers/text/ValuePrinter.java#L100-L119 |
intendia-oss/rxjava-gwt | src/main/modified/io/reactivex/super/io/reactivex/Maybe.java | Maybe.doOnComplete | @CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Maybe<T> doOnComplete(Action onComplete) {
return RxJavaPlugins.onAssembly(new MaybePeek<T>(this,
Functions.emptyConsumer(), // onSubscribe
Functions.emptyConsumer(), // onSuccess
Functions.emptyConsumer(), // onError
ObjectHelper.requireNonNull(onComplete, "onComplete is null"),
Functions.EMPTY_ACTION, // (onSuccess | onError | onComplete)
Functions.EMPTY_ACTION // dispose
));
} | java | @CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Maybe<T> doOnComplete(Action onComplete) {
return RxJavaPlugins.onAssembly(new MaybePeek<T>(this,
Functions.emptyConsumer(), // onSubscribe
Functions.emptyConsumer(), // onSuccess
Functions.emptyConsumer(), // onError
ObjectHelper.requireNonNull(onComplete, "onComplete is null"),
Functions.EMPTY_ACTION, // (onSuccess | onError | onComplete)
Functions.EMPTY_ACTION // dispose
));
} | [
"@",
"CheckReturnValue",
"@",
"SchedulerSupport",
"(",
"SchedulerSupport",
".",
"NONE",
")",
"public",
"final",
"Maybe",
"<",
"T",
">",
"doOnComplete",
"(",
"Action",
"onComplete",
")",
"{",
"return",
"RxJavaPlugins",
".",
"onAssembly",
"(",
"new",
"MaybePeek",
... | Modifies the source Maybe so that it invokes an action when it calls {@code onComplete}.
<p>
<img width="640" height="358" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/doOnComplete.m.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code doOnComplete} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param onComplete
the action to invoke when the source Maybe calls {@code onComplete}
@return the new Maybe with the side-effecting behavior applied
@see <a href="http://reactivex.io/documentation/operators/do.html">ReactiveX operators documentation: Do</a> | [
"Modifies",
"the",
"source",
"Maybe",
"so",
"that",
"it",
"invokes",
"an",
"action",
"when",
"it",
"calls",
"{",
"@code",
"onComplete",
"}",
".",
"<p",
">",
"<img",
"width",
"=",
"640",
"height",
"=",
"358",
"src",
"=",
"https",
":",
"//",
"raw",
"."... | train | https://github.com/intendia-oss/rxjava-gwt/blob/8d5635b12ce40da99e76b59dc6bfe6fc2fffc1fa/src/main/modified/io/reactivex/super/io/reactivex/Maybe.java#L2752-L2763 |
Azure/azure-sdk-for-java | eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/implementation/EventGridClientImpl.java | EventGridClientImpl.publishEventsAsync | public Observable<Void> publishEventsAsync(String topicHostname, List<EventGridEvent> events) {
return publishEventsWithServiceResponseAsync(topicHostname, events).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | java | public Observable<Void> publishEventsAsync(String topicHostname, List<EventGridEvent> events) {
return publishEventsWithServiceResponseAsync(topicHostname, events).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"Void",
">",
"publishEventsAsync",
"(",
"String",
"topicHostname",
",",
"List",
"<",
"EventGridEvent",
">",
"events",
")",
"{",
"return",
"publishEventsWithServiceResponseAsync",
"(",
"topicHostname",
",",
"events",
")",
".",
"map",
"(... | Publishes a batch of events to an Azure Event Grid topic.
@param topicHostname The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net
@param events An array of events to be published to Event Grid.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the {@link ServiceResponse} object if successful. | [
"Publishes",
"a",
"batch",
"of",
"events",
"to",
"an",
"Azure",
"Event",
"Grid",
"topic",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/eventgrid/data-plane/src/main/java/com/microsoft/azure/eventgrid/implementation/EventGridClientImpl.java#L232-L239 |
contentful/contentful-management.java | src/main/java/com/contentful/java/cma/AbsModule.java | AbsModule.getVersionOrThrow | Integer getVersionOrThrow(CMAResource resource, String action) {
final Integer version = resource.getVersion();
if (version == null) {
throw new IllegalArgumentException(String.format(
"Cannot perform %s action on a resource that has no version associated.",
action));
}
return version;
} | java | Integer getVersionOrThrow(CMAResource resource, String action) {
final Integer version = resource.getVersion();
if (version == null) {
throw new IllegalArgumentException(String.format(
"Cannot perform %s action on a resource that has no version associated.",
action));
}
return version;
} | [
"Integer",
"getVersionOrThrow",
"(",
"CMAResource",
"resource",
",",
"String",
"action",
")",
"{",
"final",
"Integer",
"version",
"=",
"resource",
".",
"getVersion",
"(",
")",
";",
"if",
"(",
"version",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumen... | Extracts the version number for the given {@code resource}.
Throws {@link IllegalArgumentException} if the value is not present. | [
"Extracts",
"the",
"version",
"number",
"for",
"the",
"given",
"{"
] | train | https://github.com/contentful/contentful-management.java/blob/ca310fb9ea9577fcff0ca57949ab7c2315fa2534/src/main/java/com/contentful/java/cma/AbsModule.java#L97-L105 |
Netflix/servo | servo-graphite/src/main/java/com/netflix/servo/publish/graphite/GraphiteMetricObserver.java | GraphiteMetricObserver.parseStringAsUri | private static URI parseStringAsUri(String ipString) {
try {
URI uri = new URI("socket://" + ipString);
if (uri.getHost() == null || uri.getPort() == -1) {
throw new URISyntaxException(ipString, "URI must have host and port parts");
}
return uri;
} catch (URISyntaxException e) {
throw (IllegalArgumentException) new IllegalArgumentException(
"Graphite server address needs to be defined as {host}:{port}.").initCause(e);
}
} | java | private static URI parseStringAsUri(String ipString) {
try {
URI uri = new URI("socket://" + ipString);
if (uri.getHost() == null || uri.getPort() == -1) {
throw new URISyntaxException(ipString, "URI must have host and port parts");
}
return uri;
} catch (URISyntaxException e) {
throw (IllegalArgumentException) new IllegalArgumentException(
"Graphite server address needs to be defined as {host}:{port}.").initCause(e);
}
} | [
"private",
"static",
"URI",
"parseStringAsUri",
"(",
"String",
"ipString",
")",
"{",
"try",
"{",
"URI",
"uri",
"=",
"new",
"URI",
"(",
"\"socket://\"",
"+",
"ipString",
")",
";",
"if",
"(",
"uri",
".",
"getHost",
"(",
")",
"==",
"null",
"||",
"uri",
... | It's a lot easier to configure and manage the location of the graphite server if we combine
the ip and port into a single string. Using a "fake" transport and the ipString means we get
standard host/port parsing (including domain names, ipv4 and ipv6) for free. | [
"It",
"s",
"a",
"lot",
"easier",
"to",
"configure",
"and",
"manage",
"the",
"location",
"of",
"the",
"graphite",
"server",
"if",
"we",
"combine",
"the",
"ip",
"and",
"port",
"into",
"a",
"single",
"string",
".",
"Using",
"a",
"fake",
"transport",
"and",
... | train | https://github.com/Netflix/servo/blob/d67b5afce8c50bd9e9e31c288dbf4b78fb2ac815/servo-graphite/src/main/java/com/netflix/servo/publish/graphite/GraphiteMetricObserver.java#L189-L200 |
UrielCh/ovh-java-sdk | ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java | ApiOvhPrice.vps_2014v1_cloud_model_modelName_GET | public OvhPrice vps_2014v1_cloud_model_modelName_GET(net.minidev.ovh.api.price.vps._2014v1.cloud.OvhModelEnum modelName) throws IOException {
String qPath = "/price/vps/2014v1/cloud/model/{modelName}";
StringBuilder sb = path(qPath, modelName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | java | public OvhPrice vps_2014v1_cloud_model_modelName_GET(net.minidev.ovh.api.price.vps._2014v1.cloud.OvhModelEnum modelName) throws IOException {
String qPath = "/price/vps/2014v1/cloud/model/{modelName}";
StringBuilder sb = path(qPath, modelName);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhPrice.class);
} | [
"public",
"OvhPrice",
"vps_2014v1_cloud_model_modelName_GET",
"(",
"net",
".",
"minidev",
".",
"ovh",
".",
"api",
".",
"price",
".",
"vps",
".",
"_2014v1",
".",
"cloud",
".",
"OvhModelEnum",
"modelName",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=... | Get price of VPS Cloud 2014
REST: GET /price/vps/2014v1/cloud/model/{modelName}
@param modelName [required] Model | [
"Get",
"price",
"of",
"VPS",
"Cloud",
"2014"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-price/src/main/java/net/minidev/ovh/api/ApiOvhPrice.java#L6745-L6750 |
sdaschner/jaxrs-analyzer | src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/JobRegistry.java | JobRegistry.analyzeResourceClass | public void analyzeResourceClass(final String className, final ClassResult classResult) {
// TODO check if class has already been analyzed
unhandledClasses.add(Pair.of(className, classResult));
} | java | public void analyzeResourceClass(final String className, final ClassResult classResult) {
// TODO check if class has already been analyzed
unhandledClasses.add(Pair.of(className, classResult));
} | [
"public",
"void",
"analyzeResourceClass",
"(",
"final",
"String",
"className",
",",
"final",
"ClassResult",
"classResult",
")",
"{",
"// TODO check if class has already been analyzed",
"unhandledClasses",
".",
"add",
"(",
"Pair",
".",
"of",
"(",
"className",
",",
"cla... | Adds the (sub-)resource class name to the analysis list with the associated class result. | [
"Adds",
"the",
"(",
"sub",
"-",
")",
"resource",
"class",
"name",
"to",
"the",
"analysis",
"list",
"with",
"the",
"associated",
"class",
"result",
"."
] | train | https://github.com/sdaschner/jaxrs-analyzer/blob/4ac62942202d05632977d6c14d3cd7e2d27e2b9b/src/main/java/com/sebastian_daschner/jaxrs_analyzer/analysis/JobRegistry.java#L26-L29 |
apache/groovy | src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java | ResourceGroovyMethods.eachLine | public static <T> T eachLine(File self, @ClosureParams(value = FromString.class, options = {"String", "String,Integer"}) Closure<T> closure) throws IOException {
return eachLine(self, 1, closure);
} | java | public static <T> T eachLine(File self, @ClosureParams(value = FromString.class, options = {"String", "String,Integer"}) Closure<T> closure) throws IOException {
return eachLine(self, 1, closure);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"eachLine",
"(",
"File",
"self",
",",
"@",
"ClosureParams",
"(",
"value",
"=",
"FromString",
".",
"class",
",",
"options",
"=",
"{",
"\"String\"",
",",
"\"String,Integer\"",
"}",
")",
"Closure",
"<",
"T",
">",
"c... | Iterates through this file line by line. Each line is passed to the
given 1 or 2 arg closure. The file is read using a reader which
is closed before this method returns.
@param self a File
@param closure a closure (arg 1 is line, optional arg 2 is line number starting at line 1)
@return the last value returned by the closure
@throws IOException if an IOException occurs.
@see #eachLine(java.io.File, int, groovy.lang.Closure)
@since 1.5.5 | [
"Iterates",
"through",
"this",
"file",
"line",
"by",
"line",
".",
"Each",
"line",
"is",
"passed",
"to",
"the",
"given",
"1",
"or",
"2",
"arg",
"closure",
".",
"The",
"file",
"is",
"read",
"using",
"a",
"reader",
"which",
"is",
"closed",
"before",
"this... | train | https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L235-L237 |
ThreeTen/threeten-extra | src/main/java/org/threeten/extra/chrono/EthiopicDate.java | EthiopicDate.ofYearDay | static EthiopicDate ofYearDay(int prolepticYear, int dayOfYear) {
EthiopicChronology.YEAR_RANGE.checkValidValue(prolepticYear, YEAR);
DAY_OF_YEAR.range().checkValidValue(dayOfYear, DAY_OF_YEAR);
if (dayOfYear == 366 && EthiopicChronology.INSTANCE.isLeapYear(prolepticYear) == false) {
throw new DateTimeException("Invalid date 'Pagumen 6' as '" + prolepticYear + "' is not a leap year");
}
return new EthiopicDate(prolepticYear, (dayOfYear - 1) / 30 + 1, (dayOfYear - 1) % 30 + 1);
} | java | static EthiopicDate ofYearDay(int prolepticYear, int dayOfYear) {
EthiopicChronology.YEAR_RANGE.checkValidValue(prolepticYear, YEAR);
DAY_OF_YEAR.range().checkValidValue(dayOfYear, DAY_OF_YEAR);
if (dayOfYear == 366 && EthiopicChronology.INSTANCE.isLeapYear(prolepticYear) == false) {
throw new DateTimeException("Invalid date 'Pagumen 6' as '" + prolepticYear + "' is not a leap year");
}
return new EthiopicDate(prolepticYear, (dayOfYear - 1) / 30 + 1, (dayOfYear - 1) % 30 + 1);
} | [
"static",
"EthiopicDate",
"ofYearDay",
"(",
"int",
"prolepticYear",
",",
"int",
"dayOfYear",
")",
"{",
"EthiopicChronology",
".",
"YEAR_RANGE",
".",
"checkValidValue",
"(",
"prolepticYear",
",",
"YEAR",
")",
";",
"DAY_OF_YEAR",
".",
"range",
"(",
")",
".",
"ch... | Obtains a {@code EthiopicDate} representing a date in the Ethiopic calendar
system from the proleptic-year and day-of-year fields.
<p>
This returns a {@code EthiopicDate} with the specified fields.
The day must be valid for the year, otherwise an exception will be thrown.
@param prolepticYear the Ethiopic proleptic-year
@param dayOfYear the Ethiopic day-of-year, from 1 to 366
@return the date in Ethiopic calendar system, not null
@throws DateTimeException if the value of any field is out of range,
or if the day-of-year is invalid for the year | [
"Obtains",
"a",
"{",
"@code",
"EthiopicDate",
"}",
"representing",
"a",
"date",
"in",
"the",
"Ethiopic",
"calendar",
"system",
"from",
"the",
"proleptic",
"-",
"year",
"and",
"day",
"-",
"of",
"-",
"year",
"fields",
".",
"<p",
">",
"This",
"returns",
"a"... | train | https://github.com/ThreeTen/threeten-extra/blob/e94ecd3592ef70e54d6eea21095239ea9ffbab78/src/main/java/org/threeten/extra/chrono/EthiopicDate.java#L203-L210 |
adobe/htl-tck | src/main/java/io/sightly/tck/html/HTMLExtractor.java | HTMLExtractor.innerHTML | public static String innerHTML(String url, String markup, String selector) {
ensureMarkup(url, markup);
Document document = documents.get(url);
Elements elements = document.select(selector);
return elements.html();
} | java | public static String innerHTML(String url, String markup, String selector) {
ensureMarkup(url, markup);
Document document = documents.get(url);
Elements elements = document.select(selector);
return elements.html();
} | [
"public",
"static",
"String",
"innerHTML",
"(",
"String",
"url",
",",
"String",
"markup",
",",
"String",
"selector",
")",
"{",
"ensureMarkup",
"(",
"url",
",",
"markup",
")",
";",
"Document",
"document",
"=",
"documents",
".",
"get",
"(",
"url",
")",
";"... | Retrieves the content of the matched elements, without their own markup tags, identified by the {@code selector} from the given
{@code markup}. The {@code url} is used only for caching purposes, to avoid parsing multiple times the markup returned for the
same resource.
@param url the url that identifies the markup
@param markup the markup
@param selector the selector used for retrieval
@return the contents of the selected element | [
"Retrieves",
"the",
"content",
"of",
"the",
"matched",
"elements",
"without",
"their",
"own",
"markup",
"tags",
"identified",
"by",
"the",
"{",
"@code",
"selector",
"}",
"from",
"the",
"given",
"{",
"@code",
"markup",
"}",
".",
"The",
"{",
"@code",
"url",
... | train | https://github.com/adobe/htl-tck/blob/2043a9616083c06cefbd685798c9a2b2ac2ea98e/src/main/java/io/sightly/tck/html/HTMLExtractor.java#L40-L45 |
nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java | Config.getProperty | public static String getProperty(String key, String aDefault)
{
return getSettings().getProperty(key, aDefault);
} | java | public static String getProperty(String key, String aDefault)
{
return getSettings().getProperty(key, aDefault);
} | [
"public",
"static",
"String",
"getProperty",
"(",
"String",
"key",
",",
"String",
"aDefault",
")",
"{",
"return",
"getSettings",
"(",
")",
".",
"getProperty",
"(",
"key",
",",
"aDefault",
")",
";",
"}"
] | Retrieves a configuration property as a String object.
Loads the file if not already initialized.
@param key Key Name of the property to be returned.
@param aDefault the default value
@return Value of the property as a string or null if no property found. | [
"Retrieves",
"a",
"configuration",
"property",
"as",
"a",
"String",
"object",
"."
] | train | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java#L251-L255 |
Azure/azure-sdk-for-java | sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/RecommendedElasticPoolsInner.java | RecommendedElasticPoolsInner.listByServerAsync | public Observable<List<RecommendedElasticPoolInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<RecommendedElasticPoolInner>>, List<RecommendedElasticPoolInner>>() {
@Override
public List<RecommendedElasticPoolInner> call(ServiceResponse<List<RecommendedElasticPoolInner>> response) {
return response.body();
}
});
} | java | public Observable<List<RecommendedElasticPoolInner>> listByServerAsync(String resourceGroupName, String serverName) {
return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1<ServiceResponse<List<RecommendedElasticPoolInner>>, List<RecommendedElasticPoolInner>>() {
@Override
public List<RecommendedElasticPoolInner> call(ServiceResponse<List<RecommendedElasticPoolInner>> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"List",
"<",
"RecommendedElasticPoolInner",
">",
">",
"listByServerAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"serverName",
")",
"{",
"return",
"listByServerWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"serverName"... | Returns recommended elastic pools.
@param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
@param serverName The name of the server.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the List<RecommendedElasticPoolInner> object | [
"Returns",
"recommended",
"elastic",
"pools",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/sql/resource-manager/v2014_04_01/src/main/java/com/microsoft/azure/management/sql/v2014_04_01/implementation/RecommendedElasticPoolsInner.java#L197-L204 |
jfinal/jfinal | src/main/java/com/jfinal/plugin/activerecord/Model.java | Model.findByIdLoadColumns | public M findByIdLoadColumns(Object idValue, String columns) {
return findByIdLoadColumns(new Object[]{idValue}, columns);
} | java | public M findByIdLoadColumns(Object idValue, String columns) {
return findByIdLoadColumns(new Object[]{idValue}, columns);
} | [
"public",
"M",
"findByIdLoadColumns",
"(",
"Object",
"idValue",
",",
"String",
"columns",
")",
"{",
"return",
"findByIdLoadColumns",
"(",
"new",
"Object",
"[",
"]",
"{",
"idValue",
"}",
",",
"columns",
")",
";",
"}"
] | Find model by id and load specific columns only.
<pre>
Example:
User user = User.dao.findByIdLoadColumns(123, "name, age");
</pre>
@param idValue the id value of the model
@param columns the specific columns to load | [
"Find",
"model",
"by",
"id",
"and",
"load",
"specific",
"columns",
"only",
".",
"<pre",
">",
"Example",
":",
"User",
"user",
"=",
"User",
".",
"dao",
".",
"findByIdLoadColumns",
"(",
"123",
"name",
"age",
")",
";",
"<",
"/",
"pre",
">"
] | train | https://github.com/jfinal/jfinal/blob/fc07f0f5d56e85ccd3cfcdd587b56b8dd9c663e9/src/main/java/com/jfinal/plugin/activerecord/Model.java#L771-L773 |
sksamuel/scrimage | scrimage-filters/src/main/java/thirdparty/jhlabs/image/ImageMath.java | ImageMath.bilinearInterpolate | public static int bilinearInterpolate(float x, float y, int nw, int ne, int sw, int se) {
float m0, m1;
int a0 = (nw >> 24) & 0xff;
int r0 = (nw >> 16) & 0xff;
int g0 = (nw >> 8) & 0xff;
int b0 = nw & 0xff;
int a1 = (ne >> 24) & 0xff;
int r1 = (ne >> 16) & 0xff;
int g1 = (ne >> 8) & 0xff;
int b1 = ne & 0xff;
int a2 = (sw >> 24) & 0xff;
int r2 = (sw >> 16) & 0xff;
int g2 = (sw >> 8) & 0xff;
int b2 = sw & 0xff;
int a3 = (se >> 24) & 0xff;
int r3 = (se >> 16) & 0xff;
int g3 = (se >> 8) & 0xff;
int b3 = se & 0xff;
float cx = 1.0f-x;
float cy = 1.0f-y;
m0 = cx * a0 + x * a1;
m1 = cx * a2 + x * a3;
int a = (int)(cy * m0 + y * m1);
m0 = cx * r0 + x * r1;
m1 = cx * r2 + x * r3;
int r = (int)(cy * m0 + y * m1);
m0 = cx * g0 + x * g1;
m1 = cx * g2 + x * g3;
int g = (int)(cy * m0 + y * m1);
m0 = cx * b0 + x * b1;
m1 = cx * b2 + x * b3;
int b = (int)(cy * m0 + y * m1);
return (a << 24) | (r << 16) | (g << 8) | b;
} | java | public static int bilinearInterpolate(float x, float y, int nw, int ne, int sw, int se) {
float m0, m1;
int a0 = (nw >> 24) & 0xff;
int r0 = (nw >> 16) & 0xff;
int g0 = (nw >> 8) & 0xff;
int b0 = nw & 0xff;
int a1 = (ne >> 24) & 0xff;
int r1 = (ne >> 16) & 0xff;
int g1 = (ne >> 8) & 0xff;
int b1 = ne & 0xff;
int a2 = (sw >> 24) & 0xff;
int r2 = (sw >> 16) & 0xff;
int g2 = (sw >> 8) & 0xff;
int b2 = sw & 0xff;
int a3 = (se >> 24) & 0xff;
int r3 = (se >> 16) & 0xff;
int g3 = (se >> 8) & 0xff;
int b3 = se & 0xff;
float cx = 1.0f-x;
float cy = 1.0f-y;
m0 = cx * a0 + x * a1;
m1 = cx * a2 + x * a3;
int a = (int)(cy * m0 + y * m1);
m0 = cx * r0 + x * r1;
m1 = cx * r2 + x * r3;
int r = (int)(cy * m0 + y * m1);
m0 = cx * g0 + x * g1;
m1 = cx * g2 + x * g3;
int g = (int)(cy * m0 + y * m1);
m0 = cx * b0 + x * b1;
m1 = cx * b2 + x * b3;
int b = (int)(cy * m0 + y * m1);
return (a << 24) | (r << 16) | (g << 8) | b;
} | [
"public",
"static",
"int",
"bilinearInterpolate",
"(",
"float",
"x",
",",
"float",
"y",
",",
"int",
"nw",
",",
"int",
"ne",
",",
"int",
"sw",
",",
"int",
"se",
")",
"{",
"float",
"m0",
",",
"m1",
";",
"int",
"a0",
"=",
"(",
"nw",
">>",
"24",
")... | Bilinear interpolation of ARGB values.
@param x the X interpolation parameter 0..1
@param y the y interpolation parameter 0..1
@param rgb array of four ARGB values in the order NW, NE, SW, SE
@return the interpolated value | [
"Bilinear",
"interpolation",
"of",
"ARGB",
"values",
"."
] | train | https://github.com/sksamuel/scrimage/blob/52dab448136e6657a71951b0e6b7d5e64dc979ac/scrimage-filters/src/main/java/thirdparty/jhlabs/image/ImageMath.java#L289-L328 |
leancloud/java-sdk-all | realtime/src/main/java/cn/leancloud/im/v2/AVIMConversation.java | AVIMConversation.updateMemberRole | public void updateMemberRole(final String memberId, final ConversationMemberRole role, final AVIMConversationCallback callback) {
AVIMConversationMemberInfo info = new AVIMConversationMemberInfo(this.conversationId, memberId, role);
Map<String, Object> params = new HashMap<String, Object>();
params.put(Conversation.PARAM_CONVERSATION_MEMBER_DETAILS, info.getUpdateAttrs());
boolean ret = InternalConfiguration.getOperationTube().processMembers(this.client.getClientId(), this.conversationId,
getType(), JSON.toJSONString(params), Conversation.AVIMOperation.CONVERSATION_PROMOTE_MEMBER, callback);
if (!ret && null != callback) {
callback.internalDone(new AVException(AVException.OPERATION_FORBIDDEN, "couldn't start service in background."));
}
} | java | public void updateMemberRole(final String memberId, final ConversationMemberRole role, final AVIMConversationCallback callback) {
AVIMConversationMemberInfo info = new AVIMConversationMemberInfo(this.conversationId, memberId, role);
Map<String, Object> params = new HashMap<String, Object>();
params.put(Conversation.PARAM_CONVERSATION_MEMBER_DETAILS, info.getUpdateAttrs());
boolean ret = InternalConfiguration.getOperationTube().processMembers(this.client.getClientId(), this.conversationId,
getType(), JSON.toJSONString(params), Conversation.AVIMOperation.CONVERSATION_PROMOTE_MEMBER, callback);
if (!ret && null != callback) {
callback.internalDone(new AVException(AVException.OPERATION_FORBIDDEN, "couldn't start service in background."));
}
} | [
"public",
"void",
"updateMemberRole",
"(",
"final",
"String",
"memberId",
",",
"final",
"ConversationMemberRole",
"role",
",",
"final",
"AVIMConversationCallback",
"callback",
")",
"{",
"AVIMConversationMemberInfo",
"info",
"=",
"new",
"AVIMConversationMemberInfo",
"(",
... | 更新成员的角色信息
@param memberId 成员的 client id
@param role 角色
@param callback 结果回调函数 | [
"更新成员的角色信息"
] | train | https://github.com/leancloud/java-sdk-all/blob/323f8e7ee38051b1350790e5192304768c5c9f5f/realtime/src/main/java/cn/leancloud/im/v2/AVIMConversation.java#L1210-L1219 |
aws/aws-sdk-java | aws-java-sdk-cognitoidentity/src/main/java/com/amazonaws/services/cognitoidentity/model/UpdateIdentityPoolRequest.java | UpdateIdentityPoolRequest.withSupportedLoginProviders | public UpdateIdentityPoolRequest withSupportedLoginProviders(java.util.Map<String, String> supportedLoginProviders) {
setSupportedLoginProviders(supportedLoginProviders);
return this;
} | java | public UpdateIdentityPoolRequest withSupportedLoginProviders(java.util.Map<String, String> supportedLoginProviders) {
setSupportedLoginProviders(supportedLoginProviders);
return this;
} | [
"public",
"UpdateIdentityPoolRequest",
"withSupportedLoginProviders",
"(",
"java",
".",
"util",
".",
"Map",
"<",
"String",
",",
"String",
">",
"supportedLoginProviders",
")",
"{",
"setSupportedLoginProviders",
"(",
"supportedLoginProviders",
")",
";",
"return",
"this",
... | <p>
Optional key:value pairs mapping provider names to provider app IDs.
</p>
@param supportedLoginProviders
Optional key:value pairs mapping provider names to provider app IDs.
@return Returns a reference to this object so that method calls can be chained together. | [
"<p",
">",
"Optional",
"key",
":",
"value",
"pairs",
"mapping",
"provider",
"names",
"to",
"provider",
"app",
"IDs",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-cognitoidentity/src/main/java/com/amazonaws/services/cognitoidentity/model/UpdateIdentityPoolRequest.java#L254-L257 |
alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java | TopologyBuilder.setSpout | public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelism_hint) throws IllegalArgumentException {
validateUnusedId(id);
initCommon(id, spout, parallelism_hint);
_spouts.put(id, spout);
return new SpoutGetter(id);
} | java | public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelism_hint) throws IllegalArgumentException {
validateUnusedId(id);
initCommon(id, spout, parallelism_hint);
_spouts.put(id, spout);
return new SpoutGetter(id);
} | [
"public",
"SpoutDeclarer",
"setSpout",
"(",
"String",
"id",
",",
"IRichSpout",
"spout",
",",
"Number",
"parallelism_hint",
")",
"throws",
"IllegalArgumentException",
"{",
"validateUnusedId",
"(",
"id",
")",
";",
"initCommon",
"(",
"id",
",",
"spout",
",",
"paral... | Define a new spout in this topology with the specified parallelism. If the spout declares
itself as non-distributed, the parallelism_hint will be ignored and only one task
will be allocated to this component.
@param id the id of this component. This id is referenced by other components that want to consume this spout's outputs.
@param parallelism_hint the number of tasks that should be assigned to execute this spout. Each task will run on a thread in a process somewhere around the cluster.
@param spout the spout
@throws IllegalArgumentException if {@code parallelism_hint} is not positive | [
"Define",
"a",
"new",
"spout",
"in",
"this",
"topology",
"with",
"the",
"specified",
"parallelism",
".",
"If",
"the",
"spout",
"declares",
"itself",
"as",
"non",
"-",
"distributed",
"the",
"parallelism_hint",
"will",
"be",
"ignored",
"and",
"only",
"one",
"t... | train | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java#L321-L326 |
spotbugs/spotbugs | spotbugs/src/main/java/edu/umd/cs/findbugs/ba/XFactory.java | XFactory.createXMethod | public static XMethod createXMethod(InvokeInstruction invokeInstruction, ConstantPoolGen cpg) {
String className = invokeInstruction.getClassName(cpg);
String methodName = invokeInstruction.getName(cpg);
String methodSig = invokeInstruction.getSignature(cpg);
if (invokeInstruction instanceof INVOKEDYNAMIC) {
// XXX the lambda representation makes no sense for XMethod
// "classical" instruction attributes are filled with garbage, causing
// the code later to produce crazy errors (looking for non existing types etc)
// We should NOT be called here from our code, but 3rd party code still may
// use this method. So *at least* provide a valid class name, which is
// (don't ask me why) is encoded in the first argument type of the lambda
// className = invokeInstruction.getArgumentTypes(cpg)[0].toString();
className = Values.DOTTED_JAVA_LANG_OBJECT;
}
return createXMethod(className, methodName, methodSig, invokeInstruction.getOpcode() == Const.INVOKESTATIC);
} | java | public static XMethod createXMethod(InvokeInstruction invokeInstruction, ConstantPoolGen cpg) {
String className = invokeInstruction.getClassName(cpg);
String methodName = invokeInstruction.getName(cpg);
String methodSig = invokeInstruction.getSignature(cpg);
if (invokeInstruction instanceof INVOKEDYNAMIC) {
// XXX the lambda representation makes no sense for XMethod
// "classical" instruction attributes are filled with garbage, causing
// the code later to produce crazy errors (looking for non existing types etc)
// We should NOT be called here from our code, but 3rd party code still may
// use this method. So *at least* provide a valid class name, which is
// (don't ask me why) is encoded in the first argument type of the lambda
// className = invokeInstruction.getArgumentTypes(cpg)[0].toString();
className = Values.DOTTED_JAVA_LANG_OBJECT;
}
return createXMethod(className, methodName, methodSig, invokeInstruction.getOpcode() == Const.INVOKESTATIC);
} | [
"public",
"static",
"XMethod",
"createXMethod",
"(",
"InvokeInstruction",
"invokeInstruction",
",",
"ConstantPoolGen",
"cpg",
")",
"{",
"String",
"className",
"=",
"invokeInstruction",
".",
"getClassName",
"(",
"cpg",
")",
";",
"String",
"methodName",
"=",
"invokeIn... | Create an XMethod object from an InvokeInstruction.
@param invokeInstruction
the InvokeInstruction
@param cpg
ConstantPoolGen from the class containing the instruction
@return XMethod representing the method called by the InvokeInstruction | [
"Create",
"an",
"XMethod",
"object",
"from",
"an",
"InvokeInstruction",
"."
] | train | https://github.com/spotbugs/spotbugs/blob/f6365c6eea6515035bded38efa4a7c8b46ccf28c/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/XFactory.java#L616-L631 |
h2oai/h2o-3 | h2o-core/src/main/java/water/fvec/NewChunk.java | NewChunk.set_impl | @Override boolean set_impl(int i, long l) {
if( _ds != null ) return set_impl(i,(double)l);
if(_sparseLen != _len){ // sparse?
int idx = Arrays.binarySearch(_id,0, _sparseLen,i);
if(idx >= 0)i = idx;
else cancel_sparse(); // for now don't bother setting the sparse value
}
_ms.set(i,l);
_xs.set(i,0);
if(_missing != null)_missing.clear(i);
_naCnt = -1;
return true;
} | java | @Override boolean set_impl(int i, long l) {
if( _ds != null ) return set_impl(i,(double)l);
if(_sparseLen != _len){ // sparse?
int idx = Arrays.binarySearch(_id,0, _sparseLen,i);
if(idx >= 0)i = idx;
else cancel_sparse(); // for now don't bother setting the sparse value
}
_ms.set(i,l);
_xs.set(i,0);
if(_missing != null)_missing.clear(i);
_naCnt = -1;
return true;
} | [
"@",
"Override",
"boolean",
"set_impl",
"(",
"int",
"i",
",",
"long",
"l",
")",
"{",
"if",
"(",
"_ds",
"!=",
"null",
")",
"return",
"set_impl",
"(",
"i",
",",
"(",
"double",
")",
"l",
")",
";",
"if",
"(",
"_sparseLen",
"!=",
"_len",
")",
"{",
"... | in-range and refer to the inflated values of the original Chunk. | [
"in",
"-",
"range",
"and",
"refer",
"to",
"the",
"inflated",
"values",
"of",
"the",
"original",
"Chunk",
"."
] | train | https://github.com/h2oai/h2o-3/blob/845eb49dfeaadf638b6e2f779d82fac996391fad/h2o-core/src/main/java/water/fvec/NewChunk.java#L1529-L1541 |
the-fascinator/plugin-indexer-solr | src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java | SolrWrapperQueueConsumer.addToBuffer | private void addToBuffer(String index, String document) {
if (timerMDC == null) {
timerMDC = MDC.get("name");
}
// Remove old entries from the buffer
int removedSize = 0;
if (docBuffer.containsKey(index)) {
log.debug("Removing buffer duplicate: '{}'", index);
removedSize = docBuffer.get(index).length();
docBuffer.remove(index);
}
int length = document.length() - removedSize;
// If this is the first document in the buffer, record its age
bufferYoungest = new Date().getTime();
if (docBuffer.isEmpty()) {
bufferOldest = new Date().getTime();
log.debug("=== New buffer starting: {}", bufferOldest);
}
// Add to the buffer
docBuffer.put(index, document);
bufferSize += length;
// Check if submission is required
checkBuffer();
} | java | private void addToBuffer(String index, String document) {
if (timerMDC == null) {
timerMDC = MDC.get("name");
}
// Remove old entries from the buffer
int removedSize = 0;
if (docBuffer.containsKey(index)) {
log.debug("Removing buffer duplicate: '{}'", index);
removedSize = docBuffer.get(index).length();
docBuffer.remove(index);
}
int length = document.length() - removedSize;
// If this is the first document in the buffer, record its age
bufferYoungest = new Date().getTime();
if (docBuffer.isEmpty()) {
bufferOldest = new Date().getTime();
log.debug("=== New buffer starting: {}", bufferOldest);
}
// Add to the buffer
docBuffer.put(index, document);
bufferSize += length;
// Check if submission is required
checkBuffer();
} | [
"private",
"void",
"addToBuffer",
"(",
"String",
"index",
",",
"String",
"document",
")",
"{",
"if",
"(",
"timerMDC",
"==",
"null",
")",
"{",
"timerMDC",
"=",
"MDC",
".",
"get",
"(",
"\"name\"",
")",
";",
"}",
"// Remove old entries from the buffer",
"int",
... | Add a new document into the buffer, and check if submission is required
@param document : The Solr document to add to the buffer. | [
"Add",
"a",
"new",
"document",
"into",
"the",
"buffer",
"and",
"check",
"if",
"submission",
"is",
"required"
] | train | https://github.com/the-fascinator/plugin-indexer-solr/blob/001159b18b78a87daa5d8b2a17ced28694bae156/src/main/java/com/googlecode/fascinator/indexer/SolrWrapperQueueConsumer.java#L441-L465 |
samskivert/samskivert | src/main/java/com/samskivert/util/ConfigUtil.java | ConfigUtil.getSystemProperty | public static int getSystemProperty (String key, int defval)
{
String valstr = System.getProperty(key);
int value = defval;
if (valstr != null) {
try {
value = Integer.parseInt(valstr);
} catch (NumberFormatException nfe) {
log.warning("'" + key + "' must be a numeric value", "value", valstr, "error", nfe);
}
}
return value;
} | java | public static int getSystemProperty (String key, int defval)
{
String valstr = System.getProperty(key);
int value = defval;
if (valstr != null) {
try {
value = Integer.parseInt(valstr);
} catch (NumberFormatException nfe) {
log.warning("'" + key + "' must be a numeric value", "value", valstr, "error", nfe);
}
}
return value;
} | [
"public",
"static",
"int",
"getSystemProperty",
"(",
"String",
"key",
",",
"int",
"defval",
")",
"{",
"String",
"valstr",
"=",
"System",
".",
"getProperty",
"(",
"key",
")",
";",
"int",
"value",
"=",
"defval",
";",
"if",
"(",
"valstr",
"!=",
"null",
")... | Obtains the specified system property via {@link System#getProperty}, parses it into an
integer and returns the value. If the property is not set, the default value will be
returned. If the property is not a properly formatted integer, an error will be logged and
the default value will be returned. | [
"Obtains",
"the",
"specified",
"system",
"property",
"via",
"{"
] | train | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ConfigUtil.java#L29-L41 |
couchbase/couchbase-java-client | src/main/java/com/couchbase/client/java/bucket/BucketFlusher.java | BucketFlusher.createMarkerDocuments | private static Observable<List<String>> createMarkerDocuments(final ClusterFacade core, final String bucket) {
return Observable
.from(FLUSH_MARKERS)
.flatMap(new Func1<String, Observable<UpsertResponse>>() {
@Override
public Observable<UpsertResponse> call(final String id) {
return deferAndWatch(new Func1<Subscriber, Observable<? extends UpsertResponse>>() {
@Override
public Observable<? extends UpsertResponse> call(final Subscriber subscriber) {
UpsertRequest request = new UpsertRequest(id, Unpooled.copiedBuffer(id, CharsetUtil.UTF_8), bucket);
request.subscriber(subscriber);
return core.send(request);
}
});
}
})
.doOnNext(new Action1<UpsertResponse>() {
@Override
public void call(UpsertResponse response) {
if (response.content() != null && response.content().refCnt() > 0) {
response.content().release();
}
}
})
.last()
.map(new Func1<UpsertResponse, List<String>>() {
@Override
public List<String> call(UpsertResponse response) {
return FLUSH_MARKERS;
}
});
} | java | private static Observable<List<String>> createMarkerDocuments(final ClusterFacade core, final String bucket) {
return Observable
.from(FLUSH_MARKERS)
.flatMap(new Func1<String, Observable<UpsertResponse>>() {
@Override
public Observable<UpsertResponse> call(final String id) {
return deferAndWatch(new Func1<Subscriber, Observable<? extends UpsertResponse>>() {
@Override
public Observable<? extends UpsertResponse> call(final Subscriber subscriber) {
UpsertRequest request = new UpsertRequest(id, Unpooled.copiedBuffer(id, CharsetUtil.UTF_8), bucket);
request.subscriber(subscriber);
return core.send(request);
}
});
}
})
.doOnNext(new Action1<UpsertResponse>() {
@Override
public void call(UpsertResponse response) {
if (response.content() != null && response.content().refCnt() > 0) {
response.content().release();
}
}
})
.last()
.map(new Func1<UpsertResponse, List<String>>() {
@Override
public List<String> call(UpsertResponse response) {
return FLUSH_MARKERS;
}
});
} | [
"private",
"static",
"Observable",
"<",
"List",
"<",
"String",
">",
">",
"createMarkerDocuments",
"(",
"final",
"ClusterFacade",
"core",
",",
"final",
"String",
"bucket",
")",
"{",
"return",
"Observable",
".",
"from",
"(",
"FLUSH_MARKERS",
")",
".",
"flatMap",... | Helper method to create marker documents for each partition.
@param core the core reference.
@param bucket the name of the bucket.
@return a list of created flush marker IDs once they are completely upserted. | [
"Helper",
"method",
"to",
"create",
"marker",
"documents",
"for",
"each",
"partition",
"."
] | train | https://github.com/couchbase/couchbase-java-client/blob/f36a0ee0c66923bdde47838ca543e50cbaa99e14/src/main/java/com/couchbase/client/java/bucket/BucketFlusher.java#L118-L149 |
fuinorg/units4j | src/main/java/org/fuin/units4j/Units4JUtils.java | Units4JUtils.indexAllClasses | public static final void indexAllClasses(final Indexer indexer, final List<File> classFiles) {
classFiles.forEach(file -> {
try {
final InputStream in = new FileInputStream(file);
try {
indexer.index(in);
} finally {
in.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
});
} | java | public static final void indexAllClasses(final Indexer indexer, final List<File> classFiles) {
classFiles.forEach(file -> {
try {
final InputStream in = new FileInputStream(file);
try {
indexer.index(in);
} finally {
in.close();
}
} catch (final IOException ex) {
throw new RuntimeException(ex);
}
});
} | [
"public",
"static",
"final",
"void",
"indexAllClasses",
"(",
"final",
"Indexer",
"indexer",
",",
"final",
"List",
"<",
"File",
">",
"classFiles",
")",
"{",
"classFiles",
".",
"forEach",
"(",
"file",
"->",
"{",
"try",
"{",
"final",
"InputStream",
"in",
"=",... | Index all class files in the given list.
@param indexer
Indexer to use.
@param classFiles
List of ".class" files. | [
"Index",
"all",
"class",
"files",
"in",
"the",
"given",
"list",
"."
] | train | https://github.com/fuinorg/units4j/blob/29383e30b0f9c246b309e734df9cc63dc5d5499e/src/main/java/org/fuin/units4j/Units4JUtils.java#L386-L399 |
OpenLiberty/open-liberty | dev/com.ibm.ws.monitor/src/com/ibm/ws/monitor/internal/ProbeManagerImpl.java | ProbeManagerImpl.createProbe | public synchronized ProbeImpl createProbe(Class<?> probedClass, String key, Constructor<?> ctor, Method method) {
ProbeImpl probeImpl = getProbe(probedClass, key);
if (probeImpl == null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(this, tc, "createProbe: " + key);
}
probeImpl = new ProbeImpl(this, probedClass, key, ctor, method);
activeProbesById.put(Long.valueOf(probeImpl.getIdentifier()), probeImpl);
Map<String, ProbeImpl> classProbes = probesByKey.get(probedClass);
if (classProbes == null) {
classProbes = new HashMap<String, ProbeImpl>();
probesByKey.put(probedClass, classProbes);
}
classProbes.put(key, probeImpl);
}
return probeImpl;
} | java | public synchronized ProbeImpl createProbe(Class<?> probedClass, String key, Constructor<?> ctor, Method method) {
ProbeImpl probeImpl = getProbe(probedClass, key);
if (probeImpl == null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(this, tc, "createProbe: " + key);
}
probeImpl = new ProbeImpl(this, probedClass, key, ctor, method);
activeProbesById.put(Long.valueOf(probeImpl.getIdentifier()), probeImpl);
Map<String, ProbeImpl> classProbes = probesByKey.get(probedClass);
if (classProbes == null) {
classProbes = new HashMap<String, ProbeImpl>();
probesByKey.put(probedClass, classProbes);
}
classProbes.put(key, probeImpl);
}
return probeImpl;
} | [
"public",
"synchronized",
"ProbeImpl",
"createProbe",
"(",
"Class",
"<",
"?",
">",
"probedClass",
",",
"String",
"key",
",",
"Constructor",
"<",
"?",
">",
"ctor",
",",
"Method",
"method",
")",
"{",
"ProbeImpl",
"probeImpl",
"=",
"getProbe",
"(",
"probedClass... | Create a new {@link ProbeImpl} with the specified information.
@param probedClass the probe source
@param key the unique name of the probe within the source class
@param ctor the probed constructor or null
@param method the probed method or null
@param probeKind the kind of probe
@return the new probe implementation | [
"Create",
"a",
"new",
"{",
"@link",
"ProbeImpl",
"}",
"with",
"the",
"specified",
"information",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.monitor/src/com/ibm/ws/monitor/internal/ProbeManagerImpl.java#L636-L652 |
katjahahn/PortEx | src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java | Visualizer.drawPixel | private void drawPixel(Color color, long fileOffset) {
long size = withMinLength(0);
drawPixels(color, fileOffset, size);
} | java | private void drawPixel(Color color, long fileOffset) {
long size = withMinLength(0);
drawPixels(color, fileOffset, size);
} | [
"private",
"void",
"drawPixel",
"(",
"Color",
"color",
",",
"long",
"fileOffset",
")",
"{",
"long",
"size",
"=",
"withMinLength",
"(",
"0",
")",
";",
"drawPixels",
"(",
"color",
",",
"fileOffset",
",",
"size",
")",
";",
"}"
] | Draws a square pixel at fileOffset with color.
@param color
of the square pixel
@param fileOffset
file location that the square pixel represents | [
"Draws",
"a",
"square",
"pixel",
"at",
"fileOffset",
"with",
"color",
"."
] | train | https://github.com/katjahahn/PortEx/blob/319f08560aa58e3d5d7abe346ffdf623d6dc6990/src/main/java/com/github/katjahahn/tools/visualizer/Visualizer.java#L916-L919 |
haifengl/smile | math/src/main/java/smile/math/matrix/SparseMatrix.java | SparseMatrix.scatter | private static int scatter(SparseMatrix A, int j, double beta, int[] w, double[] x, int mark, SparseMatrix C, int nz) {
int[] Ap = A.colIndex;
int[] Ai = A.rowIndex;
double[] Ax = A.x;
int[] Ci = C.rowIndex;
for (int p = Ap[j]; p < Ap[j + 1]; p++) {
int i = Ai[p]; // A(i,j) is nonzero
if (w[i] < mark) {
w[i] = mark; // i is new entry in column j
Ci[nz++] = i; // add i to pattern of C(:,j)
x[i] = beta * Ax[p]; // x(i) = beta*A(i,j)
} else {
x[i] += beta * Ax[p]; // i exists in C(:,j) already
}
}
return nz;
} | java | private static int scatter(SparseMatrix A, int j, double beta, int[] w, double[] x, int mark, SparseMatrix C, int nz) {
int[] Ap = A.colIndex;
int[] Ai = A.rowIndex;
double[] Ax = A.x;
int[] Ci = C.rowIndex;
for (int p = Ap[j]; p < Ap[j + 1]; p++) {
int i = Ai[p]; // A(i,j) is nonzero
if (w[i] < mark) {
w[i] = mark; // i is new entry in column j
Ci[nz++] = i; // add i to pattern of C(:,j)
x[i] = beta * Ax[p]; // x(i) = beta*A(i,j)
} else {
x[i] += beta * Ax[p]; // i exists in C(:,j) already
}
}
return nz;
} | [
"private",
"static",
"int",
"scatter",
"(",
"SparseMatrix",
"A",
",",
"int",
"j",
",",
"double",
"beta",
",",
"int",
"[",
"]",
"w",
",",
"double",
"[",
"]",
"x",
",",
"int",
"mark",
",",
"SparseMatrix",
"C",
",",
"int",
"nz",
")",
"{",
"int",
"["... | x = x + beta * A(:,j), where x is a dense vector and A(:,j) is sparse. | [
"x",
"=",
"x",
"+",
"beta",
"*",
"A",
"(",
":",
"j",
")",
"where",
"x",
"is",
"a",
"dense",
"vector",
"and",
"A",
"(",
":",
"j",
")",
"is",
"sparse",
"."
] | train | https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/matrix/SparseMatrix.java#L362-L380 |
NessComputing/components-ness-quartz | src/main/java/com/nesscomputing/quartz/QuartzJob.java | QuartzJob.startTime | @SuppressWarnings("unchecked")
public final SelfType startTime(final DateTime when, final TimeSpan jitter)
{
// Find the current week day in the same time zone as the "when" time passed in.
final DateTime now = new DateTime().withZone(when.getZone());
final int startWeekDay = when.getDayOfWeek();
final int currentWeekDay = now.getDayOfWeek();
// ( x + n ) % n is x for x > 0 and n - x for x < 0.
final int daysTilStart = (startWeekDay - currentWeekDay + DAYS_PER_WEEK) % DAYS_PER_WEEK;
Preconditions.checkState(daysTilStart >= 0 && daysTilStart < DAYS_PER_WEEK, "daysTilStart must be 0..%s, but is %s", DAYS_PER_WEEK, daysTilStart);
// same trick as above, add a full week in millis and do the modulo.
final long millisecondsTilStart = (when.getMillisOfDay() - now.getMillisOfDay() + daysTilStart * MILLIS_PER_DAY + MILLIS_PER_WEEK) % MILLIS_PER_WEEK;
Preconditions.checkState(millisecondsTilStart >= 0 && millisecondsTilStart < MILLIS_PER_WEEK, "millisecondsTilStart must be 0..%s, but is %s", MILLIS_PER_WEEK, millisecondsTilStart);
this.delay = Duration.millis((long)(ThreadLocalRandom.current().nextDouble() * jitter.getMillis()) + millisecondsTilStart);
return (SelfType) this;
} | java | @SuppressWarnings("unchecked")
public final SelfType startTime(final DateTime when, final TimeSpan jitter)
{
// Find the current week day in the same time zone as the "when" time passed in.
final DateTime now = new DateTime().withZone(when.getZone());
final int startWeekDay = when.getDayOfWeek();
final int currentWeekDay = now.getDayOfWeek();
// ( x + n ) % n is x for x > 0 and n - x for x < 0.
final int daysTilStart = (startWeekDay - currentWeekDay + DAYS_PER_WEEK) % DAYS_PER_WEEK;
Preconditions.checkState(daysTilStart >= 0 && daysTilStart < DAYS_PER_WEEK, "daysTilStart must be 0..%s, but is %s", DAYS_PER_WEEK, daysTilStart);
// same trick as above, add a full week in millis and do the modulo.
final long millisecondsTilStart = (when.getMillisOfDay() - now.getMillisOfDay() + daysTilStart * MILLIS_PER_DAY + MILLIS_PER_WEEK) % MILLIS_PER_WEEK;
Preconditions.checkState(millisecondsTilStart >= 0 && millisecondsTilStart < MILLIS_PER_WEEK, "millisecondsTilStart must be 0..%s, but is %s", MILLIS_PER_WEEK, millisecondsTilStart);
this.delay = Duration.millis((long)(ThreadLocalRandom.current().nextDouble() * jitter.getMillis()) + millisecondsTilStart);
return (SelfType) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"SelfType",
"startTime",
"(",
"final",
"DateTime",
"when",
",",
"final",
"TimeSpan",
"jitter",
")",
"{",
"// Find the current week day in the same time zone as the \"when\" time passed in.",
"final",
"Da... | Set the time-of-day when the first run of the job will take place. | [
"Set",
"the",
"time",
"-",
"of",
"-",
"day",
"when",
"the",
"first",
"run",
"of",
"the",
"job",
"will",
"take",
"place",
"."
] | train | https://github.com/NessComputing/components-ness-quartz/blob/fd41c440e21b31a5292a0606c8687eacfc5120ae/src/main/java/com/nesscomputing/quartz/QuartzJob.java#L87-L106 |
Javacord/Javacord | javacord-api/src/main/java/org/javacord/api/entity/message/embed/EmbedBuilder.java | EmbedBuilder.setImage | public EmbedBuilder setImage(InputStream image, String fileType) {
delegate.setImage(image, fileType);
return this;
} | java | public EmbedBuilder setImage(InputStream image, String fileType) {
delegate.setImage(image, fileType);
return this;
} | [
"public",
"EmbedBuilder",
"setImage",
"(",
"InputStream",
"image",
",",
"String",
"fileType",
")",
"{",
"delegate",
".",
"setImage",
"(",
"image",
",",
"fileType",
")",
";",
"return",
"this",
";",
"}"
] | Sets the image of the embed.
@param image The image.
@param fileType The type of the file, e.g. "png" or "gif".
@return The current instance in order to chain call methods. | [
"Sets",
"the",
"image",
"of",
"the",
"embed",
"."
] | train | https://github.com/Javacord/Javacord/blob/915aad084dc5e863284267529d0dccd625fc6886/javacord-api/src/main/java/org/javacord/api/entity/message/embed/EmbedBuilder.java#L278-L281 |
cdapio/tigon | tigon-api/src/main/java/co/cask/tigon/api/common/Bytes.java | Bytes.padTail | public static byte [] padTail(final byte [] a, final int length) {
byte [] padding = new byte[length];
for (int i = 0; i < length; i++) {
padding[i] = 0;
}
return add(a, padding);
} | java | public static byte [] padTail(final byte [] a, final int length) {
byte [] padding = new byte[length];
for (int i = 0; i < length; i++) {
padding[i] = 0;
}
return add(a, padding);
} | [
"public",
"static",
"byte",
"[",
"]",
"padTail",
"(",
"final",
"byte",
"[",
"]",
"a",
",",
"final",
"int",
"length",
")",
"{",
"byte",
"[",
"]",
"padding",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",... | Return a byte array with value in <code>a</code> plus <code>length</code> appended 0 bytes.
@param a array
@param length new array size
@return Value in <code>a</code> plus <code>length</code> appended 0 bytes | [
"Return",
"a",
"byte",
"array",
"with",
"value",
"in",
"<code",
">",
"a<",
"/",
"code",
">",
"plus",
"<code",
">",
"length<",
"/",
"code",
">",
"appended",
"0",
"bytes",
"."
] | train | https://github.com/cdapio/tigon/blob/5be6dffd7c79519d1211bb08f75be7dcfbbad392/tigon-api/src/main/java/co/cask/tigon/api/common/Bytes.java#L1078-L1084 |
impossibl/stencil | engine/src/main/java/com/impossibl/stencil/engine/StencilEngine.java | StencilEngine.renderInline | public String renderInline(String text, GlobalScope... extraGlobalScopes) throws IOException, ParseException {
return render(loadInline(text), extraGlobalScopes);
} | java | public String renderInline(String text, GlobalScope... extraGlobalScopes) throws IOException, ParseException {
return render(loadInline(text), extraGlobalScopes);
} | [
"public",
"String",
"renderInline",
"(",
"String",
"text",
",",
"GlobalScope",
"...",
"extraGlobalScopes",
")",
"throws",
"IOException",
",",
"ParseException",
"{",
"return",
"render",
"(",
"loadInline",
"(",
"text",
")",
",",
"extraGlobalScopes",
")",
";",
"}"
... | Renders given text and returns rendered text.
@param text Template text to render
@param extraGlobalScopes Any extra global scopes to make available
@return Rendered text
@throws IOException
@throws ParseException | [
"Renders",
"given",
"text",
"and",
"returns",
"rendered",
"text",
"."
] | train | https://github.com/impossibl/stencil/blob/4aac1be605542b4248be95bf8916be4e2f755d1c/engine/src/main/java/com/impossibl/stencil/engine/StencilEngine.java#L299-L301 |
aws/aws-sdk-java | aws-java-sdk-core/src/main/java/com/amazonaws/waiters/WaiterExecution.java | WaiterExecution.pollResource | public boolean pollResource() throws AmazonServiceException, WaiterTimedOutException, WaiterUnrecoverableException {
int retriesAttempted = 0;
while (true) {
switch (getCurrentState()) {
case SUCCESS:
return true;
case FAILURE:
throw new WaiterUnrecoverableException("Resource never entered the desired state as it failed.");
case RETRY:
PollingStrategyContext pollingStrategyContext = new PollingStrategyContext(request, retriesAttempted);
if (pollingStrategy.getRetryStrategy().shouldRetry(pollingStrategyContext)) {
safeCustomDelay(pollingStrategyContext);
retriesAttempted++;
} else {
throw new WaiterTimedOutException("Reached maximum attempts without transitioning to the desired state");
}
break;
}
}
} | java | public boolean pollResource() throws AmazonServiceException, WaiterTimedOutException, WaiterUnrecoverableException {
int retriesAttempted = 0;
while (true) {
switch (getCurrentState()) {
case SUCCESS:
return true;
case FAILURE:
throw new WaiterUnrecoverableException("Resource never entered the desired state as it failed.");
case RETRY:
PollingStrategyContext pollingStrategyContext = new PollingStrategyContext(request, retriesAttempted);
if (pollingStrategy.getRetryStrategy().shouldRetry(pollingStrategyContext)) {
safeCustomDelay(pollingStrategyContext);
retriesAttempted++;
} else {
throw new WaiterTimedOutException("Reached maximum attempts without transitioning to the desired state");
}
break;
}
}
} | [
"public",
"boolean",
"pollResource",
"(",
")",
"throws",
"AmazonServiceException",
",",
"WaiterTimedOutException",
",",
"WaiterUnrecoverableException",
"{",
"int",
"retriesAttempted",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"switch",
"(",
"getCurrentState",
"... | Polls until a specified resource transitions into either success or failure state or
until the specified number of retries has been made.
@return True if the resource transitions into desired state.
@throws AmazonServiceException If the service exception thrown doesn't match any of the expected
exceptions, it's re-thrown.
@throws WaiterUnrecoverableException If the resource transitions into a failure/unexpected state.
@throws WaiterTimedOutException If the resource doesn't transition into the desired state
even after a certain number of retries. | [
"Polls",
"until",
"a",
"specified",
"resource",
"transitions",
"into",
"either",
"success",
"or",
"failure",
"state",
"or",
"until",
"the",
"specified",
"number",
"of",
"retries",
"has",
"been",
"made",
"."
] | train | https://github.com/aws/aws-sdk-java/blob/aa38502458969b2d13a1c3665a56aba600e4dbd0/aws-java-sdk-core/src/main/java/com/amazonaws/waiters/WaiterExecution.java#L71-L92 |
jenkinsci/jenkins | core/src/main/java/hudson/security/csrf/CrumbIssuer.java | CrumbIssuer.validateCrumb | public boolean validateCrumb(ServletRequest request, MultipartFormDataParser parser) {
CrumbIssuerDescriptor<CrumbIssuer> desc = getDescriptor();
String crumbField = desc.getCrumbRequestField();
String crumbSalt = desc.getCrumbSalt();
return validateCrumb(request, crumbSalt, parser.get(crumbField));
} | java | public boolean validateCrumb(ServletRequest request, MultipartFormDataParser parser) {
CrumbIssuerDescriptor<CrumbIssuer> desc = getDescriptor();
String crumbField = desc.getCrumbRequestField();
String crumbSalt = desc.getCrumbSalt();
return validateCrumb(request, crumbSalt, parser.get(crumbField));
} | [
"public",
"boolean",
"validateCrumb",
"(",
"ServletRequest",
"request",
",",
"MultipartFormDataParser",
"parser",
")",
"{",
"CrumbIssuerDescriptor",
"<",
"CrumbIssuer",
">",
"desc",
"=",
"getDescriptor",
"(",
")",
";",
"String",
"crumbField",
"=",
"desc",
".",
"ge... | Get a crumb from multipart form data and validate it against other data
in the current request. The salt and request parameter that is used is
defined by the current configuration.
@param request
@param parser | [
"Get",
"a",
"crumb",
"from",
"multipart",
"form",
"data",
"and",
"validate",
"it",
"against",
"other",
"data",
"in",
"the",
"current",
"request",
".",
"The",
"salt",
"and",
"request",
"parameter",
"that",
"is",
"used",
"is",
"defined",
"by",
"the",
"curren... | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/security/csrf/CrumbIssuer.java#L131-L137 |
jglobus/JGlobus | gss/src/main/java/org/globus/gsi/gssapi/SSLUtil.java | SSLUtil.readFully | public static void readFully(InputStream in, byte [] buf, int off, int len)
throws IOException {
int n = 0;
while (n < len) {
int count = in.read(buf, off + n, len - n);
if (count < 0)
throw new EOFException();
n += count;
}
} | java | public static void readFully(InputStream in, byte [] buf, int off, int len)
throws IOException {
int n = 0;
while (n < len) {
int count = in.read(buf, off + n, len - n);
if (count < 0)
throw new EOFException();
n += count;
}
} | [
"public",
"static",
"void",
"readFully",
"(",
"InputStream",
"in",
",",
"byte",
"[",
"]",
"buf",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"int",
"n",
"=",
"0",
";",
"while",
"(",
"n",
"<",
"len",
")",
"{",
"int",
"... | Reads some number of bytes from the input stream.
This function blocks until all data is read or an I/O
error occurs.
@param in the input stream to read the bytes from.
@param buf the buffer into which read the data is read.
@param off the start offset in array b at which the data is written.
@param len the maximum number of bytes to read.
@exception IOException if I/O error occurs. | [
"Reads",
"some",
"number",
"of",
"bytes",
"from",
"the",
"input",
"stream",
".",
"This",
"function",
"blocks",
"until",
"all",
"data",
"is",
"read",
"or",
"an",
"I",
"/",
"O",
"error",
"occurs",
"."
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/gss/src/main/java/org/globus/gsi/gssapi/SSLUtil.java#L61-L70 |
alkacon/opencms-core | src/org/opencms/workplace/CmsWorkplace.java | CmsWorkplace.getStartSiteRoot | public static String getStartSiteRoot(CmsObject cms, CmsWorkplaceSettings settings) {
return getStartSiteRoot(cms, settings.getUserSettings());
} | java | public static String getStartSiteRoot(CmsObject cms, CmsWorkplaceSettings settings) {
return getStartSiteRoot(cms, settings.getUserSettings());
} | [
"public",
"static",
"String",
"getStartSiteRoot",
"(",
"CmsObject",
"cms",
",",
"CmsWorkplaceSettings",
"settings",
")",
"{",
"return",
"getStartSiteRoot",
"(",
"cms",
",",
"settings",
".",
"getUserSettings",
"(",
")",
")",
";",
"}"
] | Returns the start site from the given workplace settings.<p>
@param cms the cms context
@param settings the workplace settings
@return the start site root | [
"Returns",
"the",
"start",
"site",
"from",
"the",
"given",
"workplace",
"settings",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/workplace/CmsWorkplace.java#L629-L632 |
qiniu/android-sdk | library/src/main/java/com/qiniu/android/utils/Etag.java | Etag.stream | public static String stream(InputStream in, long len) throws IOException {
if (len == 0) {
return "Fto5o-5ea0sNMlW_75VgGJCv2AcJ";
}
byte[] buffer = new byte[64 * 1024];
byte[][] blocks = new byte[(int) ((len + Configuration.BLOCK_SIZE - 1) / Configuration.BLOCK_SIZE)][];
for (int i = 0; i < blocks.length; i++) {
long left = len - (long) Configuration.BLOCK_SIZE * i;
long read = left > Configuration.BLOCK_SIZE ? Configuration.BLOCK_SIZE : left;
blocks[i] = oneBlock(buffer, in, (int) read);
}
return resultEncode(blocks);
} | java | public static String stream(InputStream in, long len) throws IOException {
if (len == 0) {
return "Fto5o-5ea0sNMlW_75VgGJCv2AcJ";
}
byte[] buffer = new byte[64 * 1024];
byte[][] blocks = new byte[(int) ((len + Configuration.BLOCK_SIZE - 1) / Configuration.BLOCK_SIZE)][];
for (int i = 0; i < blocks.length; i++) {
long left = len - (long) Configuration.BLOCK_SIZE * i;
long read = left > Configuration.BLOCK_SIZE ? Configuration.BLOCK_SIZE : left;
blocks[i] = oneBlock(buffer, in, (int) read);
}
return resultEncode(blocks);
} | [
"public",
"static",
"String",
"stream",
"(",
"InputStream",
"in",
",",
"long",
"len",
")",
"throws",
"IOException",
"{",
"if",
"(",
"len",
"==",
"0",
")",
"{",
"return",
"\"Fto5o-5ea0sNMlW_75VgGJCv2AcJ\"",
";",
"}",
"byte",
"[",
"]",
"buffer",
"=",
"new",
... | 计算输入流的etag
@param in 数据输入流
@param len 数据流长度
@return 数据流的etag值
@throws IOException 文件读取异常 | [
"计算输入流的etag"
] | train | https://github.com/qiniu/android-sdk/blob/dbd2a01fb3bff7a5e75e8934bbf81713124d8466/library/src/main/java/com/qiniu/android/utils/Etag.java#L100-L112 |
prestodb/presto | presto-parser/src/main/java/com/facebook/presto/sql/tree/Node.java | Node.accept | protected <R, C> R accept(AstVisitor<R, C> visitor, C context)
{
return visitor.visitNode(this, context);
} | java | protected <R, C> R accept(AstVisitor<R, C> visitor, C context)
{
return visitor.visitNode(this, context);
} | [
"protected",
"<",
"R",
",",
"C",
">",
"R",
"accept",
"(",
"AstVisitor",
"<",
"R",
",",
"C",
">",
"visitor",
",",
"C",
"context",
")",
"{",
"return",
"visitor",
".",
"visitNode",
"(",
"this",
",",
"context",
")",
";",
"}"
] | Accessible for {@link AstVisitor}, use {@link AstVisitor#process(Node, Object)} instead. | [
"Accessible",
"for",
"{"
] | train | https://github.com/prestodb/presto/blob/89de5e379d8f85e139d292b0add8c537a2a01a88/presto-parser/src/main/java/com/facebook/presto/sql/tree/Node.java#L33-L36 |
jbundle/jbundle | thin/base/db/base/src/main/java/org/jbundle/thin/base/db/mem/base/PKeyArea.java | PKeyArea.doRemove | public void doRemove(FieldTable table, KeyAreaInfo keyArea, BaseBuffer buffer) throws DBException
{
if (!this.atCurrent(buffer))
{
buffer = this.doSeek("==", table, keyArea);
if (buffer == null)
throw new DBException(Constants.FILE_INCONSISTENCY);
}
this.removeCurrent(buffer);
} | java | public void doRemove(FieldTable table, KeyAreaInfo keyArea, BaseBuffer buffer) throws DBException
{
if (!this.atCurrent(buffer))
{
buffer = this.doSeek("==", table, keyArea);
if (buffer == null)
throw new DBException(Constants.FILE_INCONSISTENCY);
}
this.removeCurrent(buffer);
} | [
"public",
"void",
"doRemove",
"(",
"FieldTable",
"table",
",",
"KeyAreaInfo",
"keyArea",
",",
"BaseBuffer",
"buffer",
")",
"throws",
"DBException",
"{",
"if",
"(",
"!",
"this",
".",
"atCurrent",
"(",
"buffer",
")",
")",
"{",
"buffer",
"=",
"this",
".",
"... | Delete the key from this buffer.
@param table The basetable.
@param keyArea The basetable's key area.
@param buffer The buffer to compare.
@exception DBException File exception. | [
"Delete",
"the",
"key",
"from",
"this",
"buffer",
"."
] | train | https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/mem/base/PKeyArea.java#L102-L111 |
FlyingHe/UtilsMaven | src/main/java/com/github/flyinghe/tools/DBUtils.java | DBUtils.get | public static <T> T get(Class<T> clazz, String sql, Object... arg) {
List<T> list = DBUtils.getList(clazz, sql, arg);
if (list.isEmpty()) {
return null;
}
return list.get(0);
} | java | public static <T> T get(Class<T> clazz, String sql, Object... arg) {
List<T> list = DBUtils.getList(clazz, sql, arg);
if (list.isEmpty()) {
return null;
}
return list.get(0);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"get",
"(",
"Class",
"<",
"T",
">",
"clazz",
",",
"String",
"sql",
",",
"Object",
"...",
"arg",
")",
"{",
"List",
"<",
"T",
">",
"list",
"=",
"DBUtils",
".",
"getList",
"(",
"clazz",
",",
"sql",
",",
"arg... | 本函数所查找的结果只能返回一条记录,若查找到的多条记录符合要求将返回第一条符合要求的记录
@param clazz 需要查找的对象的所属类的一个类(Class)
@param sql 只能是SELECT语句,SQL语句中的字段别名必须与T类里的相应字段相同
@param arg SQL语句中的参数占位符参数
@return 将查找到的的记录包装成一个对象,并返回该对象,若没有记录则返回null | [
"本函数所查找的结果只能返回一条记录,若查找到的多条记录符合要求将返回第一条符合要求的记录"
] | train | https://github.com/FlyingHe/UtilsMaven/blob/d9605b7bfe0c28a05289252e12d163e114080b4a/src/main/java/com/github/flyinghe/tools/DBUtils.java#L263-L269 |
VoltDB/voltdb | src/frontend/org/voltdb/VoltDB.java | VoltDB.crashGlobalVoltDB | public static void crashGlobalVoltDB(String errMsg, boolean stackTrace, Throwable t) {
// for test code
wasCrashCalled = true;
crashMessage = errMsg;
if (ignoreCrash) {
throw new AssertionError("Faux crash of VoltDB successful.");
}
// end test code
// send a snmp trap crash notification
sendCrashSNMPTrap(errMsg);
try {
// turn off client interface as fast as possible
// we don't expect this to ever fail, but if it does, skip to dying immediately
if (!turnOffClientInterface()) {
return; // this will jump to the finally block and die faster
}
// instruct the rest of the cluster to die
instance().getHostMessenger().sendPoisonPill(errMsg);
// give the pill a chance to make it through the network buffer
Thread.sleep(500);
} catch (Exception e) {
e.printStackTrace();
// sleep even on exception in case the pill got sent before the exception
try { Thread.sleep(500); } catch (InterruptedException e2) {}
}
// finally block does its best to ensure death, no matter what context this
// is called in
finally {
crashLocalVoltDB(errMsg, stackTrace, t);
}
} | java | public static void crashGlobalVoltDB(String errMsg, boolean stackTrace, Throwable t) {
// for test code
wasCrashCalled = true;
crashMessage = errMsg;
if (ignoreCrash) {
throw new AssertionError("Faux crash of VoltDB successful.");
}
// end test code
// send a snmp trap crash notification
sendCrashSNMPTrap(errMsg);
try {
// turn off client interface as fast as possible
// we don't expect this to ever fail, but if it does, skip to dying immediately
if (!turnOffClientInterface()) {
return; // this will jump to the finally block and die faster
}
// instruct the rest of the cluster to die
instance().getHostMessenger().sendPoisonPill(errMsg);
// give the pill a chance to make it through the network buffer
Thread.sleep(500);
} catch (Exception e) {
e.printStackTrace();
// sleep even on exception in case the pill got sent before the exception
try { Thread.sleep(500); } catch (InterruptedException e2) {}
}
// finally block does its best to ensure death, no matter what context this
// is called in
finally {
crashLocalVoltDB(errMsg, stackTrace, t);
}
} | [
"public",
"static",
"void",
"crashGlobalVoltDB",
"(",
"String",
"errMsg",
",",
"boolean",
"stackTrace",
",",
"Throwable",
"t",
")",
"{",
"// for test code",
"wasCrashCalled",
"=",
"true",
";",
"crashMessage",
"=",
"errMsg",
";",
"if",
"(",
"ignoreCrash",
")",
... | Exit the process with an error message, optionally with a stack trace.
Also notify all connected peers that the node is going down. | [
"Exit",
"the",
"process",
"with",
"an",
"error",
"message",
"optionally",
"with",
"a",
"stack",
"trace",
".",
"Also",
"notify",
"all",
"connected",
"peers",
"that",
"the",
"node",
"is",
"going",
"down",
"."
] | train | https://github.com/VoltDB/voltdb/blob/8afc1031e475835344b5497ea9e7203bc95475ac/src/frontend/org/voltdb/VoltDB.java#L1416-L1447 |
ontop/ontop | core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java | OntologyBuilderImpl.createDataPropertyAssertion | public static DataPropertyAssertion createDataPropertyAssertion(DataPropertyExpression dpe, ObjectConstant o1, ValueConstant o2) throws InconsistentOntologyException {
if (dpe.isTop())
return null;
if (dpe.isBottom())
throw new InconsistentOntologyException();
return new DataPropertyAssertionImpl(dpe, o1, o2);
} | java | public static DataPropertyAssertion createDataPropertyAssertion(DataPropertyExpression dpe, ObjectConstant o1, ValueConstant o2) throws InconsistentOntologyException {
if (dpe.isTop())
return null;
if (dpe.isBottom())
throw new InconsistentOntologyException();
return new DataPropertyAssertionImpl(dpe, o1, o2);
} | [
"public",
"static",
"DataPropertyAssertion",
"createDataPropertyAssertion",
"(",
"DataPropertyExpression",
"dpe",
",",
"ObjectConstant",
"o1",
",",
"ValueConstant",
"o2",
")",
"throws",
"InconsistentOntologyException",
"{",
"if",
"(",
"dpe",
".",
"isTop",
"(",
")",
")... | Creates a data property assertion
<p>
DataPropertyAssertion := 'DataPropertyAssertion' '(' axiomAnnotations
DataPropertyExpression sourceIndividual targetValue ')'
<p>
Implements rule [D4]:
- ignore (return null) if the property is top
- inconsistency if the property is bot | [
"Creates",
"a",
"data",
"property",
"assertion",
"<p",
">",
"DataPropertyAssertion",
":",
"=",
"DataPropertyAssertion",
"(",
"axiomAnnotations",
"DataPropertyExpression",
"sourceIndividual",
"targetValue",
")",
"<p",
">",
"Implements",
"rule",
"[",
"D4",
"]",
":",
"... | train | https://github.com/ontop/ontop/blob/ddf78b26981b6129ee9a1a59310016830f5352e4/core/obda/src/main/java/it/unibz/inf/ontop/spec/ontology/impl/OntologyBuilderImpl.java#L480-L487 |
pf4j/pf4j | pf4j/src/main/java/org/pf4j/util/DirectedGraph.java | DirectedGraph.removeEdge | public void removeEdge(V from, V to) {
if (!containsVertex(from)) {
throw new IllegalArgumentException("Nonexistent vertex " + from);
}
if (!containsVertex(to)) {
throw new IllegalArgumentException("Nonexistent vertex " + to);
}
neighbors.get(from).remove(to);
} | java | public void removeEdge(V from, V to) {
if (!containsVertex(from)) {
throw new IllegalArgumentException("Nonexistent vertex " + from);
}
if (!containsVertex(to)) {
throw new IllegalArgumentException("Nonexistent vertex " + to);
}
neighbors.get(from).remove(to);
} | [
"public",
"void",
"removeEdge",
"(",
"V",
"from",
",",
"V",
"to",
")",
"{",
"if",
"(",
"!",
"containsVertex",
"(",
"from",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Nonexistent vertex \"",
"+",
"from",
")",
";",
"}",
"if",
"(",
... | Remove an edge from the graph. Nothing happens if no such edge.
@throws {@link IllegalArgumentException} if either vertex doesn't exist. | [
"Remove",
"an",
"edge",
"from",
"the",
"graph",
".",
"Nothing",
"happens",
"if",
"no",
"such",
"edge",
"."
] | train | https://github.com/pf4j/pf4j/blob/6dd7a6069f0e2fbd842c81e2c8c388918b88ea81/pf4j/src/main/java/org/pf4j/util/DirectedGraph.java#L75-L85 |
Waikato/moa | moa/src/main/java/moa/clusterers/dstream/CharacteristicVector.java | CharacteristicVector.updateGridDensity | public void updateGridDensity(int currTime, double decayFactor, double dl, double dm)
{
// record the last attribute
int lastAtt = this.getAttribute();
// Update the density grid's density
double densityOfG = (Math.pow(decayFactor, (currTime-this.getDensityTimeStamp())) * this.getGridDensity());
this.setGridDensity(densityOfG, currTime);
// Evaluate whether or not the density grid is now SPARSE, DENSE or TRANSITIONAL
if (this.isSparse(dl))
this.attribute = SPARSE;
else if (this.isDense(dm))
this.attribute = DENSE;
else
this.attribute = TRANSITIONAL;
// Evaluate whether or not the density grid attribute has changed and set the attChange flag accordingly
if (this.getAttribute() == lastAtt)
this.attChange = false;
else
this.attChange = true;
} | java | public void updateGridDensity(int currTime, double decayFactor, double dl, double dm)
{
// record the last attribute
int lastAtt = this.getAttribute();
// Update the density grid's density
double densityOfG = (Math.pow(decayFactor, (currTime-this.getDensityTimeStamp())) * this.getGridDensity());
this.setGridDensity(densityOfG, currTime);
// Evaluate whether or not the density grid is now SPARSE, DENSE or TRANSITIONAL
if (this.isSparse(dl))
this.attribute = SPARSE;
else if (this.isDense(dm))
this.attribute = DENSE;
else
this.attribute = TRANSITIONAL;
// Evaluate whether or not the density grid attribute has changed and set the attChange flag accordingly
if (this.getAttribute() == lastAtt)
this.attChange = false;
else
this.attChange = true;
} | [
"public",
"void",
"updateGridDensity",
"(",
"int",
"currTime",
",",
"double",
"decayFactor",
",",
"double",
"dl",
",",
"double",
"dm",
")",
"{",
"// record the last attribute",
"int",
"lastAtt",
"=",
"this",
".",
"getAttribute",
"(",
")",
";",
"// Update the den... | Implements the update the density of all grids step given at line 2 of
both Fig 3 and Fig 4 of Chen and Tu 2007.
@param currTime the data stream's current internal time
@param decayFactor the value of lambda
@param dl the threshold for sparse grids
@param dm the threshold for dense grids
@param addRecord TRUE if a record has been added to the density grid, FALSE otherwise | [
"Implements",
"the",
"update",
"the",
"density",
"of",
"all",
"grids",
"step",
"given",
"at",
"line",
"2",
"of",
"both",
"Fig",
"3",
"and",
"Fig",
"4",
"of",
"Chen",
"and",
"Tu",
"2007",
"."
] | train | https://github.com/Waikato/moa/blob/395982e5100bfe75a3a4d26115462ce2cc74cbb0/moa/src/main/java/moa/clusterers/dstream/CharacteristicVector.java#L235-L258 |
roboconf/roboconf-platform | miscellaneous/roboconf-swagger/src/main/java/net/roboconf/swagger/UpdateSwaggerJson.java | UpdateSwaggerJson.convertToTypes | public void convertToTypes( String serialization, Class<?> clazz, JsonObject newDef ) {
convertToTypes( serialization, clazz.getSimpleName(), newDef );
this.processedClasses.add( clazz );
} | java | public void convertToTypes( String serialization, Class<?> clazz, JsonObject newDef ) {
convertToTypes( serialization, clazz.getSimpleName(), newDef );
this.processedClasses.add( clazz );
} | [
"public",
"void",
"convertToTypes",
"(",
"String",
"serialization",
",",
"Class",
"<",
"?",
">",
"clazz",
",",
"JsonObject",
"newDef",
")",
"{",
"convertToTypes",
"(",
"serialization",
",",
"clazz",
".",
"getSimpleName",
"(",
")",
",",
"newDef",
")",
";",
... | Creates a JSon object from a serialization result.
@param serialization the serialization result
@param clazz the class for which this serialization was made
@param newDef the new definition object to update | [
"Creates",
"a",
"JSon",
"object",
"from",
"a",
"serialization",
"result",
"."
] | train | https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-swagger/src/main/java/net/roboconf/swagger/UpdateSwaggerJson.java#L295-L298 |
ocelotds/ocelot | ocelot-processor/src/main/java/org/ocelotds/frameworks/angularjs/FunctionWriter.java | FunctionWriter.writeDependencies | void writeDependencies(Writer writer, String deco, String... dependencies) throws IOException {
boolean first = true;
for (String dependency : dependencies) {
if (!first) {
writer.append(COMMA).append(SPACEOPTIONAL);
}
writer.append(deco).append(dependency).append(deco);
first = false;
}
} | java | void writeDependencies(Writer writer, String deco, String... dependencies) throws IOException {
boolean first = true;
for (String dependency : dependencies) {
if (!first) {
writer.append(COMMA).append(SPACEOPTIONAL);
}
writer.append(deco).append(dependency).append(deco);
first = false;
}
} | [
"void",
"writeDependencies",
"(",
"Writer",
"writer",
",",
"String",
"deco",
",",
"String",
"...",
"dependencies",
")",
"throws",
"IOException",
"{",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"String",
"dependency",
":",
"dependencies",
")",
"{",
"if... | dep1, dep2 or if deco = "'" 'dep1', 'dep2'
@param writer
@param deco
@param dependencies
@throws IOException | [
"dep1",
"dep2",
"or",
"if",
"deco",
"=",
"dep1",
"dep2"
] | train | https://github.com/ocelotds/ocelot/blob/5f0ac37afd8fa4dc9f7234a2aac8abbb522128e7/ocelot-processor/src/main/java/org/ocelotds/frameworks/angularjs/FunctionWriter.java#L39-L48 |
TheHortonMachine/hortonmachine | gears/src/main/java/org/hortonmachine/gears/utils/style/StyleUtilities.java | StyleUtilities.readStyle | public static StyledLayerDescriptor readStyle( File file ) throws IOException {
SLDParser stylereader = new SLDParser(sf, file);
StyledLayerDescriptor sld = stylereader.parseSLD();
return sld;
} | java | public static StyledLayerDescriptor readStyle( File file ) throws IOException {
SLDParser stylereader = new SLDParser(sf, file);
StyledLayerDescriptor sld = stylereader.parseSLD();
return sld;
} | [
"public",
"static",
"StyledLayerDescriptor",
"readStyle",
"(",
"File",
"file",
")",
"throws",
"IOException",
"{",
"SLDParser",
"stylereader",
"=",
"new",
"SLDParser",
"(",
"sf",
",",
"file",
")",
";",
"StyledLayerDescriptor",
"sld",
"=",
"stylereader",
".",
"par... | Parse a file and extract the {@link StyledLayerDescriptor}.
@param file the sld file to parse.
@return the styled layer descriptor.
@throws IOException | [
"Parse",
"a",
"file",
"and",
"extract",
"the",
"{",
"@link",
"StyledLayerDescriptor",
"}",
"."
] | train | https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/utils/style/StyleUtilities.java#L245-L249 |
b3dgs/lionengine | lionengine-network/src/main/java/com/b3dgs/lionengine/network/ServerImpl.java | ServerImpl.checkValidity | private static boolean checkValidity(ClientSocket client, byte from, StateConnection expected)
{
return from >= 0 && client.getState() == expected;
} | java | private static boolean checkValidity(ClientSocket client, byte from, StateConnection expected)
{
return from >= 0 && client.getState() == expected;
} | [
"private",
"static",
"boolean",
"checkValidity",
"(",
"ClientSocket",
"client",
",",
"byte",
"from",
",",
"StateConnection",
"expected",
")",
"{",
"return",
"from",
">=",
"0",
"&&",
"client",
".",
"getState",
"(",
")",
"==",
"expected",
";",
"}"
] | Check if the client is in a valid state.
@param client The client to test.
@param from The client id.
@param expected The expected client state.
@return <code>true</code> if valid, <code>false</code> else. | [
"Check",
"if",
"the",
"client",
"is",
"in",
"a",
"valid",
"state",
"."
] | train | https://github.com/b3dgs/lionengine/blob/cac3d5578532cf11724a737b9f09e71bf9995ab2/lionengine-network/src/main/java/com/b3dgs/lionengine/network/ServerImpl.java#L73-L76 |
puniverse/capsule | capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java | Jar.addEntries | public Jar addEntries(Path path, ZipInputStream zip, Filter filter) throws IOException {
beginWriting();
try (ZipInputStream zis = zip) {
for (ZipEntry entry; (entry = zis.getNextEntry()) != null;) {
final String target = path != null ? path.resolve(entry.getName()).toString() : entry.getName();
if (target.equals(MANIFEST_NAME))
continue;
if (filter == null || filter.filter(target))
addEntryNoClose(jos, target, zis);
}
}
return this;
} | java | public Jar addEntries(Path path, ZipInputStream zip, Filter filter) throws IOException {
beginWriting();
try (ZipInputStream zis = zip) {
for (ZipEntry entry; (entry = zis.getNextEntry()) != null;) {
final String target = path != null ? path.resolve(entry.getName()).toString() : entry.getName();
if (target.equals(MANIFEST_NAME))
continue;
if (filter == null || filter.filter(target))
addEntryNoClose(jos, target, zis);
}
}
return this;
} | [
"public",
"Jar",
"addEntries",
"(",
"Path",
"path",
",",
"ZipInputStream",
"zip",
",",
"Filter",
"filter",
")",
"throws",
"IOException",
"{",
"beginWriting",
"(",
")",
";",
"try",
"(",
"ZipInputStream",
"zis",
"=",
"zip",
")",
"{",
"for",
"(",
"ZipEntry",
... | Adds the contents of the zip/JAR contained in the given byte array to this JAR.
@param path the path within the JAR where the root of the zip will be placed, or {@code null} for the JAR's root
@param zip the contents of the zip/JAR file
@param filter a filter to select particular classes
@return {@code this} | [
"Adds",
"the",
"contents",
"of",
"the",
"zip",
"/",
"JAR",
"contained",
"in",
"the",
"given",
"byte",
"array",
"to",
"this",
"JAR",
"."
] | train | https://github.com/puniverse/capsule/blob/291a54e501a32aaf0284707b8c1fbff6a566822b/capsule-util/src/main/java/co/paralleluniverse/capsule/Jar.java#L456-L468 |
buschmais/extended-objects | impl/src/main/java/com/buschmais/xo/impl/cache/TransactionalCache.java | TransactionalCache.get | public Object get(Id id, Mode mode) {
Object value = writeCache.get(id);
if (value == null) {
value = readCache.get(new CacheKey(id));
if (value != null && Mode.WRITE.equals(mode)) {
writeCache.put(id, value);
}
}
return value;
} | java | public Object get(Id id, Mode mode) {
Object value = writeCache.get(id);
if (value == null) {
value = readCache.get(new CacheKey(id));
if (value != null && Mode.WRITE.equals(mode)) {
writeCache.put(id, value);
}
}
return value;
} | [
"public",
"Object",
"get",
"(",
"Id",
"id",
",",
"Mode",
"mode",
")",
"{",
"Object",
"value",
"=",
"writeCache",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"readCache",
".",
"get",
"(",
"new",
"Cach... | Lookup an instance in the cache identified by its id.
@param id
The id.
@param mode
The mode.
@return The corresponding instance or <code>null</code> if no instance is
available. | [
"Lookup",
"an",
"instance",
"in",
"the",
"cache",
"identified",
"by",
"its",
"id",
"."
] | train | https://github.com/buschmais/extended-objects/blob/186431e81f3d8d26c511cfe1143dee59b03c2e7a/impl/src/main/java/com/buschmais/xo/impl/cache/TransactionalCache.java#L83-L92 |
xwiki/xwiki-rendering | xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiPageUtil.java | WikiPageUtil.isValidXmlNameChar | public static boolean isValidXmlNameChar(char ch, boolean colonEnabled)
{
return isValidXmlNameStartChar(ch, colonEnabled)
|| (ch == '-')
|| (ch == '.')
|| (ch >= '0' && ch <= '9')
|| (ch == 0xB7)
|| (ch >= 0x0300 && ch <= 0x036F)
|| (ch >= 0x203F && ch <= 0x2040);
} | java | public static boolean isValidXmlNameChar(char ch, boolean colonEnabled)
{
return isValidXmlNameStartChar(ch, colonEnabled)
|| (ch == '-')
|| (ch == '.')
|| (ch >= '0' && ch <= '9')
|| (ch == 0xB7)
|| (ch >= 0x0300 && ch <= 0x036F)
|| (ch >= 0x203F && ch <= 0x2040);
} | [
"public",
"static",
"boolean",
"isValidXmlNameChar",
"(",
"char",
"ch",
",",
"boolean",
"colonEnabled",
")",
"{",
"return",
"isValidXmlNameStartChar",
"(",
"ch",
",",
"colonEnabled",
")",
"||",
"(",
"ch",
"==",
"'",
"'",
")",
"||",
"(",
"ch",
"==",
"'",
... | Returns <code>true</code> if the given value is a valid XML name
character.
<p>
See http://www.w3.org/TR/xml/#NT-NameChar.
</p>
@param ch the character to check
@param colonEnabled if this flag is <code>true</code> then this method
accepts the ':' symbol.
@return <code>true</code> if the given value is a valid XML name
character | [
"Returns",
"<code",
">",
"true<",
"/",
"code",
">",
"if",
"the",
"given",
"value",
"is",
"a",
"valid",
"XML",
"name",
"character",
".",
"<p",
">",
"See",
"http",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"TR",
"/",
"xml",
"/",
"#NT",
"-",
"... | train | https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiPageUtil.java#L267-L276 |
Azure/azure-sdk-for-java | containerregistry/resource-manager/v2017_03_01/src/main/java/com/microsoft/azure/management/containerregistry/v2017_03_01/implementation/RegistriesInner.java | RegistriesInner.regenerateCredential | public RegistryListCredentialsResultInner regenerateCredential(String resourceGroupName, String registryName, PasswordName name) {
return regenerateCredentialWithServiceResponseAsync(resourceGroupName, registryName, name).toBlocking().single().body();
} | java | public RegistryListCredentialsResultInner regenerateCredential(String resourceGroupName, String registryName, PasswordName name) {
return regenerateCredentialWithServiceResponseAsync(resourceGroupName, registryName, name).toBlocking().single().body();
} | [
"public",
"RegistryListCredentialsResultInner",
"regenerateCredential",
"(",
"String",
"resourceGroupName",
",",
"String",
"registryName",
",",
"PasswordName",
"name",
")",
"{",
"return",
"regenerateCredentialWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"registryNa... | Regenerates one of the login credentials for the specified container registry.
@param resourceGroupName The name of the resource group to which the container registry belongs.
@param registryName The name of the container registry.
@param name Specifies name of the password which should be regenerated -- password or password2. Possible values include: 'password', 'password2'
@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 RegistryListCredentialsResultInner object if successful. | [
"Regenerates",
"one",
"of",
"the",
"login",
"credentials",
"for",
"the",
"specified",
"container",
"registry",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/containerregistry/resource-manager/v2017_03_01/src/main/java/com/microsoft/azure/management/containerregistry/v2017_03_01/implementation/RegistriesInner.java#L962-L964 |
facebookarchive/hadoop-20 | src/hdfs/org/apache/hadoop/hdfs/DFSOutputStream.java | DFSOutputStream.setupPipelineForAppend | private boolean setupPipelineForAppend(LocatedBlock lastBlock) throws IOException {
if (nodes == null || nodes.length == 0) {
String msg = "Could not get block locations. " +
"Source file \"" + src
+ "\" - Aborting...";
DFSClient.LOG.warn(msg);
setLastException(new IOException(msg));
closed = true;
if (streamer != null) streamer.close();
return false;
}
boolean success = createBlockOutputStream(nodes, dfsClient.clientName, false, true);
long oldGenerationStamp =
((LocatedBlockWithOldGS)lastBlock).getOldGenerationStamp();
if (success) {
// bump up the generation stamp in NN.
Block newBlock = lastBlock.getBlock();
Block oldBlock = new Block(newBlock.getBlockId(), newBlock.getNumBytes(),
oldGenerationStamp);
dfsClient.namenode.updatePipeline(dfsClient.clientName,
oldBlock, newBlock, nodes);
} else {
DFSClient.LOG.warn("Fall back to block recovery process when trying" +
" to setup the append pipeline for file " + src);
// set the old generation stamp
block.setGenerationStamp(oldGenerationStamp);
// fall back the block recovery
while(processDatanodeError(true, true)) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
lastException = new IOException(e);
break;
}
}
}
return success;
} | java | private boolean setupPipelineForAppend(LocatedBlock lastBlock) throws IOException {
if (nodes == null || nodes.length == 0) {
String msg = "Could not get block locations. " +
"Source file \"" + src
+ "\" - Aborting...";
DFSClient.LOG.warn(msg);
setLastException(new IOException(msg));
closed = true;
if (streamer != null) streamer.close();
return false;
}
boolean success = createBlockOutputStream(nodes, dfsClient.clientName, false, true);
long oldGenerationStamp =
((LocatedBlockWithOldGS)lastBlock).getOldGenerationStamp();
if (success) {
// bump up the generation stamp in NN.
Block newBlock = lastBlock.getBlock();
Block oldBlock = new Block(newBlock.getBlockId(), newBlock.getNumBytes(),
oldGenerationStamp);
dfsClient.namenode.updatePipeline(dfsClient.clientName,
oldBlock, newBlock, nodes);
} else {
DFSClient.LOG.warn("Fall back to block recovery process when trying" +
" to setup the append pipeline for file " + src);
// set the old generation stamp
block.setGenerationStamp(oldGenerationStamp);
// fall back the block recovery
while(processDatanodeError(true, true)) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
lastException = new IOException(e);
break;
}
}
}
return success;
} | [
"private",
"boolean",
"setupPipelineForAppend",
"(",
"LocatedBlock",
"lastBlock",
")",
"throws",
"IOException",
"{",
"if",
"(",
"nodes",
"==",
"null",
"||",
"nodes",
".",
"length",
"==",
"0",
")",
"{",
"String",
"msg",
"=",
"\"Could not get block locations. \"",
... | Setup the Append pipeline, the length of current pipeline will shrink
if any datanodes are dead during the process. | [
"Setup",
"the",
"Append",
"pipeline",
"the",
"length",
"of",
"current",
"pipeline",
"will",
"shrink",
"if",
"any",
"datanodes",
"are",
"dead",
"during",
"the",
"process",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/hdfs/org/apache/hadoop/hdfs/DFSOutputStream.java#L1226-L1265 |
liferay/com-liferay-commerce | commerce-wish-list-service/src/main/java/com/liferay/commerce/wish/list/service/persistence/impl/CommerceWishListItemPersistenceImpl.java | CommerceWishListItemPersistenceImpl.removeByCW_CP | @Override
public void removeByCW_CP(long commerceWishListId, long CProductId) {
for (CommerceWishListItem commerceWishListItem : findByCW_CP(
commerceWishListId, CProductId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(commerceWishListItem);
}
} | java | @Override
public void removeByCW_CP(long commerceWishListId, long CProductId) {
for (CommerceWishListItem commerceWishListItem : findByCW_CP(
commerceWishListId, CProductId, QueryUtil.ALL_POS,
QueryUtil.ALL_POS, null)) {
remove(commerceWishListItem);
}
} | [
"@",
"Override",
"public",
"void",
"removeByCW_CP",
"(",
"long",
"commerceWishListId",
",",
"long",
"CProductId",
")",
"{",
"for",
"(",
"CommerceWishListItem",
"commerceWishListItem",
":",
"findByCW_CP",
"(",
"commerceWishListId",
",",
"CProductId",
",",
"QueryUtil",
... | Removes all the commerce wish list items where commerceWishListId = ? and CProductId = ? from the database.
@param commerceWishListId the commerce wish list ID
@param CProductId the c product ID | [
"Removes",
"all",
"the",
"commerce",
"wish",
"list",
"items",
"where",
"commerceWishListId",
"=",
"?",
";",
"and",
"CProductId",
"=",
"?",
";",
"from",
"the",
"database",
"."
] | 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/CommerceWishListItemPersistenceImpl.java#L2797-L2804 |
alkacon/opencms-core | src/org/opencms/repository/CmsRepositoryManager.java | CmsRepositoryManager.getRepository | @SuppressWarnings("unchecked")
public <REPO extends I_CmsRepository> REPO getRepository(String name, Class<REPO> cls) {
I_CmsRepository repo = getRepository(name);
if (repo == null) {
return null;
}
if (cls.isInstance(repo)) {
return (REPO)repo;
} else {
return null;
}
} | java | @SuppressWarnings("unchecked")
public <REPO extends I_CmsRepository> REPO getRepository(String name, Class<REPO> cls) {
I_CmsRepository repo = getRepository(name);
if (repo == null) {
return null;
}
if (cls.isInstance(repo)) {
return (REPO)repo;
} else {
return null;
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"REPO",
"extends",
"I_CmsRepository",
">",
"REPO",
"getRepository",
"(",
"String",
"name",
",",
"Class",
"<",
"REPO",
">",
"cls",
")",
"{",
"I_CmsRepository",
"repo",
"=",
"getRepository",
"(",... | Gets a repository by name, but only if its class is a subclass of the class passed as a parameter.<p>
Otherwise, null will be returned.<p>
@param name the repository name
@param cls the class used to filter repositories
@return the repository with the given name, or null | [
"Gets",
"a",
"repository",
"by",
"name",
"but",
"only",
"if",
"its",
"class",
"is",
"a",
"subclass",
"of",
"the",
"class",
"passed",
"as",
"a",
"parameter",
".",
"<p",
">",
"Otherwise",
"null",
"will",
"be",
"returned",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/repository/CmsRepositoryManager.java#L272-L285 |
querydsl/querydsl | querydsl-sql/src/main/java/com/querydsl/sql/mysql/MySQLQueryFactory.java | MySQLQueryFactory.insertOnDuplicateKeyUpdate | public SQLInsertClause insertOnDuplicateKeyUpdate(RelationalPath<?> entity, Expression<?> clause) {
SQLInsertClause insert = insert(entity);
insert.addFlag(Position.END, ExpressionUtils.template(String.class, " on duplicate key update {0}", clause));
return insert;
} | java | public SQLInsertClause insertOnDuplicateKeyUpdate(RelationalPath<?> entity, Expression<?> clause) {
SQLInsertClause insert = insert(entity);
insert.addFlag(Position.END, ExpressionUtils.template(String.class, " on duplicate key update {0}", clause));
return insert;
} | [
"public",
"SQLInsertClause",
"insertOnDuplicateKeyUpdate",
"(",
"RelationalPath",
"<",
"?",
">",
"entity",
",",
"Expression",
"<",
"?",
">",
"clause",
")",
"{",
"SQLInsertClause",
"insert",
"=",
"insert",
"(",
"entity",
")",
";",
"insert",
".",
"addFlag",
"(",... | Create a INSERT ... ON DUPLICATE KEY UPDATE clause
@param entity table to insert to
@param clause clause
@return insert clause | [
"Create",
"a",
"INSERT",
"...",
"ON",
"DUPLICATE",
"KEY",
"UPDATE",
"clause"
] | train | https://github.com/querydsl/querydsl/blob/2bf234caf78549813a1e0f44d9c30ecc5ef734e3/querydsl-sql/src/main/java/com/querydsl/sql/mysql/MySQLQueryFactory.java#L80-L84 |
spockframework/spock | spock-core/src/main/java/spock/util/environment/OperatingSystem.java | OperatingSystem.getCurrent | public static OperatingSystem getCurrent() {
String name = System.getProperty("os.name");
String version = System.getProperty("os.version");
String lowerName = name.toLowerCase();
if (lowerName.contains("linux")) return new OperatingSystem(name, version, Family.LINUX);
if (lowerName.contains("mac os") || lowerName.contains("darwin")) return new OperatingSystem(name, version, Family.MAC_OS);
if (lowerName.contains("windows")) return new OperatingSystem(name, version, Family.WINDOWS);
if (lowerName.contains("sunos")) return new OperatingSystem(name, version, Family.SOLARIS);
return new OperatingSystem(name, version, Family.OTHER);
} | java | public static OperatingSystem getCurrent() {
String name = System.getProperty("os.name");
String version = System.getProperty("os.version");
String lowerName = name.toLowerCase();
if (lowerName.contains("linux")) return new OperatingSystem(name, version, Family.LINUX);
if (lowerName.contains("mac os") || lowerName.contains("darwin")) return new OperatingSystem(name, version, Family.MAC_OS);
if (lowerName.contains("windows")) return new OperatingSystem(name, version, Family.WINDOWS);
if (lowerName.contains("sunos")) return new OperatingSystem(name, version, Family.SOLARIS);
return new OperatingSystem(name, version, Family.OTHER);
} | [
"public",
"static",
"OperatingSystem",
"getCurrent",
"(",
")",
"{",
"String",
"name",
"=",
"System",
".",
"getProperty",
"(",
"\"os.name\"",
")",
";",
"String",
"version",
"=",
"System",
".",
"getProperty",
"(",
"\"os.version\"",
")",
";",
"String",
"lowerName... | Returns the current operating system.
@return the current operating system | [
"Returns",
"the",
"current",
"operating",
"system",
"."
] | train | https://github.com/spockframework/spock/blob/d751a0abd8d5a2ec5338aa10bc2d19371b3b3ad9/spock-core/src/main/java/spock/util/environment/OperatingSystem.java#L140-L149 |
code4everything/util | src/main/java/com/zhazhapan/util/encryption/SimpleEncrypt.java | SimpleEncrypt.xor | public static String xor(String string, int key) {
char[] encrypt = string.toCharArray();
for (int i = 0; i < encrypt.length; i++) {
encrypt[i] = (char) (encrypt[i] ^ key);
}
return new String(encrypt);
} | java | public static String xor(String string, int key) {
char[] encrypt = string.toCharArray();
for (int i = 0; i < encrypt.length; i++) {
encrypt[i] = (char) (encrypt[i] ^ key);
}
return new String(encrypt);
} | [
"public",
"static",
"String",
"xor",
"(",
"String",
"string",
",",
"int",
"key",
")",
"{",
"char",
"[",
"]",
"encrypt",
"=",
"string",
".",
"toCharArray",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"encrypt",
".",
"length",
"... | 异或加密
@param string {@link String}
@param key {@link Integer}
@return {@link String} | [
"异或加密"
] | train | https://github.com/code4everything/util/blob/1fc9f0ead1108f4d7208ba7c000df4244f708418/src/main/java/com/zhazhapan/util/encryption/SimpleEncrypt.java#L32-L38 |
UrielCh/ovh-java-sdk | ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java | ApiOvhTelephony.billingAccount_fax_serviceName_campaigns_id_detail_GET | public OvhFaxCampaignDetail billingAccount_fax_serviceName_campaigns_id_detail_GET(String billingAccount, String serviceName, Long id) throws IOException {
String qPath = "/telephony/{billingAccount}/fax/{serviceName}/campaigns/{id}/detail";
StringBuilder sb = path(qPath, billingAccount, serviceName, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFaxCampaignDetail.class);
} | java | public OvhFaxCampaignDetail billingAccount_fax_serviceName_campaigns_id_detail_GET(String billingAccount, String serviceName, Long id) throws IOException {
String qPath = "/telephony/{billingAccount}/fax/{serviceName}/campaigns/{id}/detail";
StringBuilder sb = path(qPath, billingAccount, serviceName, id);
String resp = exec(qPath, "GET", sb.toString(), null);
return convertTo(resp, OvhFaxCampaignDetail.class);
} | [
"public",
"OvhFaxCampaignDetail",
"billingAccount_fax_serviceName_campaigns_id_detail_GET",
"(",
"String",
"billingAccount",
",",
"String",
"serviceName",
",",
"Long",
"id",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/telephony/{billingAccount}/fax/{serviceNa... | Detail of the fax recipients by status
REST: GET /telephony/{billingAccount}/fax/{serviceName}/campaigns/{id}/detail
@param billingAccount [required] The name of your billingAccount
@param serviceName [required]
@param id [required] Id of the object | [
"Detail",
"of",
"the",
"fax",
"recipients",
"by",
"status"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-telephony/src/main/java/net/minidev/ovh/api/ApiOvhTelephony.java#L4335-L4340 |
unbescape/unbescape | src/main/java/org/unbescape/xml/XmlEscape.java | XmlEscape.escapeXml11 | public static void escapeXml11(final String text, final Writer writer, final XmlEscapeType type, final XmlEscapeLevel level)
throws IOException {
escapeXml(text, writer, XmlEscapeSymbols.XML11_SYMBOLS, type, level);
} | java | public static void escapeXml11(final String text, final Writer writer, final XmlEscapeType type, final XmlEscapeLevel level)
throws IOException {
escapeXml(text, writer, XmlEscapeSymbols.XML11_SYMBOLS, type, level);
} | [
"public",
"static",
"void",
"escapeXml11",
"(",
"final",
"String",
"text",
",",
"final",
"Writer",
"writer",
",",
"final",
"XmlEscapeType",
"type",
",",
"final",
"XmlEscapeLevel",
"level",
")",
"throws",
"IOException",
"{",
"escapeXml",
"(",
"text",
",",
"writ... | <p>
Perform a (configurable) XML 1.1 <strong>escape</strong> operation on a <tt>String</tt> input,
writing results to a <tt>Writer</tt>.
</p>
<p>
This method will perform an escape operation according to the specified
{@link org.unbescape.xml.XmlEscapeType} and {@link org.unbescape.xml.XmlEscapeLevel}
argument values.
</p>
<p>
All other <tt>String</tt>/<tt>Writer</tt>-based <tt>escapeXml11*(...)</tt> methods call this one with preconfigured
<tt>type</tt> and <tt>level</tt> values.
</p>
<p>
This method is <strong>thread-safe</strong>.
</p>
@param text the <tt>String</tt> to be escaped.
@param type the type of escape operation to be performed, see {@link org.unbescape.xml.XmlEscapeType}.
@param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing will
be written at all to this writer if input is <tt>null</tt>.
@param level the escape level to be applied, see {@link org.unbescape.xml.XmlEscapeLevel}.
@throws IOException if an input/output exception occurs
@since 1.1.2 | [
"<p",
">",
"Perform",
"a",
"(",
"configurable",
")",
"XML",
"1",
".",
"1",
"<strong",
">",
"escape<",
"/",
"strong",
">",
"operation",
"on",
"a",
"<tt",
">",
"String<",
"/",
"tt",
">",
"input",
"writing",
"results",
"to",
"a",
"<tt",
">",
"Writer<",
... | train | https://github.com/unbescape/unbescape/blob/ec5435fb3508c2eed25d8165dc27ded2602cae13/src/main/java/org/unbescape/xml/XmlEscape.java#L1088-L1091 |
OpenLiberty/open-liberty | dev/com.ibm.ws.classloading/src/com/ibm/ws/classloading/internal/util/CanonicalStore.java | CanonicalStore.retrieveOrCreate | public V retrieveOrCreate(K key, Factory<V> factory) {
// Clean up stale entries on every put.
// This should avoid a slow memory leak of reference objects.
this.cleanUpStaleEntries();
return retrieveOrCreate(key, factory, new FutureRef<V>());
} | java | public V retrieveOrCreate(K key, Factory<V> factory) {
// Clean up stale entries on every put.
// This should avoid a slow memory leak of reference objects.
this.cleanUpStaleEntries();
return retrieveOrCreate(key, factory, new FutureRef<V>());
} | [
"public",
"V",
"retrieveOrCreate",
"(",
"K",
"key",
",",
"Factory",
"<",
"V",
">",
"factory",
")",
"{",
"// Clean up stale entries on every put.",
"// This should avoid a slow memory leak of reference objects.",
"this",
".",
"cleanUpStaleEntries",
"(",
")",
";",
"return",... | Create a value for the given key iff one has not already been stored.
This method is safe to be called concurrently from multiple threads.
It will ensure that only one thread succeeds to create the value for the given key.
@return the created/retrieved {@link AppClassLoader} | [
"Create",
"a",
"value",
"for",
"the",
"given",
"key",
"iff",
"one",
"has",
"not",
"already",
"been",
"stored",
".",
"This",
"method",
"is",
"safe",
"to",
"be",
"called",
"concurrently",
"from",
"multiple",
"threads",
".",
"It",
"will",
"ensure",
"that",
... | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.classloading/src/com/ibm/ws/classloading/internal/util/CanonicalStore.java#L70-L75 |
osmdroid/osmdroid | osmdroid-android/src/main/java/org/osmdroid/views/overlay/ClickableIconOverlay.java | ClickableIconOverlay.onLongPress | public boolean onLongPress(final MotionEvent event, final MapView mapView) {
boolean touched = hitTest(event, mapView);
if (touched) {
return onMarkerLongPress(mapView, mId, mPosition, mData);
} else {
return super.onLongPress(event, mapView);
}
} | java | public boolean onLongPress(final MotionEvent event, final MapView mapView) {
boolean touched = hitTest(event, mapView);
if (touched) {
return onMarkerLongPress(mapView, mId, mPosition, mData);
} else {
return super.onLongPress(event, mapView);
}
} | [
"public",
"boolean",
"onLongPress",
"(",
"final",
"MotionEvent",
"event",
",",
"final",
"MapView",
"mapView",
")",
"{",
"boolean",
"touched",
"=",
"hitTest",
"(",
"event",
",",
"mapView",
")",
";",
"if",
"(",
"touched",
")",
"{",
"return",
"onMarkerLongPress... | By default does nothing ({@code return false}). If you handled the Event, return {@code true}
, otherwise return {@code false}. If you returned {@code true} none of the following Overlays
or the underlying {@link MapView} has the chance to handle this event. | [
"By",
"default",
"does",
"nothing",
"(",
"{"
] | train | https://github.com/osmdroid/osmdroid/blob/3b178b2f078497dd88c137110e87aafe45ad2b16/osmdroid-android/src/main/java/org/osmdroid/views/overlay/ClickableIconOverlay.java#L87-L94 |
StripesFramework/stripes-stuff | src/main/java/org/stripesstuff/plugin/security/J2EESecurityManager.java | J2EESecurityManager.isUserAuthenticated | protected Boolean isUserAuthenticated(ActionBean bean, Method handler)
{
return bean.getContext().getRequest().getUserPrincipal() != null;
} | java | protected Boolean isUserAuthenticated(ActionBean bean, Method handler)
{
return bean.getContext().getRequest().getUserPrincipal() != null;
} | [
"protected",
"Boolean",
"isUserAuthenticated",
"(",
"ActionBean",
"bean",
",",
"Method",
"handler",
")",
"{",
"return",
"bean",
".",
"getContext",
"(",
")",
".",
"getRequest",
"(",
")",
".",
"getUserPrincipal",
"(",
")",
"!=",
"null",
";",
"}"
] | Determine if the user is authenticated. The default implementation is to use {@code getUserPrincipal() != null}
on the HttpServletRequest in the ActionBeanContext.
@param bean the current action bean; used for security decisions
@param handler the current event handler; used for security decisions
@return {@link Boolean#TRUE TRUE} if the user is authenticated, {@link Boolean#FALSE FALSE} if not, and {@code null} if undecided | [
"Determine",
"if",
"the",
"user",
"is",
"authenticated",
".",
"The",
"default",
"implementation",
"is",
"to",
"use",
"{",
"@code",
"getUserPrincipal",
"()",
"!",
"=",
"null",
"}",
"on",
"the",
"HttpServletRequest",
"in",
"the",
"ActionBeanContext",
"."
] | train | https://github.com/StripesFramework/stripes-stuff/blob/51ad92b4bd5862ba34d7c18c5829fb00ea3a3811/src/main/java/org/stripesstuff/plugin/security/J2EESecurityManager.java#L149-L152 |
OpenLiberty/open-liberty | dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/StatefulBeanO.java | StatefulBeanO.updateFailoverEntry | public void updateFailoverEntry(byte[] beanData, long lastAccessTime) throws RemoteException //LIDB2018
{
try {
// Note, updating failover entry for a SFSB only occurs when
// the bean is passivated. Therefore, the updateEntry
// method implicitly sets the passivated flag in reaper.
ivSfFailoverClient.passivated(beanId, beanData, lastAccessTime); //d204278.2
} catch (Exception e) {
FFDCFilter.processException(e, CLASS_NAME + ".updateFailoverEntry", "1137", this);
throw new RemoteException("Could not update SFSB Entry", e);
}
} | java | public void updateFailoverEntry(byte[] beanData, long lastAccessTime) throws RemoteException //LIDB2018
{
try {
// Note, updating failover entry for a SFSB only occurs when
// the bean is passivated. Therefore, the updateEntry
// method implicitly sets the passivated flag in reaper.
ivSfFailoverClient.passivated(beanId, beanData, lastAccessTime); //d204278.2
} catch (Exception e) {
FFDCFilter.processException(e, CLASS_NAME + ".updateFailoverEntry", "1137", this);
throw new RemoteException("Could not update SFSB Entry", e);
}
} | [
"public",
"void",
"updateFailoverEntry",
"(",
"byte",
"[",
"]",
"beanData",
",",
"long",
"lastAccessTime",
")",
"throws",
"RemoteException",
"//LIDB2018",
"{",
"try",
"{",
"// Note, updating failover entry for a SFSB only occurs when",
"// the bean is passivated. Therefore, th... | Update failover entry for this SFSB with the replicated data for this SFSB
and indicate SFSB status is passivated.
@param beanData is the replicated data for this SFSB.
@param lastAccessTime is the last access time for this SFSB. | [
"Update",
"failover",
"entry",
"for",
"this",
"SFSB",
"with",
"the",
"replicated",
"data",
"for",
"this",
"SFSB",
"and",
"indicate",
"SFSB",
"status",
"is",
"passivated",
"."
] | train | https://github.com/OpenLiberty/open-liberty/blob/ca725d9903e63645018f9fa8cbda25f60af83a5d/dev/com.ibm.ws.ejbcontainer.core/src/com/ibm/ejs/container/StatefulBeanO.java#L1718-L1729 |
FedericoPecora/meta-csp-framework | src/main/java/org/metacsp/multi/spatioTemporal/paths/TrajectoryEnvelope.java | TrajectoryEnvelope.setTrajectory | public void setTrajectory(Trajectory traj) {
if (this.footprint == null) {
throw new NoFootprintException("No footprint set for " + this + ", please specify one before setting the trajecotry.");
}
else{
createOuterEnvelope(traj);
}
if(this.innerFootprint != null){
createInnerEnvelope(traj);
}
} | java | public void setTrajectory(Trajectory traj) {
if (this.footprint == null) {
throw new NoFootprintException("No footprint set for " + this + ", please specify one before setting the trajecotry.");
}
else{
createOuterEnvelope(traj);
}
if(this.innerFootprint != null){
createInnerEnvelope(traj);
}
} | [
"public",
"void",
"setTrajectory",
"(",
"Trajectory",
"traj",
")",
"{",
"if",
"(",
"this",
".",
"footprint",
"==",
"null",
")",
"{",
"throw",
"new",
"NoFootprintException",
"(",
"\"No footprint set for \"",
"+",
"this",
"+",
"\", please specify one before setting th... | Set the {@link Trajectory} of this {@link TrajectoryEnvelope}.
@param traj The {@link Trajectory} of this {@link TrajectoryEnvelope}. | [
"Set",
"the",
"{"
] | train | https://github.com/FedericoPecora/meta-csp-framework/blob/42aaef2e2b76d0f738427f0dd9653c4f62b40517/src/main/java/org/metacsp/multi/spatioTemporal/paths/TrajectoryEnvelope.java#L761-L772 |
pgjdbc/pgjdbc | pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions.java | EscapedFunctions.sqlcurdate | public static String sqlcurdate(List<?> parsedArgs) throws SQLException {
if (!parsedArgs.isEmpty()) {
throw new PSQLException(GT.tr("{0} function doesn''t take any argument.", "curdate"),
PSQLState.SYNTAX_ERROR);
}
return "current_date";
} | java | public static String sqlcurdate(List<?> parsedArgs) throws SQLException {
if (!parsedArgs.isEmpty()) {
throw new PSQLException(GT.tr("{0} function doesn''t take any argument.", "curdate"),
PSQLState.SYNTAX_ERROR);
}
return "current_date";
} | [
"public",
"static",
"String",
"sqlcurdate",
"(",
"List",
"<",
"?",
">",
"parsedArgs",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"!",
"parsedArgs",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"PSQLException",
"(",
"GT",
".",
"tr",
"(",
"\"{... | curdate to current_date translation.
@param parsedArgs arguments
@return sql call
@throws SQLException if something wrong happens | [
"curdate",
"to",
"current_date",
"translation",
"."
] | train | https://github.com/pgjdbc/pgjdbc/blob/95ba7b261e39754674c5817695ae5ebf9a341fae/pgjdbc/src/main/java/org/postgresql/jdbc/EscapedFunctions.java#L407-L413 |
haraldk/TwelveMonkeys | imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTUtil.java | PICTUtil.readRGBColor | public static Color readRGBColor(final DataInput pStream) throws IOException {
short r = pStream.readShort();
short g = pStream.readShort();
short b = pStream.readShort();
return new RGBColor(r, g, b);
} | java | public static Color readRGBColor(final DataInput pStream) throws IOException {
short r = pStream.readShort();
short g = pStream.readShort();
short b = pStream.readShort();
return new RGBColor(r, g, b);
} | [
"public",
"static",
"Color",
"readRGBColor",
"(",
"final",
"DataInput",
"pStream",
")",
"throws",
"IOException",
"{",
"short",
"r",
"=",
"pStream",
".",
"readShort",
"(",
")",
";",
"short",
"g",
"=",
"pStream",
".",
"readShort",
"(",
")",
";",
"short",
"... | /*
http://developer.apple.com/DOCUMENTATION/mac/QuickDraw/QuickDraw-269.html#HEADING269-11
RGBColor =
RECORD
red: Integer; {red component}
green: Integer; {green component}
blue: Integer; {blue component}
END; | [
"/",
"*",
"http",
":",
"//",
"developer",
".",
"apple",
".",
"com",
"/",
"DOCUMENTATION",
"/",
"mac",
"/",
"QuickDraw",
"/",
"QuickDraw",
"-",
"269",
".",
"html#HEADING269",
"-",
"11",
"RGBColor",
"=",
"RECORD",
"red",
":",
"Integer",
";",
"{",
"red",
... | train | https://github.com/haraldk/TwelveMonkeys/blob/7fad4d5cd8cb3a6728c7fd3f28a7b84d8ce0101d/imageio/imageio-pict/src/main/java/com/twelvemonkeys/imageio/plugins/pict/PICTUtil.java#L223-L229 |
aragozin/jvm-tools | mxdump/src/main/java/org/gridkit/jvmtool/jackson/JsonGenerator.java | JsonGenerator.configure | public JsonGenerator configure(Feature f, boolean state)
{
if (state) {
enable(f);
} else {
disable(f);
}
return this;
} | java | public JsonGenerator configure(Feature f, boolean state)
{
if (state) {
enable(f);
} else {
disable(f);
}
return this;
} | [
"public",
"JsonGenerator",
"configure",
"(",
"Feature",
"f",
",",
"boolean",
"state",
")",
"{",
"if",
"(",
"state",
")",
"{",
"enable",
"(",
"f",
")",
";",
"}",
"else",
"{",
"disable",
"(",
"f",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Method for enabling or disabling specified feature:
check {@link Feature} for list of available features.
@return Generator itself (this), to allow chaining
@since 1.2 | [
"Method",
"for",
"enabling",
"or",
"disabling",
"specified",
"feature",
":",
"check",
"{",
"@link",
"Feature",
"}",
"for",
"list",
"of",
"available",
"features",
"."
] | train | https://github.com/aragozin/jvm-tools/blob/d3a4d0c6a47fb9317f274988569655f30dcd2f76/mxdump/src/main/java/org/gridkit/jvmtool/jackson/JsonGenerator.java#L240-L248 |
nextreports/nextreports-engine | src/ro/nextreports/engine/chart/ChartRunner.java | ChartRunner.setConnection | public void setConnection(Connection connection, boolean csv) {
this.connection = connection;
this.csv = csv;
try {
dialect = DialectUtil.getDialect(connection);
} catch (Exception e) {
e.printStackTrace();
}
if (chart != null) {
if (chart.getReport().getQuery() != null) {
chart.getReport().getQuery().setDialect(dialect);
}
}
} | java | public void setConnection(Connection connection, boolean csv) {
this.connection = connection;
this.csv = csv;
try {
dialect = DialectUtil.getDialect(connection);
} catch (Exception e) {
e.printStackTrace();
}
if (chart != null) {
if (chart.getReport().getQuery() != null) {
chart.getReport().getQuery().setDialect(dialect);
}
}
} | [
"public",
"void",
"setConnection",
"(",
"Connection",
"connection",
",",
"boolean",
"csv",
")",
"{",
"this",
".",
"connection",
"=",
"connection",
";",
"this",
".",
"csv",
"=",
"csv",
";",
"try",
"{",
"dialect",
"=",
"DialectUtil",
".",
"getDialect",
"(",
... | Set database connection
@param connection database connection
@param csv true for a csv file connection | [
"Set",
"database",
"connection"
] | train | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/chart/ChartRunner.java#L100-L113 |
antopen/alipay-sdk-java | src/main/java/com/alipay/api/internal/util/AlipaySignature.java | AlipaySignature.rsaDecrypt | public static String rsaDecrypt(String content, String privateKey,
String charset) throws AlipayApiException {
try {
PrivateKey priKey = getPrivateKeyFromPKCS8(AlipayConstants.SIGN_TYPE_RSA,
new ByteArrayInputStream(privateKey.getBytes()));
Cipher cipher = Cipher.getInstance(AlipayConstants.SIGN_TYPE_RSA);
cipher.init(Cipher.DECRYPT_MODE, priKey);
byte[] encryptedData = StringUtils.isEmpty(charset)
? Base64.decodeBase64(content.getBytes())
: Base64.decodeBase64(content.getBytes(charset));
int inputLen = encryptedData.length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] cache;
int i = 0;
// 对数据分段解密
while (inputLen - offSet > 0) {
if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
} else {
cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
}
out.write(cache, 0, cache.length);
i++;
offSet = i * MAX_DECRYPT_BLOCK;
}
byte[] decryptedData = out.toByteArray();
out.close();
return StringUtils.isEmpty(charset) ? new String(decryptedData)
: new String(decryptedData, charset);
} catch (Exception e) {
throw new AlipayApiException("EncodeContent = " + content + ",charset = " + charset, e);
}
} | java | public static String rsaDecrypt(String content, String privateKey,
String charset) throws AlipayApiException {
try {
PrivateKey priKey = getPrivateKeyFromPKCS8(AlipayConstants.SIGN_TYPE_RSA,
new ByteArrayInputStream(privateKey.getBytes()));
Cipher cipher = Cipher.getInstance(AlipayConstants.SIGN_TYPE_RSA);
cipher.init(Cipher.DECRYPT_MODE, priKey);
byte[] encryptedData = StringUtils.isEmpty(charset)
? Base64.decodeBase64(content.getBytes())
: Base64.decodeBase64(content.getBytes(charset));
int inputLen = encryptedData.length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] cache;
int i = 0;
// 对数据分段解密
while (inputLen - offSet > 0) {
if (inputLen - offSet > MAX_DECRYPT_BLOCK) {
cache = cipher.doFinal(encryptedData, offSet, MAX_DECRYPT_BLOCK);
} else {
cache = cipher.doFinal(encryptedData, offSet, inputLen - offSet);
}
out.write(cache, 0, cache.length);
i++;
offSet = i * MAX_DECRYPT_BLOCK;
}
byte[] decryptedData = out.toByteArray();
out.close();
return StringUtils.isEmpty(charset) ? new String(decryptedData)
: new String(decryptedData, charset);
} catch (Exception e) {
throw new AlipayApiException("EncodeContent = " + content + ",charset = " + charset, e);
}
} | [
"public",
"static",
"String",
"rsaDecrypt",
"(",
"String",
"content",
",",
"String",
"privateKey",
",",
"String",
"charset",
")",
"throws",
"AlipayApiException",
"{",
"try",
"{",
"PrivateKey",
"priKey",
"=",
"getPrivateKeyFromPKCS8",
"(",
"AlipayConstants",
".",
"... | 私钥解密
@param content 待解密内容
@param privateKey 私钥
@param charset 字符集,如UTF-8, GBK, GB2312
@return 明文内容
@throws AlipayApiException | [
"私钥解密"
] | train | https://github.com/antopen/alipay-sdk-java/blob/e82aeac7d0239330ee173c7e393596e51e41c1cd/src/main/java/com/alipay/api/internal/util/AlipaySignature.java#L598-L632 |
jglobus/JGlobus | ssl-proxies/src/main/java/org/globus/gsi/trustmanager/UnsupportedCriticalExtensionChecker.java | UnsupportedCriticalExtensionChecker.invoke | public void invoke(X509Certificate cert, GSIConstants.CertificateType certType) throws CertPathValidatorException {
Set<String> criticalExtensionOids =
cert.getCriticalExtensionOIDs();
if (criticalExtensionOids == null) {
return;
}
for (String criticalExtensionOid : criticalExtensionOids) {
isUnsupported(certType, criticalExtensionOid);
}
} | java | public void invoke(X509Certificate cert, GSIConstants.CertificateType certType) throws CertPathValidatorException {
Set<String> criticalExtensionOids =
cert.getCriticalExtensionOIDs();
if (criticalExtensionOids == null) {
return;
}
for (String criticalExtensionOid : criticalExtensionOids) {
isUnsupported(certType, criticalExtensionOid);
}
} | [
"public",
"void",
"invoke",
"(",
"X509Certificate",
"cert",
",",
"GSIConstants",
".",
"CertificateType",
"certType",
")",
"throws",
"CertPathValidatorException",
"{",
"Set",
"<",
"String",
">",
"criticalExtensionOids",
"=",
"cert",
".",
"getCriticalExtensionOIDs",
"("... | Method that checks if there are unsupported critical extension. Supported
ones are only BasicConstrains, KeyUsage, Proxy Certificate (old and new)
@param cert The certificate to validate.
@param certType The type of certificate to validate.
@throws CertPathValidatorException If any critical extension that is not supported is in the certificate.
Anything other than those listed above will trigger the exception. | [
"Method",
"that",
"checks",
"if",
"there",
"are",
"unsupported",
"critical",
"extension",
".",
"Supported",
"ones",
"are",
"only",
"BasicConstrains",
"KeyUsage",
"Proxy",
"Certificate",
"(",
"old",
"and",
"new",
")"
] | train | https://github.com/jglobus/JGlobus/blob/e14f6f6636544fd84298f9cec749d626ea971930/ssl-proxies/src/main/java/org/globus/gsi/trustmanager/UnsupportedCriticalExtensionChecker.java#L44-L53 |
Azure/azure-sdk-for-java | network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ExpressRoutePortsInner.java | ExpressRoutePortsInner.beginUpdateTagsAsync | public Observable<ExpressRoutePortInner> beginUpdateTagsAsync(String resourceGroupName, String expressRoutePortName) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, expressRoutePortName).map(new Func1<ServiceResponse<ExpressRoutePortInner>, ExpressRoutePortInner>() {
@Override
public ExpressRoutePortInner call(ServiceResponse<ExpressRoutePortInner> response) {
return response.body();
}
});
} | java | public Observable<ExpressRoutePortInner> beginUpdateTagsAsync(String resourceGroupName, String expressRoutePortName) {
return beginUpdateTagsWithServiceResponseAsync(resourceGroupName, expressRoutePortName).map(new Func1<ServiceResponse<ExpressRoutePortInner>, ExpressRoutePortInner>() {
@Override
public ExpressRoutePortInner call(ServiceResponse<ExpressRoutePortInner> response) {
return response.body();
}
});
} | [
"public",
"Observable",
"<",
"ExpressRoutePortInner",
">",
"beginUpdateTagsAsync",
"(",
"String",
"resourceGroupName",
",",
"String",
"expressRoutePortName",
")",
"{",
"return",
"beginUpdateTagsWithServiceResponseAsync",
"(",
"resourceGroupName",
",",
"expressRoutePortName",
... | Update ExpressRoutePort tags.
@param resourceGroupName The name of the resource group.
@param expressRoutePortName The name of the ExpressRoutePort resource.
@throws IllegalArgumentException thrown if parameters fail the validation
@return the observable to the ExpressRoutePortInner object | [
"Update",
"ExpressRoutePort",
"tags",
"."
] | train | https://github.com/Azure/azure-sdk-for-java/blob/aab183ddc6686c82ec10386d5a683d2691039626/network/resource-manager/v2018_08_01/src/main/java/com/microsoft/azure/management/network/v2018_08_01/implementation/ExpressRoutePortsInner.java#L697-L704 |
alkacon/opencms-core | src/org/opencms/xml/content/CmsXmlContent.java | CmsXmlContent.addBookmarkForValue | protected void addBookmarkForValue(I_CmsXmlContentValue value, String path, Locale locale, boolean enabled) {
addBookmark(path, locale, enabled, value);
} | java | protected void addBookmarkForValue(I_CmsXmlContentValue value, String path, Locale locale, boolean enabled) {
addBookmark(path, locale, enabled, value);
} | [
"protected",
"void",
"addBookmarkForValue",
"(",
"I_CmsXmlContentValue",
"value",
",",
"String",
"path",
",",
"Locale",
"locale",
",",
"boolean",
"enabled",
")",
"{",
"addBookmark",
"(",
"path",
",",
"locale",
",",
"enabled",
",",
"value",
")",
";",
"}"
] | Adds a bookmark for the given value.<p>
@param value the value to bookmark
@param path the lookup path to use for the bookmark
@param locale the locale to use for the bookmark
@param enabled if true, the value is enabled, if false it is disabled | [
"Adds",
"a",
"bookmark",
"for",
"the",
"given",
"value",
".",
"<p",
">"
] | train | https://github.com/alkacon/opencms-core/blob/bc104acc75d2277df5864da939a1f2de5fdee504/src/org/opencms/xml/content/CmsXmlContent.java#L847-L850 |
dnsjava/dnsjava | org/xbill/DNS/TSIG.java | TSIG.verify | private static boolean
verify(Mac mac, byte [] signature, boolean truncation_ok) {
byte [] expected = mac.doFinal();
if (truncation_ok && signature.length < expected.length) {
byte [] truncated = new byte[signature.length];
System.arraycopy(expected, 0, truncated, 0, truncated.length);
expected = truncated;
}
return Arrays.equals(signature, expected);
} | java | private static boolean
verify(Mac mac, byte [] signature, boolean truncation_ok) {
byte [] expected = mac.doFinal();
if (truncation_ok && signature.length < expected.length) {
byte [] truncated = new byte[signature.length];
System.arraycopy(expected, 0, truncated, 0, truncated.length);
expected = truncated;
}
return Arrays.equals(signature, expected);
} | [
"private",
"static",
"boolean",
"verify",
"(",
"Mac",
"mac",
",",
"byte",
"[",
"]",
"signature",
",",
"boolean",
"truncation_ok",
")",
"{",
"byte",
"[",
"]",
"expected",
"=",
"mac",
".",
"doFinal",
"(",
")",
";",
"if",
"(",
"truncation_ok",
"&&",
"sign... | Verifies the data (computes the secure hash and compares it to the input)
@param mac The HMAC generator
@param signature The signature to compare against
@param truncation_ok If true, the signature may be truncated; only the
number of bytes in the provided signature are compared.
@return true if the signature matches, false otherwise | [
"Verifies",
"the",
"data",
"(",
"computes",
"the",
"secure",
"hash",
"and",
"compares",
"it",
"to",
"the",
"input",
")"
] | train | https://github.com/dnsjava/dnsjava/blob/d97b6a0685d59143372bb392ab591dd8dd840b61/org/xbill/DNS/TSIG.java#L109-L118 |
cqframework/clinical_quality_language | Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java | ElmBaseVisitor.visitInstanceElement | public T visitInstanceElement(InstanceElement elm, C context) {
visitElement(elm.getValue(), context);
return null;
} | java | public T visitInstanceElement(InstanceElement elm, C context) {
visitElement(elm.getValue(), context);
return null;
} | [
"public",
"T",
"visitInstanceElement",
"(",
"InstanceElement",
"elm",
",",
"C",
"context",
")",
"{",
"visitElement",
"(",
"elm",
".",
"getValue",
"(",
")",
",",
"context",
")",
";",
"return",
"null",
";",
"}"
] | Visit a InstanceElement. This method will be called for
every node in the tree that is a InstanceElement.
@param elm the ELM tree
@param context the context passed to the visitor
@return the visitor result | [
"Visit",
"a",
"InstanceElement",
".",
"This",
"method",
"will",
"be",
"called",
"for",
"every",
"node",
"in",
"the",
"tree",
"that",
"is",
"a",
"InstanceElement",
"."
] | train | https://github.com/cqframework/clinical_quality_language/blob/67459d1ef453e49db8d7c5c86e87278377ed0a0b/Src/java/elm/src/main/java/org/cqframework/cql/elm/visiting/ElmBaseVisitor.java#L483-L486 |
comapi/comapi-sdk-android | COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java | InternalService.createConversation | public Observable<ComapiResult<ConversationDetails>> createConversation(@NonNull final ConversationCreate request) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueCreateConversation(request);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doCreateConversation(token, request);
}
} | java | public Observable<ComapiResult<ConversationDetails>> createConversation(@NonNull final ConversationCreate request) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueCreateConversation(request);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doCreateConversation(token, request);
}
} | [
"public",
"Observable",
"<",
"ComapiResult",
"<",
"ConversationDetails",
">",
">",
"createConversation",
"(",
"@",
"NonNull",
"final",
"ConversationCreate",
"request",
")",
"{",
"final",
"String",
"token",
"=",
"getToken",
"(",
")",
";",
"if",
"(",
"sessionContr... | Returns observable to create a conversation.
@param request Request with conversation details to create.
@return Observable to to create a conversation. | [
"Returns",
"observable",
"to",
"create",
"a",
"conversation",
"."
] | train | https://github.com/comapi/comapi-sdk-android/blob/53140a58d5a62afe196047ccc5120bfe090ef211/COMAPI/foundation/src/main/java/com/comapi/internal/network/InternalService.java#L414-L425 |
vanilladb/vanillacore | src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java | LockTable.sixLock | void sixLock(Object obj, long txNum) {
Object anchor = getAnchor(obj);
txWaitMap.put(txNum, anchor);
synchronized (anchor) {
Lockers lks = prepareLockers(obj);
if (hasSixLock(lks, txNum))
return;
try {
long timestamp = System.currentTimeMillis();
while (!sixLockable(lks, txNum) && !waitingTooLong(timestamp)) {
avoidDeadlock(lks, txNum, SIX_LOCK);
lks.requestSet.add(txNum);
anchor.wait(MAX_TIME);
lks.requestSet.remove(txNum);
}
if (!sixLockable(lks, txNum))
throw new LockAbortException();
lks.sixLocker = txNum;
getObjectSet(txNum).add(obj);
} catch (InterruptedException e) {
throw new LockAbortException();
}
}
txWaitMap.remove(txNum);
} | java | void sixLock(Object obj, long txNum) {
Object anchor = getAnchor(obj);
txWaitMap.put(txNum, anchor);
synchronized (anchor) {
Lockers lks = prepareLockers(obj);
if (hasSixLock(lks, txNum))
return;
try {
long timestamp = System.currentTimeMillis();
while (!sixLockable(lks, txNum) && !waitingTooLong(timestamp)) {
avoidDeadlock(lks, txNum, SIX_LOCK);
lks.requestSet.add(txNum);
anchor.wait(MAX_TIME);
lks.requestSet.remove(txNum);
}
if (!sixLockable(lks, txNum))
throw new LockAbortException();
lks.sixLocker = txNum;
getObjectSet(txNum).add(obj);
} catch (InterruptedException e) {
throw new LockAbortException();
}
}
txWaitMap.remove(txNum);
} | [
"void",
"sixLock",
"(",
"Object",
"obj",
",",
"long",
"txNum",
")",
"{",
"Object",
"anchor",
"=",
"getAnchor",
"(",
"obj",
")",
";",
"txWaitMap",
".",
"put",
"(",
"txNum",
",",
"anchor",
")",
";",
"synchronized",
"(",
"anchor",
")",
"{",
"Lockers",
"... | Grants an sixlock on the specified item. If any conflict lock exists when
the method is called, then the calling thread will be placed on a wait
list until the lock is released. If the thread remains on the wait list
for a certain amount of time, then an exception is thrown.
@param obj
a lockable item
@param txNum
a transaction number | [
"Grants",
"an",
"sixlock",
"on",
"the",
"specified",
"item",
".",
"If",
"any",
"conflict",
"lock",
"exists",
"when",
"the",
"method",
"is",
"called",
"then",
"the",
"calling",
"thread",
"will",
"be",
"placed",
"on",
"a",
"wait",
"list",
"until",
"the",
"... | train | https://github.com/vanilladb/vanillacore/blob/d9a34e876b1b83226036d1fa982a614bbef59bd1/src/main/java/org/vanilladb/core/storage/tx/concurrency/LockTable.java#L268-L295 |
google/j2objc | xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/URI.java | URI.initializeScheme | private void initializeScheme(String p_uriSpec) throws MalformedURIException
{
int uriSpecLen = p_uriSpec.length();
int index = 0;
String scheme = null;
char testChar = '\0';
while (index < uriSpecLen)
{
testChar = p_uriSpec.charAt(index);
if (testChar == ':' || testChar == '/' || testChar == '?'
|| testChar == '#')
{
break;
}
index++;
}
scheme = p_uriSpec.substring(0, index);
if (scheme.length() == 0)
{
throw new MalformedURIException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_SCHEME_INURI, null)); //"No scheme found in URI.");
}
else
{
setScheme(scheme);
}
} | java | private void initializeScheme(String p_uriSpec) throws MalformedURIException
{
int uriSpecLen = p_uriSpec.length();
int index = 0;
String scheme = null;
char testChar = '\0';
while (index < uriSpecLen)
{
testChar = p_uriSpec.charAt(index);
if (testChar == ':' || testChar == '/' || testChar == '?'
|| testChar == '#')
{
break;
}
index++;
}
scheme = p_uriSpec.substring(0, index);
if (scheme.length() == 0)
{
throw new MalformedURIException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_SCHEME_INURI, null)); //"No scheme found in URI.");
}
else
{
setScheme(scheme);
}
} | [
"private",
"void",
"initializeScheme",
"(",
"String",
"p_uriSpec",
")",
"throws",
"MalformedURIException",
"{",
"int",
"uriSpecLen",
"=",
"p_uriSpec",
".",
"length",
"(",
")",
";",
"int",
"index",
"=",
"0",
";",
"String",
"scheme",
"=",
"null",
";",
"char",
... | Initialize the scheme for this URI from a URI string spec.
@param p_uriSpec the URI specification (cannot be null)
@throws MalformedURIException if URI does not have a conformant
scheme | [
"Initialize",
"the",
"scheme",
"for",
"this",
"URI",
"from",
"a",
"URI",
"string",
"spec",
"."
] | train | https://github.com/google/j2objc/blob/471504a735b48d5d4ace51afa1542cc4790a921a/xalan/third_party/android/platform/external/apache-xml/src/main/java/org/apache/xml/utils/URI.java#L600-L631 |
facebookarchive/hadoop-20 | src/core/org/apache/hadoop/io/file/tfile/TFile.java | TFile.main | public static void main(String[] args) {
System.out.printf("TFile Dumper (TFile %s, BCFile %s)\n", TFile.API_VERSION
.toString(), BCFile.API_VERSION.toString());
if (args.length == 0) {
System.out
.println("Usage: java ... org.apache.hadoop.io.file.tfile.TFile tfile-path [tfile-path ...]");
System.exit(0);
}
Configuration conf = new Configuration();
for (String file : args) {
System.out.println("===" + file + "===");
try {
TFileDumper.dumpInfo(file, System.out, conf);
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
} | java | public static void main(String[] args) {
System.out.printf("TFile Dumper (TFile %s, BCFile %s)\n", TFile.API_VERSION
.toString(), BCFile.API_VERSION.toString());
if (args.length == 0) {
System.out
.println("Usage: java ... org.apache.hadoop.io.file.tfile.TFile tfile-path [tfile-path ...]");
System.exit(0);
}
Configuration conf = new Configuration();
for (String file : args) {
System.out.println("===" + file + "===");
try {
TFileDumper.dumpInfo(file, System.out, conf);
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"System",
".",
"out",
".",
"printf",
"(",
"\"TFile Dumper (TFile %s, BCFile %s)\\n\"",
",",
"TFile",
".",
"API_VERSION",
".",
"toString",
"(",
")",
",",
"BCFile",
".",
"API_VERSIO... | Dumping the TFile information.
@param args
A list of TFile paths. | [
"Dumping",
"the",
"TFile",
"information",
"."
] | train | https://github.com/facebookarchive/hadoop-20/blob/2a29bc6ecf30edb1ad8dbde32aa49a317b4d44f4/src/core/org/apache/hadoop/io/file/tfile/TFile.java#L2335-L2353 |
geomajas/geomajas-project-client-gwt | client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java | Feature.setUrlAttribute | public void setUrlAttribute(String name, String value) {
Attribute attribute = getAttributes().get(name);
if (!(attribute instanceof UrlAttribute)) {
throw new IllegalStateException("Cannot set url value on attribute with different type, " +
attribute.getClass().getName() + " setting value " + value);
}
((UrlAttribute) attribute).setValue(value);
} | java | public void setUrlAttribute(String name, String value) {
Attribute attribute = getAttributes().get(name);
if (!(attribute instanceof UrlAttribute)) {
throw new IllegalStateException("Cannot set url value on attribute with different type, " +
attribute.getClass().getName() + " setting value " + value);
}
((UrlAttribute) attribute).setValue(value);
} | [
"public",
"void",
"setUrlAttribute",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"Attribute",
"attribute",
"=",
"getAttributes",
"(",
")",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"!",
"(",
"attribute",
"instanceof",
"UrlAttribute",
")",
... | Set attribute value of given type.
@param name attribute name
@param value attribute value | [
"Set",
"attribute",
"value",
"of",
"given",
"type",
"."
] | train | https://github.com/geomajas/geomajas-project-client-gwt/blob/1c1adc48deb192ed825265eebcc74d70bbf45670/client/src/main/java/org/geomajas/gwt/client/map/feature/Feature.java#L365-L372 |
ppiastucki/recast4j | detour-extras/src/main/java/org/recast4j/detour/extras/unity/astar/LinkBuilder.java | LinkBuilder.buildExternalLink | private void buildExternalLink(MeshData tile, Poly node, MeshData neighbourTile) {
if (neighbourTile.header.bmin[0] > tile.header.bmin[0]) {
node.neis[PolyUtils.findEdge(node, tile, neighbourTile.header.bmin[0], 0)] = NavMesh.DT_EXT_LINK;
} else if (neighbourTile.header.bmin[0] < tile.header.bmin[0]) {
node.neis[PolyUtils.findEdge(node, tile, tile.header.bmin[0], 0)] = NavMesh.DT_EXT_LINK | 4;
} else if (neighbourTile.header.bmin[2] > tile.header.bmin[2]) {
node.neis[PolyUtils.findEdge(node, tile, neighbourTile.header.bmin[2], 2)] = NavMesh.DT_EXT_LINK | 2;
} else {
node.neis[PolyUtils.findEdge(node, tile, tile.header.bmin[2], 2)] = NavMesh.DT_EXT_LINK | 6;
}
} | java | private void buildExternalLink(MeshData tile, Poly node, MeshData neighbourTile) {
if (neighbourTile.header.bmin[0] > tile.header.bmin[0]) {
node.neis[PolyUtils.findEdge(node, tile, neighbourTile.header.bmin[0], 0)] = NavMesh.DT_EXT_LINK;
} else if (neighbourTile.header.bmin[0] < tile.header.bmin[0]) {
node.neis[PolyUtils.findEdge(node, tile, tile.header.bmin[0], 0)] = NavMesh.DT_EXT_LINK | 4;
} else if (neighbourTile.header.bmin[2] > tile.header.bmin[2]) {
node.neis[PolyUtils.findEdge(node, tile, neighbourTile.header.bmin[2], 2)] = NavMesh.DT_EXT_LINK | 2;
} else {
node.neis[PolyUtils.findEdge(node, tile, tile.header.bmin[2], 2)] = NavMesh.DT_EXT_LINK | 6;
}
} | [
"private",
"void",
"buildExternalLink",
"(",
"MeshData",
"tile",
",",
"Poly",
"node",
",",
"MeshData",
"neighbourTile",
")",
"{",
"if",
"(",
"neighbourTile",
".",
"header",
".",
"bmin",
"[",
"0",
"]",
">",
"tile",
".",
"header",
".",
"bmin",
"[",
"0",
... | In case of external link to other tiles we must find the direction | [
"In",
"case",
"of",
"external",
"link",
"to",
"other",
"tiles",
"we",
"must",
"find",
"the",
"direction"
] | train | https://github.com/ppiastucki/recast4j/blob/a414dc34f16b87c95fb4e0f46c28a7830d421788/detour-extras/src/main/java/org/recast4j/detour/extras/unity/astar/LinkBuilder.java#L40-L50 |
ckpoint/CheckPoint | src/main/java/hsim/checkpoint/core/msg/MsgChecker.java | MsgChecker.replaceCallback | public MsgChecker replaceCallback(BasicCheckRule type, ValidationInvalidCallback cb) {
this.callbackMap.put(type.name(), cb);
return this;
} | java | public MsgChecker replaceCallback(BasicCheckRule type, ValidationInvalidCallback cb) {
this.callbackMap.put(type.name(), cb);
return this;
} | [
"public",
"MsgChecker",
"replaceCallback",
"(",
"BasicCheckRule",
"type",
",",
"ValidationInvalidCallback",
"cb",
")",
"{",
"this",
".",
"callbackMap",
".",
"put",
"(",
"type",
".",
"name",
"(",
")",
",",
"cb",
")",
";",
"return",
"this",
";",
"}"
] | Replace callback msg checker.
@param type the type
@param cb the cb
@return the msg checker | [
"Replace",
"callback",
"msg",
"checker",
"."
] | train | https://github.com/ckpoint/CheckPoint/blob/2c2b1a87a88485d49ea6afa34acdf16ef4134f19/src/main/java/hsim/checkpoint/core/msg/MsgChecker.java#L36-L39 |
mfornos/humanize | humanize-slim/src/main/java/humanize/Humanize.java | Humanize.lossyEquals | public static boolean lossyEquals(final Locale locale, final String source, final String target)
{
return withinLocale(new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
return lossyEquals(source, target);
}
}, locale);
} | java | public static boolean lossyEquals(final Locale locale, final String source, final String target)
{
return withinLocale(new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
return lossyEquals(source, target);
}
}, locale);
} | [
"public",
"static",
"boolean",
"lossyEquals",
"(",
"final",
"Locale",
"locale",
",",
"final",
"String",
"source",
",",
"final",
"String",
"target",
")",
"{",
"return",
"withinLocale",
"(",
"new",
"Callable",
"<",
"Boolean",
">",
"(",
")",
"{",
"@",
"Overri... | <p>
Same as {@link #lossyEquals(String, String)} for the specified locale.
</p>
@param locale
The target locale
@param source
The source string to be compared
@param target
The target string to be compared
@return true if the two strings are equals according to primary
differences only, false otherwise | [
"<p",
">",
"Same",
"as",
"{",
"@link",
"#lossyEquals",
"(",
"String",
"String",
")",
"}",
"for",
"the",
"specified",
"locale",
".",
"<",
"/",
"p",
">"
] | train | https://github.com/mfornos/humanize/blob/59fc103045de9d217c9e77dbcb7621f992f46c63/humanize-slim/src/main/java/humanize/Humanize.java#L1242-L1253 |
stratosphere/stratosphere | stratosphere-addons/spargel/src/main/java/eu/stratosphere/spargel/java/MessagingFunction.java | MessagingFunction.sendMessageTo | public void sendMessageTo(VertexKey target, Message m) {
outValue.f0 = target;
outValue.f1 = m;
out.collect(outValue);
} | java | public void sendMessageTo(VertexKey target, Message m) {
outValue.f0 = target;
outValue.f1 = m;
out.collect(outValue);
} | [
"public",
"void",
"sendMessageTo",
"(",
"VertexKey",
"target",
",",
"Message",
"m",
")",
"{",
"outValue",
".",
"f0",
"=",
"target",
";",
"outValue",
".",
"f1",
"=",
"m",
";",
"out",
".",
"collect",
"(",
"outValue",
")",
";",
"}"
] | Sends the given message to the vertex identified by the given key. If the target vertex does not exist,
the next superstep will cause an exception due to a non-deliverable message.
@param target The key (id) of the target vertex to message.
@param m The message. | [
"Sends",
"the",
"given",
"message",
"to",
"the",
"vertex",
"identified",
"by",
"the",
"given",
"key",
".",
"If",
"the",
"target",
"vertex",
"does",
"not",
"exist",
"the",
"next",
"superstep",
"will",
"cause",
"an",
"exception",
"due",
"to",
"a",
"non",
"... | train | https://github.com/stratosphere/stratosphere/blob/c543a08f9676c5b2b0a7088123bd6e795a8ae0c8/stratosphere-addons/spargel/src/main/java/eu/stratosphere/spargel/java/MessagingFunction.java#L122-L126 |
astrapi69/jaulp-wicket | jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/menu/suckerfish/MenuItemFactory.java | MenuItemFactory.newMenuItem | public static MenuItem newMenuItem(final Class<? extends Page> pageClass,
final String resourceModelKey, final Component component, final PageParameters parameters)
{
final BookmarkablePageLink<String> bookmarkablePageLink = new BookmarkablePageLink<>(
MenuPanel.LINK_ID, pageClass, parameters);
final IModel<String> labelModel = ResourceModelFactory.newResourceModel(resourceModelKey,
component);
final MenuItem menuItem = new MenuItem(bookmarkablePageLink, labelModel);
return menuItem;
} | java | public static MenuItem newMenuItem(final Class<? extends Page> pageClass,
final String resourceModelKey, final Component component, final PageParameters parameters)
{
final BookmarkablePageLink<String> bookmarkablePageLink = new BookmarkablePageLink<>(
MenuPanel.LINK_ID, pageClass, parameters);
final IModel<String> labelModel = ResourceModelFactory.newResourceModel(resourceModelKey,
component);
final MenuItem menuItem = new MenuItem(bookmarkablePageLink, labelModel);
return menuItem;
} | [
"public",
"static",
"MenuItem",
"newMenuItem",
"(",
"final",
"Class",
"<",
"?",
"extends",
"Page",
">",
"pageClass",
",",
"final",
"String",
"resourceModelKey",
",",
"final",
"Component",
"component",
",",
"final",
"PageParameters",
"parameters",
")",
"{",
"fina... | Creates the menu item.
@param pageClass
the page class
@param resourceModelKey
the resource model key
@param component
the component
@param parameters
the {@link PageParameters}
@return the suckerfish menu panel. menu item | [
"Creates",
"the",
"menu",
"item",
"."
] | train | https://github.com/astrapi69/jaulp-wicket/blob/85d74368d00abd9bb97659b5794e38c0f8a013d4/jaulp-wicket-components/src/main/java/de/alpharogroup/wicket/components/menu/suckerfish/MenuItemFactory.java#L97-L106 |
zk1931/jzab | src/main/java/com/github/zk1931/jzab/PersistentState.java | PersistentState.setSnapshotFile | File setSnapshotFile(File tempFile, Zxid zxid) throws IOException {
File snapshot =
new File(dataDir, String.format("snapshot.%s", zxid.toSimpleString()));
LOG.debug("Atomically move snapshot file to {}", snapshot);
FileUtils.atomicMove(tempFile, snapshot);
// Since the new snapshot file gets created, we need to fsync the directory.
fsyncDirectory();
return snapshot;
} | java | File setSnapshotFile(File tempFile, Zxid zxid) throws IOException {
File snapshot =
new File(dataDir, String.format("snapshot.%s", zxid.toSimpleString()));
LOG.debug("Atomically move snapshot file to {}", snapshot);
FileUtils.atomicMove(tempFile, snapshot);
// Since the new snapshot file gets created, we need to fsync the directory.
fsyncDirectory();
return snapshot;
} | [
"File",
"setSnapshotFile",
"(",
"File",
"tempFile",
",",
"Zxid",
"zxid",
")",
"throws",
"IOException",
"{",
"File",
"snapshot",
"=",
"new",
"File",
"(",
"dataDir",
",",
"String",
".",
"format",
"(",
"\"snapshot.%s\"",
",",
"zxid",
".",
"toSimpleString",
"(",... | Turns a temporary snapshot file into a valid snapshot file.
@param tempFile the temporary file which stores current state.
@param zxid the last applied zxid for state machine.
@return the snapshot file. | [
"Turns",
"a",
"temporary",
"snapshot",
"file",
"into",
"a",
"valid",
"snapshot",
"file",
"."
] | train | https://github.com/zk1931/jzab/blob/2a8893bcc1a125f3aebdaddee80ad49c9761bba1/src/main/java/com/github/zk1931/jzab/PersistentState.java#L286-L294 |
UrielCh/ovh-java-sdk | ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java | ApiOvhIpLoadbalancing.serviceName_http_farm_farmId_PUT | public void serviceName_http_farm_farmId_PUT(String serviceName, Long farmId, OvhBackendHttp body) throws IOException {
String qPath = "/ipLoadbalancing/{serviceName}/http/farm/{farmId}";
StringBuilder sb = path(qPath, serviceName, farmId);
exec(qPath, "PUT", sb.toString(), body);
} | java | public void serviceName_http_farm_farmId_PUT(String serviceName, Long farmId, OvhBackendHttp body) throws IOException {
String qPath = "/ipLoadbalancing/{serviceName}/http/farm/{farmId}";
StringBuilder sb = path(qPath, serviceName, farmId);
exec(qPath, "PUT", sb.toString(), body);
} | [
"public",
"void",
"serviceName_http_farm_farmId_PUT",
"(",
"String",
"serviceName",
",",
"Long",
"farmId",
",",
"OvhBackendHttp",
"body",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/ipLoadbalancing/{serviceName}/http/farm/{farmId}\"",
";",
"StringBuilder"... | Alter this object properties
REST: PUT /ipLoadbalancing/{serviceName}/http/farm/{farmId}
@param body [required] New object properties
@param serviceName [required] The internal name of your IP load balancing
@param farmId [required] Id of your farm | [
"Alter",
"this",
"object",
"properties"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-ipLoadbalancing/src/main/java/net/minidev/ovh/api/ApiOvhIpLoadbalancing.java#L379-L383 |
pac4j/spring-security-pac4j | src/main/java/org/pac4j/springframework/security/util/SpringSecurityHelper.java | SpringSecurityHelper.populateAuthentication | public static void populateAuthentication(final LinkedHashMap<String, CommonProfile> profiles) {
if (profiles != null && profiles.size() > 0) {
final List<CommonProfile> listProfiles = ProfileHelper.flatIntoAProfileList(profiles);
try {
if (IS_FULLY_AUTHENTICATED_AUTHORIZER.isAuthorized(null, listProfiles)) {
SecurityContextHolder.getContext().setAuthentication(new Pac4jAuthenticationToken(listProfiles));
} else if (IS_REMEMBERED_AUTHORIZER.isAuthorized(null, listProfiles)) {
SecurityContextHolder.getContext().setAuthentication(new Pac4jRememberMeAuthenticationToken(listProfiles));
}
} catch (final HttpAction e) {
throw new TechnicalException(e);
}
}
} | java | public static void populateAuthentication(final LinkedHashMap<String, CommonProfile> profiles) {
if (profiles != null && profiles.size() > 0) {
final List<CommonProfile> listProfiles = ProfileHelper.flatIntoAProfileList(profiles);
try {
if (IS_FULLY_AUTHENTICATED_AUTHORIZER.isAuthorized(null, listProfiles)) {
SecurityContextHolder.getContext().setAuthentication(new Pac4jAuthenticationToken(listProfiles));
} else if (IS_REMEMBERED_AUTHORIZER.isAuthorized(null, listProfiles)) {
SecurityContextHolder.getContext().setAuthentication(new Pac4jRememberMeAuthenticationToken(listProfiles));
}
} catch (final HttpAction e) {
throw new TechnicalException(e);
}
}
} | [
"public",
"static",
"void",
"populateAuthentication",
"(",
"final",
"LinkedHashMap",
"<",
"String",
",",
"CommonProfile",
">",
"profiles",
")",
"{",
"if",
"(",
"profiles",
"!=",
"null",
"&&",
"profiles",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"final",
... | Populate the authenticated user profiles in the Spring Security context.
@param profiles the linked hashmap of profiles | [
"Populate",
"the",
"authenticated",
"user",
"profiles",
"in",
"the",
"Spring",
"Security",
"context",
"."
] | train | https://github.com/pac4j/spring-security-pac4j/blob/5beaea9c9667a60dc933fa9738a5bfe24830c63d/src/main/java/org/pac4j/springframework/security/util/SpringSecurityHelper.java#L55-L68 |
Alluxio/alluxio | core/server/worker/src/main/java/alluxio/worker/block/allocator/RoundRobinAllocator.java | RoundRobinAllocator.getNextAvailDirInTier | private int getNextAvailDirInTier(StorageTierView tierView, long blockSize) {
int dirViewIndex = mTierAliasToLastDirMap.get(tierView.getTierViewAlias());
for (int i = 0; i < tierView.getDirViews().size(); i++) { // try this many times
dirViewIndex = (dirViewIndex + 1) % tierView.getDirViews().size();
if (tierView.getDirView(dirViewIndex).getAvailableBytes() >= blockSize) {
return dirViewIndex;
}
}
return -1;
} | java | private int getNextAvailDirInTier(StorageTierView tierView, long blockSize) {
int dirViewIndex = mTierAliasToLastDirMap.get(tierView.getTierViewAlias());
for (int i = 0; i < tierView.getDirViews().size(); i++) { // try this many times
dirViewIndex = (dirViewIndex + 1) % tierView.getDirViews().size();
if (tierView.getDirView(dirViewIndex).getAvailableBytes() >= blockSize) {
return dirViewIndex;
}
}
return -1;
} | [
"private",
"int",
"getNextAvailDirInTier",
"(",
"StorageTierView",
"tierView",
",",
"long",
"blockSize",
")",
"{",
"int",
"dirViewIndex",
"=",
"mTierAliasToLastDirMap",
".",
"get",
"(",
"tierView",
".",
"getTierViewAlias",
"(",
")",
")",
";",
"for",
"(",
"int",
... | Finds an available dir in a given tier for a block with blockSize.
@param tierView the tier to find a dir
@param blockSize the requested block size
@return the index of the dir if non-negative; -1 if fail to find a dir | [
"Finds",
"an",
"available",
"dir",
"in",
"a",
"given",
"tier",
"for",
"a",
"block",
"with",
"blockSize",
"."
] | train | https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/allocator/RoundRobinAllocator.java#L109-L118 |
hector-client/hector | core/src/main/java/me/prettyprint/hector/api/factory/HFactory.java | HFactory.getOrCreateCluster | public static Cluster getOrCreateCluster(String clusterName,
CassandraHostConfigurator cassandraHostConfigurator) {
return createCluster(clusterName, cassandraHostConfigurator, null);
} | java | public static Cluster getOrCreateCluster(String clusterName,
CassandraHostConfigurator cassandraHostConfigurator) {
return createCluster(clusterName, cassandraHostConfigurator, null);
} | [
"public",
"static",
"Cluster",
"getOrCreateCluster",
"(",
"String",
"clusterName",
",",
"CassandraHostConfigurator",
"cassandraHostConfigurator",
")",
"{",
"return",
"createCluster",
"(",
"clusterName",
",",
"cassandraHostConfigurator",
",",
"null",
")",
";",
"}"
] | Calls the three argument version with a null credentials map.
{@link #getOrCreateCluster(String, me.prettyprint.cassandra.service.CassandraHostConfigurator, java.util.Map)}
for details. | [
"Calls",
"the",
"three",
"argument",
"version",
"with",
"a",
"null",
"credentials",
"map",
".",
"{"
] | train | https://github.com/hector-client/hector/blob/a302e68ca8d91b45d332e8c9afd7d98030b54de1/core/src/main/java/me/prettyprint/hector/api/factory/HFactory.java#L142-L145 |
census-instrumentation/opencensus-java | api/src/main/java/io/opencensus/stats/ViewData.java | ViewData.createInternal | private static ViewData createInternal(
View view,
Map<List</*@Nullable*/ TagValue>, AggregationData> aggregationMap,
AggregationWindowData window,
Timestamp start,
Timestamp end) {
@SuppressWarnings("nullness")
Map<List<TagValue>, AggregationData> map = aggregationMap;
return new AutoValue_ViewData(view, map, window, start, end);
} | java | private static ViewData createInternal(
View view,
Map<List</*@Nullable*/ TagValue>, AggregationData> aggregationMap,
AggregationWindowData window,
Timestamp start,
Timestamp end) {
@SuppressWarnings("nullness")
Map<List<TagValue>, AggregationData> map = aggregationMap;
return new AutoValue_ViewData(view, map, window, start, end);
} | [
"private",
"static",
"ViewData",
"createInternal",
"(",
"View",
"view",
",",
"Map",
"<",
"List",
"<",
"/*@Nullable*/",
"TagValue",
">",
",",
"AggregationData",
">",
"aggregationMap",
",",
"AggregationWindowData",
"window",
",",
"Timestamp",
"start",
",",
"Timestam... | constructor does not have the @Nullable annotation on TagValue. | [
"constructor",
"does",
"not",
"have",
"the"
] | train | https://github.com/census-instrumentation/opencensus-java/blob/deefac9bed77e40a2297bff1ca5ec5aa48a5f755/api/src/main/java/io/opencensus/stats/ViewData.java#L195-L204 |
windup/windup | rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/EjbRemoteServiceModelService.java | EjbRemoteServiceModelService.getOrCreate | public EjbRemoteServiceModel getOrCreate(Iterable<ProjectModel> applications, JavaClassModel remoteInterface, JavaClassModel implementationClass)
{
GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V();
pipeline.has(WindupVertexFrame.TYPE_PROP, EjbRemoteServiceModel.TYPE);
if (remoteInterface != null)
pipeline.as("remoteInterface").out(EjbRemoteServiceModel.EJB_INTERFACE)
.filter(vertexTraverser -> vertexTraverser.get().equals(remoteInterface.getElement()))
.select("remoteInterface");
if (implementationClass != null)
pipeline.as("implementationClass").out(EjbRemoteServiceModel.EJB_IMPLEMENTATION_CLASS)
.filter(vertexTraverser -> vertexTraverser.get().equals(implementationClass.getElement()))
.select("implementationClass");
if (pipeline.hasNext())
{
EjbRemoteServiceModel result = frame(pipeline.next());
for (ProjectModel application : applications)
{
if (!Iterables.contains(result.getApplications(), application))
result.addApplication(application);
}
return result;
}
else
{
EjbRemoteServiceModel model = create();
model.setApplications(applications);
model.setInterface(remoteInterface);
model.setImplementationClass(implementationClass);
return model;
}
} | java | public EjbRemoteServiceModel getOrCreate(Iterable<ProjectModel> applications, JavaClassModel remoteInterface, JavaClassModel implementationClass)
{
GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V();
pipeline.has(WindupVertexFrame.TYPE_PROP, EjbRemoteServiceModel.TYPE);
if (remoteInterface != null)
pipeline.as("remoteInterface").out(EjbRemoteServiceModel.EJB_INTERFACE)
.filter(vertexTraverser -> vertexTraverser.get().equals(remoteInterface.getElement()))
.select("remoteInterface");
if (implementationClass != null)
pipeline.as("implementationClass").out(EjbRemoteServiceModel.EJB_IMPLEMENTATION_CLASS)
.filter(vertexTraverser -> vertexTraverser.get().equals(implementationClass.getElement()))
.select("implementationClass");
if (pipeline.hasNext())
{
EjbRemoteServiceModel result = frame(pipeline.next());
for (ProjectModel application : applications)
{
if (!Iterables.contains(result.getApplications(), application))
result.addApplication(application);
}
return result;
}
else
{
EjbRemoteServiceModel model = create();
model.setApplications(applications);
model.setInterface(remoteInterface);
model.setImplementationClass(implementationClass);
return model;
}
} | [
"public",
"EjbRemoteServiceModel",
"getOrCreate",
"(",
"Iterable",
"<",
"ProjectModel",
">",
"applications",
",",
"JavaClassModel",
"remoteInterface",
",",
"JavaClassModel",
"implementationClass",
")",
"{",
"GraphTraversal",
"<",
"Vertex",
",",
"Vertex",
">",
"pipeline"... | Either creates a new {@link EjbRemoteServiceModel} or returns an existing one if one already exists. | [
"Either",
"creates",
"a",
"new",
"{"
] | train | https://github.com/windup/windup/blob/6668f09e7f012d24a0b4212ada8809417225b2ad/rules-java-ee/addon/src/main/java/org/jboss/windup/rules/apps/javaee/service/EjbRemoteServiceModelService.java#L30-L62 |
jenkinsci/jenkins | core/src/main/java/hudson/scm/SCM.java | SCM.postCheckout | public void postCheckout(@Nonnull Run<?,?> build, @Nonnull Launcher launcher, @Nonnull FilePath workspace, @Nonnull TaskListener listener) throws IOException, InterruptedException {
if (build instanceof AbstractBuild && listener instanceof BuildListener) {
postCheckout((AbstractBuild) build, launcher, workspace, (BuildListener) listener);
}
} | java | public void postCheckout(@Nonnull Run<?,?> build, @Nonnull Launcher launcher, @Nonnull FilePath workspace, @Nonnull TaskListener listener) throws IOException, InterruptedException {
if (build instanceof AbstractBuild && listener instanceof BuildListener) {
postCheckout((AbstractBuild) build, launcher, workspace, (BuildListener) listener);
}
} | [
"public",
"void",
"postCheckout",
"(",
"@",
"Nonnull",
"Run",
"<",
"?",
",",
"?",
">",
"build",
",",
"@",
"Nonnull",
"Launcher",
"launcher",
",",
"@",
"Nonnull",
"FilePath",
"workspace",
",",
"@",
"Nonnull",
"TaskListener",
"listener",
")",
"throws",
"IOEx... | Get a chance to do operations after the workspace i checked out and the changelog is written.
@since 1.568 | [
"Get",
"a",
"chance",
"to",
"do",
"operations",
"after",
"the",
"workspace",
"i",
"checked",
"out",
"and",
"the",
"changelog",
"is",
"written",
"."
] | train | https://github.com/jenkinsci/jenkins/blob/44c4d3989232082c254d27ae360aa810669f44b7/core/src/main/java/hudson/scm/SCM.java#L512-L516 |
UrielCh/ovh-java-sdk | ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java | ApiOvhOrder.email_domain_new_duration_POST | public OvhOrder email_domain_new_duration_POST(String duration, String domain, OvhOfferEnum offer) throws IOException {
String qPath = "/order/email/domain/new/{duration}";
StringBuilder sb = path(qPath, duration);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "domain", domain);
addBody(o, "offer", offer);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
} | java | public OvhOrder email_domain_new_duration_POST(String duration, String domain, OvhOfferEnum offer) throws IOException {
String qPath = "/order/email/domain/new/{duration}";
StringBuilder sb = path(qPath, duration);
HashMap<String, Object>o = new HashMap<String, Object>();
addBody(o, "domain", domain);
addBody(o, "offer", offer);
String resp = exec(qPath, "POST", sb.toString(), o);
return convertTo(resp, OvhOrder.class);
} | [
"public",
"OvhOrder",
"email_domain_new_duration_POST",
"(",
"String",
"duration",
",",
"String",
"domain",
",",
"OvhOfferEnum",
"offer",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/order/email/domain/new/{duration}\"",
";",
"StringBuilder",
"sb",
"="... | Create order
REST: POST /order/email/domain/new/{duration}
@param domain [required] Domain name which will be linked to this mx account
@param offer [required] Offer for your new mx account
@param duration [required] Duration
@deprecated | [
"Create",
"order"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-order/src/main/java/net/minidev/ovh/api/ApiOvhOrder.java#L4125-L4133 |
gocd/gocd | common/src/main/java/com/thoughtworks/go/util/URLService.java | URLService.getRestfulArtifactUrl | public String getRestfulArtifactUrl(JobIdentifier jobIdentifier, String filePath) {
return format("/%s/%s", "files", jobIdentifier.artifactLocator(filePath));
} | java | public String getRestfulArtifactUrl(JobIdentifier jobIdentifier, String filePath) {
return format("/%s/%s", "files", jobIdentifier.artifactLocator(filePath));
} | [
"public",
"String",
"getRestfulArtifactUrl",
"(",
"JobIdentifier",
"jobIdentifier",
",",
"String",
"filePath",
")",
"{",
"return",
"format",
"(",
"\"/%s/%s\"",
",",
"\"files\"",
",",
"jobIdentifier",
".",
"artifactLocator",
"(",
"filePath",
")",
")",
";",
"}"
] | /*
Server will use this method, the base url is in the request. | [
"/",
"*",
"Server",
"will",
"use",
"this",
"method",
"the",
"base",
"url",
"is",
"in",
"the",
"request",
"."
] | train | https://github.com/gocd/gocd/blob/59a8480e23d6c06de39127635108dff57603cb71/common/src/main/java/com/thoughtworks/go/util/URLService.java#L77-L79 |
apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.renamePath | public static void renamePath(FileSystem fs, Path oldName, Path newName, boolean overwrite) throws IOException {
if (!fs.exists(oldName)) {
throw new FileNotFoundException(String.format("Failed to rename %s to %s: src not found", oldName, newName));
}
if (fs.exists(newName)) {
if (overwrite) {
HadoopUtils.moveToTrash(fs, newName);
} else {
throw new FileAlreadyExistsException(
String.format("Failed to rename %s to %s: dst already exists", oldName, newName));
}
}
if (!fs.rename(oldName, newName)) {
throw new IOException(String.format("Failed to rename %s to %s", oldName, newName));
}
} | java | public static void renamePath(FileSystem fs, Path oldName, Path newName, boolean overwrite) throws IOException {
if (!fs.exists(oldName)) {
throw new FileNotFoundException(String.format("Failed to rename %s to %s: src not found", oldName, newName));
}
if (fs.exists(newName)) {
if (overwrite) {
HadoopUtils.moveToTrash(fs, newName);
} else {
throw new FileAlreadyExistsException(
String.format("Failed to rename %s to %s: dst already exists", oldName, newName));
}
}
if (!fs.rename(oldName, newName)) {
throw new IOException(String.format("Failed to rename %s to %s", oldName, newName));
}
} | [
"public",
"static",
"void",
"renamePath",
"(",
"FileSystem",
"fs",
",",
"Path",
"oldName",
",",
"Path",
"newName",
",",
"boolean",
"overwrite",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"fs",
".",
"exists",
"(",
"oldName",
")",
")",
"{",
"throw"... | A wrapper around {@link FileSystem#rename(Path, Path)} which throws {@link IOException} if
{@link FileSystem#rename(Path, Path)} returns False. | [
"A",
"wrapper",
"around",
"{"
] | train | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L268-L283 |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java | ModbusSlaveFactory.createUDPSlave | public static synchronized ModbusSlave createUDPSlave(InetAddress address, int port) throws ModbusException {
String key = ModbusSlaveType.UDP.getKey(port);
if (slaves.containsKey(key)) {
return slaves.get(key);
}
else {
ModbusSlave slave = new ModbusSlave(address, port, false);
slaves.put(key, slave);
return slave;
}
} | java | public static synchronized ModbusSlave createUDPSlave(InetAddress address, int port) throws ModbusException {
String key = ModbusSlaveType.UDP.getKey(port);
if (slaves.containsKey(key)) {
return slaves.get(key);
}
else {
ModbusSlave slave = new ModbusSlave(address, port, false);
slaves.put(key, slave);
return slave;
}
} | [
"public",
"static",
"synchronized",
"ModbusSlave",
"createUDPSlave",
"(",
"InetAddress",
"address",
",",
"int",
"port",
")",
"throws",
"ModbusException",
"{",
"String",
"key",
"=",
"ModbusSlaveType",
".",
"UDP",
".",
"getKey",
"(",
"port",
")",
";",
"if",
"(",... | Creates a UDP modbus slave or returns the one already allocated to this port
@param address IP address to listen on
@param port Port to listen on
@return new or existing UDP modbus slave associated with the port
@throws ModbusException If a problem occurs e.g. port already in use | [
"Creates",
"a",
"UDP",
"modbus",
"slave",
"or",
"returns",
"the",
"one",
"already",
"allocated",
"to",
"this",
"port"
] | train | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java#L114-L124 |
leancloud/java-sdk-all | android-sdk/storage-android/src/main/java/cn/leancloud/AVManifestUtils.java | AVManifestUtils.checkService | public static boolean checkService(Context context, Class<?> service) {
try {
ServiceInfo info = context.getPackageManager().getServiceInfo(
new ComponentName(context, service), 0);
return null != info;
} catch (PackageManager.NameNotFoundException e) {
printErrorLog("service " + service.getName() + " is missing!");
return false;
}
} | java | public static boolean checkService(Context context, Class<?> service) {
try {
ServiceInfo info = context.getPackageManager().getServiceInfo(
new ComponentName(context, service), 0);
return null != info;
} catch (PackageManager.NameNotFoundException e) {
printErrorLog("service " + service.getName() + " is missing!");
return false;
}
} | [
"public",
"static",
"boolean",
"checkService",
"(",
"Context",
"context",
",",
"Class",
"<",
"?",
">",
"service",
")",
"{",
"try",
"{",
"ServiceInfo",
"info",
"=",
"context",
".",
"getPackageManager",
"(",
")",
".",
"getServiceInfo",
"(",
"new",
"ComponentNa... | 判断 Mainifest 中是否包含对应到 Service
如有,则返回 true,反之,则返回 false 并输出日志
@param context
@param service
@return | [
"判断",
"Mainifest",
"中是否包含对应到",
"Service",
"如有,则返回",
"true,反之,则返回",
"false",
"并输出日志"
] | train | https://github.com/leancloud/java-sdk-all/blob/323f8e7ee38051b1350790e5192304768c5c9f5f/android-sdk/storage-android/src/main/java/cn/leancloud/AVManifestUtils.java#L45-L54 |
UrielCh/ovh-java-sdk | ovh-java-sdk-sms/src/main/java/net/minidev/ovh/api/ApiOvhSms.java | ApiOvhSms.serviceName_phonebooks_bookKey_DELETE | public void serviceName_phonebooks_bookKey_DELETE(String serviceName, String bookKey) throws IOException {
String qPath = "/sms/{serviceName}/phonebooks/{bookKey}";
StringBuilder sb = path(qPath, serviceName, bookKey);
exec(qPath, "DELETE", sb.toString(), null);
} | java | public void serviceName_phonebooks_bookKey_DELETE(String serviceName, String bookKey) throws IOException {
String qPath = "/sms/{serviceName}/phonebooks/{bookKey}";
StringBuilder sb = path(qPath, serviceName, bookKey);
exec(qPath, "DELETE", sb.toString(), null);
} | [
"public",
"void",
"serviceName_phonebooks_bookKey_DELETE",
"(",
"String",
"serviceName",
",",
"String",
"bookKey",
")",
"throws",
"IOException",
"{",
"String",
"qPath",
"=",
"\"/sms/{serviceName}/phonebooks/{bookKey}\"",
";",
"StringBuilder",
"sb",
"=",
"path",
"(",
"qP... | Delete a phonebook
REST: DELETE /sms/{serviceName}/phonebooks/{bookKey}
@param serviceName [required] The internal name of your SMS offer
@param bookKey [required] Identifier of the phonebook | [
"Delete",
"a",
"phonebook"
] | train | https://github.com/UrielCh/ovh-java-sdk/blob/6d531a40e56e09701943e334c25f90f640c55701/ovh-java-sdk-sms/src/main/java/net/minidev/ovh/api/ApiOvhSms.java#L1114-L1118 |
bitcoinj/bitcoinj | core/src/main/java/org/bitcoinj/utils/Fiat.java | Fiat.parseFiat | public static Fiat parseFiat(final String currencyCode, final String str) {
try {
long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValueExact();
return Fiat.valueOf(currencyCode, val);
} catch (ArithmeticException e) {
throw new IllegalArgumentException(e);
}
} | java | public static Fiat parseFiat(final String currencyCode, final String str) {
try {
long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValueExact();
return Fiat.valueOf(currencyCode, val);
} catch (ArithmeticException e) {
throw new IllegalArgumentException(e);
}
} | [
"public",
"static",
"Fiat",
"parseFiat",
"(",
"final",
"String",
"currencyCode",
",",
"final",
"String",
"str",
")",
"{",
"try",
"{",
"long",
"val",
"=",
"new",
"BigDecimal",
"(",
"str",
")",
".",
"movePointRight",
"(",
"SMALLEST_UNIT_EXPONENT",
")",
".",
... | <p>Parses an amount expressed in the way humans are used to.</p>
<p>This takes string in a format understood by {@link BigDecimal#BigDecimal(String)}, for example "0", "1", "0.10",
"1.23E3", "1234.5E-5".</p>
@throws IllegalArgumentException
if you try to specify more than 4 digits after the comma, or a value out of range. | [
"<p",
">",
"Parses",
"an",
"amount",
"expressed",
"in",
"the",
"way",
"humans",
"are",
"used",
"to",
".",
"<",
"/",
"p",
">",
"<p",
">",
"This",
"takes",
"string",
"in",
"a",
"format",
"understood",
"by",
"{",
"@link",
"BigDecimal#BigDecimal",
"(",
"St... | train | https://github.com/bitcoinj/bitcoinj/blob/9cf13d29315014ed59cf4fc5944e5f227e8df9a6/core/src/main/java/org/bitcoinj/utils/Fiat.java#L83-L90 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.